智慧保安后台管理-外网
Administrator
2021-08-31 08363052cecb30230a2c8b3eba791ca8d1be00a5
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package org.springblade.modules.exam.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamSubjectChoices;
import org.springblade.modules.exam.excel.ExamScoreExcel;
import org.springblade.modules.exam.excel.ExamScoreImporter;
import org.springblade.modules.exam.excel.ExamSubjectExcel;
import org.springblade.modules.exam.excel.ExamSubjectImporter;
import org.springblade.modules.exam.service.ExamSubjectChoicesService;
import org.springblade.modules.exam.vo.ExamSubjectChoicesVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * @author zhongrj
 * @time 2021-07-16
 * @desc 选择题管理控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/examSubjectChoices")
public class ExamSubjectChoicesController {
 
    private final ExamSubjectChoicesService examSubjectChoicesService;
 
    /**
     * 自定义分页
     *
     * @param query              page,size
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/page")
    public R<IPage<ExamSubjectChoicesVO>> page(ExamSubjectChoicesVO examSubjectChoices, Query query) {
        IPage<ExamSubjectChoicesVO> pages = examSubjectChoicesService.selectExamSubjectChoicesPage(Condition.getPage(query), examSubjectChoices);
        return R.data(pages);
    }
 
    /**
     * 分页
     */
    @GetMapping("/list")
    public R<IPage<ExamSubjectChoices>> list(ExamSubjectChoices examSubjectChoices, Query query) {
        IPage<ExamSubjectChoices> pages = examSubjectChoicesService.page(Condition.getPage(query), Condition.getQueryWrapper(examSubjectChoices));
        return R.data(pages);
    }
 
 
    /**
     * 新增
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入examSubjectChoices")
    public R save(@RequestBody ExamSubjectChoices examSubjectChoices) {
        return R.status(examSubjectChoicesService.save(examSubjectChoices));
    }
 
 
    /**
     * 新增题目及选项信息
     *
     * @param examSubjectChoices 题目信息对象
     */
    @PostMapping("/saveSubjectChoicesAndOption")
    @ApiOperation(value = "新增", notes = "传入examSubjectChoices")
    public R saveSubjectChoicesAndOption(@RequestBody ExamSubjectChoicesVO examSubjectChoices) {
        return R.status(examSubjectChoicesService.saveSubjectChoicesAndOption(examSubjectChoices));
    }
 
    /**
     * 修改
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody ExamSubjectChoices examSubjectChoices) {
        return R.status(examSubjectChoicesService.updateById(examSubjectChoices));
    }
 
    /**
     * 新增或修改
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody ExamSubjectChoices examSubjectChoices) {
        if (null != examSubjectChoices.getId()) {
            examSubjectChoices.setCreateDate(new Date());
        } else {
            examSubjectChoices.setModifyDate(new Date());
        }
        return R.status(examSubjectChoicesService.saveOrUpdate(examSubjectChoices));
    }
 
    /**
     * 删除
     *
     * @param ids 选择题信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        return R.status(examSubjectChoicesService.removeByIds(Func.toLongList(ids)));
    }
 
    /**
     * 详情
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入examSubjectChoices")
    public R<ExamSubjectChoices> detail(ExamSubjectChoices examSubjectChoices) {
        //查询选择题详情
        ExamSubjectChoices detail = examSubjectChoicesService.getOne(Condition.getQueryWrapper(examSubjectChoices));
        //返回
        return R.data(detail);
    }
 
 
    /**
     * 详情(包含选项信息)
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/details")
    @ApiOperation(value = "详情", notes = "传入examSubjectChoices")
    public R<ExamSubjectChoicesVO> details(ExamSubjectChoices examSubjectChoices) {
        //查询选择题详情
        ExamSubjectChoicesVO detail = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices);
        //返回
        return R.data(detail);
    }
 
    /**
     * 获取下一题的题目,并判断上一题的答案,且返回上一题答题结果
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/getSubjectResultInfo")
    @ApiOperation(value = "详情", notes = "传入examSubjectChoices")
    public R<ExamSubjectChoicesVO> getSubjectResultInfo(ExamSubjectChoicesVO examSubjectChoices) {
        //查询下一题题目详情
        ExamSubjectChoicesVO detail = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices);
        //判断当前题目的答题结果
        if (examSubjectChoices.getPreSubJectId()!=null) {
            if (null!=examSubjectChoices.getPreResult() && examSubjectChoices.getPreResult()!="" && !examSubjectChoices.getPreResult().equals("")) {
                detail.setResult(examSubjectChoicesService.getAnswerResult(examSubjectChoices.getPreSubJectId(), examSubjectChoices.getPreResult()));
            }else {
                //无
                detail.setResult(3);
            }
        }
        //返回
        return R.data(detail);
    }
 
    /**
     * 查询试卷包含的题目
     */
    @GetMapping("/getEexPaperChoices")
    public R<IPage<ExamSubjectChoicesVO>> getEexPaperChoices(ExamSubjectChoicesVO examSubjectChoices, Query query) {
        IPage<ExamSubjectChoicesVO> pages = examSubjectChoicesService.getEexPaperChoices(Condition.getPage(query), examSubjectChoices);
        return R.data(pages);
    }
 
    /**
     * 修改单项题目分值
     */
    @PostMapping("/updateChoicesValue")
    public R updateChoicesValue(String id,String value) {
        return R.status(examSubjectChoicesService.updateChoicesValue(id,value));
    }
 
    /**
     * 导入题库
     * @param isCovered 1 覆盖  0不覆盖
     * @return
     */
    @PostMapping("import-examSubject")
    @ApiOperation(value = "导入题库", notes = "传入excel")
    public R importExamScore(MultipartFile file, Integer isCovered) {
        ExamSubjectImporter examSubjectImporter = new ExamSubjectImporter(examSubjectChoicesService, false);
        ExcelUtil.save(file, examSubjectImporter, ExamSubjectExcel.class);
        return R.success("操作成功");
    }
 
    /**
     * 导出模板
     */
    @GetMapping("export-template")
    @ApiOperation(value = "导出模板")
    public void exportUser(HttpServletResponse response) {
        List<ExamSubjectExcel> list = new ArrayList<>();
        ExcelUtil.export(response, "题库导入数据模板", "题库导入数据表", list, ExamSubjectExcel.class);
    }
 
}