提交 | 用户 | 时间
|
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.iailab.framework.common.constant.Constant; |
08b6a5
|
6 |
import com.iailab.framework.common.pojo.PageResult; |
149dd0
|
7 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
08b6a5
|
8 |
import com.iailab.framework.common.util.object.BeanUtils; |
149dd0
|
9 |
import com.iailab.framework.common.util.object.ConvertUtils; |
08b6a5
|
10 |
import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; |
149dd0
|
11 |
import com.iailab.module.data.video.dao.ImageDao; |
H |
12 |
import com.iailab.module.data.video.dto.ImageDTO; |
|
13 |
import com.iailab.module.data.video.entity.ImageEntity; |
08b6a5
|
14 |
import com.iailab.module.data.video.entity.DataEntity; |
149dd0
|
15 |
import com.iailab.module.data.video.service.ImageService; |
H |
16 |
import org.apache.commons.lang3.ObjectUtils; |
|
17 |
import org.springframework.stereotype.Service; |
|
18 |
import org.springframework.util.CollectionUtils; |
|
19 |
|
08b6a5
|
20 |
import javax.validation.Valid; |
149dd0
|
21 |
import java.util.*; |
H |
22 |
|
|
23 |
/** |
08b6a5
|
24 |
* @author Houzhongjian |
149dd0
|
25 |
* @Description |
H |
26 |
* @createTime 2024年02月27日 |
|
27 |
*/ |
|
28 |
@Service |
|
29 |
public class ImageServiceImpl extends BaseServiceImpl<ImageDao, ImageEntity> implements ImageService { |
|
30 |
|
|
31 |
@Override |
08b6a5
|
32 |
public PageResult<ImageDTO> getPage(ImagePageReqVO imagePageReqVO) { |
H |
33 |
PageResult<ImageEntity> pageResult = baseDao.selectPage(imagePageReqVO); |
|
34 |
return BeanUtils.toBean(pageResult, ImageDTO.class); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public List<ImageDTO> list(@Valid ImagePageReqVO imagePageReqVO) { |
|
39 |
QueryWrapper<ImageEntity> queryWrapper = getWrapper(imagePageReqVO); |
|
40 |
queryWrapper.orderByDesc(Constant.CREATE_DATE); |
|
41 |
List<ImageEntity> list = baseDao.selectList(queryWrapper); |
|
42 |
return ConvertUtils.sourceToTarget(list, ImageDTO.class); |
149dd0
|
43 |
} |
H |
44 |
|
|
45 |
@Override |
|
46 |
public ImageDTO get(String id) { |
|
47 |
ImageEntity entity = baseDao.selectById(id); |
|
48 |
|
|
49 |
return ConvertUtils.sourceToTarget(entity, ImageDTO.class); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
@DSTransactional(rollbackFor = Exception.class) |
08b6a5
|
54 |
public void delete(String id) { |
149dd0
|
55 |
//删除菜单 |
08b6a5
|
56 |
baseDao.deleteById(id); |
149dd0
|
57 |
} |
H |
58 |
|
|
59 |
@Override |
|
60 |
public ImageDTO get(String cameraId, Date createDate) { |
|
61 |
QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); |
|
62 |
wrapper.eq( "camera_id", cameraId) |
|
63 |
.eq( "create_date", createDate); |
|
64 |
ImageEntity entity = new ImageEntity(); |
|
65 |
List<ImageEntity> devImageEntities = baseDao.selectList(wrapper); |
|
66 |
if (ObjectUtils.isNotEmpty(devImageEntities)) { |
|
67 |
entity = devImageEntities.get(0); |
|
68 |
} |
|
69 |
return ConvertUtils.sourceToTarget(entity, ImageDTO.class); |
|
70 |
} |
|
71 |
|
08b6a5
|
72 |
private QueryWrapper<ImageEntity> getWrapper(ImagePageReqVO imagePageReqVO){ |
H |
73 |
String cameraId = imagePageReqVO.getCameraId(); |
|
74 |
QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); |
|
75 |
wrapper.eq( "camera_id", cameraId); |
|
76 |
return wrapper; |
|
77 |
} |
|
78 |
|
149dd0
|
79 |
} |