qirong
2023-07-28 fbdd6af3039a83cd4727a03cecb7c5914277371f
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
package com.mindskip.xzs.controller.student;
 
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.User;
import com.mindskip.xzs.domain.vo.ExamTemplatesUserCountVO;
import com.mindskip.xzs.repository.ExamTemplatesMapper;
import com.mindskip.xzs.service.ExamTemplatesUserCountService;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.stream.Collectors;
 
@RestController("StudentExamTemplatesUserCountController")
@RequestMapping(value = "/api/student/exam/count")
public class ExamTemplatesUserCountController extends BaseApiController {
 
    private final ExamTemplatesUserCountService examTemplatesUserCountService;
    private final ExamTemplatesMapper examTemplatesMapper;
 
    public ExamTemplatesUserCountController(ExamTemplatesUserCountService examTemplatesUserCountService, ExamTemplatesMapper examTemplatesMapper) {
        this.examTemplatesUserCountService = examTemplatesUserCountService;
        this.examTemplatesMapper = examTemplatesMapper;
    }
 
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public RestResponse<PageInfo<ExamTemplatesUserCountVO>> select(@RequestBody ExamPaperPageRequestVM model) throws Exception {
        User user = getCurrentUser();
        model.setUserId(user.getId());
        PageInfo<ExamTemplatesUserCountVO> info = examTemplatesUserCountService.list(model);
        info.setList(info.getList().stream().map(e->{
            e.setName(examTemplatesMapper.getById(e.getId()).getName());
            return e;
        }).collect(Collectors.toList()));
        return RestResponse.ok(info);
    }
}