郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package com.gkhy.safePlatform.account.service.baseService.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.account.entity.schedule.GroupInfo;
import com.gkhy.safePlatform.account.entity.schedule.GroupInfoDO;
import com.gkhy.safePlatform.account.entity.schedule.GroupStrategyInfoDO;
import com.gkhy.safePlatform.account.model.bo.GroupInfoBO;
import com.gkhy.safePlatform.account.model.bo.GroupInfoPageBO;
import com.gkhy.safePlatform.account.model.query.db.GroupDBQuery;
import com.gkhy.safePlatform.account.model.query.db.GroupPageDBQuery;
import com.gkhy.safePlatform.account.repository.schedule.GroupInfoRepository;
import com.gkhy.safePlatform.account.service.baseService.GroupInfoService;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Collection;
import java.util.List;
 
 
@Service("groupInfoService")
public class GroupInfoServiceImpl extends ServiceImpl<GroupInfoRepository, GroupInfo> implements GroupInfoService {
 
    @Autowired
    private GroupInfoRepository groupInfoRepository;
 
    @Override
    public GroupInfoDO getGroupInfoById(Long groupId) {
        if (groupId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.getGroupInfoDOById(groupId);
    }
 
    @Override
    public List<GroupInfoDO> listGroupInfoDO(GroupDBQuery groupDBQuery) {
        if (groupDBQuery == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.listGroupInfoDO(groupDBQuery);
    }
 
    @Override
    public GroupStrategyInfoDO getGroupStrategyByGroupId(Long groupId) {
        if (groupId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.getGroupStrategyByGroupId(groupId);
    }
 
    @Override
    public List<Long> listGroupIdsByGroupStrategyId(Long groupStrategyId) {
        if (groupStrategyId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.getGroupIdsByGroupStrategyId(groupStrategyId);
    }
 
    @Override
    public void unbindBatchGroupStrategyByGroupIds(List<Long> groupIds) {
        if (groupIds == null || groupIds.size() == 0) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        groupInfoRepository.deleteGroupStrategyByGroupIds(groupIds);
    }
 
    @Override
    public void unbindGroupStrategyByGroupStrategyId(Long groupStrategyId) {
        if (groupStrategyId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        groupInfoRepository.deleteGroupStrategyByGroupStrategyId(groupStrategyId);
    }
 
    @Override
    public List<GroupInfoDO> listGroupInfoDOsByGroupStrategyId(Long groupStrategyId) {
        if (groupStrategyId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.getGroupInfosByGroupStrategyId(groupStrategyId);
    }
 
    @Override
    public List<GroupInfoPageBO> listGroupInfo(Page<GroupInfo> page, GroupPageDBQuery dbQuery) {
        if (dbQuery == null || page == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.listGroupInfo(page,dbQuery);
    }
 
    @Override
    public List<GroupInfoBO> listGroupInfoBO(GroupDBQuery dbQuery) {
        if (dbQuery == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.listGroupInfoBO(dbQuery);
    }
 
    @Override
    public void deleteGroupInfo(GroupInfo groupInfo) {
        if (groupInfo == null || groupInfo.getId() == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        groupInfoRepository.deleteGroupInfo(groupInfo);
    }
 
    @Override
    public boolean isExistGroupMountedByDepartment(Long depId) {
        if (depId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        List<GroupInfo> groupInfos = groupInfoRepository.selectList(new LambdaQueryWrapper<GroupInfo>()
                // 部门id
                .eq(GroupInfo::getDepId, depId)
                // 一条记录
                .last("limit 1"));
 
        return groupInfos.size() > 0;
    }
 
 
 
    @Override
    public List<GroupInfoDO> listGroupDOByGroupIds(Collection<Long> groupIds) {
        if (groupIds == null || groupIds.size() == 0) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return groupInfoRepository.listGroupDOByGroupIds(groupIds);
    }
 
}