소스 검색

fix 新增车队选项,车队数量可选

chenbiao 2 년 전
부모
커밋
eb006ac279

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

@@ -57,7 +57,7 @@ public interface ChatGptAccountService {
 
     ChatgptUser getCarChatGptUserWithToken(String userToken);
 
-    Set<ChatgptCarInfoView> getCarInfoList(String userToken);
+    Set<ChatgptCarInfoView> getCarInfoList(String userToken, Integer limit, Boolean isPlus);
 
     ChatGptUserView getUserInfo(long userId, Long relationId);
 

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

@@ -624,7 +624,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
      * 获取车队信息
      */
     @Override
-    public Set<ChatgptCarInfoView> getCarInfoList(String userToken) {
+    public Set<ChatgptCarInfoView> getCarInfoList(String userToken, Integer limit, Boolean isPlus) {
         SearchResult<ChatGptUserConversationRecordHistoryView> search = beanSearcher.search(ChatGptUserConversationRecordHistoryView.class, MapUtils.builder().field("userToken", userToken).limit(0, 2).build());
         Set<ChatgptCarInfoView> res = search.getDataList().stream()
                 .map((historyView) -> {
@@ -635,7 +635,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                     return chatgptCarInfoView;
                 }).collect(Collectors.toCollection(LinkedHashSet::new));
 
-        Set<ChatgptCarInfoView> lowestScoreFleets = getLowestScoreFleets(10);
+        Set<ChatgptCarInfoView> lowestScoreFleets = getLowestScoreFleets(limit, isPlus);
 
         res.addAll(lowestScoreFleets);
 
@@ -685,7 +685,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
 
 
     // 获取得分最低的N个车队的方法
-    public Set<ChatgptCarInfoView> getLowestScoreFleets(int count) {
+    public Set<ChatgptCarInfoView> getLowestScoreFleets(int count, Boolean isPlus) {
         Set<ZSetOperations.TypedTuple<Object>> lowestScorecarIds;
         Long fleetsSize = redisService.zCard(RedisService.key.CHATGPT_CAR_SCORES.getName());
         // 构建ChatgptCarInfoView集合
@@ -698,7 +698,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         }
         lowestScorecarIds = redisService.zRangeWithScores(RedisService.key.CHATGPT_CAR_SCORES.getName(), 0L, count - 1);
         Map<Object, Double> collect = lowestScorecarIds.stream().collect(Collectors.toMap(ZSetOperations.TypedTuple::getValue, ZSetOperations.TypedTuple::getScore));
-        List<ChatgptSession> chatgptSessions = chatgptSessionMapper.selectList(Wrappers.lambdaQuery(ChatgptSession.class).in(ChatgptSession::getCarId, collect.keySet()));
+        List<ChatgptSession> chatgptSessions = chatgptSessionMapper.selectList(Wrappers.lambdaQuery(ChatgptSession.class).in(ChatgptSession::getCarId, collect.keySet()).eq(isPlus !=null && isPlus, ChatgptSession::getIsPlus, true));
         return chatgptSessions.stream().map((chatgptSession)-> buildChatgptCarInfoView(chatgptSession.getCarId(),chatgptSession.getCarName(), chatgptSession.getIsPlus(), collect.get(chatgptSession.getCarId())))
                 .sorted(Comparator.comparing(ChatgptCarInfoView::getScore)).collect(Collectors.toCollection(LinkedHashSet::new));
     }

+ 4 - 6
netflix-web/src/main/java/com/cyksj/web/controller/mirror/MirrorController.java

@@ -177,15 +177,14 @@ public class MirrorController {
      * @return
      */
     @GetMapping("/gpt/cars")
-    public Result<Set<ChatgptCarInfoView>> getCarInfoList(Long relationId) {
+    public Result<Set<ChatgptCarInfoView>> getCarInfoList(Long relationId,@RequestParam(defaultValue = "10") Integer limit,@RequestParam(defaultValue = "false") Boolean isPlus) {
         long userId = StpUserUtil.getLoginIdAsLong();
         //查看用户是否存在车票
         ChatgptUser carChatGptUser = chatGptAccountService.getCarChatGptUser(userId, relationId);
         if (carChatGptUser == null) {
             throw BusinessRuntimeException.getInstance("您还未购买车票");
         }
-
-        Set<ChatgptCarInfoView> carInfoList = chatGptAccountService.getCarInfoList(carChatGptUser.getUserToken());
+        Set<ChatgptCarInfoView> carInfoList = chatGptAccountService.getCarInfoList(carChatGptUser.getUserToken(),10, isPlus);
         return GatewayResponse.SUCCESS.newBuilder().toResult(carInfoList);
     }
 
@@ -264,14 +263,13 @@ public class MirrorController {
      * 根据userToken获取车队列表
      */
     @GetMapping("/gpt/cars/withToken")
-    public Result<Set<ChatgptCarInfoView>> getCarInfoListWithToken(String userToken) {
+    public Result<Set<ChatgptCarInfoView>> getCarInfoListWithToken(String userToken,@RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "false") Boolean isPlus) {
         //查看用户是否存在车票
         ChatgptUser carChatGptUser = chatGptAccountService.getCarChatGptUserWithToken(userToken);
         if (carChatGptUser == null) {
             throw BusinessRuntimeException.getInstance("您还未购买车票");
         }
-
-        Set<ChatgptCarInfoView> carInfoList = chatGptAccountService.getCarInfoList(carChatGptUser.getUserToken());
+        Set<ChatgptCarInfoView> carInfoList = chatGptAccountService.getCarInfoList(carChatGptUser.getUserToken(), limit, isPlus);
         return GatewayResponse.SUCCESS.newBuilder().toResult(carInfoList);
     }