zhangfeng
2023-07-27 cc3ddfda6bfb9a2aa0cd55073e8864320daf1f20
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
package com.gk.hotwork.Service.ServiceImpl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.hotwork.Domain.AttachmentInfo;
import com.gk.hotwork.Domain.UserInfo;
import com.gk.hotwork.Mapper.AttachmentInfoMapper;
import com.gk.hotwork.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, UserInfo userInfo) {
        AttachmentInfo attachmentInfo = new AttachmentInfo();
        attachmentInfo.setId(id);
        attachmentInfo.setUpdateTime(new Date());
        attachmentInfo.setUpdateUid(userInfo.getId());
        attachmentInfo.setUpdateUname(userInfo.getRealname());
        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);
    }
}