该项目是一个前后端分离,后端使用 SpringBoot,前端使用 VUE 和 Element-UI 组件库配合完成开发。
开发工具:IDEA,数据库:mysql5.7
如果也想学习本系统,下面领取。回复:007
```java
package com.exam.controller;
import com.exam.entity.*;
import com.exam.serviceimpl.LoginServiceImpl;
import com.exam.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginController {
@Autowired
private LoginServiceImpl loginService;
@PostMapping("/login")
public ApiResult login(@RequestBody Login login) {
Integer username = login.getUsername();
String password = login.getPassword();
//不建议这样写,会造成过多的查询
//查询admin表
Admin adminRes = loginService.adminLogin(username, password);
if (adminRes != null) {
return ApiResultHandler.buildApiResult(200, "请求成功", adminRes);
}
//查询teacher表
Teacher teacherRes = loginService.teacherLogin(username,password);
if (teacherRes != null) {
return ApiResultHandler.buildApiResult(200, "请求成功", teacherRes);
}
//查询student表
Student studentRes = loginService.studentLogin(username,password);
if (studentRes != null) {
return ApiResultHandler.buildApiResult(200, "请求成功", studentRes);
}
return ApiResultHandler.buildApiResult(400, "请求失败", null);
}
}