Ver Fonte

fix mj-plus 接口增加api秘钥

zwhui há 2 anos atrás
pai
commit
361661ddcb

+ 5 - 5
netflix-service/src/main/java/com/cyksj/service/midjourney/impl/MidJourneyAccountServiceImpl.java

@@ -129,7 +129,7 @@ public class MidJourneyAccountServiceImpl extends ServiceImpl<MidjourneyAccountM
 
     private void addAcount(MidjourneyAccount midjourneyAccount) throws Exception {
         Map<String, Object> accountParam = createAccountParam(midjourneyAccount);
-        String body = HttpRequest.post(HOST + "/mj/account/create").body(Jsons.toJson(accountParam)).execute().body();
+        String body = HttpRequest.post(HOST + "/mj/account/create").header("mj-api-secret", "5a9a3e9b-5a5e-4b6b-9a5a-9a5a5a5a5a5a").body(Jsons.toJson(accountParam)).execute().body();
         log.info("addAccount body:{}", body);
         JSONObject jsonObject = JSONUtil.parseObj(body);
         if (jsonObject.getInt("code") != 1) {
@@ -184,7 +184,7 @@ public class MidJourneyAccountServiceImpl extends ServiceImpl<MidjourneyAccountM
     }
 
     private void delAcount(Long id) {
-        String body = HttpRequest.delete(HOST + "/mj/account/"+id+"/delete").execute().body();
+        String body = HttpRequest.delete(HOST + "/mj/account/"+id+"/delete").header("mj-api-secret", "5a9a3e9b-5a5e-4b6b-9a5a-9a5a5a5a5a5a").execute().body();
         log.info("delAcount body:{}", body);
         JSONObject jsonObject = JSONUtil.parseObj(body);
         if (jsonObject.getInt("code") != 1) {
@@ -193,7 +193,7 @@ public class MidJourneyAccountServiceImpl extends ServiceImpl<MidjourneyAccountM
     }
 
     private Long getAccount(Long id) throws Exception {
-        String body = HttpRequest.post(HOST + "/mj/account/query").body(Jsons.toJson(MapUtil.of("remark", id))).execute().body();
+        String body = HttpRequest.post(HOST + "/mj/account/query").header("mj-api-secret", "5a9a3e9b-5a5e-4b6b-9a5a-9a5a5a5a5a5a").body(Jsons.toJson(MapUtil.of("remark", id))).execute().body();
         log.info("getAccount body:{}", body);
         JSONObject jsonObject = JSONUtil.parseObj(body);
         return JSONUtil.parseObj(JSONUtil.parseArray(jsonObject.getStr("content")).get(0)).get("id", Long.class);
@@ -202,7 +202,7 @@ public class MidJourneyAccountServiceImpl extends ServiceImpl<MidjourneyAccountM
     private void updAccount(MidjourneyAccount midjourneyAccount){
         Map<String, Object> accountParam = createAccountParam(midjourneyAccount);
         String body = HttpRequest.put(HOST + "/mj/account/"+midjourneyAccount.getInstanceId()+"/update-reconnect")
-                .body(JSONUtil.toJsonStr(accountParam)).execute().body();
+                .header("mj-api-secret", "5a9a3e9b-5a5e-4b6b-9a5a-9a5a5a5a5a5a").body(JSONUtil.toJsonStr(accountParam)).execute().body();
         log.info("updAccount body:{}", body);
         JSONObject jsonObject = JSONUtil.parseObj(body);
         if (jsonObject.getInt("code") != 1) {
@@ -211,7 +211,7 @@ public class MidJourneyAccountServiceImpl extends ServiceImpl<MidjourneyAccountM
     }
 
     private String syncInfo(Long id){
-        String body = HttpRequest.post(HOST + "/mj/account/"+id+"/sync-info").execute().body();
+        String body = HttpRequest.post(HOST + "/mj/account/"+id+"/sync-info").header("mj-api-secret", "5a9a3e9b-5a5e-4b6b-9a5a-9a5a5a5a5a5a").execute().body();
         log.info("syncInfo body:{}", body);
         JSONObject jsonObject = JSONUtil.parseObj(body);
         if (jsonObject.getInt("code") != 1) {