From ccca8c65b3c76a9021a471a3667d61d965a4f2cb Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期六, 11 五月 2024 18:04:44 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/mindskip/xzs/domain/ExamPaperAnswer.java | 13 + src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java | 15 + src/main/java/com/mindskip/xzs/controller/student/QuestionAndAnswerController.java | 34 +++ src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java | 57 ++--- src/main/resources/mapper/QuestionAnswerMapper.xml | 18 + src/main/java/com/mindskip/xzs/repository/UserMapper.java | 3 src/main/resources/mapper/UserMapper.xml | 16 + src/main/java/com/mindskip/xzs/domain/enums/AnswerInvalidEnum.java | 31 +++ src/main/java/com/mindskip/xzs/repository/ExamPaperMapper.java | 4 src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java | 6 src/main/resources/mapper/ExamPaperMapper.xml | 15 - src/main/java/com/mindskip/xzs/controller/admin/DepartmentController.java | 14 + src/main/java/com/mindskip/xzs/domain/Feedback.java | 9 src/main/java/com/mindskip/xzs/controller/admin/QuestionAnswerController.java | 76 +++++++ src/main/java/com/mindskip/xzs/domain/vo/QuestionAnswerVO.java | 30 +++ src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java | 5 src/main/java/com/mindskip/xzs/service/impl/TagServiceImpl.java | 1 src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java | 11 - src/main/java/com/mindskip/xzs/service/QuestionAnswerService.java | 19 + src/main/java/com/mindskip/xzs/controller/student/FeedBackController.java | 2 src/main/java/com/mindskip/xzs/controller/admin/FeedBackController.java | 2 src/main/resources/mapper/ExamPaperAnswerMapper.xml | 31 ++ src/main/java/com/mindskip/xzs/service/impl/QuestionAnswerServiceImpl.java | 58 +++++ src/main/java/com/mindskip/xzs/repository/QuestionAnswerMapper.java | 20 ++ src/main/java/com/mindskip/xzs/service/ExamPaperService.java | 4 /dev/null | 16 - src/main/java/com/mindskip/xzs/domain/QuestionAnswer.java | 33 +++ src/main/resources/mapper/FeedbackMapper.xml | 3 src/main/java/com/mindskip/xzs/domain/enums/QuestionAnswerStatusEnum.java | 31 +++ src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java | 1 src/main/java/com/mindskip/xzs/domain/enums/UserConditionEnum.java | 1 src/main/java/com/mindskip/xzs/domain/vo/FeedbackVO.java | 2 src/main/java/com/mindskip/xzs/service/UserService.java | 3 33 files changed, 484 insertions(+), 100 deletions(-) diff --git a/src/main/java/com/mindskip/xzs/controller/admin/DepartmentController.java b/src/main/java/com/mindskip/xzs/controller/admin/DepartmentController.java index 5228899..1d3da20 100644 --- a/src/main/java/com/mindskip/xzs/controller/admin/DepartmentController.java +++ b/src/main/java/com/mindskip/xzs/controller/admin/DepartmentController.java @@ -4,6 +4,7 @@ import com.mindskip.xzs.base.BaseApiController; import com.mindskip.xzs.base.RestResponse; import com.mindskip.xzs.domain.Department; +import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.User; import com.mindskip.xzs.domain.UserDepartment; import com.mindskip.xzs.domain.vo.BaseSelect; @@ -93,7 +94,7 @@ } @RequestMapping(value = "/getDepartmentUser", method = RequestMethod.POST) - public RestResponse<List<DepartmentVO>> getUserDepartment(){ + public RestResponse<List<DepartmentVO>> getUserDepartment(Integer examPaperId){ User currentUser = webContext.getCurrentUser(); Integer deptId = null; if (Objects.nonNull(currentUser)) { @@ -108,7 +109,16 @@ List<UserDepartment> userDepartments = userDepartmentMapper.selectByDepartmentId(e.getId()); List<User> list = new ArrayList<>(); for (UserDepartment userDepartment : userDepartments) { - User user = userService.getUserById(userDepartment.getUserId()); + User user; + // 閫夋嫨琛ヨ�冪敤鎴锋椂鏌ヨ绗﹀悎琛ヨ�冩潯浠剁殑鐢ㄦ埛 + if (examPaperId != null) { + ExamPaper examPaper = new ExamPaper(); + examPaper.setCreateUser(userDepartment.getUserId()); + examPaper.setId(examPaperId); + user = userService.getUserByExam(examPaper); + } else { + user = userService.getUserById(userDepartment.getUserId()); + } if (ObjectUtils.isNotEmpty(user)) { list.add(user); } diff --git a/src/main/java/com/mindskip/xzs/controller/admin/ExamMissController.java b/src/main/java/com/mindskip/xzs/controller/admin/ExamMissController.java deleted file mode 100644 index a2ed3a5..0000000 --- a/src/main/java/com/mindskip/xzs/controller/admin/ExamMissController.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mindskip.xzs.controller.admin; - -import com.mindskip.xzs.service.ExamMissService; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author gonghl - * @since 2024/5/9 涓嬪崍 5:58 - */ - -@RestController -@RequiredArgsConstructor -public class ExamMissController { - - private final ExamMissService examMissService; - - - -} diff --git a/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java b/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java index 6881c2c..662afdb 100644 --- a/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java +++ b/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java @@ -87,13 +87,20 @@ ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser()); ExamPaperEditRequestVO newVM = examPaperService.examPaperToVM(examPaper.getId()); - // 鍔犲叆寤舵椂闃熷垪锛屽畾鏃惰瘯鍗风粨鏉熸椂璁板綍缂鸿�冨鐢� - if (examPaper.getPaperType() == 4) { - examPaperService.addTimeTask(examPaper); - } return RestResponse.ok(newVM); } + /** + * 琛ヨ�� + * @param model 鏁版嵁 + * @return 鎿嶄綔缁撴灉 + */ + @RequestMapping(value = "/missExam", method = RequestMethod.POST) + public RestResponse<String> missExam(@RequestBody ExamPaperEditRequestVM model) { + examPaperService.missExam(model); + return RestResponse.ok("鎿嶄綔鎴愬姛"); + } + @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) public RestResponse<ExamPaperEditRequestVO> select(@PathVariable Integer id) { ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id); diff --git a/src/main/java/com/mindskip/xzs/controller/admin/FeedBackController.java b/src/main/java/com/mindskip/xzs/controller/admin/FeedBackController.java index 94c4370..43180d2 100644 --- a/src/main/java/com/mindskip/xzs/controller/admin/FeedBackController.java +++ b/src/main/java/com/mindskip/xzs/controller/admin/FeedBackController.java @@ -15,7 +15,7 @@ */ @RequiredArgsConstructor -@RestController("adminFeedBackController") +@RestController("AdminFeedBackController") @RequestMapping("/api/admin/feedback") public class FeedBackController extends BaseApiController { diff --git a/src/main/java/com/mindskip/xzs/controller/admin/QuestionAnswerController.java b/src/main/java/com/mindskip/xzs/controller/admin/QuestionAnswerController.java new file mode 100644 index 0000000..b13a647 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/controller/admin/QuestionAnswerController.java @@ -0,0 +1,76 @@ +package com.mindskip.xzs.controller.admin; + +import com.github.pagehelper.PageInfo; +import com.mindskip.xzs.base.BaseApiController; +import com.mindskip.xzs.base.RestResponse; +import com.mindskip.xzs.domain.QuestionAnswer; +import com.mindskip.xzs.domain.vo.QuestionAnswerVO; +import com.mindskip.xzs.service.QuestionAnswerService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * @author gonghl + * @since 2024/5/11 涓嬪崍 3:57 + */ + +@RequiredArgsConstructor +@RestController("AdminQuestionAnswerController") +@RequestMapping("/api/admin/questionAnswer") +public class QuestionAnswerController extends BaseApiController { + + private final QuestionAnswerService questionAnswerService; + + /** + * 淇濆瓨銆佷慨鏀归棶绛� + */ + @PostMapping("save") + public RestResponse<String> saveQuestionAnswer(@RequestBody QuestionAnswer questionAnswer) { + questionAnswerService.saveOrUpdate(questionAnswer); + return RestResponse.ok("鎿嶄綔鎴愬姛"); + } + + /** + * 鍒嗛〉鏌ヨ + */ + @PostMapping("page") + public RestResponse<PageInfo<QuestionAnswerVO>> page(@RequestBody QuestionAnswerVO questionAnswer) { + return RestResponse.ok(questionAnswerService.questionAnswerPage(questionAnswer)); + } + + /** + * 鍒犻櫎闂瓟 + */ + @PostMapping("delete/{id}") + public RestResponse<String> delete(@PathVariable Integer id) { + questionAnswerService.removeById(id); + return RestResponse.ok("鎿嶄綔鎴愬姛"); + } + + /** + * 鏌ヨ闂瓟 + */ + @PostMapping("query/{id}") + public RestResponse<QuestionAnswer> query(@PathVariable Integer id) { + return RestResponse.ok(questionAnswerService.getById(id)); + } + + /** + * 淇敼闂瓟 + */ + @PostMapping("update") + public RestResponse<String> update(@RequestBody QuestionAnswer questionAnswer) { + questionAnswerService.updateById(questionAnswer); + return RestResponse.ok("鎿嶄綔鎴愬姛"); + } + + /** + * 淇敼闂瓟鐘舵�� + */ + @PostMapping("updateStatus/{id}") + public RestResponse<String> updateStatus(@PathVariable Integer id) { + questionAnswerService.updateStatus(id); + return RestResponse.ok("鎿嶄綔鎴愬姛"); + } + +} diff --git a/src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java b/src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java index 155183d..d08fe72 100644 --- a/src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java +++ b/src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java @@ -34,17 +34,15 @@ private final ApplicationEventPublisher eventPublisher; private final ExamPaperSubjectService examPaperSubjectService; private final ExamTemplatesUserCountService examTemplatesUserCountService; - private final ExamMissService examMissService; @Autowired - public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher, ExamPaperSubjectService examPaperSubjectService, ExamTemplatesUserCountService examTemplatesUserCountService, ExamMissService examMissService) { + public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher, ExamPaperSubjectService examPaperSubjectService, ExamTemplatesUserCountService examTemplatesUserCountService) { this.examPaperAnswerService = examPaperAnswerService; this.examPaperService = examPaperService; this.subjectService = subjectService; this.eventPublisher = eventPublisher; this.examPaperSubjectService = examPaperSubjectService; this.examTemplatesUserCountService = examTemplatesUserCountService; - this.examMissService = examMissService; } @@ -100,13 +98,6 @@ examTemplatesUserCountService.add(examTemplatesUserCount); } - // 鑷姩鎻愪氦瀹氫箟涓虹己鑰� - if (examPaperSubmitVM.isAutoCommit()) { - ExamMiss examMiss = new ExamMiss(); - examMiss.setExamId(examPaperSubmitVM.getId()); - examMiss.setUserId(user.getId()); - examMissService.save(examMiss); - } return RestResponse.ok(scoreVm); } diff --git a/src/main/java/com/mindskip/xzs/controller/student/FeedBackController.java b/src/main/java/com/mindskip/xzs/controller/student/FeedBackController.java index 14a5048..566c178 100644 --- a/src/main/java/com/mindskip/xzs/controller/student/FeedBackController.java +++ b/src/main/java/com/mindskip/xzs/controller/student/FeedBackController.java @@ -16,7 +16,7 @@ */ @RequiredArgsConstructor -@RestController("studentFeedBackController") +@RestController("StudentFeedBackController") @RequestMapping("/api/student/feedback") public class FeedBackController extends BaseApiController { diff --git a/src/main/java/com/mindskip/xzs/controller/student/QuestionAndAnswerController.java b/src/main/java/com/mindskip/xzs/controller/student/QuestionAndAnswerController.java new file mode 100644 index 0000000..2feeac4 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/controller/student/QuestionAndAnswerController.java @@ -0,0 +1,34 @@ +package com.mindskip.xzs.controller.student; + +import com.mindskip.xzs.base.BaseApiController; +import com.mindskip.xzs.base.RestResponse; +import com.mindskip.xzs.domain.QuestionAnswer; +import com.mindskip.xzs.service.QuestionAnswerService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author gonghl + * @since 2024/5/11 涓嬪崍 3:57 + */ + +@RequiredArgsConstructor +@RestController("StudentQuestionAndAnswerController") +@RequestMapping("/api/student/questionAnswer") +public class QuestionAndAnswerController extends BaseApiController { + + private final QuestionAnswerService questionAnswerService; + + /** + * 鏌ヨ + */ + @PostMapping("list") + public RestResponse<List<QuestionAnswer>> page() { + return RestResponse.ok(questionAnswerService.list()); + } + +} diff --git a/src/main/java/com/mindskip/xzs/domain/ExamMiss.java b/src/main/java/com/mindskip/xzs/domain/ExamMiss.java deleted file mode 100644 index e972e42..0000000 --- a/src/main/java/com/mindskip/xzs/domain/ExamMiss.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mindskip.xzs.domain; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.io.Serializable; - -/** - * @author gonghl - */ -@TableName(value = "t_exam_miss") -@Data -public class ExamMiss implements Serializable { - - @TableId(type = IdType.AUTO) - private Integer id; - - private Integer examId; - - private Integer userId; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/mindskip/xzs/domain/ExamPaperAnswer.java b/src/main/java/com/mindskip/xzs/domain/ExamPaperAnswer.java index 0e8aa9d..d2c2eec 100644 --- a/src/main/java/com/mindskip/xzs/domain/ExamPaperAnswer.java +++ b/src/main/java/com/mindskip/xzs/domain/ExamPaperAnswer.java @@ -1,5 +1,7 @@ package com.mindskip.xzs.domain; +import com.mindskip.xzs.domain.enums.AnswerInvalidEnum; + import java.io.Serializable; import java.util.Date; @@ -83,8 +85,19 @@ private String userName; + /** + * 鏄惁浣滃簾锛�1/0 鏄�/鍚︼紙浣滃簾浠h〃闇�瑕佽ˉ鑰冿級 + */ + private AnswerInvalidEnum invalid; + public AnswerInvalidEnum getInvalid() { + return invalid; + } + + public void setInvalid(AnswerInvalidEnum invalid) { + this.invalid = invalid; + } public Integer getId() { return id; diff --git a/src/main/java/com/mindskip/xzs/domain/Feedback.java b/src/main/java/com/mindskip/xzs/domain/Feedback.java index 7cbb4d0..e8ad14b 100644 --- a/src/main/java/com/mindskip/xzs/domain/Feedback.java +++ b/src/main/java/com/mindskip/xzs/domain/Feedback.java @@ -1,14 +1,10 @@ package com.mindskip.xzs.domain; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.io.Serializable; import java.time.LocalDateTime; -import java.util.Date; /** * @author gonghl @@ -34,5 +30,8 @@ private LocalDateTime fixTime; + @TableLogic + private Boolean deleted; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/src/main/java/com/mindskip/xzs/domain/QuestionAnswer.java b/src/main/java/com/mindskip/xzs/domain/QuestionAnswer.java new file mode 100644 index 0000000..1c29c77 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/domain/QuestionAnswer.java @@ -0,0 +1,33 @@ +package com.mindskip.xzs.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mindskip.xzs.domain.enums.QuestionAnswerStatusEnum; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author gonghl + * @TableName t_question_answer + */ +@TableName(value = "t_question_answer") +@Data +public class QuestionAnswer implements Serializable { + + @TableId(type = IdType.AUTO) + private Integer id; + + private String question; + + private String answer; + + private QuestionAnswerStatusEnum status; + + @TableLogic + private Boolean deleted; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/mindskip/xzs/domain/enums/AnswerInvalidEnum.java b/src/main/java/com/mindskip/xzs/domain/enums/AnswerInvalidEnum.java new file mode 100644 index 0000000..b60e0e4 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/domain/enums/AnswerInvalidEnum.java @@ -0,0 +1,31 @@ +package com.mindskip.xzs.domain.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * 鑰冭瘯浣滃簾 + * + * @author gonghl + */ +@Getter +public enum AnswerInvalidEnum { + + VALID("0", "鏈夋晥"), + INVALID("1", "鏃犳晥"), + ; + + + @EnumValue // 鏍囨槑璇ュ瓧娈靛瓨鍏ユ暟鎹簱 + private final String code; + + @JsonValue // 鏍囨槑鍦ㄨ浆JSON鏃朵娇鐢ㄨ瀛楁锛屽嵆鍝嶅簲鏃� + private final String desc; + + AnswerInvalidEnum(String code, String desc) { + this.code = code; + this.desc = desc; + } + +} diff --git a/src/main/java/com/mindskip/xzs/domain/enums/QuestionAnswerStatusEnum.java b/src/main/java/com/mindskip/xzs/domain/enums/QuestionAnswerStatusEnum.java new file mode 100644 index 0000000..7bd8a05 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/domain/enums/QuestionAnswerStatusEnum.java @@ -0,0 +1,31 @@ +package com.mindskip.xzs.domain.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * 闂瓟鐘舵�� + * + * @author gonghl + */ +@Getter +public enum QuestionAnswerStatusEnum { + + ENABLE("1", "鍚敤"), + DISABLE("2", "绂佺敤"), + ; + + + @EnumValue // 鏍囨槑璇ュ瓧娈靛瓨鍏ユ暟鎹簱 + private final String code; + + @JsonValue // 鏍囨槑鍦ㄨ浆JSON鏃朵娇鐢ㄨ瀛楁锛屽嵆鍝嶅簲鏃� + private final String desc; + + QuestionAnswerStatusEnum(String code, String desc) { + this.code = code; + this.desc = desc; + } + +} diff --git a/src/main/java/com/mindskip/xzs/domain/enums/UserConditionEnum.java b/src/main/java/com/mindskip/xzs/domain/enums/UserConditionEnum.java index fdcaf01..c1fa8c2 100644 --- a/src/main/java/com/mindskip/xzs/domain/enums/UserConditionEnum.java +++ b/src/main/java/com/mindskip/xzs/domain/enums/UserConditionEnum.java @@ -12,6 +12,7 @@ @Getter public enum UserConditionEnum { + NORMAL("0", "姝e父"), SICK("1", "鐥呭亣"), BUSINESS_TRIP("2", "鍑哄樊"), OTHER("3", "鍏朵粬"), diff --git a/src/main/java/com/mindskip/xzs/domain/vo/ExamMissVO.java b/src/main/java/com/mindskip/xzs/domain/vo/ExamMissVO.java deleted file mode 100644 index 04eb497..0000000 --- a/src/main/java/com/mindskip/xzs/domain/vo/ExamMissVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mindskip.xzs.domain.vo; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @author gonghl - */ -@Data -public class ExamMissVO implements Serializable { - - private Integer id; - - private Integer examId; - - private Integer examName; - - private Integer userId; - - private Integer userName; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/mindskip/xzs/domain/vo/FeedbackVO.java b/src/main/java/com/mindskip/xzs/domain/vo/FeedbackVO.java index 2e3f6dd..cefa44c 100644 --- a/src/main/java/com/mindskip/xzs/domain/vo/FeedbackVO.java +++ b/src/main/java/com/mindskip/xzs/domain/vo/FeedbackVO.java @@ -31,6 +31,8 @@ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private LocalDateTime fixTime; + private Boolean deleted; + private Integer pageIndex; private Integer pageSize; diff --git a/src/main/java/com/mindskip/xzs/domain/vo/QuestionAnswerVO.java b/src/main/java/com/mindskip/xzs/domain/vo/QuestionAnswerVO.java new file mode 100644 index 0000000..8991f5c --- /dev/null +++ b/src/main/java/com/mindskip/xzs/domain/vo/QuestionAnswerVO.java @@ -0,0 +1,30 @@ +package com.mindskip.xzs.domain.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author gonghl + * @TableName t_question_answer + */ +@Data +public class QuestionAnswerVO implements Serializable { + + @TableId(type = IdType.AUTO) + private Integer id; + + private String question; + + private String answer; + + private Boolean deleted; + + private static final long serialVersionUID = 1L; + + private Integer pageIndex; + + private Integer pageSize; +} \ No newline at end of file diff --git a/src/main/java/com/mindskip/xzs/queue/ExamPaperTimeTask.java b/src/main/java/com/mindskip/xzs/queue/ExamPaperTimeTask.java deleted file mode 100644 index a6831b1..0000000 --- a/src/main/java/com/mindskip/xzs/queue/ExamPaperTimeTask.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.mindskip.xzs.queue; - -import lombok.Getter; -import lombok.Setter; - -import java.util.concurrent.Delayed; -import java.util.concurrent.TimeUnit; - -/** - * @author gonghl - */ - -@Getter -@Setter -public class ExamPaperTimeTask implements Delayed { - - private long examPaperId; - - private long expiry; - - @Override - public long getDelay(TimeUnit unit) { - return unit.convert(expiry - System.currentTimeMillis(), TimeUnit.MILLISECONDS); - } - - @Override - public int compareTo(Delayed o) { - return Long.compare(expiry, ((ExamPaperTimeTask) o).expiry); - } - -} \ No newline at end of file diff --git a/src/main/java/com/mindskip/xzs/repository/ExamMissMapper.java b/src/main/java/com/mindskip/xzs/repository/ExamMissMapper.java deleted file mode 100644 index 43a45ce..0000000 --- a/src/main/java/com/mindskip/xzs/repository/ExamMissMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mindskip.xzs.repository; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.mindskip.xzs.domain.ExamMiss; -import org.apache.ibatis.annotations.Mapper; - -/** - * @author gonghl - * @description 閽堝琛ㄣ�恡_exam_miss(璇曞嵎缂鸿��)銆戠殑鏁版嵁搴撴搷浣淢apper - * @createDate 2024-05-09 15:41:36 - * @Entity com.mindskip.xzs.examMiss.ExamMiss - */ -@Mapper -public interface ExamMissMapper extends BaseMapper<ExamMiss> { - -} - - - - diff --git a/src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java b/src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java index 8c6d5ec..a1ff9fa 100644 --- a/src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java +++ b/src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java @@ -1,11 +1,14 @@ package com.mindskip.xzs.repository; +import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.ExamPaperAnswer; import com.mindskip.xzs.domain.ExamTemplatesUserCount; import com.mindskip.xzs.domain.ScoreTemplatesUserCount; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.ScoreTemplatesCountVO; import com.mindskip.xzs.domain.vo.TeamplatesUserExcelVO; +import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; +import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVO; import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM; import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradeQuery; import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM; @@ -46,7 +49,8 @@ List<TeamplatesUserExcelVO> getByTimeOne(); + void setMissExam(ExamPaperEditRequestVM model); - + void insertDefault(ExamPaperEditRequestVM model); } diff --git a/src/main/java/com/mindskip/xzs/repository/ExamPaperMapper.java b/src/main/java/com/mindskip/xzs/repository/ExamPaperMapper.java index 2e81460..7997772 100644 --- a/src/main/java/com/mindskip/xzs/repository/ExamPaperMapper.java +++ b/src/main/java/com/mindskip/xzs/repository/ExamPaperMapper.java @@ -1,6 +1,5 @@ package com.mindskip.xzs.repository; -import com.mindskip.xzs.domain.ExamMiss; import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.PaperExcelVO; @@ -39,7 +38,4 @@ List<PaperExcelVO> getPaperExcelById(@Param("id") Integer id); - void saveMissExamUser(long examPaperId); - - List<ExamPaper> selectTimeTaskPaper(Date time); } diff --git a/src/main/java/com/mindskip/xzs/repository/QuestionAnswerMapper.java b/src/main/java/com/mindskip/xzs/repository/QuestionAnswerMapper.java new file mode 100644 index 0000000..aa04b79 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/repository/QuestionAnswerMapper.java @@ -0,0 +1,20 @@ +package com.mindskip.xzs.repository; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mindskip.xzs.domain.QuestionAnswer; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author gonghl + * @description 閽堝琛ㄣ�恡_question_answer(闂瓟)銆戠殑鏁版嵁搴撴搷浣淢apper + * @createDate 2024-05-11 11:53:55 + * @Entity com.mindskip.xzs.questionAnswer.QuestionAnswer + */ +@Mapper +public interface QuestionAnswerMapper extends BaseMapper<QuestionAnswer> { + +} + + + + diff --git a/src/main/java/com/mindskip/xzs/repository/UserMapper.java b/src/main/java/com/mindskip/xzs/repository/UserMapper.java index 1895320..4ae498b 100644 --- a/src/main/java/com/mindskip/xzs/repository/UserMapper.java +++ b/src/main/java/com/mindskip/xzs/repository/UserMapper.java @@ -1,5 +1,6 @@ package com.mindskip.xzs.repository; +import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.ExamPaperAnswer; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.User; @@ -158,4 +159,6 @@ * @param deptId */ void clearDeptAdmin(List<Integer> userIds, @Param("deptId") Integer deptId); + + User getUserByExam(ExamPaper examPaper); } diff --git a/src/main/java/com/mindskip/xzs/service/ExamMissService.java b/src/main/java/com/mindskip/xzs/service/ExamMissService.java deleted file mode 100644 index 9463aeb..0000000 --- a/src/main/java/com/mindskip/xzs/service/ExamMissService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mindskip.xzs.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.mindskip.xzs.domain.ExamMiss; - -/** - * @author gonghl - * @description 閽堝琛ㄣ�恡_exam_miss(璇曞嵎缂鸿��)銆戠殑鏁版嵁搴撴搷浣淪ervice - * @createDate 2024-05-09 15:41:36 - */ -public interface ExamMissService extends IService<ExamMiss> { - -} diff --git a/src/main/java/com/mindskip/xzs/service/ExamPaperService.java b/src/main/java/com/mindskip/xzs/service/ExamPaperService.java index 691162c..ba50cd5 100644 --- a/src/main/java/com/mindskip/xzs/service/ExamPaperService.java +++ b/src/main/java/com/mindskip/xzs/service/ExamPaperService.java @@ -38,7 +38,5 @@ List<PaperExcelVO> getPaperExcelById(Integer id); - void addTimeTask(ExamPaper examPaper); - - void saveMissExamUser(long examPaperId); + void missExam(ExamPaperEditRequestVM model); } diff --git a/src/main/java/com/mindskip/xzs/service/QuestionAnswerService.java b/src/main/java/com/mindskip/xzs/service/QuestionAnswerService.java new file mode 100644 index 0000000..4808151 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/service/QuestionAnswerService.java @@ -0,0 +1,19 @@ +package com.mindskip.xzs.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.github.pagehelper.PageInfo; +import com.mindskip.xzs.domain.QuestionAnswer; +import com.mindskip.xzs.domain.vo.QuestionAnswerVO; + +/** + * @author gonghl + * @description 閽堝琛ㄣ�恡_question_answer(闂瓟)銆戠殑鏁版嵁搴撴搷浣淪ervice + * @createDate 2024-05-11 11:53:55 + */ +public interface QuestionAnswerService extends IService<QuestionAnswer> { + + PageInfo<QuestionAnswerVO> questionAnswerPage(QuestionAnswerVO questionAnswer); + + void updateStatus(Integer id); + +} diff --git a/src/main/java/com/mindskip/xzs/service/UserService.java b/src/main/java/com/mindskip/xzs/service/UserService.java index ab61ec6..6fc577d 100644 --- a/src/main/java/com/mindskip/xzs/service/UserService.java +++ b/src/main/java/com/mindskip/xzs/service/UserService.java @@ -1,5 +1,6 @@ package com.mindskip.xzs.service; +import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.User; import com.mindskip.xzs.domain.vo.UserVO; @@ -135,4 +136,6 @@ User getUserByRealName(String realName); void setStatus(UserVO user); + + User getUserByExam(ExamPaper examPaper); } diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamMissServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamMissServiceImpl.java deleted file mode 100644 index fc1a371..0000000 --- a/src/main/java/com/mindskip/xzs/service/impl/ExamMissServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mindskip.xzs.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.mindskip.xzs.domain.ExamMiss; -import com.mindskip.xzs.repository.ExamMissMapper; -import com.mindskip.xzs.service.ExamMissService; -import org.springframework.stereotype.Service; - -/** - * @author gonghl - * @description 閽堝琛ㄣ�恡_exam_miss(璇曞嵎缂鸿��)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 - * @createDate 2024-05-09 15:41:36 - */ -@Service -public class ExamMissServiceImpl extends ServiceImpl<ExamMissMapper, ExamMiss> implements ExamMissService { - -} - - - - diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java index f434bc1..67543e5 100644 --- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java +++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java @@ -10,7 +10,7 @@ import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.PaperExcelVO; -import com.mindskip.xzs.queue.ExamPaperTimeTask; +import com.mindskip.xzs.repository.ExamPaperAnswerMapper; import com.mindskip.xzs.repository.ExamPaperMapper; import com.mindskip.xzs.repository.QuestionMapper; import com.mindskip.xzs.repository.UserDepartmentMapper; @@ -20,22 +20,21 @@ import com.mindskip.xzs.utility.ExamUtil; import com.mindskip.xzs.utility.JsonUtil; import com.mindskip.xzs.utility.ModelMapperSingle; -import com.mindskip.xzs.utility.minio.DateUtils; import com.mindskip.xzs.viewmodel.admin.exam.*; import com.mindskip.xzs.viewmodel.admin.question.ExamQuestionVO; import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM; import com.mindskip.xzs.viewmodel.student.dashboard.PaperFilter; import com.mindskip.xzs.viewmodel.student.dashboard.PaperInfo; import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM; +import org.apache.commons.lang3.ObjectUtils; import org.modelmapper.ModelMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; -import javax.annotation.PostConstruct; import java.util.*; -import java.util.concurrent.DelayQueue; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -44,6 +43,7 @@ protected final static ModelMapper modelMapper = ModelMapperSingle.Instance(); private final ExamPaperMapper examPaperMapper; + private final ExamPaperAnswerMapper examPaperAnswerMapper; private final QuestionMapper questionMapper; private final TextContentService textContentService; private final QuestionService questionService; @@ -55,29 +55,14 @@ private final UserService userService; private final UserDepartmentMapper userDepartmentMapper; private final DepartmentService departmentService; - private final DelayQueue<ExamPaperTimeTask> QUEUE = new DelayQueue<>(); - /** - * 灏嗚繘琛屼腑鐨勫畾鏃惰瘯鍗峰姞鍏ュ埌闃熷垪涓紝骞跺惎鍔ㄤ竴涓嚎绋嬫潵杞闃熷垪 - */ - @PostConstruct - public void pollQueue() { - examPaperMapper.selectTimeTaskPaper(DateUtils.getNowDate()).forEach(this::addTimeTask); - new Thread(() -> { - try { - ExamPaperTimeTask task = QUEUE.take(); - saveMissExamUser(task.getExamPaperId()); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - }).start(); - } @Autowired - public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { + public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, ExamPaperAnswerMapper examPaperAnswerMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { super(examPaperMapper); this.examPaperMapper = examPaperMapper; + this.examPaperAnswerMapper = examPaperAnswerMapper; this.questionMapper = questionMapper; this.textContentService = textContentService; this.questionService = questionService; @@ -220,8 +205,11 @@ List<ExamPaperUser> examPaperUsers = examPaperUserService.getByExamPaperId(examPaper.getId()); Integer[][] userIds = new Integer[examPaperUsers.size()][2]; for (int i = 0; i < examPaperUsers.size(); i++) { - Integer[] userId = {userService.getUserById(examPaperUsers.get(i).getUserId()).getUserLevel(), examPaperUsers.get(i).getUserId()}; - userIds[i] = userId; + User user = userService.getUserById(examPaperUsers.get(i).getUserId()); + if (ObjectUtils.isNotEmpty(user)) { + Integer[] userId = {user.getUserLevel(), examPaperUsers.get(i).getUserId()}; + userIds[i] = userId; + } } vm.setUserId(userIds); return vm; @@ -617,15 +605,20 @@ } @Override - public void addTimeTask(ExamPaper examPaper) { - ExamPaperTimeTask examPaperTimeTask = new ExamPaperTimeTask(); - examPaperTimeTask.setExamPaperId(examPaper.getId()); - examPaperTimeTask.setExpiry(examPaper.getLimitEndTime().getTime()); - QUEUE.add(examPaperTimeTask); - } + @Transactional + public void missExam(ExamPaperEditRequestVM model) { + // 淇敼鍘熸潵鐨勮瘯鍗锋椂闂� + if (ObjectUtils.isNotEmpty(model.getLimitDateTime())) { + ExamPaper examPaper = new ExamPaper(); + examPaper.setId(model.getExamPaperId()); + examPaper.setLimitStartTime(DateTimeUtil.parse(model.getLimitDateTime().get(0), DateTimeUtil.STANDER_FORMAT)); + examPaper.setLimitEndTime(DateTimeUtil.parse(model.getLimitDateTime().get(1), DateTimeUtil.STANDER_FORMAT)); + examPaperMapper.updateByPrimaryKeySelective(examPaper); + } + // 鏍规嵁鑰冭瘯id灏嗛�夋嫨鐨勮ˉ鑰冭�冪敓鐨勮�冭瘯鎴愮哗璁剧疆涓烘棤鏁� + examPaperAnswerMapper.setMissExam(model); - @Override - public void saveMissExamUser(long examPaperId) { - examPaperMapper.saveMissExamUser(examPaperId); + // 琛ヨ�冩椂灏嗘病鏈夐�夋嫨鐨勫苟涓旀病鏈夊弬鍔犺繃鑰冭瘯鐨勮�冪敓澧炲姞涓�鏉¢浂鍒嗚�冭瘯璁板綍锛屽惁鍒欐病鏈夊弬鍔犺繃鑰冭瘯鐨勫嵆浣夸笉琚�夋嫨涔熷彲浠ュ弬鍔犺ˉ鑰� + examPaperAnswerMapper.insertDefault(model); } } diff --git a/src/main/java/com/mindskip/xzs/service/impl/QuestionAnswerServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/QuestionAnswerServiceImpl.java new file mode 100644 index 0000000..0694389 --- /dev/null +++ b/src/main/java/com/mindskip/xzs/service/impl/QuestionAnswerServiceImpl.java @@ -0,0 +1,58 @@ +package com.mindskip.xzs.service.impl; + +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.mindskip.xzs.domain.QuestionAnswer; +import com.mindskip.xzs.domain.enums.QuestionAnswerStatusEnum; +import com.mindskip.xzs.domain.vo.QuestionAnswerVO; +import com.mindskip.xzs.repository.QuestionAnswerMapper; +import com.mindskip.xzs.service.QuestionAnswerService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; + +/** + * @author gonghl + * @description 閽堝琛ㄣ�恡_question_answer(闂瓟)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 + * @createDate 2024-05-11 11:53:55 + */ +@Service +@RequiredArgsConstructor +public class QuestionAnswerServiceImpl extends ServiceImpl<QuestionAnswerMapper, QuestionAnswer> implements QuestionAnswerService { + + private final QuestionAnswerMapper questionAnswerMapper; + + @Override + public void updateStatus(Integer id) { + new LambdaUpdateChainWrapper<>(questionAnswerMapper) + .eq(QuestionAnswer::getId, id) + .set(QuestionAnswer::getStatus, "1".equals(getById(id).getStatus().getCode()) ? QuestionAnswerStatusEnum.DISABLE : QuestionAnswerStatusEnum.ENABLE) + .update(); + } + + @Override + public PageInfo<QuestionAnswerVO> questionAnswerPage(QuestionAnswerVO questionAnswerVO) { + return PageHelper.startPage(questionAnswerVO.getPageIndex(), questionAnswerVO.getPageSize()).doSelectPageInfo(() -> + new LambdaQueryChainWrapper<>(questionAnswerMapper) + .like(StringUtils.hasText(questionAnswerVO.getQuestion()), QuestionAnswer::getQuestion, questionAnswerVO.getQuestion()) + .or(StringUtils.hasText(questionAnswerVO.getQuestion()), wrapper -> wrapper.like(QuestionAnswer::getAnswer, questionAnswerVO.getQuestion())) + .orderByDesc(QuestionAnswer::getId) + .list()); + } + + @Override + public List<QuestionAnswer> list() { + return new LambdaQueryChainWrapper<>(questionAnswerMapper) + .eq(QuestionAnswer::getStatus, QuestionAnswerStatusEnum.ENABLE.getCode()) + .list(); + } +} + + + + diff --git a/src/main/java/com/mindskip/xzs/service/impl/TagServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/TagServiceImpl.java index c1f8c8b..9938353 100644 --- a/src/main/java/com/mindskip/xzs/service/impl/TagServiceImpl.java +++ b/src/main/java/com/mindskip/xzs/service/impl/TagServiceImpl.java @@ -28,7 +28,6 @@ return PageHelper.startPage(tag.getPageIndex(), tag.getPageSize(), "id desc").doSelectPageInfo(() -> new LambdaQueryChainWrapper<>(baseMapper) .like(StringUtils.hasText(tag.getName()), Tag::getName, tag.getName()) - .eq(Tag::getDeleted, false) .list() ); } diff --git a/src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java index b7c4452..b470504 100644 --- a/src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java +++ b/src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java @@ -1,5 +1,6 @@ package com.mindskip.xzs.service.impl; +import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.UserVO; import com.mindskip.xzs.exception.BusinessException; @@ -178,4 +179,8 @@ userMapper.setStatus(user); } + @Override + public User getUserByExam(ExamPaper examPaper) { + return userMapper.getUserByExam(examPaper); + } } diff --git a/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java b/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java index 5fc0d0a..67fc687 100644 --- a/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java +++ b/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java @@ -54,5 +54,6 @@ private String type; private String status; private String menuIds; + private Integer examPaperId; } diff --git a/src/main/resources/mapper/ExamMissMapper.xml b/src/main/resources/mapper/ExamMissMapper.xml deleted file mode 100644 index 48d51b4..0000000 --- a/src/main/resources/mapper/ExamMissMapper.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper - PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="com.mindskip.xzs.repository.ExamMissMapper"> - - <resultMap id="BaseResultMap" type="com.mindskip.xzs.domain.ExamMiss"> - <id property="id" column="id" jdbcType="INTEGER"/> - <result property="examId" column="exam_id" jdbcType="INTEGER"/> - <result property="userId" column="user_id" jdbcType="INTEGER"/> - </resultMap> - - <sql id="Base_Column_List"> - id,exam_id,user_id - </sql> -</mapper> diff --git a/src/main/resources/mapper/ExamPaperAnswerMapper.xml b/src/main/resources/mapper/ExamPaperAnswerMapper.xml index 2e9cba5..9f4e0bf 100644 --- a/src/main/resources/mapper/ExamPaperAnswerMapper.xml +++ b/src/main/resources/mapper/ExamPaperAnswerMapper.xml @@ -231,11 +231,19 @@ where id = #{id,jdbcType=INTEGER} </update> + <update id="setMissExam"> + update t_exam_paper_answer + set invalid = 1 + where exam_paper_id = #{examPaperId} + and create_user in ( + <foreach collection="userIds" item="item" index="index" separator=","> + #{item} + </foreach> + ) + </update> - - - <select id="studentPage" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM"> + <select id="studentPage" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM"> SELECT <include refid="Base_Column_List"/> FROM t_exam_paper_answer @@ -321,6 +329,7 @@ (#{item.examPaperId},#{item.userId}) </foreach> </if> + and (invalid = 0 or invalid is null) </select> <select id="adminPageByGrade" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM"> select @@ -386,4 +395,20 @@ where a.create_time </select> + <insert id="insertDefault"> + INSERT INTO t_exam_paper_answer(exam_paper_id, paper_name, paper_type, system_score, user_score, paper_score, question_correct, question_count, do_time, status, + create_user, create_time, invalid) + SELECT + a.id, a.name, a.paper_type, 0, 0, a.score, 0, a.question_count, 0, 2, b.user_id, NOW(), 0 + FROM t_exam_paper a + left join t_exam_paper_user b on a.id = b.exam_paper_id and b.deleted = 0 + left join t_exam_paper_answer c on a.id = c.exam_paper_id and c.create_user = b.user_id + WHERE a.id = #{examPaperId} + and c.id is null + and b.user_id not in + <foreach collection="userIds" item="item" open="(" close=")" separator=","> + #{item} + </foreach> + </insert> + </mapper> diff --git a/src/main/resources/mapper/ExamPaperMapper.xml b/src/main/resources/mapper/ExamPaperMapper.xml index de8bcd2..9a4c638 100644 --- a/src/main/resources/mapper/ExamPaperMapper.xml +++ b/src/main/resources/mapper/ExamPaperMapper.xml @@ -423,19 +423,4 @@ where a.exam_paper_id = #{id} </select> - <select id="saveMissExamUser" resultType="com.mindskip.xzs.domain.ExamMiss"> - INSERT INTO t_exam_miss(exam_id, user_id) - SELECT a.id, - b.user_id - FROM t_exam_paper a - left join t_exam_paper_user b on a.id = b.exam_paper_id - left join t_exam_paper_answer c on a.id = c.exam_paper_id and c.create_user = b.user_id - WHERE a.id = #{examPaperId} - and c.id is null - </select> - - <select id="selectTimeTaskPaper" resultType="com.mindskip.xzs.domain.ExamPaper"> - select id, limit_end_time from t_exam_paper where paper_type = 4 and limit_end_time >= #{time} and deleted = 0 - </select> - </mapper> diff --git a/src/main/resources/mapper/FeedbackMapper.xml b/src/main/resources/mapper/FeedbackMapper.xml index 6b6c8d0..64180f6 100644 --- a/src/main/resources/mapper/FeedbackMapper.xml +++ b/src/main/resources/mapper/FeedbackMapper.xml @@ -26,7 +26,8 @@ c.real_name as userName from t_feedback a left join t_text_content b on a.content_id = b.id - left join t_user c on a.user_id = c.id and deleted = 0 + left join t_user c on a.user_id = c.id and c.deleted = 0 + where a.deleted = 0 order by id desc </select> </mapper> diff --git a/src/main/resources/mapper/QuestionAnswerMapper.xml b/src/main/resources/mapper/QuestionAnswerMapper.xml new file mode 100644 index 0000000..ab8011f --- /dev/null +++ b/src/main/resources/mapper/QuestionAnswerMapper.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.mindskip.xzs.repository.QuestionAnswerMapper"> + + <resultMap id="BaseResultMap" type="com.mindskip.xzs.domain.QuestionAnswer"> + <id property="id" column="id" jdbcType="INTEGER"/> + <result property="question" column="question" jdbcType="VARCHAR"/> + <result property="answer" column="answer" jdbcType="VARCHAR"/> + <result property="deleted" column="deleted" jdbcType="BIT"/> + </resultMap> + + <sql id="Base_Column_List"> + id,question,answer, + deleted + </sql> +</mapper> diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index bf9ec38..45aa42a 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -268,7 +268,7 @@ select <include refid="Base_Column_List"/> from t_user - where id=#{value} and status = 1 and deleted = 0 + where id=#{value} and status = 1 and deleted = 0 and (`condition` = 0 or `condition` is null) </select> <select id="getUserByUserName" resultMap="BaseResultMap"> @@ -494,4 +494,18 @@ tu.id desc </select> + <select id="getUserByExam" resultType="com.mindskip.xzs.domain.User"> + <![CDATA[ + SELECT + d.* + FROM t_exam_paper a + left join t_exam_paper_user b on a.id = b.exam_paper_id and b.deleted = 0 + left join t_exam_paper_answer c on a.id = c.exam_paper_id and c.create_user = b.user_id + left join t_user d on b.user_id = d.id + WHERE a.id = #{id} + and (c.id is null or (user_score / paper_score) < 0.6) + and b.user_id = #{createUser} + ]]> + </select> + </mapper> -- Gitblit v1.8.0