提交 | 用户 | 时间
|
ce910c
|
1 |
package com.iailab.module.data.dev.service.impl; |
H |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
5 |
import com.iailab.framework.common.constant.Constant; |
|
6 |
import com.iailab.framework.common.page.PageData; |
|
7 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
8 |
import com.iailab.framework.common.util.object.ConvertUtils; |
|
9 |
import com.iailab.module.data.dev.dao.DevLogDao; |
|
10 |
import com.iailab.module.data.dev.dto.DevLogDTO; |
|
11 |
import com.iailab.module.data.dev.entity.DevLogEntity; |
|
12 |
import com.iailab.module.data.dev.service.DevLogService; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.springframework.stereotype.Service; |
|
15 |
import org.springframework.transaction.annotation.Transactional; |
|
16 |
|
|
17 |
import java.util.Arrays; |
|
18 |
import java.util.List; |
|
19 |
import java.util.Map; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author PanZhibao |
|
23 |
* @Description |
|
24 |
* @createTime 2024年03月07日 |
|
25 |
*/ |
|
26 |
@Service |
|
27 |
public class DevLogServiceImpl extends BaseServiceImpl<DevLogDao, DevLogEntity> implements DevLogService { |
|
28 |
|
|
29 |
@Override |
|
30 |
public PageData<DevLogDTO> page(Map<String, Object> params) { |
|
31 |
IPage<DevLogEntity> page = baseDao.selectPage( |
|
32 |
getPage(params, Constant.CREATE_DATE, false), |
|
33 |
getWrapper(params) |
|
34 |
); |
|
35 |
return getPageData(page, DevLogDTO.class); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public List<DevLogDTO> list(Map<String, Object> params) { |
|
40 |
QueryWrapper<DevLogEntity> queryWrapper = getWrapper(params); |
|
41 |
queryWrapper.orderByDesc(Constant.CREATE_DATE); |
|
42 |
List<DevLogEntity> list = baseDao.selectList(queryWrapper); |
|
43 |
return ConvertUtils.sourceToTarget(list, DevLogDTO.class); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public DevLogDTO get(String id) { |
|
48 |
DevLogEntity entity = baseDao.selectById(id); |
|
49 |
|
|
50 |
return ConvertUtils.sourceToTarget(entity, DevLogDTO.class); |
|
51 |
} |
|
52 |
|
|
53 |
private QueryWrapper<DevLogEntity> getWrapper(Map<String, Object> params){ |
|
54 |
String code = (String)params.get("code"); |
|
55 |
String location = (String)params.get("location"); |
|
56 |
Integer status = params.get("status") == null ? null : Integer.parseInt(params.get("status").toString()); |
|
57 |
|
|
58 |
QueryWrapper<DevLogEntity> wrapper = new QueryWrapper<>(); |
|
59 |
wrapper.like(StringUtils.isNotBlank(code), "code", code) |
|
60 |
.like(StringUtils.isNotBlank(location), "location", location) |
|
61 |
.eq(status != null, "status", status); |
|
62 |
|
|
63 |
return wrapper; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public void save(DevLogDTO dto) { |
|
68 |
DevLogEntity entity = ConvertUtils.sourceToTarget(dto, DevLogEntity.class); |
|
69 |
|
|
70 |
insert(entity); |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public void update(DevLogDTO dto) { |
|
75 |
DevLogEntity entity = ConvertUtils.sourceToTarget(dto, DevLogEntity.class); |
|
76 |
updateById(entity); |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
@Transactional(rollbackFor = Exception.class) |
|
81 |
public void delete(String[] ids) { |
|
82 |
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
83 |
} |
|
84 |
} |