package cc.mrbird.febs.ai.service.impl; import cc.mrbird.febs.ai.entity.AiProductPrompt; import cc.mrbird.febs.ai.entity.AiProductQuestionLabel; import cc.mrbird.febs.ai.mapper.AiProductQuestionLabelMapper; import cc.mrbird.febs.ai.service.AiProductQuestionLabelService; 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 cn.hutool.core.util.StrUtil; 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 java.util.Date; @Slf4j @Service @RequiredArgsConstructor public class AiProductQuestionLabelServiceImpl extends ServiceImpl implements AiProductQuestionLabelService { private final AiProductQuestionLabelMapper aiProductQuestionLabelMapper; @Override public AiProductQuestionLabel getById(String id) { return aiProductQuestionLabelMapper.selectById( id); } @Override public IPage listInPage(AiProductQuestionLabel dto, QueryRequest request) { Page page = new Page<>(request.getPageNum(), request.getPageSize()); LambdaQueryWrapper query = Wrappers.lambdaQuery(AiProductQuestionLabel.class); if (StrUtil.isNotEmpty(dto.getCompanyId())){ query.eq(AiProductQuestionLabel::getCompanyId, dto.getCompanyId()); } query.orderByDesc(AiProductQuestionLabel::getCreatedTime); Page pages = aiProductQuestionLabelMapper.selectPage(page, query); return pages; } @Override public FebsResponse add(AiProductQuestionLabel dto) { Date createTime = new Date(); AiProductQuestionLabel entity = new AiProductQuestionLabel(); entity.setId(UUID.getSimpleUUIDString()); entity.setName(dto.getName()); if (StrUtil.isNotEmpty(dto.getCompanyId())){ entity.setCompanyId(dto.getCompanyId()); } entity.setCreatedTime(createTime); aiProductQuestionLabelMapper.insert( entity); return new FebsResponse().success().message("操作成功"); } @Override public FebsResponse update(AiProductQuestionLabel dto) { String id = dto.getId(); AiProductQuestionLabel entity = this.getById(id); if(ObjectUtil.isNotNull( entity)){ this.update(null, Wrappers.lambdaUpdate(AiProductQuestionLabel.class) .set(AiProductQuestionLabel::getName, dto.getName()) .set(AiProductQuestionLabel::getUpdatedTime, new Date()) .eq(AiProductQuestionLabel::getId, id)); } return new FebsResponse().success().message("操作成功"); } }