SettingsController.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package thyyxxk.webserver.controller.settings;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import lombok.Data;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.GetMapping;
  7. import org.springframework.web.bind.annotation.PostMapping;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import org.springframework.web.bind.annotation.RestController;
  12. import org.springframework.web.multipart.MultipartFile;
  13. import thyyxxk.webserver.config.auth.PassToken;
  14. import thyyxxk.webserver.entity.ResultVo;
  15. import thyyxxk.webserver.entity.login.PersonnelQueryConditions;
  16. import thyyxxk.webserver.entity.login.UserInfo;
  17. import thyyxxk.webserver.entity.settings.deptphones.DeptPhones;
  18. import thyyxxk.webserver.entity.settings.permissions.DeptTree;
  19. import thyyxxk.webserver.entity.settings.permissions.Role;
  20. import thyyxxk.webserver.entity.settings.permissions.SaveRoleMenusParam;
  21. import thyyxxk.webserver.entity.settings.permissions.SaveUserRolesParam;
  22. import thyyxxk.webserver.entity.settings.users.ChangePwdParam;
  23. import thyyxxk.webserver.entity.settings.users.WorkIntegrationPlatformAdvice;
  24. import thyyxxk.webserver.service.settings.SettingsService;
  25. import thyyxxk.webserver.utils.ResultVoUtil;
  26. import java.io.IOException;
  27. import java.util.List;
  28. import java.util.Map;
  29. @RestController
  30. @RequestMapping("/settings")
  31. public class SettingsController {
  32. private final SettingsService service;
  33. @Autowired
  34. public SettingsController(SettingsService service) {
  35. this.service = service;
  36. }
  37. @GetMapping("/getUserInfo")
  38. public ResultVo<UserInfo> getUserInfo() {
  39. return service.getUserInfo();
  40. }
  41. @PostMapping("/changePassword")
  42. public ResultVo<String> changePassword(@RequestBody ChangePwdParam param) {
  43. return service.changePassword(param);
  44. }
  45. @GetMapping("/getDeptTree")
  46. public ResultVo<List<DeptTree>> getDeptTree() {
  47. return service.getDeptTree();
  48. }
  49. @PostMapping("/getAllUsers")
  50. public ResultVo<IPage<UserInfo>> getAllUsers(@RequestBody PersonnelQueryConditions param) {
  51. return service.getAllUsers(param);
  52. }
  53. @GetMapping("/getAllRoles")
  54. public ResultVo<List<Role>> getAllRoles() {
  55. return service.getAllRoles();
  56. }
  57. @GetMapping("/getUserRoles")
  58. public ResultVo<List<Integer>> getUserRoles(@RequestParam("code") String code) {
  59. return service.getUserRoles(code);
  60. }
  61. @PostMapping("/saveUserRoles")
  62. public ResultVo<String> saveUserRoles(@RequestBody SaveUserRolesParam param) {
  63. return service.saveUserRoles(param);
  64. }
  65. @GetMapping("/addNewRole")
  66. public ResultVo<String> addNewRole(@RequestParam("name") String name) {
  67. return service.addNewRole(name.trim());
  68. }
  69. @GetMapping("/getDeptPhones")
  70. public ResultVo<List<DeptPhones>> getDeptPhones() {
  71. return service.getDeptPhones();
  72. }
  73. @PostMapping("/saveDeptPhone")
  74. public ResultVo<String> saveDeptPhone(@RequestBody DeptPhones param) {
  75. return service.saveDeptPhone(param);
  76. }
  77. @GetMapping("/getMyAdvices")
  78. public ResultVo<List<WorkIntegrationPlatformAdvice>> getMyAdvices() {
  79. return service.getMyAdvices();
  80. }
  81. @PostMapping("/submitNewAdvice")
  82. public ResultVo<String> submitNewAdvice(@RequestBody WorkIntegrationPlatformAdvice advice) {
  83. return service.submitNewAdvice(advice);
  84. }
  85. @GetMapping("/checkAdvice")
  86. public ResultVo<String> checkAdvice(@RequestParam("id") Integer id) {
  87. return service.checkAdvice(id);
  88. }
  89. @GetMapping("/dismissUserBadge")
  90. public ResultVo<String> dismissUserBadge(@RequestParam("id") Integer id) {
  91. return service.dismissUserBadge(id);
  92. }
  93. @PostMapping("/replyAdvice")
  94. public ResultVo<String> replyAdvice(@RequestBody WorkIntegrationPlatformAdvice advice) {
  95. return service.replyAdvice(advice);
  96. }
  97. @GetMapping("/getRoleVueMenus")
  98. public ResultVo<List<Integer>> getRoleVueMenus(@RequestParam("id") Integer id) {
  99. return service.getRoleVueMenus(id);
  100. }
  101. @PostMapping("/saveRoleVueMenus")
  102. public ResultVo<String> saveRoleVueMenus(@RequestBody SaveRoleMenusParam param) {
  103. return service.saveRoleVueMenus(param);
  104. }
  105. @PostMapping("/modifyEmployeeInfo")
  106. public ResultVo<String> modifyEmployeeInfo(@RequestBody UserInfo userInfo) {
  107. return service.modifyEmployeeInfo(userInfo);
  108. }
  109. @PassToken
  110. @PostMapping("/saveEmployeeInfo")
  111. public ResultVo<String> saveEmployeeInfo(@RequestBody UserInfo userInfo) {
  112. return service.saveEmployeeInfo(userInfo);
  113. }
  114. @Data
  115. public static class ResetPassword {
  116. private String code;
  117. private Integer nextTime;
  118. }
  119. @PostMapping("/resetPasswordByCode")
  120. public ResultVo<String> resetPasswordByCode(@RequestBody ResetPassword r) {
  121. return service.resetPasswordByCode(r.getCode(), r.getNextTime());
  122. }
  123. @GetMapping("/selectAutographImageByCode")
  124. public ResultVo<Map<String, Object>> selectAutographImageByCode(@RequestParam("code") String code) {
  125. return service.selectAutographImageByCode(code);
  126. }
  127. @PostMapping("/putAutographImage")
  128. public ResultVo<JSONObject> putAutographImage(@RequestBody MultipartFile file,
  129. @RequestParam(value = "code", required = false) String code) {
  130. return service.putAutographImage(file, code);
  131. }
  132. @PostMapping("/setUserConfig")
  133. public ResultVo<String> setUserConfig(@RequestBody UserInfo js) {
  134. service.setUserConfig(js.getUserConfig());
  135. return ResultVoUtil.success();
  136. }
  137. @PassToken
  138. @GetMapping("/importUser")
  139. public void importUser() throws IOException {
  140. service.importUser();
  141. }
  142. }