| | |
| | | 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.AiProductPointMapper; |
| | | import cc.mrbird.febs.ai.service.AiProductPointLinkService; |
| | | import cc.mrbird.febs.ai.service.AiProductPointService; |
| | | import cc.mrbird.febs.ai.util.UUID; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class AiProductPointServiceImpl extends ServiceImpl<AiProductPointMapper, AiProductPoint> implements AiProductPointService { |
| | | |
| | | private final AiProductPointMapper aiProductPointMapper; |
| | | private final AiProductPointLinkService aiProductPointLinkService; |
| | | |
| | | @Override |
| | | public AiProductPoint getById(String id) { |
| | | return aiProductPointMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AiProductPoint> listInPage(AiProductPoint dto, QueryRequest request) { |
| | | Page<AiProductPoint> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | LambdaQueryWrapper<AiProductPoint> query = Wrappers.lambdaQuery(AiProductPoint.class); |
| | | Page<AiProductPoint> pages = aiProductPointMapper.selectPage(page, query); |
| | | return pages; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse add(AiProductPoint dto) { |
| | | AiProductPoint entity = new AiProductPoint(); |
| | | entity.setId(UUID.getSimpleUUIDString()); |
| | | entity.setCompanyId(dto.getCompanyId()); |
| | | entity.setIsNormal(dto.getIsNormal() ); |
| | | entity.setFinderUserName(dto.getFinderUserName()); |
| | | entity.setFeedId(dto.getFeedId()); |
| | | entity.setFeedImg(dto.getFeedImg()); |
| | | entity.setTitle(dto.getTitle()); |
| | | entity.setDescription(dto.getDescription()); |
| | | entity.setCreatedTime(new Date()); |
| | | this.save(entity); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse update(AiProductPoint dto) { |
| | | String id = dto.getId(); |
| | | AiProductPoint entity = this.getById(id); |
| | | if (ObjectUtil.isNotNull( entity)){ |
| | | this.update(null, |
| | | Wrappers.lambdaUpdate(AiProductPoint.class) |
| | | .set(AiProductPoint::getIsNormal, dto.getIsNormal()) |
| | | .set(AiProductPoint::getFinderUserName, dto.getFinderUserName()) |
| | | .set(AiProductPoint::getFeedId, dto.getFeedId()) |
| | | .set(AiProductPoint::getTitle, dto.getTitle()) |
| | | .set(AiProductPoint::getFeedImg, dto.getFeedImg()) |
| | | .set(AiProductPoint::getDescription, dto.getDescription()) |
| | | .set(AiProductPoint::getUpdatedTime, new Date()) |
| | | .eq(AiProductPoint::getId, id) |
| | | ); |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse delete(String id) { |
| | | AiProductPoint entity = this.getById(id); |
| | | if(ObjectUtil.isNotNull( entity)){ |
| | | // 删除 |
| | | aiProductPointMapper.deleteById( id); |
| | | aiProductPointLinkService.deleteByProductPointId(id); |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductPoint> pointTree() { |
| | | |
| | | return aiProductPointMapper.selectList(null); |
| | | } |
| | | |
| | | |
| | | |
| | | } |