package com.iailab.module.data.video.service.impl; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.constant.Constant; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; import com.iailab.module.data.video.dao.ImageDao; import com.iailab.module.data.video.dto.ImageDTO; import com.iailab.module.data.video.entity.ImageEntity; import com.iailab.module.data.video.entity.DataEntity; import com.iailab.module.data.video.service.ImageService; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.validation.Valid; import java.util.*; /** * @author Houzhongjian * @Description * @createTime 2024年02月27日 */ @Service public class ImageServiceImpl extends BaseServiceImpl implements ImageService { @Override public PageResult getPage(ImagePageReqVO imagePageReqVO) { PageResult pageResult = baseDao.selectPage(imagePageReqVO); return BeanUtils.toBean(pageResult, ImageDTO.class); } @Override public List list(@Valid ImagePageReqVO imagePageReqVO) { QueryWrapper queryWrapper = getWrapper(imagePageReqVO); queryWrapper.orderByDesc(Constant.CREATE_DATE); List list = baseDao.selectList(queryWrapper); return ConvertUtils.sourceToTarget(list, ImageDTO.class); } @Override public ImageDTO get(String id) { ImageEntity entity = baseDao.selectById(id); return ConvertUtils.sourceToTarget(entity, ImageDTO.class); } @Override @DSTransactional(rollbackFor = Exception.class) public void delete(String id) { //删除菜单 baseDao.deleteById(id); } @Override public ImageDTO get(String cameraId, Date createDate) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq( "camera_id", cameraId) .eq( "create_date", createDate); ImageEntity entity = new ImageEntity(); List devImageEntities = baseDao.selectList(wrapper); if (ObjectUtils.isNotEmpty(devImageEntities)) { entity = devImageEntities.get(0); } return ConvertUtils.sourceToTarget(entity, ImageDTO.class); } private QueryWrapper getWrapper(ImagePageReqVO imagePageReqVO){ String cameraId = imagePageReqVO.getCameraId(); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq( "camera_id", cameraId); return wrapper; } }