“djh”
4 天以前 f99d902db3c31e57229439962abd2746bb06868d
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
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.ExStudent;
import com.gkhy.exam.system.service.ExStudentService;
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.*;
 
import java.util.Map;
 
/**
 * <p>
 * 学员表 前端控制器
 * </p>
 *
 * @author kzy
 * @since 2024-06-06 13:53:17
 */
@Api(tags = "学员前端控制器")
@RestController
@RequestMapping("/student")
public class ExStudentController {
    @Autowired
    private ExStudentService studentService;
 
 
    @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"),
            @ApiImplicitParam(paramType = "query", name = "duty", dataType = "String", required = false, value = "职务"),
            @ApiImplicitParam(paramType = "query", name = "name", dataType = "String", required = false, value = "姓名")
    })
    @GetMapping("/list")
    public CommonResult list(ExStudent student){
        return CommonResult.success(studentService.selectStudentList(student));
    }
 
    @ApiOperation(value = "学员列表全选")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "duty", dataType = "String", required = false, value = "职务"),
            @ApiImplicitParam(paramType = "query", name = "name", dataType = "String", required = false, value = "姓名")
    })
    @GetMapping("/list/checkAll")
    public CommonResult checkAll(ExStudent student){
        return CommonResult.success(studentService.selectStudentCheckAll(student));
    }
 
    @ApiOperation(value = "根据id获取学员信息")
    @GetMapping(value = { "/{studentId}" })
    public CommonResult getStudentInfo(@PathVariable(value = "studentId", required = true) Long studentId)
    {
        return CommonResult.success(studentService.selectStudentById(studentId));
    }
 
    @RepeatSubmit
    @Log(title = "学员管理", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增学员")
    @PostMapping
    public CommonResult add(@Validated @RequestBody ExStudent student){
        return CommonResult.success(studentService.insertStudent(student));
    }
 
    @RepeatSubmit
    @Log(title = "学员管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "编辑学员")
    @PutMapping
    public CommonResult edit(@RequestBody ExStudent student){
        return CommonResult.success(studentService.updateStudent(student));
    }
 
    @RepeatSubmit
    @Log(title = "学员管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除学员")
    @DeleteMapping(value = { "/{studentId}" })
    public CommonResult delete(@PathVariable(value = "studentId", required = true) Long studentId){
        return CommonResult.success(studentService.deleteStudentById(studentId));
    }
 
    @RepeatSubmit
    @Log(title = "学员管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "重置密码")
    @PutMapping(value = "/resetPwd")
    public CommonResult restPwd(@RequestBody ExStudent student){
        studentService.resetUserPwd(student);
        return CommonResult.success();
    }
 
 
    @ApiOperation(value = "校验手机号是否唯一")
    @PostMapping(value = "/checkPhoneUnique")
    public CommonResult checkPhoneUnique(@RequestBody ExStudent student){
        return CommonResult.success(studentService.checkPhoneUnique(student));
    }
 
 
    @ApiOperation(value = "校验身份证是否为一")
    @PostMapping(value = "/checkIdNoUnique")
    public CommonResult checkIdNoUnique(@RequestBody ExStudent student){
        return CommonResult.success(studentService.checkIdNoUnique(student.getIdNo()));
    }
 
 
    @ApiOperation(value = "学员企业归属变更")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "studentId", dataType = "long", required = true, value = "学员id"),
            @ApiImplicitParam(paramType = "body", name = "companyId", dataType = "long", required = true, value = "公司id")
    })
    @PreAuthorize("hasAnyAuthority('train:exam:system','train:exam:company')")
    @PostMapping(value = "/changeStudentCompany")
    public CommonResult changeStudentCompany(@RequestBody Map<String,Long> bodyMap){
        studentService.changeStudentCompany(bodyMap);
        return CommonResult.success();
    }
 
 
    @ApiOperation(value = "学员培训记录")
    @GetMapping(value = "/trainRecord")
    public CommonResult trainRecord(Long studentId){
        return CommonResult.success(studentService.trainRecord(studentId));
    }
 
}