Explorar o código

清除GPT次数接口

zoujiajian hai 1 ano
pai
achega
92d6aa4f85

+ 1 - 3
netflix-service/src/main/java/com/cyksj/service/chatgpt/ChatGptAccountService.java

@@ -1,10 +1,7 @@
 package com.cyksj.service.chatgpt;
 
-import com.cyksj.model.entity.Account;
 import com.cyksj.model.entity.ChatgptSession;
 import com.cyksj.model.entity.ChatgptUser;
-import com.cyksj.model.request.gpt.ConversationRequest;
-import com.cyksj.model.response.ConversationLimitResponse;
 import com.cyksj.model.views.ChatGptUserView;
 import com.cyksj.model.views.ChatgptCarInfoView;
 import com.ejlchina.searcher.SearchResult;
@@ -57,4 +54,5 @@ public interface ChatGptAccountService {
      */
     String getGptSession(String account, String password);
 
+    void clearGptNum(Long relationId) throws Exception;
 }

+ 11 - 0
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -16,6 +16,7 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.common.util.Jsons;
 import com.cyksj.common.util.StringUtil;
 import com.cyksj.mapper.*;
 import com.cyksj.mapper.station.CollegeStudentStationUseTicketRecordMapper;
@@ -114,6 +115,16 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         return officialSession;
     }
 
+    @Override
+    public void clearGptNum(Long relationId) throws Exception {
+        HttpRequest request = new HttpRequest("http://154.198.213.52:9611/cleanUserTokenLimit?relationId=" + relationId);
+        HttpResponse execute = request.method(Method.GET).execute();
+        String body = execute.body();
+        JSONObject re = Jsons.parseObject(body, JSONObject.class);
+        if (!body.contains("成功")) {
+            throw BusinessRuntimeException.getInstance(re.getStr("message"));
+        }
+    }
 
     /**
      * 获取登录结果

+ 12 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java

@@ -30,6 +30,7 @@ import com.cyksj.model.request.OrderRefundReq;
 import com.cyksj.model.request.corp.CorpCommonReq;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
+import com.cyksj.service.chatgpt.ChatGptAccountService;
 import com.cyksj.service.corp.CorpService;
 import com.cyksj.service.corp.CorpUserService;
 import com.cyksj.service.mange.CmsOrderDonService;
@@ -90,6 +91,8 @@ public class WxCorpController {
 
 	private final CorpFollowMapper corpFollowMapper;
 
+	private final ChatGptAccountService chatGptAccountService;
+
 	private final static String CORP_UUID = "corp-uuid";
 
 	/**
@@ -519,4 +522,13 @@ public class WxCorpController {
 		corpUserService.spotifySelfService(orderId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
+
+	/**
+	 * 清除gpt次数
+	 */
+	@PutMapping("/clear/gpt/num")
+	public Result<String> clearGptNum(Long relationId) throws Exception {
+		chatGptAccountService.clearGptNum(relationId);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
 }