|
@@ -9,10 +9,12 @@ import com.gis.cms.entity.dto.ImgDto;
|
|
|
import com.gis.cms.entity.dto.TypePageDto;
|
|
|
import com.gis.cms.entity.po.ImgEntity;
|
|
|
import com.gis.cms.entity.po.ImgEntity;
|
|
|
+import com.gis.cms.entity.po.VideoEntity;
|
|
|
import com.gis.cms.mapper.ImgMapper;
|
|
|
import com.gis.cms.mapper.ImgMapper;
|
|
|
import com.gis.cms.service.ImgService;
|
|
|
import com.gis.common.base.entity.dto.PageDto;
|
|
|
+import com.gis.common.constant.MsgCode;
|
|
|
import com.gis.common.constant.TypeCode;
|
|
|
import com.gis.common.util.BaseUtil;
|
|
|
import com.gis.common.util.FileUtils;
|
|
@@ -52,6 +54,12 @@ public class ImgServiceImpl extends ServiceImpl<ImgMapper, ImgEntity> implements
|
|
|
Long id = param.getId();
|
|
|
ImgEntity entity = null;
|
|
|
if (id == null){
|
|
|
+
|
|
|
+
|
|
|
+ if (checkSize(module) > 100){
|
|
|
+ return Result.failure(MsgCode.e3002, "数据量最大为100条");
|
|
|
+ }
|
|
|
+
|
|
|
entity = new ImgEntity();
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
entity.setModule(module);
|
|
@@ -70,21 +78,30 @@ public class ImgServiceImpl extends ServiceImpl<ImgMapper, ImgEntity> implements
|
|
|
}
|
|
|
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
- imgMapper.update(entity, null);
|
|
|
+ imgMapper.updateById(entity);
|
|
|
}
|
|
|
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+ private long checkSize(String module){
|
|
|
+ LambdaQueryWrapper<ImgEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(ImgEntity::getModule, module);
|
|
|
+ return this.count(wrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public Result imgList(PageDto param, String module) {
|
|
|
+
|
|
|
BaseUtil.startPage(param);
|
|
|
IPage<ImgEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
|
|
|
LambdaQueryWrapper<ImgEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(ImgEntity::getModule, module);
|
|
|
+
|
|
|
IPage<ImgEntity> iPage = imgMapper.selectPage(page, wrapper);
|
|
|
return Result.success(iPage);
|
|
|
}
|
|
@@ -96,4 +113,16 @@ public class ImgServiceImpl extends ServiceImpl<ImgMapper, ImgEntity> implements
|
|
|
return this.list(wrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result removeEntity(Long id) {
|
|
|
+ ImgEntity entity = this.getById(id);
|
|
|
+ if (entity == null){
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+ fileUtils.del(entity.getThumb());
|
|
|
+ this.removeById(entity);
|
|
|
+ return Result.success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|