提交 | 用户 | 时间
|
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.ChartDao; |
|
8 |
import com.iailab.module.model.mpk.dto.ChartDTO; |
|
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 com.iailab.module.model.mpk.service.ChartService; |
|
13 |
import lombok.extern.slf4j.Slf4j; |
|
14 |
import org.apache.commons.lang3.StringUtils; |
91343d
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
200ade
|
16 |
import org.springframework.stereotype.Service; |
91343d
|
17 |
import org.springframework.util.CollectionUtils; |
200ade
|
18 |
|
91343d
|
19 |
import java.util.*; |
200ade
|
20 |
|
D |
21 |
/** |
|
22 |
* @description: |
|
23 |
* @author: dzd |
|
24 |
* @date: 2024/11/5 11:21 |
|
25 |
**/ |
|
26 |
@Slf4j |
|
27 |
@Service |
|
28 |
public class ChartServiceImpl extends BaseServiceImpl<ChartDao, ChartEntity> implements ChartService { |
91343d
|
29 |
|
潘 |
30 |
@Autowired |
|
31 |
private ChartParamService chartParamService; |
200ade
|
32 |
|
D |
33 |
@Override |
|
34 |
public PageData<ChartDTO> page(Map<String, Object> params) { |
|
35 |
IPage<ChartEntity> page = baseDao.selectPage( |
|
36 |
getPage(params, "create_time", false), |
|
37 |
getWrapper(params) |
|
38 |
); |
|
39 |
|
|
40 |
return getPageData(page, ChartDTO.class); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public void create(ChartEntity entity) { |
|
45 |
entity.setId(UUID.randomUUID().toString()); |
|
46 |
entity.setCreateTime(new Date()); |
|
47 |
baseDao.insert(entity); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
public void update(ChartEntity entity) { |
|
52 |
entity.setUpdateTime(new Date()); |
|
53 |
baseDao.updateById(entity); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public ChartEntity get(String id) { |
|
58 |
return baseDao.selectById(id); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public void delete(String id) { |
|
63 |
baseDao.deleteById(id); |
|
64 |
} |
|
65 |
|
|
66 |
private QueryWrapper<ChartEntity> getWrapper(Map<String, Object> params) { |
|
67 |
String chartName = (String) params.get("chartName"); |
|
68 |
String chartCode = (String) params.get("chartCode"); |
|
69 |
|
|
70 |
QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>(); |
|
71 |
wrapper.like(StringUtils.isNotBlank(chartName), "chart_name", chartName) |
|
72 |
.like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode); |
|
73 |
return wrapper; |
|
74 |
} |
91343d
|
75 |
|
潘 |
76 |
@Override |
|
77 |
public Map<String, String> getByChartCode(String chartCode) { |
|
78 |
Map<String, String> result = new HashMap<>(); |
|
79 |
QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>(); |
|
80 |
wrapper.eq("chart_code", chartCode); |
|
81 |
ChartEntity entity = baseDao.selectOne(wrapper); |
977edc
|
82 |
if (entity == null) { |
91343d
|
83 |
return result; |
潘 |
84 |
} |
|
85 |
return chartParamService.getByChartId(entity.getId()); |
|
86 |
} |
200ade
|
87 |
} |