liukangdong
2024-12-10 8ead63412bbda132ba9404583c1704121dfbcbaf
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
95
96
97
98
99
100
package com.doumee.service.system.impl;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.dao.system.SystemDepartmentUserMapper;
import com.doumee.dao.system.model.SystemDepartmentUser;
import com.doumee.service.system.SystemDepartmentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
 
/**
 * 部门用户Service实现
 * @author Eva.Caesar Liu
 * @date 2023/03/21 14:49
 */
@Service
public class SystemDepartmentUserServiceImpl implements SystemDepartmentUserService {
 
    @Autowired
    private SystemDepartmentUserMapper systemDepartmentUserMapper;
 
    @Override
    public Integer create(SystemDepartmentUser systemDepartmentUser) {
        systemDepartmentUserMapper.insert(systemDepartmentUser);
        return systemDepartmentUser.getId();
    }
 
    @Override
    public void deleteById(Integer id) {
        SystemDepartmentUser systemDepartmentUser = new SystemDepartmentUser();
        systemDepartmentUser.setId(id);
        systemDepartmentUser.setDeleted(Boolean.TRUE);
        systemDepartmentUserMapper.updateById(systemDepartmentUser);
    }
 
    @Override
    public void delete(SystemDepartmentUser dto) {
//        SystemDepartmentUser newDepartmentUser = new SystemDepartmentUser();
//        newDepartmentUser.setDeleted(Boolean.TRUE);
        UpdateWrapper<SystemDepartmentUser> updateWrapper = new UpdateWrapper<>(dto);
        systemDepartmentUserMapper.delete(updateWrapper);
    }
 
    @Override
    @Transactional
    public void deleteByIdInBatch(List<Integer> ids) {
        if (CollectionUtils.isEmpty(ids)) return;
        for (Integer id: ids) {
            this.deleteById(id);
        }
    }
 
    @Override
    public void updateById(SystemDepartmentUser systemDepartmentUser) {
        systemDepartmentUserMapper.updateById(systemDepartmentUser);
    }
 
    @Override
    public void update(UpdateWrapper<SystemDepartmentUser> systemDepartmentUser) {
 
        systemDepartmentUserMapper.update(null,systemDepartmentUser);
    }
 
    @Override
    @Transactional
    public void updateByIdInBatch(List<SystemDepartmentUser> systemDepartmentUsers) {
        if (CollectionUtils.isEmpty(systemDepartmentUsers)) return;
        for (SystemDepartmentUser systemDepartmentUser: systemDepartmentUsers) {
            this.updateById(systemDepartmentUser);
        }
    }
 
    @Override
    public SystemDepartmentUser findById(Integer id) {
        return systemDepartmentUserMapper.selectById(id);
    }
 
    @Override
    public SystemDepartmentUser findOne(SystemDepartmentUser systemDepartmentUser) {
        Wrapper<SystemDepartmentUser> wrapper = new QueryWrapper<>(systemDepartmentUser);
        return systemDepartmentUserMapper.selectOne(wrapper);
    }
 
    @Override
    public List<SystemDepartmentUser> findList(SystemDepartmentUser systemDepartmentUser) {
        Wrapper<SystemDepartmentUser> wrapper = new QueryWrapper<>(systemDepartmentUser);
        return systemDepartmentUserMapper.selectList(wrapper);
    }
 
    @Override
    public long count(SystemDepartmentUser systemDepartmentUser) {
        Wrapper<SystemDepartmentUser> wrapper = new QueryWrapper<>(systemDepartmentUser);
        return systemDepartmentUserMapper.selectCount(wrapper);
    }
}