郑永安
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
package com.gkhy.safePlatform.specialWork.service.baseService.impl;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import com.gkhy.safePlatform.specialWork.entity.ApprovalRuleItemStand;
import com.gkhy.safePlatform.specialWork.entity.ApprovalRuleItemStandDO;
import com.gkhy.safePlatform.specialWork.enums.RuleItemStandStatusEnum;
import com.gkhy.safePlatform.specialWork.enums.RuleStatusEnum;
import com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleStandListDBQuery;
import com.gkhy.safePlatform.specialWork.model.update.EntityStatusBatchUO;
import com.gkhy.safePlatform.specialWork.model.query.ApprovalRuleStandListQuery;
import com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleStandPageDBQuery;
import com.gkhy.safePlatform.specialWork.repository.ApprovalRuleItemStandRepository;
import com.gkhy.safePlatform.specialWork.service.baseService.ApprovalRuleStandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Set;
 
@Service("ApprovalRuleStandService")
public class ApprovalRuleStandServiceImpl extends ServiceImpl<ApprovalRuleItemStandRepository, ApprovalRuleItemStand> implements ApprovalRuleStandService {
 
    @Autowired
    private ApprovalRuleItemStandRepository approvalRuleItemStandRepository;
 
    @Override
    public void saveRuleStand(ApprovalRuleItemStand itemStandEntity) {
        if (itemStandEntity == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        int i = approvalRuleItemStandRepository.insert(itemStandEntity);
        if (i != 1) {
            throw new BusinessException(ResultCodes.SERVER_ADD_ERROR);
        }
    }
 
    @Override
    public ApprovalRuleItemStandDO getRuleStandDOById(Long ruleStandId) {
        if (ruleStandId == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return approvalRuleItemStandRepository.getRuleStandDOById(ruleStandId, RuleItemStandStatusEnum.VALID.getCode());
    }
 
    @Override
    public void updateRuleStand(ApprovalRuleItemStand itemStandEntity) {
        if (itemStandEntity == null || itemStandEntity.getId() == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        int i = approvalRuleItemStandRepository.updateById(itemStandEntity);
        if (i == 0) {
            throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE);
        }
        if (i > 1) {
            throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
        }
    }
 
    @Override
    public List<ApprovalRuleItemStandDO> listRuleStandDO(ApprovalRuleStandListDBQuery dbQuery) {
        if (dbQuery == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return approvalRuleItemStandRepository.listRuleStandDO(dbQuery);
    }
 
    @Override
    public List<ApprovalRuleItemStand> listRuleStandByPage(Page<ApprovalRuleItemStand> page, ApprovalRuleStandPageDBQuery dbQuery) {
        if (page == null || dbQuery == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return approvalRuleItemStandRepository.listRuleStandByPage(page,dbQuery);
    }
 
    @Override
    public void deleteBatch(EntityStatusBatchUO batchDeleteObj) {
        if (batchDeleteObj == null ||
                batchDeleteObj.getIds() == null ||
                batchDeleteObj.getIds().size() == 0 ||
                batchDeleteObj.getStatus() == null) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        int i = approvalRuleItemStandRepository.updateStatusBatch(batchDeleteObj);
        if (i == 0) {
            throw new BusinessException(ResultCodes.SERVER_UPDATE_DATA_NO_CHANGE);
        }
        if (i != batchDeleteObj.getIds().size()) {
            throw new BusinessException(ResultCodes.SERVER_BATCH_UPDATE_ERROR);
        }
 
    }
 
    /**
     * 获取标准列表 无条件
     * @return
     */
    @Override
    public List<Long> listStandId() {
        return baseMapper.listStandId(RuleItemStandStatusEnum.VALID.getCode());
    }
 
    @Override
    public List<ApprovalRuleItemStandDO> listItemStandByIds(Set<Long> standIds) {
        if (standIds == null || standIds.size() == 0) {
            throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
        }
        return approvalRuleItemStandRepository.listItemStandByIds(standIds);
    }
}