| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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(String companyId) { |
| | | return aiProductMapper.selectList( |
| | | Wrappers.lambdaQuery(AiProduct.class) |
| | | .eq(AiProduct::getCompanyId, companyId) |
| | | .ne(AiProduct::getState, 2) |
| | | ); |
| | | 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 |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |