地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
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
135
136
137
138
139
140
package com.javaweb.geo.service.impl;
 
import java.util.List;
import java.util.UUID;
 
import com.javaweb.common.utils.IdGenerate;
import com.javaweb.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.javaweb.geo.mapper.DataSourceMapper;
import com.javaweb.geo.domain.DataSource;
import com.javaweb.geo.service.IDataSourceService;
import com.javaweb.common.core.text.Convert;
import org.springframework.util.ObjectUtils;
 
/**
 * 数据来源Service业务层处理
 * 
 * @author cxy
 * @date 2022-12-30
 */
@Service
public class DataSourceServiceImpl implements IDataSourceService {
 
    @Autowired
    private DataSourceMapper dataSourceMapper;
 
    /**
     * 查询数据来源
     * 
     * @param ids 数据来源ID
     * @return 数据来源
     */
    @Override
    public DataSource selectDataSourceById(String ids)
    {
        return dataSourceMapper.selectDataSourceById(ids);
    }
 
    /**
     * 查询数据来源列表
     * 
     * @param dataSource 数据来源
     * @return 数据来源
     */
    @Override
    public List<DataSource> selectDataSourceList(DataSource dataSource)
    {
        return dataSourceMapper.selectDataSourceList(dataSource);
    }
 
    /**
     * 新增数据来源
     * 
     * @param dataSource 数据来源
     * @return 结果
     */
    @Override
    public int insertDataSource(DataSource dataSource)
    {
        dataSource.setIds(IdGenerate.nextId());
        dataSource.setSecretKey(IdGenerate.uuid());
        return dataSourceMapper.insertDataSource(dataSource);
    }
 
    /**
     * 修改数据来源
     * 
     * @param dataSource 数据来源
     * @return 结果
     */
    @Override
    public int updateDataSource(DataSource dataSource)
    {
        if (StringUtils.isEmpty(dataSource.getIds())){
            return dataSourceMapper.insertDataSource(dataSource);
        }
        return dataSourceMapper.updateDataSource(dataSource);
    }
 
    /**
     * 删除数据来源对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteDataSourceByIds(String ids)
    {
        return dataSourceMapper.deleteDataSourceByIds(Convert.toStrArray(ids));
    }
 
    /**
     * 删除数据来源信息
     * 
     * @param ids 数据来源ID
     * @return 结果
     */
    @Override
    public int deleteDataSourceById(String ids)
    {
        return dataSourceMapper.deleteDataSourceById(ids);
    }
 
 
    /**
     * 校验key是否存在
     * @param secretKey
     * @return true校验通过,false不通过
     */
    @Override
    public Boolean checkSecretKey(String secretKey) {
        DataSource dataSource = new DataSource();
        dataSource.setSecretKey(secretKey);
 
        List<DataSource> dataSources = selectDataSourceList(dataSource);
        if (ObjectUtils.isEmpty(dataSources)){
            return false;
        }
        return true;
    }
 
 
    @Override
    public String selectDataSourceBySecretKey(String secretKey) {
        return dataSourceMapper.selectDataSourceBySecretKey(secretKey);
    }
 
    @Override
    public String selectCompanyIdBySecretKey(String secretKey) {
        return dataSourceMapper.selectCompanyIdBySecretKey(secretKey);
    }
 
    @Override
    public int updateDataSourceBySecretKey(String secretKey,String companyId) {
        return dataSourceMapper.updateDataSourceBySecretKey(secretKey,companyId);
    }
 
 
}