package com.ruoyi.file.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.file.entity.AttachmentInfo; import com.ruoyi.file.mapper.AttachmentInfoMapper; import com.ruoyi.file.service.AttachmentInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** * @email 1603559716@qq.com * @author: zf * @date: 2023/7/24 * @time: 13:48 */ @Service public class AttachmentInfoServiceImpl extends ServiceImpl implements AttachmentInfoService { @Autowired private AttachmentInfoMapper attachmentInfoMapper; @Override public AttachmentInfo findByKey(String key) { AttachmentInfo attachmentInfo = attachmentInfoMapper.selectOne(new LambdaQueryWrapper() .eq(AttachmentInfo::getDelFlag,0) .eq(AttachmentInfo::getFileKey,key)); return attachmentInfo; } @Override public AttachmentInfo findById(Long id) { AttachmentInfo attachmentInfo = attachmentInfoMapper.selectOne(new LambdaQueryWrapper() .eq(AttachmentInfo::getDelFlag,0) .eq(AttachmentInfo::getId,id)); return attachmentInfo; } @Override public List findByBusinessId(Long businessId) { List attachmentInfoList = attachmentInfoMapper.selectList(new LambdaQueryWrapper() .eq(AttachmentInfo::getDelFlag,0) .eq(AttachmentInfo::getBusinessId,businessId)); return attachmentInfoList; } @Override public List findByIds(List ids) { return attachmentInfoMapper.selectList(new LambdaQueryWrapper() .in(AttachmentInfo::getId,ids) .eq(AttachmentInfo::getDelFlag,0)); } @Override public void delete(Long id) { AttachmentInfo attachmentInfo = new AttachmentInfo(); attachmentInfo.setId(id); attachmentInfo.setUpdateTime(new Date()); attachmentInfo.setUpdateBy(SecurityUtils.getUsername()); attachmentInfo.setDelFlag(1); attachmentInfoMapper.updateById(attachmentInfo); } @Override public AttachmentInfo saveOne(AttachmentInfo attachmentInfo) { attachmentInfoMapper.insert(attachmentInfo); return attachmentInfoMapper.selectById(attachmentInfo.getId()); } @Override public List saveBatchAttachment(List attachmentInfoList) { attachmentInfoMapper.saveBatch(attachmentInfoList); return attachmentInfoList; } @Override public void updateBusinessIdBatch(List attachmentList) { attachmentInfoMapper.updateBusinessIdBatch(attachmentList); } @Override public void deleteByBusinessId(Long businessId) { attachmentInfoMapper.deleteByBusinessId(businessId); } @Override public List findByKeys(List keys) { return attachmentInfoMapper.selectList(new LambdaQueryWrapper() .in(AttachmentInfo::getFileKey,keys) .eq(AttachmentInfo::getDelFlag,0)); } }