提交 | 用户 | 时间
|
200ade
|
1 |
package com.iailab.module.model.mpk.service.impl; |
D |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
5 |
import com.iailab.framework.common.page.PageData; |
|
6 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
7 |
import com.iailab.module.model.mpk.dao.ChartParamDao; |
|
8 |
import com.iailab.module.model.mpk.dto.ChartParamDTO; |
|
9 |
import com.iailab.module.model.mpk.entity.ChartEntity; |
|
10 |
import com.iailab.module.model.mpk.entity.ChartParamEntity; |
|
11 |
import com.iailab.module.model.mpk.service.ChartParamService; |
|
12 |
import lombok.extern.slf4j.Slf4j; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.springframework.beans.factory.annotation.Autowired; |
|
15 |
import org.springframework.stereotype.Service; |
91343d
|
16 |
import org.springframework.util.CollectionUtils; |
200ade
|
17 |
|
91343d
|
18 |
import java.util.*; |
200ade
|
19 |
|
D |
20 |
/** |
|
21 |
* @description: |
|
22 |
* @author: dzd |
|
23 |
* @date: 2024/11/5 11:21 |
|
24 |
**/ |
|
25 |
@Slf4j |
|
26 |
@Service |
|
27 |
public class ChartParamServiceImpl extends BaseServiceImpl<ChartParamDao, ChartParamEntity> implements ChartParamService { |
|
28 |
|
|
29 |
@Override |
|
30 |
public PageData<ChartParamDTO> page(Map<String, Object> params) { |
|
31 |
IPage<ChartParamEntity> page = baseDao.selectPage( |
|
32 |
getPage(params, "create_time", false), |
|
33 |
getWrapper(params) |
|
34 |
); |
|
35 |
|
|
36 |
return getPageData(page, ChartParamDTO.class); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public void create(ChartParamEntity entity) { |
|
41 |
entity.setId(UUID.randomUUID().toString()); |
|
42 |
entity.setCreateTime(new Date()); |
|
43 |
baseDao.insert(entity); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void update(ChartParamEntity entity) { |
|
48 |
entity.setUpdateTime(new Date()); |
|
49 |
baseDao.updateById(entity); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public ChartParamEntity get(String id) { |
|
54 |
return baseDao.selectById(id); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
91343d
|
58 |
public Map<String, String> getByChartId(String chartId) { |
潘 |
59 |
Map<String, String> result = new HashMap<>(); |
|
60 |
Map<String, Object> params = new HashMap<String, Object>(1); |
|
61 |
params.put("chartId", chartId); |
|
62 |
List<ChartParamEntity> list = baseDao.selectList(getWrapper(params)); |
|
63 |
if (CollectionUtils.isEmpty(list)) { |
|
64 |
return result; |
|
65 |
} |
|
66 |
list.forEach(item -> { |
|
67 |
result.put(item.getParamCode(), item.getParamValue()); |
|
68 |
}); |
|
69 |
return result; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
200ade
|
73 |
public void delete(String id) { |
D |
74 |
baseDao.deleteById(id); |
|
75 |
} |
|
76 |
|
|
77 |
private QueryWrapper<ChartParamEntity> getWrapper(Map<String, Object> params) { |
|
78 |
String paramName = (String) params.get("paramName"); |
|
79 |
String paramCode = (String) params.get("paramCode"); |
|
80 |
String chartId = (String) params.get("chartId"); |
|
81 |
|
|
82 |
QueryWrapper<ChartParamEntity> wrapper = new QueryWrapper<>(); |
|
83 |
wrapper.like(StringUtils.isNotBlank(paramName), "param_name", paramName) |
|
84 |
.like(StringUtils.isNotBlank(paramCode), "param_code", paramCode) |
|
85 |
.eq(StringUtils.isNotBlank(chartId), "chart_id", chartId); |
|
86 |
return wrapper; |
|
87 |
} |
|
88 |
} |