| | |
| | | package cc.mrbird.febs.ai.service.impl; |
| | | |
| | | import cc.mrbird.febs.ai.entity.AiProduct; |
| | | import cc.mrbird.febs.ai.entity.AiProductPoint; |
| | | import cc.mrbird.febs.ai.mapper.AiProductMapper; |
| | | import cc.mrbird.febs.ai.service.AiProductService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import cc.mrbird.febs.ai.req.product.ApiProductInfoDto; |
| | | import cc.mrbird.febs.ai.req.product.ApiProductPageDto; |
| | | import cc.mrbird.febs.ai.res.product.ApiProductInfoVo; |
| | | import cc.mrbird.febs.ai.res.product.ApiProductVo; |
| | | import cc.mrbird.febs.ai.service.*; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * AI产品表 Service实现类 |
| | |
| | | public class AiProductServiceImpl extends ServiceImpl<AiProductMapper, AiProduct> implements AiProductService { |
| | | |
| | | private final AiProductMapper aiProductMapper; |
| | | private final AiMemberRoleService aiMemberRoleService; |
| | | private final AiProductCategoryService aiProductCategoryService; |
| | | private final AiProductPointService aiProductPointService; |
| | | |
| | | |
| | | @Override |
| | | public AiProduct getById(String id) { |
| | | return aiProductMapper.selectById( id); |
| | | } |
| | | |
| | | @Override |
| | | public Page<ApiProductVo> getPageListByQuery(Page<ApiProductVo> page, ApiProductPageDto dto) { |
| | | return aiProductMapper.selectPageListByQuery(page, dto); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse productList(ApiProductPageDto dto) { |
| | | |
| | | if(StrUtil.isEmpty(dto.getMemberRoleId())){ |
| | | String memberRoleId = aiMemberRoleService.getDefaultMemberRoleId(); |
| | | dto.setMemberRoleId(memberRoleId); |
| | | } |
| | | |
| | | if(StrUtil.isEmpty(dto.getCategoryId())){ |
| | | String categoryId = aiProductCategoryService.getDefaultProductCategoryId(); |
| | | dto.setCategoryId(categoryId); |
| | | } |
| | | // 创建分页对象,传入当前页和每页大小 |
| | | Page<ApiProductVo> page = new Page<>(dto.getPageNow(), dto.getPageSize()); |
| | | Page<ApiProductVo> pageListByQuery = this.getPageListByQuery(page, dto); |
| | | return new FebsResponse().success().data(pageListByQuery); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse productInfo(ApiProductInfoDto dto) { |
| | | |
| | | String id = dto.getId(); |
| | | AiProduct entity = this.getById(id); |
| | | ApiProductInfoVo vo = new ApiProductInfoVo(); |
| | | vo.setId(entity.getId()); |
| | | vo.setProductCategoryId(entity.getProductCategoryId()); |
| | | vo.setName(entity.getName()); |
| | | vo.setScene(entity.getScene()); |
| | | vo.setTarget(entity.getTarget()); |
| | | vo.setBackImg(entity.getBackImg()); |
| | | vo.setIconImg(entity.getIconImg()); |
| | | vo.setDescription(entity.getDescription()); |
| | | vo.setQuestionCount(entity.getQuestionCount()); |
| | | |
| | | vo.setProductPointList(aiProductPointService.listByProductId(id)); |
| | | return new FebsResponse().success().data(vo); |
| | | } |
| | | } |