2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-05-10 56d8ffd22d0fd65c6a582de2e57286f9f37f4883
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
package com.sandu.ximon.admin.service;
 
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.param.InterphoneSubParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.bo.InterphoneHostBo;
import com.sandu.ximon.dao.bo.InterphoneSubBo;
import com.sandu.ximon.dao.domain.InterphoneSub;
import com.sandu.ximon.dao.mapper.InterphoneSubMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
@AllArgsConstructor
public class InterphoneSubService extends BaseServiceImpl<InterphoneSubMapper, InterphoneSub> {
 
    private final InterphoneSubMapper interphoneSubMapper;
 
    /**
     * 新增子设备
     */
    public boolean addSub(InterphoneSubParam interphoneSubParam) {
        InterphoneSub interphoneSub = new InterphoneSub();
        BeanUtils.copyProperties(interphoneSubParam, interphoneSub);
        return save(interphoneSub);
    }
 
    /**
     * 修改子设备
     */
    public boolean updateSub(Integer id, InterphoneSubParam interphoneSubParam) {
        InterphoneSub byId = getById(id);
        if (byId == null) {
            return false;
        }
        InterphoneSub interphoneSub = new InterphoneSub();
        BeanUtils.copyProperties(interphoneSubParam, interphoneSub);
        interphoneSub.setSubId(id);
        return updateById(interphoneSub);
    }
 
    /**
     * 删除子设备
     */
    public boolean deleteSub(Integer id) {
        InterphoneSub byId = getById(id);
        if (byId == null) {
            return false;
        }
        return removeById(id);
    }
 
    /**
     * 查询子设备
     */
    public InterphoneSub getSub(Integer id) {
        InterphoneSub byId = getById(id);
        if (byId == null) {
            return null;
        }
        return byId;
    }
 
    /**
     * 查询主机列表
     */
    public List<InterphoneSubBo> getInterphoneSubList(String keyword) {
        List<InterphoneSubBo> list;
        if (SecurityUtils.getClientId() == null) {
            list = interphoneSubMapper.getInterphoneSubList(keyword, null);
        } else {
            list = interphoneSubMapper.getInterphoneSubList(keyword, SecurityUtils.getUserId());
        }
        return list;
    }
}