Browse Source

修改编辑小二账号功能缺失

zhangqiang 10 months ago
parent
commit
d5d0775aa4

+ 33 - 2
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/account/service/impl/OkkiAccountServiceImpl.java

@@ -77,8 +77,39 @@ public class OkkiAccountServiceImpl extends ServiceImpl<OkkiAccountMapper, OkkiA
     public void updateAccount(OkkiAccount okkiAccount) {
         // TODO::密码重置
         // 站点关联
-        bindSites(okkiAccount);
-        this.updateById(okkiAccount);
+        // 请求okki平台接口
+        Map<String, String> query = new TreeMap<>();
+        query.put("sign_method", "hmac-md5");
+        query.put("timestamp", String.valueOf(System.currentTimeMillis()));
+        query.put("site_id", "sp_weichi");
+        query.put("method", "bindSite");
+        Map<String, Object> postData = new HashMap<>();
+        try {
+            String queryStr = HttpClientUtils.buildQueryString(query);
+            postData.put("user_id", okkiAccount.getUserId());
+            // 字符串转数组
+            String siteIds = okkiAccount.getSiteIds();
+            String[] split = siteIds.split(",");
+            postData.put("site_ids", split);
+            postData.put("type", "update");
+
+            String body = HttpClientUtils.toJsonString(postData);
+            String signStr = queryStr + body;
+            query.put("signature", HttpClientUtils.generateHmacMD5(signStr, CLIENT_SECRET));
+            String okkiUrl = URL + "?" + HttpClientUtils.buildQueryString(query);
+            log.info("url:" + okkiUrl + ",body:" + body);
+            String res = HttpClientUtils.doPost(okkiUrl, body);
+            log.info(res);
+            // {"code":0,"msg":"success","now":"2024-05-06 15:34:54","data":[]}
+            JSONObject jsonObject= JSONObject.parseObject(res);
+            if (jsonObject.get("code").equals(0)) {
+                this.updateById(okkiAccount);
+            }else {
+                throw new RuntimeException(jsonObject.get("msg").toString());
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
     }
 
     private void bindSites(OkkiAccount okkiAccount) {