| | |
| | | package cc.mrbird.febs.ai.service.impl; |
| | | |
| | | import cc.mrbird.febs.ai.entity.*; |
| | | import cc.mrbird.febs.ai.mapper.AiProductQuestionJobMapper; |
| | | import cc.mrbird.febs.ai.mapper.AiProductQuestionMapper; |
| | | import cc.mrbird.febs.ai.req.AiProductQuestionAiDto; |
| | | import cc.mrbird.febs.ai.service.AiProductQuestionItemService; |
| | |
| | | public class AiProductQuestionServiceImpl extends ServiceImpl<AiProductQuestionMapper, AiProductQuestion> implements AiProductQuestionService { |
| | | |
| | | private final AiProductQuestionMapper aiProductQuestionMapper; |
| | | private final AiProductQuestionJobMapper aiProductQuestionJobMapper; |
| | | private final AiProductQuestionItemService aiProductQuestionItemService; |
| | | private final AiService aiService; |
| | | |
| | |
| | | query.ne(AiProductQuestion::getState, 2); |
| | | query.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | Page<AiProductQuestion> pages = aiProductQuestionMapper.selectPage(page, query); |
| | | return pages; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AiProductQuestionJob> listJobInPage(AiProductQuestionJob dto, QueryRequest request) { |
| | | Page<AiProductQuestionJob> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | LambdaQueryWrapper<AiProductQuestionJob> query = Wrappers.lambdaQuery(AiProductQuestionJob.class); |
| | | if (StrUtil.isNotEmpty(dto.getCompanyId())){ |
| | | query.eq(AiProductQuestionJob::getCompanyId, dto.getCompanyId()); |
| | | } |
| | | if (StrUtil.isNotEmpty(dto.getProductCategoryId())){ |
| | | query.eq(AiProductQuestionJob::getProductCategoryId, dto.getProductCategoryId()); |
| | | } |
| | | query.orderByDesc(AiProductQuestionJob::getCreatedTime); |
| | | Page<AiProductQuestionJob> pages = aiProductQuestionJobMapper.selectPage(page, query); |
| | | return pages; |
| | | } |
| | | |
| | |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse aiAddV2(AiProductQuestionAiDto dto) { |
| | | String companyId = dto.getCompanyId(); |
| | | String productCategoryId = dto.getProductCategoryId(); |
| | | Integer questionCnt = dto.getQuestionCnt(); |
| | | String query = dto.getQuery(); |
| | | Integer difficulty = dto.getDifficulty(); |
| | | Date createdTime = new Date(); |
| | | AiProductQuestionJob aiProductQuestionJob = new AiProductQuestionJob(); |
| | | aiProductQuestionJob.setId(UUID.getSimpleUUIDString()); |
| | | aiProductQuestionJob.setCompanyId(companyId); |
| | | aiProductQuestionJob.setProductCategoryId(productCategoryId); |
| | | aiProductQuestionJob.setTitle(query); |
| | | aiProductQuestionJob.setQuestionCnt(questionCnt); |
| | | aiProductQuestionJob.setDifficulty(difficulty); |
| | | aiProductQuestionJob.setCreatedTime(createdTime); |
| | | aiProductQuestionJobMapper.insert(aiProductQuestionJob); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 解析AI返回的包含问题和答案的JSON字符串 |
| | | * @param aiResponse AI返回的原始响应字符串 |