| | |
| | | import cc.mrbird.febs.ai.entity.*; |
| | | import cc.mrbird.febs.ai.mapper.AiProductMapper; |
| | | import cc.mrbird.febs.ai.req.AdminMoveChooseInfoDto; |
| | | import cc.mrbird.febs.ai.service.AiProductCategoryService; |
| | | import cc.mrbird.febs.ai.service.AiProductPointLinkService; |
| | | import cc.mrbird.febs.ai.service.AiProductRoleLinkService; |
| | | import cc.mrbird.febs.ai.service.AiProductService; |
| | | import cc.mrbird.febs.ai.service.*; |
| | | import cc.mrbird.febs.ai.util.UUID; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private final AiProductCategoryService aiProductCategoryService; |
| | | private final AiProductPointLinkService aiProductPointLinkService; |
| | | private final AiProductRoleLinkService aiProductRoleLinkService; |
| | | private final AiProductQuestionLinkService aiProductQuestionLinkService; |
| | | |
| | | @Override |
| | | public AiProduct getById(String id) { |
| | |
| | | LambdaQueryWrapper<AiProduct> query = Wrappers.lambdaQuery(AiProduct.class); |
| | | if (StrUtil.isNotEmpty(dto.getProductCategoryId())){ |
| | | query.eq(AiProduct::getProductCategoryId, dto.getProductCategoryId()); |
| | | } |
| | | if (StrUtil.isNotEmpty(dto.getCompanyId())){ |
| | | query.eq(AiProduct::getCompanyId, dto.getCompanyId()); |
| | | } |
| | | query.ne(AiProduct::getState, 2); |
| | | query.orderByDesc(AiProduct::getHotState); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public FebsResponse changeState(String id, Integer type, Integer state) { |
| | | |
| | | AiProduct entity = this.getById(id); |
| | | if(ObjectUtil.isNotNull(entity)){ |
| | | if(1 == type){ |
| | | if (1 == state){ |
| | | List<AiProductPointLink> list = aiProductPointLinkService.selectListByQuery( |
| | | Wrappers.lambdaQuery(AiProductPointLink.class) |
| | | .eq(AiProductPointLink::getProductId, id) |
| | | ); |
| | | if(CollUtil.isEmpty(list)){ |
| | | return new FebsResponse().fail().message("请配置知识点"); |
| | | } |
| | | List<AiProductRoleLink> list1 = aiProductRoleLinkService.selectListByQuery( |
| | | Wrappers.lambdaQuery(AiProductRoleLink.class) |
| | | .eq(AiProductRoleLink::getProductId, id) |
| | | ); |
| | | if(CollUtil.isEmpty(list1)){ |
| | | return new FebsResponse().fail().message("请配置AI陪练"); |
| | | } |
| | | List<AiProductQuestionLink> list2 = aiProductQuestionLinkService.selectListByQuery( |
| | | Wrappers.lambdaQuery(AiProductQuestionLink.class) |
| | | .eq(AiProductQuestionLink::getProductId, id) |
| | | ); |
| | | if(CollUtil.isEmpty(list2)){ |
| | | return new FebsResponse().fail().message("请配置AI题目"); |
| | | } |
| | | } |
| | | |
| | | aiProductMapper.update(null, |
| | | Wrappers.lambdaUpdate(AiProduct.class) |
| | | .set(AiProduct::getState, state) |
| | |
| | | entity.setTarget(dto.getTarget()); |
| | | entity.setDescription(dto.getDescription()); |
| | | entity.setQuestionCount(dto.getQuestionCount()); |
| | | entity.setTalkCnt(dto.getTalkCnt()); |
| | | entity.setCreatedTime(new Date()); |
| | | this.save(entity); |
| | | return new FebsResponse().success().message("操作成功"); |
| | |
| | | .set(AiProduct::getTarget, dto.getTarget()) |
| | | .set(AiProduct::getDescription, dto.getDescription()) |
| | | .set(AiProduct::getQuestionCount, dto.getQuestionCount()) |
| | | .set(AiProduct::getTalkCnt, dto.getTalkCnt()) |
| | | .set(AiProduct::getUpdatedTime, new Date()) |
| | | .eq(AiProduct::getId, id) |
| | | ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> selectList() { |
| | | return aiProductMapper.selectList( |
| | | Wrappers.lambdaQuery(AiProduct.class) |
| | | .ne(AiProduct::getState, 2) |
| | | ); |
| | | public List<AiProduct> selectList(String companyId) { |
| | | LambdaQueryWrapper<AiProduct> query = Wrappers.lambdaQuery(AiProduct.class); |
| | | if (StrUtil.isNotEmpty(companyId)){ |
| | | query.eq(AiProduct::getCompanyId, companyId); |
| | | } |
| | | query.ne(AiProduct::getState, 2); |
| | | return aiProductMapper.selectList(query); |
| | | } |
| | | |
| | | @Override |
| | |
| | | List<String> chooseIds = dto.getChooseIds(); |
| | | AiProduct aiProduct = this.getById(chooseId); |
| | | if (ObjectUtil.isNotNull(aiProduct)) { |
| | | String companyId = aiProduct.getCompanyId(); |
| | | aiProductPointLinkService.deleteByQuery( |
| | | Wrappers.lambdaQuery(AiProductPointLink.class) |
| | | .eq(AiProductPointLink::getProductId,chooseId) |
| | | .eq(AiProductPointLink::getCompanyId,companyId) |
| | | ); |
| | | if(CollUtil.isNotEmpty(chooseIds)){ |
| | | Date createdTime = new Date(); |
| | | for (String item : chooseIds){ |
| | | AiProductPointLink entity = new AiProductPointLink(); |
| | | entity.setId(UUID.getSimpleUUIDString()); |
| | | entity.setCompanyId(companyId); |
| | | entity.setProductId(chooseId); |
| | | entity.setProductPointId(item); |
| | | entity.setCreatedTime(createdTime); |
| | |
| | | List<String> chooseIds = dto.getChooseIds(); |
| | | AiProduct aiProduct = this.getById(chooseId); |
| | | if (ObjectUtil.isNotNull(aiProduct)) { |
| | | String companyId = aiProduct.getCompanyId(); |
| | | aiProductRoleLinkService.deleteByQuery( |
| | | Wrappers.lambdaQuery(AiProductRoleLink.class) |
| | | .eq(AiProductRoleLink::getProductId,chooseId) |
| | | .eq(AiProductRoleLink::getCompanyId,companyId) |
| | | ); |
| | | if(CollUtil.isNotEmpty(chooseIds)){ |
| | | Date createdTime = new Date(); |
| | | for (String item : chooseIds){ |
| | | AiProductRoleLink entity = new AiProductRoleLink(); |
| | | entity.setId(UUID.getSimpleUUIDString()); |
| | | entity.setCompanyId(companyId); |
| | | entity.setProductId(chooseId); |
| | | entity.setProductRoleId(item); |
| | | entity.setCreatedTime(createdTime); |
| | |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse productQuestionSet(AdminMoveChooseInfoDto dto) { |
| | | String chooseId = dto.getChooseId(); |
| | | List<String> chooseIds = dto.getChooseIds(); |
| | | AiProduct aiProduct = this.getById(chooseId); |
| | | if (ObjectUtil.isNotNull(aiProduct)) { |
| | | String companyId = aiProduct.getCompanyId(); |
| | | aiProductQuestionLinkService.deleteByQuery( |
| | | Wrappers.lambdaQuery(AiProductQuestionLink.class) |
| | | .eq(AiProductQuestionLink::getProductId,chooseId) |
| | | .eq(AiProductQuestionLink::getCompanyId,companyId) |
| | | ); |
| | | if(CollUtil.isNotEmpty(chooseIds)){ |
| | | Date createdTime = new Date(); |
| | | for (String item : chooseIds){ |
| | | AiProductQuestionLink entity = new AiProductQuestionLink(); |
| | | entity.setId(UUID.getSimpleUUIDString()); |
| | | entity.setCompanyId(companyId); |
| | | entity.setProductId(chooseId); |
| | | entity.setProductQuestionId(item); |
| | | entity.setCreatedTime(createdTime); |
| | | aiProductQuestionLinkService.getBaseMapper().insert(entity); |
| | | } |
| | | } |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> listByCategory(AiProduct dto) { |
| | | LambdaQueryWrapper<AiProduct> query = Wrappers.lambdaQuery(AiProduct.class); |
| | | if (StrUtil.isNotEmpty(dto.getProductCategoryId())){ |
| | | query.eq(AiProduct::getProductCategoryId, dto.getProductCategoryId()); |
| | | } |
| | | if (StrUtil.isNotEmpty(dto.getCompanyId())){ |
| | | query.eq(AiProduct::getCompanyId, dto.getCompanyId()); |
| | | } |
| | | query.ne(AiProduct::getState, 2); |
| | | query.orderByAsc(AiProduct::getSort); |
| | | return aiProductMapper.selectList(query); |
| | | } |
| | | } |