InnerAPIController.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package com.fdkankan.manage.controller.inner;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.fdkankan.manage.common.ResultCode;
  4. import com.fdkankan.manage.common.ResultData;
  5. import com.fdkankan.manage.controller.BaseController;
  6. import com.fdkankan.manage.entity.JySceneUserAuth;
  7. import com.fdkankan.manage.entity.JyUser;
  8. import com.fdkankan.manage.entity.UserShareParam;
  9. import com.fdkankan.manage.exception.BusinessException;
  10. import com.fdkankan.manage.service.*;
  11. import com.fdkankan.manage.util.RsaUtils;
  12. import com.fdkankan.manage.vo.request.SceneParam;
  13. import com.fdkankan.manage.vo.request.UserParam;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.*;
  17. @RestController
  18. @RequestMapping("/service/manage/inner")
  19. public class InnerAPIController extends BaseController {
  20. @Autowired
  21. IJyUserService jyUserService;
  22. @Autowired
  23. IUserService userService;
  24. @Autowired
  25. IJySceneUserAuthService jySceneUserAuthService;
  26. @Autowired
  27. IScenePlusService scenePlusService;
  28. @Autowired
  29. IJyUserShareService jyUserShareService;
  30. @PostMapping("/getByRyId")
  31. public ResultData getByRyId(@RequestBody UserParam param){
  32. if(StringUtils.isBlank(param.getRyNo()) && StringUtils.isBlank(param.getRyId())){
  33. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  34. }
  35. JyUser jyuser = null;
  36. if(StringUtils.isNotBlank(param.getRyId())){
  37. jyuser = jyUserService.getByRyId(param.getRyId());
  38. if(jyuser == null){
  39. throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
  40. }
  41. }
  42. if(StringUtils.isNotBlank(param.getRyNo())){
  43. jyuser = jyUserService.getByRyNo(param.getRyNo());
  44. if(jyuser == null){
  45. throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
  46. }
  47. }
  48. return ResultData.ok(jyuser);
  49. }
  50. @PostMapping("/getByRyNo")
  51. public ResultData getByRyNo(@RequestBody UserParam param){
  52. return ResultData.ok(jyUserService.getByRyNo(param.getRyNo()));
  53. }
  54. @PostMapping("/updateStatus")
  55. public ResultData updateStatus(@RequestBody UserParam userParam){
  56. userService.updateStatus(userParam);
  57. return ResultData.ok();
  58. }
  59. @PostMapping("/addUcenterUser")
  60. public ResultData addUcenterUser(@RequestBody UserParam param){
  61. userService.addUcenterUser(param);
  62. return ResultData.ok();
  63. }
  64. @PostMapping("/delUcenterUser")
  65. public ResultData delUcenterUser(@RequestBody UserParam param){
  66. userService.delUcenterUser(param);
  67. return ResultData.ok();
  68. }
  69. @PostMapping("/addAuth")
  70. public ResultData addAuth(@RequestBody JySceneUserAuth param){
  71. param.setCanDel(1);
  72. jySceneUserAuthService.addAuth(param);
  73. return ResultData.ok();
  74. }
  75. @PostMapping("/setAuthType")
  76. public ResultData setAuthType(@RequestBody JySceneUserAuth param){
  77. jySceneUserAuthService.setAuthType(param);
  78. return ResultData.ok();
  79. }
  80. @PostMapping("/delAuth")
  81. public ResultData delAuth(@RequestBody JySceneUserAuth param){
  82. if(StringUtils.isBlank(param.getNum()) || (StringUtils.isBlank(param.getRyId()) && StringUtils.isBlank(param.getRyNo()))){
  83. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  84. }
  85. JySceneUserAuth db = null;
  86. if(StringUtils.isNotBlank(param.getRyId())){
  87. db = jySceneUserAuthService.getByNumAndRyId(param.getNum(),param.getRyId());
  88. }
  89. if(StringUtils.isNotBlank(param.getRyNo())){
  90. db = jySceneUserAuthService.getByNumAndRyNo(param.getNum(),param.getRyNo());
  91. }
  92. if(db == null){
  93. throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
  94. }
  95. jySceneUserAuthService.delAuth(db);
  96. return ResultData.ok();
  97. }
  98. @PostMapping("/checkAuthOther")
  99. public ResultData checkAuthOther(@RequestBody JySceneUserAuth param){
  100. return ResultData.ok(jySceneUserAuthService.checkAuthOther(param));
  101. }
  102. @GetMapping("/checkNumAuth/{num}")
  103. public ResultData checkNumAuth(@PathVariable String num){
  104. return ResultData.ok( jySceneUserAuthService.checkNumAuth(num,getToken()));
  105. }
  106. @PostMapping("/getAuthType")
  107. public ResultData getAuthType(@RequestBody SceneParam param){
  108. return ResultData.ok(jySceneUserAuthService.getAuthType(param));
  109. }
  110. @PostMapping("/getAuthList")
  111. public ResultData getAuthList(@RequestBody SceneParam param){
  112. if(StringUtils.isBlank(param.getRyId()) && StringUtils.isBlank(param.getRyNo())){
  113. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  114. }
  115. return ResultData.ok(jySceneUserAuthService.getAuthList(param));
  116. }
  117. @PostMapping("/getSceneList")
  118. public ResultData getSceneList(@RequestBody SceneParam param){
  119. if(StringUtils.isBlank(param.getRyId()) && StringUtils.isBlank(param.getRyNo())){
  120. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  121. }
  122. JyUser jyUser = null;
  123. if(StringUtils.isNotBlank(param.getRyId()) ){
  124. jyUser = jyUserService.getByRyId(param.getRyId());
  125. if(jyUser == null){
  126. throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
  127. }
  128. }
  129. if(StringUtils.isNotBlank(param.getRyNo()) ){
  130. jyUser = jyUserService.getByRyNo(param.getRyNo());
  131. if(jyUser == null){
  132. throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
  133. }
  134. }
  135. if(jyUser == null){
  136. throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
  137. }
  138. UserShareParam shareParam = new UserShareParam();
  139. shareParam.setJyUserId(Math.toIntExact(jyUser.getUserId()));
  140. return ResultData.ok(jyUserShareService.sceneList(shareParam));
  141. }
  142. }