| | |
| | | package cc.mrbird.febs.ai.service.impl; |
| | | |
| | | import cc.mrbird.febs.ai.entity.AiMemberRole; |
| | | import cc.mrbird.febs.ai.entity.AiProductPoint; |
| | | import cc.mrbird.febs.ai.entity.AiProductQuestion; |
| | | import cc.mrbird.febs.ai.mapper.AiProductQuestionMapper; |
| | | import cc.mrbird.febs.ai.service.AiProductQuestionService; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public AiProductQuestion getById(String id) { |
| | | |
| | | return aiProductQuestionMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AiProductQuestion> listInPage(AiProductQuestion dto, QueryRequest request) { |
| | | Page<AiProductQuestion> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | LambdaQueryWrapper<AiProductQuestion> query = Wrappers.lambdaQuery(AiProductQuestion.class); |
| | | Page<AiProductQuestion> pages = aiProductQuestionMapper.selectPage(page, query); |
| | | return pages; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse changeState(String id, Integer state) { |
| | | AiProductQuestion entity = this.getById(id); |
| | | if(ObjectUtil.isNotEmpty(entity)){ |
| | | this.update(null, |
| | | Wrappers.lambdaUpdate(AiProductQuestion.class) |
| | | .set(AiProductQuestion::getState, state) |
| | | .set(AiProductQuestion::getUpdatedTime, new Date()) |
| | | .eq(AiProductQuestion::getId, id)); |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse add(AiProductQuestion dto) { |
| | | |
| | | AiProductQuestion entity = new AiProductQuestion(); |
| | | entity.setId(UUID.getSimpleUUIDString()); |
| | | entity.setCompanyId(dto.getCompanyId()); |
| | | entity.setProductCategoryId(dto.getProductCategoryId()); |
| | | entity.setTitle(dto.getTitle()); |
| | | entity.setDifficulty(dto.getDifficulty()); |
| | | entity.setCreatedTime(new Date()); |
| | | this.save(entity); |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse update(AiProductQuestion dto) { |
| | | String id = dto.getId(); |
| | | AiProductQuestion entity = this.getById(id); |
| | | if (ObjectUtil.isNotNull( entity)){ |
| | | this.update(null, |
| | | Wrappers.lambdaUpdate(AiProductQuestion.class) |
| | | .set(AiProductQuestion::getCompanyId, dto.getCompanyId()) |
| | | .set(AiProductQuestion::getProductCategoryId, dto.getProductCategoryId()) |
| | | .set(AiProductQuestion::getTitle, dto.getTitle()) |
| | | .set(AiProductQuestion::getDifficulty, dto.getDifficulty()) |
| | | .set(AiProductQuestion::getUpdatedTime, new Date()) |
| | | .eq(AiProductQuestion::getId, id) |
| | | ); |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse delete(String id) { |
| | | AiProductQuestion entity = this.getById(id); |
| | | if(ObjectUtil.isNotNull( entity)){ |
| | | this.update(null, |
| | | Wrappers.lambdaUpdate(AiProductQuestion.class) |
| | | .set(AiProductQuestion::getState, 2) |
| | | .set(AiProductQuestion::getUpdatedTime, new Date()) |
| | | .eq(AiProductQuestion::getId, id)); |
| | | |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> questionTree() { |
| | | |
| | | return aiProductQuestionMapper.selectList(null); |
| | | } |
| | | |
| | | } |