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