xiangpei
2024-05-31 16d10cef208de048f8b325facd143c54b7be9963
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.ycl.jxkg.controller.admin;
 
import com.ycl.jxkg.base.BaseApiController;
import com.ycl.jxkg.base.Result;
import com.ycl.jxkg.domain.ExamPaper;
import com.ycl.jxkg.service.ExamPaperService;
import com.ycl.jxkg.utils.DateTimeUtil;
import com.ycl.jxkg.utils.PageInfoHelper;
import com.ycl.jxkg.vo.admin.exam.ExamPaperPageRequestVO;
import com.ycl.jxkg.vo.admin.exam.ExamPaperEditRequestVO;
import com.ycl.jxkg.vo.admin.exam.ExamResponseVO;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
 
@RestController("AdminExamPaperController")
@RequestMapping(value = "/api/admin/exam/paper")
public class ExamPaperController extends BaseApiController {
 
    private final ExamPaperService examPaperService;
 
    @Autowired
    public ExamPaperController(ExamPaperService examPaperService) {
        this.examPaperService = examPaperService;
    }
 
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public Result<PageInfo<ExamResponseVO>> pageList(@RequestBody ExamPaperPageRequestVO model) {
        PageInfo<ExamPaper> pageInfo = examPaperService.page(model);
        PageInfo<ExamResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> {
            ExamResponseVO vo = new ExamResponseVO();
            BeanUtils.copyProperties(e, vo);
            vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            return vo;
        });
        return Result.ok(page);
    }
 
 
 
    @RequestMapping(value = "/taskExamPage", method = RequestMethod.POST)
    public Result<PageInfo<ExamResponseVO>> taskExamPageList(@RequestBody ExamPaperPageRequestVO model) {
        PageInfo<ExamPaper> pageInfo = examPaperService.taskExamPage(model);
        PageInfo<ExamResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> {
            ExamResponseVO vo = new ExamResponseVO();
            BeanUtils.copyProperties(e, vo);
            vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            return vo;
        });
        return Result.ok(page);
    }
 
 
 
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public Result<ExamPaperEditRequestVO> edit(@RequestBody @Valid ExamPaperEditRequestVO model) {
        ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser());
        ExamPaperEditRequestVO newVM = examPaperService.examPaperToVM(examPaper.getId());
        return Result.ok(newVM);
    }
 
    @RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
    public Result<ExamPaperEditRequestVO> select(@PathVariable Integer id) {
        ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id);
        return Result.ok(vm);
    }
 
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
    public Result delete(@PathVariable Integer id) {
        ExamPaper examPaper = examPaperService.selectById(id);
        examPaper.setDeleted(true);
        examPaperService.updateByIdFilter(examPaper);
        return Result.ok();
    }
}