|
@@ -1,6 +1,9 @@
|
|
|
package com.skyversation.xjcy.controller;
|
|
package com.skyversation.xjcy.controller;
|
|
|
|
|
|
|
|
-import com.skyversation.xjcy.service.SerialNumberGenerator;
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.skyversation.xjcy.dms.DMSColumn;
|
|
|
|
|
+import com.skyversation.xjcy.dms.DMSService;
|
|
|
|
|
+import com.skyversation.xjcy.service.AuthService;
|
|
|
import com.skyversation.xjcy.service.WeChatService;
|
|
import com.skyversation.xjcy.service.WeChatService;
|
|
|
import com.skyversation.xjcy.util.MessageManage;
|
|
import com.skyversation.xjcy.util.MessageManage;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -11,8 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+import static com.skyversation.xjcy.service.AuthService.RESPONSE_FIELD_USERNAME;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Validated
|
|
@Validated
|
|
@@ -21,14 +26,45 @@ import java.util.Arrays;
|
|
|
public class OtherController {
|
|
public class OtherController {
|
|
|
|
|
|
|
|
private final WeChatService weChatService;
|
|
private final WeChatService weChatService;
|
|
|
|
|
+ private final AuthService authService;
|
|
|
|
|
+ private final DMSService dMSService;
|
|
|
|
|
|
|
|
- public OtherController(WeChatService weChatService) {
|
|
|
|
|
|
|
+ public OtherController(WeChatService weChatService, AuthService authService, DMSService dMSService) {
|
|
|
this.weChatService = weChatService;
|
|
this.weChatService = weChatService;
|
|
|
|
|
+ this.authService = authService;
|
|
|
|
|
+ this.dMSService = dMSService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "/wxacode", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
@RequestMapping(value = "/wxacode", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
- public ResponseEntity<byte[]> serialNumber(@RequestParam(required = false)String path,
|
|
|
|
|
- @RequestParam(required = false)String scene) {
|
|
|
|
|
|
|
+ public ResponseEntity<byte[]> wxacode(@RequestParam(required = false) String path,
|
|
|
|
|
+ @RequestParam(required = false) String scene) {
|
|
|
return weChatService.createWxacode(path, scene);
|
|
return weChatService.createWxacode(path, scene);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping(value = "/bindEnterprise")
|
|
|
|
|
+ public String bindEnterprise(@RequestParam(required = false) String enterprise, @RequestParam(required = false) String token) {
|
|
|
|
|
+ if (enterprise != null && enterprise.isEmpty()) enterprise = null;
|
|
|
|
|
+ if (!authService.checkToken(token)) {
|
|
|
|
|
+ return MessageManage.error(-1, "请提供有效token");
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject userContent = authService.getUserContentByToken(token);
|
|
|
|
|
+ String usercode = userContent.getString(RESPONSE_FIELD_USERNAME);
|
|
|
|
|
+
|
|
|
|
|
+ //更新dms记录
|
|
|
|
|
+ List<JSONObject> userJsons = dMSService.getUserJSONByCode(usercode, authService.getTokenOfServiceAccount());
|
|
|
|
|
+ if (!userJsons.isEmpty()) {
|
|
|
|
|
+ JSONObject userJSON = userJsons.get(0);
|
|
|
|
|
+ if (userJSON != null) {
|
|
|
|
|
+ userJSON.put("c_gl_gs", enterprise);
|
|
|
|
|
+ dMSService.updateToDms(Collections.singletonList(userJSON), authService.getTokenOfServiceAccount(), DMSColumn.USER);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (enterprise == null) {
|
|
|
|
|
+ authService.deUpgradeRoleEnterprise(userContent);
|
|
|
|
|
+ return MessageManage.successWithNoData("成功解除此用户的相关绑定");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ authService.upgradeRoleEnterprise(userContent);
|
|
|
|
|
+ return MessageManage.successWithNoData("成功绑定到对应企业");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|