package cn.cslg.pas.service; import cn.cslg.pas.common.model.params.PatentInstructionTextParams; import cn.cslg.pas.domain.PatentInstructionText; import cn.cslg.pas.mapper.PatentInstructionTextMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @author Administrator * @description 针对表【os_patent_instruction_text(专利说明书(文本))】的数据库操作Service * @createDate 2022-04-16 08:38:10 */ @Service @RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class PatentInstructionTextService extends ServiceImpl { private final PatentService patentService; public PatentInstructionText getPatentInstructionTextByPatentId(Integer patentId) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(PatentInstructionText::getPatentId, patentId); return this.getOne(queryWrapper); } public List getPatentInstructionTextByPatentIds(List patentIds) { if (patentIds == null || patentIds.size() == 0) { return new ArrayList<>(); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(PatentInstructionText::getPatentId, patentIds); return this.list(queryWrapper); } public void deleteByPatentId(Integer patentId) { this.remove(Wrappers.lambdaQuery().eq(PatentInstructionText::getPatentId, patentId)); } public void importPatentInstructionText(Integer localPatentId, Integer importPatentId, List importPatentInstructionTextList) { this.deleteByPatentId(localPatentId); PatentInstructionText patentInstructionText = importPatentInstructionTextList.stream().filter(item -> item.getPatentId().equals(importPatentId)).findFirst().orElse(null); if (patentInstructionText != null) { patentInstructionText.setId(null); patentInstructionText.setPatentId(localPatentId); patentInstructionText.insert(); } } public void updatePatentInstructionText(PatentInstructionTextParams params) { PatentInstructionText patentInstructionText = this.getPatentInstructionTextByPatentId(params.getPatentId()); if (patentInstructionText == null) { patentInstructionText = new PatentInstructionText(); } patentInstructionText.setPatentId(params.getPatentId()); patentInstructionText.setManual(params.getManual()); patentInstructionText.setManualOut(params.getManualOut()); patentInstructionText.insertOrUpdate(); } }