StaffController.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. package com.dk.mdm.controller.mst;
  2. import com.dk.common.model.pojo.PageList;
  3. import com.dk.common.response.ResponseResultUtil;
  4. import com.dk.common.response.ResponseResultVO;
  5. import com.dk.common.util.ExcelUtils;
  6. import com.dk.mdm.model.pojo.mst.Staff;
  7. import com.dk.common.service.BaseService;
  8. import com.dk.mdm.model.query.mst.StaffQuery;
  9. import com.dk.common.model.response.mst.StaffResponse;
  10. import com.dk.mdm.model.vo.mst.StaffVO;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import org.springframework.web.bind.annotation.*;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import io.swagger.annotations.Api;
  17. import com.dk.mdm.service.mst.StaffService;
  18. import org.springframework.web.multipart.MultipartFile;
  19. import javax.servlet.http.HttpServletResponse;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. /**
  23. * @author : 姜永辉
  24. * @desc : 员工API接口
  25. * @date : 2023/1/4 9:25
  26. */
  27. @Api(tags = "员工API接口")
  28. @RestController
  29. @RequestMapping("/mst/staff")
  30. @Slf4j
  31. public class StaffController {
  32. public BaseService<Staff> getService() {
  33. return staffService;
  34. }
  35. @Autowired
  36. private StaffService staffService;
  37. /**
  38. * @desc : 条件查询
  39. * @author : 姜永辉
  40. * @date : 2023/1/9 10:36
  41. */
  42. @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
  43. @PostMapping({"list_by"})
  44. public ResponseResultVO<PageList<StaffResponse>> selectByCond(@RequestBody StaffQuery staffQuery) {
  45. return staffService.selectByCond(staffQuery);
  46. }
  47. /**
  48. * @desc : 通过ID查询
  49. * @author : 姜永辉
  50. * @date : 2023/1/9 10:41
  51. */
  52. @PostMapping({"/{id}"})
  53. public ResponseResultVO selectById(@PathVariable String id) {
  54. return staffService.selectById(id);
  55. }
  56. /**
  57. * @desc : 新建员工--权限
  58. * @author : 姜永辉
  59. * @date : 2023/1/9 10:48
  60. */
  61. @ApiOperation(value = "新建员工--权限", notes = "新建员工--权限")
  62. @PostMapping({"save_staff_right"})
  63. public ResponseResultVO<?> saveStaffRight(@RequestBody StaffVO staffVO) {
  64. return staffService.saveStaffRight(staffVO);
  65. }
  66. /**
  67. * @desc : 新建员工--权限
  68. * @author : 姜永辉
  69. * @date : 2023/1/9 10:48
  70. */
  71. @ApiOperation(value = "新建员工--权限", notes = "新建员工--权限")
  72. @PostMapping({"save_staff_preview"})
  73. public ResponseResultVO<?> saveStaffPurview(@RequestBody StaffVO staffVO) {
  74. return staffService.saveStaffPurview(staffVO);
  75. }
  76. /**
  77. * @desc : 新建员工
  78. * @author : 姜永辉
  79. * @date : 2023/1/9 10:48
  80. */
  81. @ApiOperation(value = "新建员工", notes = "新建员工")
  82. @PostMapping({"insert"})
  83. public ResponseResultVO<?> insert(@RequestBody StaffVO staffVO) {
  84. return staffService.insert(staffVO);
  85. }
  86. /**
  87. * @desc : 新建员工--邀请员工的确定
  88. * @author : 姜永辉
  89. * @date : 2023/1/9 10:48
  90. */
  91. @ApiOperation(value = "邀请员工的确定", notes = "邀请员工的确定")
  92. @PostMapping({"insert_request"})
  93. public ResponseResultVO<?> insertRequestStaff(@RequestBody StaffVO staffVO) {
  94. return staffService.insertRequestStaff(staffVO);
  95. }
  96. /**
  97. * @desc : 编辑员工
  98. * @author : 姜永辉
  99. * @date : 2023/1/9 10:49
  100. */
  101. @ApiOperation(value = "编辑员工", notes = "编辑员工")
  102. @PostMapping({"update"})
  103. public ResponseResultVO<Boolean> update(@RequestBody StaffVO staffVO) {
  104. return staffService.update(staffVO);
  105. }
  106. /**
  107. * @desc : 停用
  108. * @author : 姜永辉
  109. * @date : 2023/1/9 10:34
  110. */
  111. @ApiOperation(value = "停用", notes = "停用")
  112. @PostMapping("disable/{id}")
  113. public ResponseResultVO<Boolean> disable(@PathVariable String id) {
  114. return this.getService().disable(id);
  115. }
  116. /**
  117. * @desc : 启用
  118. * @author : 姜永辉
  119. * @date : 2023/1/9 10:34
  120. */
  121. @ApiOperation(value = "启用", notes = "启用")
  122. @PostMapping("enable/{id}")
  123. public ResponseResultVO<Boolean> enable(@PathVariable String id) {
  124. return this.getService().enable(id);
  125. }
  126. /**
  127. * @desc : 员工离职
  128. * @author : 姜永辉
  129. * @date : 2023/2/13 13:15
  130. */
  131. @ApiOperation(value = "员工离职", notes = "员工离职")
  132. @PostMapping({"dimission"})
  133. @Transactional(rollbackFor = Exception.class)
  134. public ResponseResultVO<Boolean> dimission(@RequestBody StaffVO staffVO) {
  135. return staffService.dimission(staffVO);
  136. }
  137. /**
  138. * @desc : 员工导入
  139. * @author : 姜永辉
  140. * @date : 2023/2/28 14:32
  141. */
  142. @ApiOperation(value = "导入", notes = "导入")
  143. @PostMapping("import")
  144. @Transactional(rollbackFor = Exception.class)
  145. public ResponseResultVO<Boolean> importList(MultipartFile file) {
  146. List<StaffVO> list = ExcelUtils.importExcel(file, 1, 1, StaffVO.class);
  147. return staffService.importStaffList(list);
  148. }
  149. /**
  150. * @desc : 导出模板
  151. * @author : 洪旭东
  152. * @date : 2023-08-01 11:44
  153. */
  154. @ApiOperation(value = "导出模板", notes = "导出模板")
  155. @GetMapping("export_template")
  156. public void exportTemplate(HttpServletResponse response) {
  157. String title = "员工导入模板";
  158. ExcelUtils.exportExcel(new ArrayList<>(), title, title, StaffVO.class, title + ".xls", response);
  159. }
  160. /**
  161. * @desc : 体验产品-从oauth服务调用的函数
  162. * @author : 姜永辉
  163. * @date : 2023-11-02 16:27
  164. */
  165. @PostMapping({"/feign_get_experience"})
  166. ResponseResultVO<StaffResponse> getFeignExperience(@RequestBody StaffQuery staffQuery) {
  167. ResponseResultVO<PageList<StaffResponse>> pageListResponseResultVO = staffService.selectByCond(staffQuery);
  168. log.info("feign_get_experience" + pageListResponseResultVO.toString());
  169. return ResponseResultUtil.success(pageListResponseResultVO.getData().getList().get(0));
  170. }
  171. }