|
@@ -2,20 +2,28 @@ package com.qmth.themis.backend.api;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.qmth.themis.backend.util.ServletUtil;
|
|
|
+import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
|
+import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
+import com.qmth.themis.business.entity.TBUser;
|
|
|
import com.qmth.themis.business.entity.TEExamStudent;
|
|
|
+import com.qmth.themis.business.entity.TEStudent;
|
|
|
import com.qmth.themis.business.service.TEStudentService;
|
|
|
+import com.qmth.themis.business.util.JacksonUtil;
|
|
|
+import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.themis.common.exception.BusinessException;
|
|
|
import com.qmth.themis.common.util.Result;
|
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @Description: 学生档案 前端控制器
|
|
@@ -41,4 +49,72 @@ public class TEStudentController {
|
|
|
map.put(SystemConstant.RECORDS, teExamStudentIPage);
|
|
|
return ResultUtil.ok(map);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "学生停用/启用接口")
|
|
|
+ @RequestMapping(value = "/toggle", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ @Transactional
|
|
|
+ public Result toggle(
|
|
|
+// @ApiJsonObject(name = "toggle", value = {
|
|
|
+// @ApiJsonProperty(key = "id", type = "long", example = "1", description = "学生ID"),
|
|
|
+// @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")
|
|
|
+// })
|
|
|
+ @ApiParam(value = "学生信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ if (Objects.isNull(mapParameter.get("id")) || Objects.equals(mapParameter.get("id"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.STUDENT_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ Long id = Long.parseLong(String.valueOf(mapParameter.get("id")));
|
|
|
+ if (Objects.isNull(mapParameter.get("enable")) || Objects.equals(mapParameter.get("enable"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.ENABLE_IS_NULL);
|
|
|
+ }
|
|
|
+ Integer enable = Integer.parseInt(String.valueOf(mapParameter.get("enable")));
|
|
|
+ TEStudent teStudent = teStudentService.getById(id);
|
|
|
+ if (Objects.isNull(teStudent)) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.STUDENT_INFO_IS_NULL);
|
|
|
+ }
|
|
|
+ HttpServletRequest request = ServletUtil.getRequest();
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount(request);
|
|
|
+ teStudent.setEnable(enable);
|
|
|
+ teStudent.setUpdateId(tbUser.getId());
|
|
|
+ teStudentService.updateById(teStudent);
|
|
|
+ return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学生修改密码接口")
|
|
|
+ @RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ @Transactional
|
|
|
+ public Result updatePwd(@ApiJsonObject(name = "updatePwd", value = {
|
|
|
+ @ApiJsonProperty(key = "id", type = "long", example = "1", description = "学生ID"),
|
|
|
+ @ApiJsonProperty(key = "password", description = "新密码")
|
|
|
+ }) @ApiParam(value = "学生信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ if (Objects.isNull(mapParameter.get("id")) || Objects.equals(mapParameter.get("id"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.STUDENT_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ Long id = Long.parseLong(String.valueOf(mapParameter.get("id")));
|
|
|
+ if (Objects.isNull(mapParameter.get("password")) || Objects.equals(mapParameter.get("password"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.PASSWORD_IS_NULL);
|
|
|
+ }
|
|
|
+ String password = String.valueOf(mapParameter.get("password"));
|
|
|
+ TEStudent teStudent = teStudentService.getById(id);
|
|
|
+ if (Objects.isNull(teStudent)) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.STUDENT_INFO_IS_NULL);
|
|
|
+ }
|
|
|
+ HttpServletRequest request = ServletUtil.getRequest();
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount(request);
|
|
|
+ teStudent.setPassword(password);
|
|
|
+ teStudent.setUpdateId(tbUser.getId());
|
|
|
+ teStudentService.updateById(teStudent);
|
|
|
+ return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学生考试记录查询接口")
|
|
|
+ @RequestMapping(value = "/studentExamRecordQuery", method = RequestMethod.GET)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考生信息", response = TEExamStudent.class)})
|
|
|
+ public Result studentExamRecordQuery(@ApiParam(value = "学生id", required = true) @RequestParam Long id, @ApiParam(value = "批次名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
+ IPage<Map> studentExamRecordQuery = teStudentService.studentExamRecordQuery(new Page<>(pageNumber, pageSize), id, name);
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, studentExamRecordQuery);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
}
|