| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | |
| | | } |
| | | return aiProductQuestion; |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> createQuestionList(String productId, int questionCount) { |
| | | List<AiProductQuestion> list = new ArrayList<>(); |
| | | LambdaQueryWrapper<AiProductQuestionLink> aiProductQuestionLinkLambdaQueryWrapper = Wrappers.lambdaQuery(AiProductQuestionLink.class); |
| | | aiProductQuestionLinkLambdaQueryWrapper.eq(AiProductQuestionLink::getProductId, productId); |
| | | List<AiProductQuestionLink> linkList = aiProductQuestionLinkService.getListByQuery(aiProductQuestionLinkLambdaQueryWrapper); |
| | | if(CollUtil.isNotEmpty(linkList)){ |
| | | List<String> collect = linkList.stream().map(AiProductQuestionLink::getProductQuestionId).collect(Collectors.toList()); |
| | | if(CollUtil.isNotEmpty( collect)){ |
| | | Set<String> randomEleSet = RandomUtil.randomEleSet(collect, questionCount); |
| | | |
| | | LambdaQueryWrapper<AiProductQuestion> questionLambdaQueryWrapper = Wrappers.lambdaQuery(AiProductQuestion.class); |
| | | questionLambdaQueryWrapper.in(AiProductQuestion::getId,randomEleSet); |
| | | list = this.getListByQuery(questionLambdaQueryWrapper); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | } |