部分后端修改6

master3
Cys 8 months ago
parent c79d549ce8
commit bbcc362d2b

@ -32,9 +32,9 @@ public class JudgeQuestionController {
public R add(@RequestBody JudgeQuestion judgeQuestion) { public R add(@RequestBody JudgeQuestion judgeQuestion) {
int res = judgeQuestionService.add(judgeQuestion); int res = judgeQuestionService.add(judgeQuestion);
if (res != 0) { if (res != 0) {
return buildApiResult(200,"添加成功",res); return ApiResultHandler.buildApiResult(200,"添加成功",res);
} }
return buildApiResult(400,"添加失败",res); return ApiResultHandler.buildApiResult(400,"添加失败",res);
} }
/** /**
@ -45,7 +45,7 @@ public class JudgeQuestionController {
@GetMapping("/judgeQuestionId") @GetMapping("/judgeQuestionId")
public R<JudgeQuestion> findOnlyQuestionId() { public R<JudgeQuestion> findOnlyQuestionId() {
JudgeQuestion res = judgeQuestionService.findOnlyQuestionId(); JudgeQuestion res = judgeQuestionService.findOnlyQuestionId();
return buildApiResult(200,"查询成功",res); return ApiResultHandler.buildApiResult(200,"查询成功",res);
} }
/** /**
@ -58,8 +58,8 @@ public class JudgeQuestionController {
public R edit(@RequestBody JudgeQuestion judgeQuestion) { public R edit(@RequestBody JudgeQuestion judgeQuestion) {
int res = judgeQuestionService.edit(judgeQuestion); int res = judgeQuestionService.edit(judgeQuestion);
if (res != 0) { if (res != 0) {
return buildApiResult(200,"修改成功",res); return ApiResultHandler.buildApiResult(200,"修改成功",res);
} }
return buildApiResult(400,"修改失败",res); return ApiResultHandler.buildApiResult(400,"修改失败",res);
} }
} }

@ -36,8 +36,8 @@ public class LoginController {
*/ */
@PostMapping("/login") @PostMapping("/login")
public R login(@RequestBody Login login, HttpServletResponse response) { public R login(@RequestBody Login login, HttpServletResponse response) {
Integer username = login(); Integer username = login.getUsername();
String password = login(); String password = login.getPassword();
//登录管理员 //登录管理员
Admin adminRes = loginService.adminLogin(username, password); Admin adminRes = loginService.adminLogin(username, password);
@ -51,7 +51,7 @@ public class LoginController {
response.addCookie(token); response.addCookie(token);
response.addCookie(role); response.addCookie(role);
return buildApiResult(200, "请求成功", adminRes); return ApiResultHandler.buildApiResult(200, "请求成功", adminRes);
} }
//登录教师 //登录教师
@ -63,7 +63,7 @@ public class LoginController {
role.setPath("/"); role.setPath("/");
response.addCookie(token); response.addCookie(token);
response.addCookie(role); response.addCookie(role);
return buildApiResult(200, "请求成功", teacherRes); return ApiResultHandler.buildApiResult(200, "请求成功", teacherRes);
} }
//登录选 //登录选
@ -75,10 +75,10 @@ public class LoginController {
role.setPath("/"); role.setPath("/");
response.addCookie(token); response.addCookie(token);
response.addCookie(role); response.addCookie(role);
return buildApiResult(200, "请求成功", studentRes); return ApiResultHandler.buildApiResult(200, "请求成功", studentRes);
} }
return buildApiResult(400, "请求失败", null); return ApiResultHandler.buildApiResult(400, "请求失败", null);
} }
/** /**

@ -14,6 +14,7 @@ import java.util.List;
/** /**
* *
* *
*/ */
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@ -29,7 +30,7 @@ public class ScoreController {
@GetMapping("/scores") @GetMapping("/scores")
public R<List<Score>> findAll() { public R<List<Score>> findAll() {
List<Score> res = scoreService.findAll(); List<Score> res = scoreService.findAll();
return buildApiResult(200, "查询所有学生成绩", res); return ApiResultHandler.buildApiResult(200, "查询所有学生成绩", res);
} }
/** /**
@ -47,7 +48,7 @@ public class ScoreController {
@PathVariable("studentId") Integer studentId @PathVariable("studentId") Integer studentId
) { ) {
IPage<Score> res = scoreService.findById(new Page<>(page, size), studentId); IPage<Score> res = scoreService.findById(new Page<>(page, size), studentId);
return buildApiResult(200, "根据ID查询成绩", res); return ApiResultHandler.buildApiResult(200, "根据ID查询成绩", res);
} }
/** /**

@ -49,7 +49,7 @@ public class StudentController {
IPage<Student> res = studentService.findAll( IPage<Student> res = studentService.findAll(
new Page<>(page, size), name, grade, tel, institute, major, clazz new Page<>(page, size), name, grade, tel, institute, major, clazz
); );
return buildApiResult(200, "分页查询所有学生", res); return ApiResultHandler.buildApiResult(200, "分页查询所有学生", res);
} }
/** /**
@ -62,9 +62,9 @@ public class StudentController {
public R<Student> findById(@PathVariable("studentId") Integer studentId) { public R<Student> findById(@PathVariable("studentId") Integer studentId) {
Student res = studentService.findById(studentId); Student res = studentService.findById(studentId);
if (res != null) { if (res != null) {
return buildApiResult(200, "请求成功", res); return ApiResultHandler.buildApiResult(200, "请求成功", res);
} else { } else {
return buildApiResult(404, "查询的用户不存在", null); return ApiResultHandler.buildApiResult(404, "查询的用户不存在", null);
} }
} }
@ -76,7 +76,7 @@ public class StudentController {
*/ */
@DeleteMapping("/student/{studentId}") @DeleteMapping("/student/{studentId}")
public R<Integer> deleteById(@PathVariable("studentId") Integer studentId) { public R<Integer> deleteById(@PathVariable("studentId") Integer studentId) {
return buildApiResult(200, "删除成功", studentService.deleteById(studentId)); return ApiResultHandler.buildApiResult(200, "删除成功", studentService.deleteById(studentId));
} }
/** /**
@ -89,9 +89,9 @@ public class StudentController {
public R update(@RequestBody Student student) { public R update(@RequestBody Student student) {
int res = studentService.update(student); int res = studentService.update(student);
if (res != 0) { if (res != 0) {
return buildApiResult(200, "更新成功", res); return ApiResultHandler.buildApiResult(200, "更新成功", res);
} }
return buildApiResult(400, "更新失败", res); return ApiResultHandler.buildApiResult(400, "更新失败", res);
} }
/** /**

Loading…
Cancel
Save