dengsixing hace 4 meses
padre
commit
59c43ba557

+ 7 - 0
pom.xml

@@ -201,6 +201,13 @@
       <version>1.5.24</version>
     </dependency>
 
+    <dependency>
+      <groupId>com.coze</groupId>
+      <artifactId>coze-api</artifactId>
+      <version>0.3.0</version>
+    </dependency>
+
+
   </dependencies>
   <build>
     <finalName>${artifactId}</finalName>

+ 56 - 0
src/main/java/com/fdkankan/contro/controller/Test.java

@@ -0,0 +1,56 @@
+package com.fdkankan.contro.controller;
+
+import com.coze.openapi.client.chat.CreateChatReq;
+import com.coze.openapi.client.chat.model.ChatEvent;
+import com.coze.openapi.client.chat.model.ChatEventType;
+import com.coze.openapi.client.connversations.message.model.Message;
+import com.coze.openapi.service.auth.TokenAuth;
+import com.coze.openapi.service.config.Consts;
+import com.coze.openapi.service.service.CozeAPI;
+import io.reactivex.Flowable;
+import okhttp3.OkHttpClient;
+
+import java.util.Collections;
+
+public class Test {
+
+    public static void main(String[] args) {
+
+        //客户端id
+        String token = "pat_0Y2BAveK0QbYuBf288449wQtuVoq52SWJsfeCkYU6WJ3Fi1iJnKezCi8LWolfr2z";
+        String botID = "7494469232462676008";
+        String userID = "123123";
+
+        TokenAuth authCli = new TokenAuth(token);
+
+        CozeAPI coze =
+                new CozeAPI.Builder()
+                        .baseURL(Consts.COZE_CN_BASE_URL)
+                        .auth(authCli)
+                        .client(new OkHttpClient.Builder().build())
+                        .build();
+
+        CreateChatReq req =
+                CreateChatReq.builder()
+                        .botID(botID)
+                        .userID(userID)
+                        .messages(Collections.singletonList(Message.buildUserQuestionText("我帅吗?")))
+                        .build();
+
+        Flowable<ChatEvent> resp = coze.chat().stream(req);
+        resp.blockingForEach(
+                event -> {
+                    if (ChatEventType.CONVERSATION_MESSAGE_DELTA.equals(event.getEvent())) {
+                        System.out.print(event.getMessage().getContent());
+                    }
+                    if (ChatEventType.CONVERSATION_CHAT_COMPLETED.equals(event.getEvent())) {
+                        System.out.println("Token usage:" + event.getChat().getUsage().getTokenCount());
+                    }
+                });
+        System.out.println("done");
+        coze.shutdownExecutor();
+
+    }
+
+
+}

+ 14 - 0
src/main/java/com/fdkankan/contro/service/impl/GenerateObjFileServiceImpl.java

@@ -62,6 +62,14 @@ public class GenerateObjFileServiceImpl implements IGenerateObjFileService {
             throw new BusinessException(ErrorCode.FAILURE_CODE_3037);
         }
 
+        LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper
+                .set(ScenePro::getStatus, 0)
+                .set(ScenePro::getIsObj, 1)
+                .set(ScenePro::getIsUpgrade, 2)   //   升级中
+                .eq(ScenePro::getNum, sceneProEntity.getNum());
+        sceneProService.update(updateWrapper);
+
         // 获取最新的场景名称
         //同步到scenePlus、scenePlus
         ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
@@ -103,6 +111,12 @@ public class GenerateObjFileServiceImpl implements IGenerateObjFileService {
 
         }
 
+        LambdaUpdateWrapper<ScenePlus> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper
+                .set(ScenePlus::getSceneStatus, 0)
+                .eq(ScenePlus::getNum, num);
+        scenePlusService.update(updateWrapper);
+
         LambdaUpdateWrapper<ScenePlusExt> plusExtUpdateWrapper = new LambdaUpdateWrapper<>();
         plusExtUpdateWrapper
                 .set(ScenePlusExt::getIsObj, 1)