heheng
6 天以前 d8012ee77b6a9e86611aae9074d5925826f4210d
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
package com.gkhy.exam.admin.controller.web;
 
 
import com.gkhy.exam.common.annotation.Log;
import com.gkhy.exam.common.annotation.RepeatSubmit;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.common.enums.BusinessType;
import com.gkhy.exam.system.domain.ExExamPaper;
import com.gkhy.exam.system.service.ExExamPaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 * 考卷(组卷)表 前端控制器
 * </p>
 *
 * @author kzy
 * @since 2024-06-05 15:07:36
 */
@Api(tags = "组卷(试卷)前端控制器")
@RestController
@RequestMapping("/exam-paper")
public class ExExamPaperController {
    @Autowired
    private ExExamPaperService examPaperService;
 
    @ApiOperation(value = "试卷列表(分页)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", dataType = "int", required = false, value = "当前页,默认1"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", dataType = "int", required = false, value = "每页数目,默认10")
    })
    @GetMapping("/list")
    public CommonResult list(ExExamPaper examPaper){
        return CommonResult.success(examPaperService.selectExamPaperList(examPaper));
    }
 
    @ApiOperation(value = "根据id获取考卷信息")
    @GetMapping(value = { "/{paperId}" })
    public CommonResult getExamPaperInfo(@PathVariable(value = "paperId", required = true) Long paperId)
    {
        return CommonResult.success(examPaperService.selectExamPaperById(paperId));
    }
 
    @RepeatSubmit
    @PreAuthorize("hasAnyAuthority('train:exam:company','train:exam:depart','train:exam:workshop','train:exam:other')")
    @Log(title = "试卷管理", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增试卷")
    @PostMapping
    public CommonResult add(@Validated @RequestBody ExExamPaper examPaper){
        return CommonResult.success(examPaperService.insertExamPaper(examPaper));
    }
 
    @RepeatSubmit
    @PreAuthorize("hasAnyAuthority('train:exam:company','train:exam:depart','train:exam:workshop','train:exam:other')")
    @Log(title = "试卷管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "编辑试卷")
    @PutMapping
    public CommonResult edit(@Validated @RequestBody ExExamPaper examPaper){
        return CommonResult.success(examPaperService.updateExamPaper(examPaper));
    }
 
    @RepeatSubmit
    @PreAuthorize("hasAnyAuthority('train:exam:company','train:exam:depart','train:exam:workshop','train:exam:other')")
    @Log(title = "试卷管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除试卷")
    @DeleteMapping(value = { "/{paperId}" })
    public CommonResult delete(@PathVariable(value = "paperId", required = true) Long paperId){
        return CommonResult.success(examPaperService.deleteExamPaperById(paperId));
    }
 
    @ApiOperation(value = "校验试卷名称是否唯一")
    @PostMapping("/checkNameUnique")
    public CommonResult checkNameUnique(@RequestBody ExExamPaper examPaper)
    {
        return CommonResult.success(examPaperService.checkNameUnique(examPaper));
    }
 
    @RepeatSubmit
    @Log(title = "试卷管理", businessType = BusinessType.UPDATE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "id", dataType = "long", required = false, value = "试卷id"),
            @ApiImplicitParam(paramType = "body", name = "status", dataType = "int", required = false, value = "状态(0正常,1停用)")
    })
    @ApiOperation(value = "修改试卷状态")
    @PutMapping("/changeStatus")
    public CommonResult changeStatus(@Validated @RequestBody ExExamPaper examPaper){
        return CommonResult.success(examPaperService.changeExamPaperStatus(examPaper.getId(),examPaper.getStatus()));
    }
 
}