ExaminationBasicController.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package com.keao.edu.user.controller;
  2. import com.keao.edu.auth.api.client.SysUserFeignService;
  3. import com.keao.edu.auth.api.entity.SysUser;
  4. import com.keao.edu.common.controller.BaseController;
  5. import com.keao.edu.common.entity.HttpResponseResult;
  6. import com.keao.edu.common.page.PageInfo;
  7. import com.keao.edu.user.dto.ExaminationBasicDto;
  8. import com.keao.edu.user.entity.Employee;
  9. import com.keao.edu.user.entity.ExaminationBasic;
  10. import com.keao.edu.user.enums.ExamStatusEnum;
  11. import com.keao.edu.user.page.ExaminationQueryInfo;
  12. import com.keao.edu.user.service.EmployeeService;
  13. import com.keao.edu.user.service.ExaminationBasicService;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.*;
  18. import java.util.Objects;
  19. /**
  20. * @Author Joburgess
  21. * @Date 2020.06.18
  22. */
  23. @RestController
  24. @RequestMapping("examinationBasic")
  25. @Api(tags = "考级项目服务")
  26. public class ExaminationBasicController extends BaseController {
  27. @Autowired
  28. private ExaminationBasicService examinationBasicService;
  29. @Autowired
  30. private SysUserFeignService sysUserFeignService;
  31. @Autowired
  32. private EmployeeService employeeService;
  33. @ApiOperation("查询指定考级项目")
  34. @GetMapping(value = "/getExaminationBasic")
  35. public HttpResponseResult<ExaminationBasicDto> getExaminationBasic(Integer examId) {
  36. return succeed(examinationBasicService.getExaminationBasic(examId));
  37. }
  38. @ApiOperation("分页查询")
  39. @GetMapping(value = "/list")
  40. public HttpResponseResult<PageInfo<ExaminationBasicDto>> getList(ExaminationQueryInfo queryInfo) {
  41. SysUser sysUser = sysUserFeignService.queryUserInfo();
  42. if(!sysUser.getIsSuperAdmin()){
  43. Employee employee = employeeService.get(sysUser.getId());
  44. if(Objects.isNull(employee)){
  45. return failed("用户信息异常");
  46. }
  47. queryInfo.setOrganId(employee.getOrganId());
  48. }
  49. return succeed(examinationBasicService.findExaminationBasics(queryInfo));
  50. }
  51. @ApiOperation("创建考级项目")
  52. @PostMapping(value = "/addExaminationBasic")
  53. public HttpResponseResult<ExaminationBasic> addExaminationBasic(@RequestBody ExaminationBasic examinationBasic){
  54. SysUser sysUser = sysUserFeignService.queryUserInfo();
  55. Employee employee = employeeService.get(sysUser.getId());
  56. if(Objects.isNull(employee)){
  57. return failed("用户信息异常");
  58. }
  59. examinationBasic.setCreatorId(sysUser.getId());
  60. examinationBasic.setOrganId(employee.getOrganId());
  61. return succeed(examinationBasicService.addExaminationBasic(examinationBasic));
  62. }
  63. @ApiOperation("更新考级项目")
  64. @PostMapping(value = "/update")
  65. public HttpResponseResult update(@RequestBody ExaminationBasic examinationBasic){
  66. SysUser sysUser = sysUserFeignService.queryUserInfo();
  67. examinationBasicService.updateExam(examinationBasic,sysUser.getId());
  68. return succeed();
  69. }
  70. @ApiOperation("更新考级项目状态")
  71. @PostMapping(value = "/updateExamBasicStatus")
  72. public HttpResponseResult updateExamBasicStatus(Long examId, ExamStatusEnum statusEnum){
  73. SysUser sysUser = sysUserFeignService.queryUserInfo();
  74. examinationBasicService.updateExamBasicStatus(examId, statusEnum, sysUser.getId());
  75. return succeed();
  76. }
  77. @ApiOperation("关闭考级项目")
  78. @PostMapping(value = "/closeExam")
  79. public HttpResponseResult closeExam(Integer examId, String reason){
  80. SysUser sysUser = sysUserFeignService.queryUserInfo();
  81. Integer organId = null;
  82. if(!sysUser.getIsSuperAdmin()){
  83. Employee employee = employeeService.get(sysUser.getId());
  84. if(Objects.isNull(employee)){
  85. return failed("用户信息异常");
  86. }
  87. organId = employee.getOrganId();
  88. }
  89. examinationBasicService.closeExam(organId, examId, reason);
  90. return succeed();
  91. }
  92. @ApiOperation("获取考级项目信息")
  93. @PostMapping(value = "/getInfo")
  94. public HttpResponseResult<ExaminationBasic> getInfo(Integer examId){
  95. return succeed(examinationBasicService.getInfo(examId));
  96. }
  97. }