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; /** *
* 学员表 前端控制器 *
* * @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