郑永安
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
package com.gkhy.safePlatform.safeCheck.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.commons.enums.E;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.AusinessException;
import com.gkhy.safePlatform.commons.exception.BusinessException;
import com.gkhy.safePlatform.safeCheck.entity.SafeCheckQuota;
import com.gkhy.safePlatform.safeCheck.enums.DelectStatusEnum;
import com.gkhy.safePlatform.safeCheck.repository.SafeCheckQuotaRepository;
import com.gkhy.safePlatform.safeCheck.service.baseService.SafeCheckQuotaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service("SafeCheckQuotaService")
public class SafeCheckQuotaServiceImpl extends ServiceImpl<SafeCheckQuotaRepository, SafeCheckQuota> implements SafeCheckQuotaService {
 
    @Autowired
    private SafeCheckQuotaRepository safeCheckQuotaRepository;
 
    /**
     * @description 新增巡检指标
     */
    @Override
    public int saveQuota(SafeCheckQuota safeCheckQuota) {
        int insertResult = safeCheckQuotaRepository.insert(safeCheckQuota);
        if (insertResult == 0){
            throw new BusinessException(ResultCodes.SERVER_ADD_ERROR);
        }
        return insertResult;
    }
 
    /**
     * @description 根据巡检指标id删除巡检指标
     */
    @Override
    public void deleteQuotaById(SafeCheckQuota quota,int deleteStatus) {
        int delectResult = safeCheckQuotaRepository.deleteQuotaById(quota,deleteStatus);
        if (delectResult == 0){
            throw new AusinessException(E.NOT_DELETE,"数据不存在");
        }
    }
 
    /**
     * @description 根据巡检指标id修改巡检指标
     */
    @Override
    public void updateQuotaById(SafeCheckQuota safeCheckQuota,int deleteStatus) {
        int updateResult = safeCheckQuotaRepository.updateQuotaById(safeCheckQuota,deleteStatus);
        if (updateResult == 0){
            throw new BusinessException(ResultCodes.SERVER_UPDATE_ERROR);
        }
    }
 
    /**
     * @description 根据指标名查询是否存在同名指标
     */
    @Override
    public SafeCheckQuota getQuotaByName(String quotaName,int deteleStatus) {
        return safeCheckQuotaRepository.getQuotaByName(quotaName,deteleStatus);
    }
 
    /**
     * @description 根据巡检指标id获取巡检指标
     */
    @Override
    public SafeCheckQuota getQuotaById(Long id, int deleteStatus) {
        return safeCheckQuotaRepository.getQuataById(id,deleteStatus);
    }
 
    /**
     * @description 分页获取当前页中的巡检指标信息
     */
    @Override
    public Page listQuotaByPage(Page pageInfo,String quotaName) {
        LambdaQueryWrapper<SafeCheckQuota> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SafeCheckQuota::getDeleteStatus, DelectStatusEnum.DELECT_NO.getStatus())
                .orderByDesc(SafeCheckQuota::getGmtModitify)
                        .like(quotaName != null,SafeCheckQuota::getQuota,quotaName);
        Page pageInfoResult = safeCheckQuotaRepository.selectPage(pageInfo,queryWrapper);
        return pageInfoResult;
    }
 
 
}