瀏覽代碼

考务接口修改

wangliang 5 年之前
父節點
當前提交
80405cca54

+ 8 - 6
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java

@@ -120,10 +120,12 @@ public class TEExamController {
     @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) {
+    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.EXAM_ID_IS_NULL);
         }
@@ -141,7 +143,7 @@ public class TEExamController {
         teExam.setEnable(enable);
         teExam.setUpdateId(tbUser.getId());
         teExamService.updateById(teExam);
-        return ResultUtil.ok(JSONObject.parseObject(SystemConstant.SUCCESS));
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
     }
 
     @ApiOperation(value = "考试批次详情接口")
@@ -218,6 +220,6 @@ public class TEExamController {
                 throw new RuntimeException(e);
             }
         }
-        return ResultUtil.ok(JSONObject.parseObject(SystemConstant.SUCCESS));
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
     }
 }

+ 4 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamPaperController.java

@@ -63,9 +63,12 @@ public class TEExamPaperController {
             teExamPaperList.forEach(s -> {
                 if (Objects.nonNull(s.getId())) {
                     s.setUpdateId(tbUser.getId());
+                } else {
+                    s.setId(Constants.idGen.next());
+                    s.setCreateId(tbUser.getId());
                 }
             });
-            teExamPaperService.updateBatchById(teExamPaperList);
+            teExamPaperService.saveOrUpdateBatch(teExamPaperList);
         } catch (Exception e) {
             e.printStackTrace();
             if (e instanceof DuplicateKeyException) {

+ 51 - 4
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamStudentController.java

@@ -2,23 +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.service.TEExamStudentService;
 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.transaction.annotation.Transactional;
-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.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * @Description: 考生库 前端控制器
@@ -45,6 +50,48 @@ public class TEExamStudentController {
         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.EXAM_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")));
+        TEExamStudent teExamStudent = teExamStudentService.getById(id);
+        if (Objects.isNull(teExamStudent)) {
+            throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
+        }
+        HttpServletRequest request = ServletUtil.getRequest();
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount(request);
+        teExamStudent.setEnable(enable);
+        teExamStudent.setUpdateId(tbUser.getId());
+        teExamStudentService.updateById(teExamStudent);
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
+    }
+
+    @ApiOperation(value = "考生修改接口")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @Transactional
+    public Result save(@ApiParam(value = "考生信息", required = true) @RequestBody TEExamStudent teExamStudent) {
+        if (Objects.isNull(teExamStudent)) {
+            throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
+        }
+        teExamStudentService.updateById(teExamStudent);
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
+    }
+
     @ApiOperation(value = "考生导入接口")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
     @Transactional

+ 80 - 4
themis-backend/src/main/java/com/qmth/themis/backend/api/TEStudentController.java

@@ -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);
+    }
 }

+ 10 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEStudentMapper.java

@@ -28,4 +28,14 @@ public interface TEStudentMapper extends BaseMapper<TEStudent> {
      * @return
      */
     public IPage<Map> studentQuery(IPage<Map> iPage, @Param("identity") String identity, @Param("name") String name, @Param("enable") Integer enable);
+
+    /**
+     * 学生考试记录查询
+     *
+     * @param iPage
+     * @param id
+     * @param name
+     * @return
+     */
+    public IPage<Map> studentExamRecordQuery(IPage<Map> iPage, @Param("id") Long id, @Param("name") String name);
 }

+ 10 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEStudentService.java

@@ -25,4 +25,14 @@ public interface TEStudentService extends IService<TEStudent> {
      * @return
      */
     public IPage<Map> studentQuery(IPage<Map> iPage, String identity, String name, Integer enable);
+
+    /**
+     * 学生考试记录查询
+     *
+     * @param iPage
+     * @param id
+     * @param name
+     * @return
+     */
+    public IPage<Map> studentExamRecordQuery(IPage<Map> iPage, Long id, String name);
 }

+ 13 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java

@@ -36,4 +36,17 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
     public IPage<Map> studentQuery(IPage<Map> iPage, String identity, String name, Integer enable) {
         return teStudentMapper.studentQuery(iPage, identity, name, enable);
     }
+
+    /**
+     * 学生考试记录查询
+     *
+     * @param iPage
+     * @param id
+     * @param name
+     * @return
+     */
+    @Override
+    public IPage<Map> studentExamRecordQuery(IPage<Map> iPage, Long id, String name) {
+        return teStudentMapper.studentExamRecordQuery(iPage, id, name);
+    }
 }

+ 7 - 14
themis-business/src/main/resources/mapper/TEStudentMapper.xml

@@ -4,25 +4,14 @@
 
     <select id="studentQuery" resultType="java.util.Map">
         select
+            tes.id,
             tes.name,
             tes.`identity`,
             tbo.name as orgName,
             tes.enable,
             tes.base_photo_path as basePhotoPath,
-            (
-            select
-                tbu.name
-            from
-                t_b_user tbu
-            where
-                tbu.id = tes.create_id) as createName,
-            (
-            select
-                tbu.name
-            from
-                t_b_user tbu
-            where
-                tbu.id = tes.update_id) as updateName,
+            (select tbu.name from t_b_user tbu where tbu.id = tes.create_id) as createName,
+            (select tbu.name from t_b_user tbu where tbu.id = tes.update_id) as updateName,
             tes.create_time as createTime,
             tes.update_time as updateTime
         from
@@ -41,4 +30,8 @@
             </if>
         </where>
     </select>
+
+    <select id="studentExamRecordQuery" resultType="java.util.Map">
+
+    </select>
 </mapper>

+ 6 - 0
themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java

@@ -28,10 +28,16 @@ public enum ExceptionResultEnum {
 
     EXAM_IS_NULL("102", "考试不能为空"),
 
+    EXAM_STUDENT_ID_IS_NULL("102", "考生id不能为空"),
+
+    EXAM_STUDENT_INFO_IS_NULL("102", "待修改的考生信息不能为空"),
+
     EXAM_DETAIL_ID_IS_NULL("102", "考试详情id不能为空"),
 
     STUDENT_ID_IS_NULL("102", "学生id不能为空"),
 
+    STUDENT_INFO_IS_NULL("102", "待修改的学生信息不能为空"),
+
     LOGIN_NAME_IS_NULL("102", "用户名不能为空"),
 
     PASSWORD_IS_NULL("102", "密码不能为空"),