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