zf
2023-09-14 395f924baaf24f421eb378f3730b28acaefd027c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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<AttachmentInfoMapper, AttachmentInfo> implements AttachmentInfoService {
    @Autowired
    private AttachmentInfoMapper attachmentInfoMapper;
 
    @Override
    public AttachmentInfo findByKey(String key) {
        AttachmentInfo attachmentInfo = attachmentInfoMapper.selectOne(new LambdaQueryWrapper<AttachmentInfo>()
                .eq(AttachmentInfo::getDelFlag,0)
                .eq(AttachmentInfo::getFileKey,key));
        return attachmentInfo;
    }
    @Override
    public AttachmentInfo findById(Long id) {
        AttachmentInfo attachmentInfo = attachmentInfoMapper.selectOne(new LambdaQueryWrapper<AttachmentInfo>()
                .eq(AttachmentInfo::getDelFlag,0)
                .eq(AttachmentInfo::getId,id));
        return attachmentInfo;
    }
    @Override
    public List<AttachmentInfo> findByBusinessId(Long businessId) {
        List<AttachmentInfo> attachmentInfoList = attachmentInfoMapper.selectList(new LambdaQueryWrapper<AttachmentInfo>()
                .eq(AttachmentInfo::getDelFlag,0)
                .eq(AttachmentInfo::getBusinessId,businessId));
        return attachmentInfoList;
    }
 
    @Override
    public List<AttachmentInfo> findByIds(List<Long> ids) {
        return attachmentInfoMapper.selectList(new LambdaQueryWrapper<AttachmentInfo>()
                .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<AttachmentInfo> saveBatchAttachment(List<AttachmentInfo> attachmentInfoList) {
        attachmentInfoMapper.saveBatch(attachmentInfoList);
        return attachmentInfoList;
    }
 
    @Override
    public void updateBusinessIdBatch(List<AttachmentInfo> attachmentList) {
        attachmentInfoMapper.updateBusinessIdBatch(attachmentList);
    }
 
    @Override
    public void deleteByBusinessId(Long businessId) {
        attachmentInfoMapper.deleteByBusinessId(businessId);
    }
 
    @Override
    public List<AttachmentInfo> findByKeys(List<String> keys) {
        return attachmentInfoMapper.selectList(new LambdaQueryWrapper<AttachmentInfo>()
                .in(AttachmentInfo::getFileKey,keys)
                .eq(AttachmentInfo::getDelFlag,0));
    }
}