StaffController.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.common.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.Dictionary;
  22. import java.util.List;
  23. import java.util.Map;
  24. /**
  25. * @author : 姜永辉
  26. * @desc : 员工API接口
  27. * @date : 2023/1/4 9:25
  28. */
  29. @Api(tags = "员工API接口")
  30. @RestController
  31. @RequestMapping("/mst/staff")
  32. @Slf4j
  33. public class StaffController {
  34. public BaseService<Staff> getService() {
  35. return staffService;
  36. }
  37. @Autowired
  38. private StaffService staffService;
  39. /**
  40. * @desc : 条件查询
  41. * @author : 姜永辉
  42. * @date : 2023/1/9 10:36
  43. */
  44. @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
  45. @PostMapping({"list_by"})
  46. public ResponseResultVO<PageList<StaffResponse>> selectByCond(@RequestBody StaffQuery staffQuery) {
  47. return staffService.selectByCond(staffQuery);
  48. }
  49. /**
  50. * @desc : 通过ID查询
  51. * @author : 姜永辉
  52. * @date : 2023/1/9 10:41
  53. */
  54. @PostMapping({"/{id}"})
  55. public ResponseResultVO selectById(@PathVariable String id) {
  56. return staffService.selectById(id);
  57. }
  58. /**
  59. * @desc : 新建员工--权限
  60. * @author : 姜永辉
  61. * @date : 2023/1/9 10:48
  62. */
  63. @ApiOperation(value = "新建员工--权限", notes = "新建员工--权限")
  64. @PostMapping({"save_staff_right"})
  65. public ResponseResultVO<?> saveStaffRight(@RequestBody StaffVO staffVO) {
  66. return staffService.saveStaffRight(staffVO);
  67. }
  68. /**
  69. * @desc : 新建员工--权限
  70. * @author : 姜永辉
  71. * @date : 2023/1/9 10:48
  72. */
  73. @ApiOperation(value = "新建员工--权限", notes = "新建员工--权限")
  74. @PostMapping({"save_staff_preview"})
  75. public ResponseResultVO<?> saveStaffPurview(@RequestBody StaffVO staffVO) {
  76. return staffService.saveStaffPurview(staffVO);
  77. }
  78. /**
  79. * @desc : 新建员工
  80. * @author : 姜永辉
  81. * @date : 2023/1/9 10:48
  82. */
  83. @ApiOperation(value = "新建员工", notes = "新建员工")
  84. @PostMapping({"insert"})
  85. public ResponseResultVO<?> insert(@RequestBody StaffVO staffVO) {
  86. return staffService.insert(staffVO);
  87. }
  88. /**
  89. * @desc : 新建员工--邀请员工的确定
  90. * @author : 姜永辉
  91. * @date : 2023/1/9 10:48
  92. */
  93. @ApiOperation(value = "邀请员工的确定", notes = "邀请员工的确定")
  94. @PostMapping({"insert_request"})
  95. public ResponseResultVO<?> insertRequestStaff(@RequestBody StaffVO staffVO) {
  96. return staffService.insertRequestStaff(staffVO);
  97. }
  98. /**
  99. * @desc : 新建员工--注册商户用的
  100. * @author : 姜永辉
  101. * @date : 2023/1/9 10:48
  102. */
  103. @ApiOperation(value = "新建员工", notes = "新建员工")
  104. @PostMapping({"insert_feign_staff"})
  105. public ResponseResultVO<?> insertFeignStaff(@RequestBody StaffVO staffVO) {
  106. return staffService.insertFeignStaff(staffVO);
  107. }
  108. /**
  109. * @desc : 编辑员工
  110. * @author : 姜永辉
  111. * @date : 2023/1/9 10:49
  112. */
  113. @ApiOperation(value = "编辑员工", notes = "编辑员工")
  114. @PostMapping({"update"})
  115. public ResponseResultVO<Boolean> update(@RequestBody StaffVO staffVO) {
  116. return staffService.update(staffVO);
  117. }
  118. /**
  119. * @desc : 停用
  120. * @author : 姜永辉
  121. * @date : 2023/1/9 10:34
  122. */
  123. @ApiOperation(value = "停用", notes = "停用")
  124. @PostMapping("disable/{id}")
  125. public ResponseResultVO<Boolean> disable(@PathVariable String id) {
  126. return this.getService().disable(id);
  127. }
  128. /**
  129. * @desc : 启用
  130. * @author : 姜永辉
  131. * @date : 2023/1/9 10:34
  132. */
  133. @ApiOperation(value = "启用", notes = "启用")
  134. @PostMapping("enable/{id}")
  135. public ResponseResultVO<Boolean> enable(@PathVariable String id) {
  136. return this.getService().enable(id);
  137. }
  138. /**
  139. * @desc : 员工离职
  140. * @author : 姜永辉
  141. * @date : 2023/2/13 13:15
  142. */
  143. @ApiOperation(value = "员工离职", notes = "员工离职")
  144. @PostMapping({"dimission"})
  145. @Transactional(rollbackFor = Exception.class)
  146. public ResponseResultVO<Boolean> dimission(@RequestBody StaffVO staffVO) {
  147. return staffService.dimission(staffVO);
  148. }
  149. /**
  150. * @desc : 员工导入
  151. * @author : 姜永辉
  152. * @date : 2023/2/28 14:32
  153. */
  154. @ApiOperation(value = "导入", notes = "导入")
  155. @PostMapping("import")
  156. @Transactional(rollbackFor = Exception.class)
  157. public ResponseResultVO<Boolean> importList(MultipartFile file) {
  158. List<StaffVO> list = ExcelUtils.importExcel(file, 1, 1, StaffVO.class);
  159. return staffService.importStaffList(list);
  160. }
  161. /**
  162. * @desc : 导出模板
  163. * @author : 洪旭东
  164. * @date : 2023-08-01 11:44
  165. */
  166. @ApiOperation(value = "导出模板", notes = "导出模板")
  167. @GetMapping("export_template")
  168. public void exportTemplate(HttpServletResponse response) {
  169. String title = "员工导入模板";
  170. ExcelUtils.exportExcel(new ArrayList<>(), title, title, StaffVO.class, title + ".xls", response);
  171. }
  172. /**
  173. * @desc : 体验产品-从oauth服务调用的函数
  174. * @author : 姜永辉
  175. * @date : 2023-11-02 16:27
  176. */
  177. @PostMapping({"/feign_get_experience"})
  178. ResponseResultVO<StaffResponse> getFeignExperience(@RequestBody StaffQuery staffQuery) {
  179. ResponseResultVO<PageList<StaffResponse>> pageListResponseResultVO = staffService.selectByCond(staffQuery);
  180. log.info("feign_get_experience" + pageListResponseResultVO.toString());
  181. return ResponseResultUtil.success(pageListResponseResultVO.getData().getList().get(0));
  182. }
  183. /**
  184. * @desc : 登录后获取信息
  185. * @author : 周兴
  186. * @date : 2024/3/4 12:47
  187. */
  188. @ApiOperation(
  189. value = "登录后获取信息",
  190. notes = "登录后获取信息"
  191. )
  192. @PostMapping("get_info_after_login")
  193. public ResponseResultVO<Dictionary<String,Object>> getInfoAfterLogin(@RequestBody Map<String, Object> param) {
  194. return staffService.getInfoAfterLogin(param);
  195. }
  196. /**
  197. * @desc : 退出登录
  198. * @author : 周兴
  199. * @date : 2024/3/18 12:47
  200. */
  201. @ApiOperation(
  202. value = "退出登录",
  203. notes = "退出登录"
  204. )
  205. @PostMapping("logout")
  206. public ResponseResultVO<Boolean> logout(@RequestBody Map<String, Object> param) {
  207. return staffService.logout(param);
  208. }
  209. }