提交 | 用户 | 时间
|
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.dao.ChartParamDao; |
|
9 |
import com.iailab.module.model.mpk.dto.ChartDTO; |
|
10 |
import com.iailab.module.model.mpk.dto.ChartParamDTO; |
|
11 |
import com.iailab.module.model.mpk.entity.ChartEntity; |
|
12 |
import com.iailab.module.model.mpk.entity.ChartParamEntity; |
|
13 |
import com.iailab.module.model.mpk.service.ChartParamService; |
|
14 |
import com.iailab.module.model.mpk.service.ChartService; |
|
15 |
import lombok.extern.slf4j.Slf4j; |
|
16 |
import org.apache.commons.lang3.StringUtils; |
|
17 |
import org.springframework.stereotype.Service; |
|
18 |
|
|
19 |
import java.util.Date; |
|
20 |
import java.util.Map; |
|
21 |
import java.util.UUID; |
|
22 |
|
|
23 |
/** |
|
24 |
* @description: |
|
25 |
* @author: dzd |
|
26 |
* @date: 2024/11/5 11:21 |
|
27 |
**/ |
|
28 |
@Slf4j |
|
29 |
@Service |
|
30 |
public class ChartServiceImpl extends BaseServiceImpl<ChartDao, ChartEntity> implements ChartService { |
|
31 |
|
|
32 |
@Override |
|
33 |
public PageData<ChartDTO> page(Map<String, Object> params) { |
|
34 |
IPage<ChartEntity> page = baseDao.selectPage( |
|
35 |
getPage(params, "create_time", false), |
|
36 |
getWrapper(params) |
|
37 |
); |
|
38 |
|
|
39 |
return getPageData(page, ChartDTO.class); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void create(ChartEntity entity) { |
|
44 |
entity.setId(UUID.randomUUID().toString()); |
|
45 |
entity.setCreateTime(new Date()); |
|
46 |
baseDao.insert(entity); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public void update(ChartEntity entity) { |
|
51 |
entity.setUpdateTime(new Date()); |
|
52 |
baseDao.updateById(entity); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public ChartEntity get(String id) { |
|
57 |
return baseDao.selectById(id); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public void delete(String id) { |
|
62 |
baseDao.deleteById(id); |
|
63 |
} |
|
64 |
|
|
65 |
private QueryWrapper<ChartEntity> getWrapper(Map<String, Object> params) { |
|
66 |
String chartName = (String) params.get("chartName"); |
|
67 |
String chartCode = (String) params.get("chartCode"); |
|
68 |
|
|
69 |
QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>(); |
|
70 |
wrapper.like(StringUtils.isNotBlank(chartName), "chart_name", chartName) |
|
71 |
.like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode); |
|
72 |
return wrapper; |
|
73 |
} |
|
74 |
} |