From be2b2bdda5192533814da191f5eb286d78f56437 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 07 六月 2024 11:29:36 +0800 Subject: [PATCH] 替换为restful风格 --- src/main/java/com/ycl/jxkg/controller/admin/ExamPaperAnswerController.java | 46 ++++++++++++---------------------------------- 1 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperAnswerController.java b/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperAnswerController.java index 30937ca..043c20b 100644 --- a/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperAnswerController.java +++ b/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperAnswerController.java @@ -1,21 +1,17 @@ package com.ycl.jxkg.controller.admin; +import com.github.pagehelper.PageInfo; import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; -import com.ycl.jxkg.domain.ExamPaperAnswer; -import com.ycl.jxkg.domain.Subject; -import com.ycl.jxkg.domain.User; -import com.ycl.jxkg.service.*; -import com.ycl.jxkg.utils.DateTimeUtil; -import com.ycl.jxkg.utils.ExamUtil; -import com.ycl.jxkg.utils.PageInfoHelper; -import com.ycl.jxkg.vo.student.exampaper.ExamPaperAnswerPageResponseVO; -import com.ycl.jxkg.vo.admin.paper.ExamPaperAnswerPageRequestVO; -import com.github.pagehelper.PageInfo; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; +import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; +import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; +import com.ycl.jxkg.service.ExamPaperAnswerService; +import com.ycl.jxkg.service.SubjectService; +import com.ycl.jxkg.service.UserService; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +@RequiredArgsConstructor @RestController("AdminExamPaperAnswerController") @RequestMapping(value = "/api/admin/examPaperAnswer") public class ExamPaperAnswerController extends BaseApiController { @@ -24,32 +20,14 @@ private final SubjectService subjectService; private final UserService userService; - @Autowired - public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, SubjectService subjectService, UserService userService) { - this.examPaperAnswerService = examPaperAnswerService; - this.subjectService = subjectService; - this.userService = userService; + @PostMapping("/pageExamPaper") + public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageExamPaper(@RequestBody ExamPaperAnswerPageRequestVO model) { + return Result.ok(examPaperAnswerService.pageExamPaper(model)); } - @RequestMapping(value = "/page", method = RequestMethod.POST) public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageJudgeList(@RequestBody ExamPaperAnswerPageRequestVO model) { - PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.adminPage(model); - PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { - ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO(); - BeanUtils.copyProperties(e, vo); - Subject subject = subjectService.selectById(vo.getSubjectId()); - vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); - vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); - vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); - vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); - vo.setSubjectName(subject.getName()); - vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); - User user = userService.selectById(e.getCreateUser()); - vo.setUserName(user.getUserName()); - return vo; - }); - return Result.ok(page); + return Result.ok(examPaperAnswerService.adminPage(model)); } -- Gitblit v1.8.0