|
@@ -39,24 +39,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> impl
|
|
|
IBaseService iBaseService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public Result search(GoodsPageDto param) {
|
|
|
BaseUtil.startPage(param);
|
|
|
- IPage<GoodsEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
+ IPage<GoodsEntity> page = new Page<>(param.getPageNum(), param.getPageSize());
|
|
|
LambdaQueryWrapper<GoodsEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
String searchKey = param.getSearchKey();
|
|
|
wrapper.eq(GoodsEntity::getType, param.getType());
|
|
|
+ Integer display = param.getDisplay();
|
|
|
+ wrapper.eq(display!=null, GoodsEntity::getDisplay, display);
|
|
|
String startTime = param.getStartTime();
|
|
|
String endTime = param.getEndTime();
|
|
|
- if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime) ){
|
|
|
+ if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)) {
|
|
|
wrapper.between(GoodsEntity::getCreateTime, startTime, endTime);
|
|
|
}
|
|
|
wrapper.like(StrUtil.isNotBlank(searchKey), GoodsEntity::getName, searchKey);
|
|
|
|
|
|
- return Result.success( this.page(page, wrapper));
|
|
|
+ return Result.success(this.page(page, wrapper));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -76,24 +75,32 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> impl
|
|
|
return Result.success(entity);
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
-// public Result imgIndex(Long fileId, Long id) {
|
|
|
-// fileService.indexDisable(id, "goods");
|
|
|
-// fileService.indexEnabled(fileId);
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
|
|
|
@Override
|
|
|
public void setVisit(Long id) {
|
|
|
getBaseMapper().setVisit(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result del(Long id) {
|
|
|
+ GoodsEntity entity = this.getById(id);
|
|
|
+ if (entity == null) {
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+ // 删除图片
|
|
|
+
|
|
|
+ fileUtils.del(entity.getFilePath());
|
|
|
+ fileUtils.del(entity.getThumb());
|
|
|
+ this.removeById(id);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Result saveEntity(GoodsDto param) {
|
|
|
Long id = param.getId();
|
|
|
GoodsEntity entity = null;
|
|
|
- if (id == null){
|
|
|
+ if (id == null) {
|
|
|
entity = new GoodsEntity();
|
|
|
entity.setCreatorId(iBaseService.getUserId());
|
|
|
|
|
@@ -102,11 +109,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> impl
|
|
|
BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
|
|
|
// 判断图片
|
|
|
String filePath = entity.getFilePath();
|
|
|
- if (StrUtil.isNotBlank(filePath) && !StrUtil.equals(param.getFilePath(), filePath)){
|
|
|
+ if (StrUtil.isNotBlank(filePath) && !StrUtil.equals(param.getFilePath(), filePath)) {
|
|
|
fileUtils.del(filePath);
|
|
|
}
|
|
|
String thumb = entity.getThumb();
|
|
|
- if (StrUtil.isNotBlank(thumb) && !StrUtil.equals(param.getThumb(), thumb)){
|
|
|
+ if (StrUtil.isNotBlank(thumb) && !StrUtil.equals(param.getThumb(), thumb)) {
|
|
|
fileUtils.del(thumb);
|
|
|
}
|
|
|
}
|
|
@@ -125,13 +132,12 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> impl
|
|
|
// fileService.bindingModuleId(id, ids, "goods");
|
|
|
//
|
|
|
// }
|
|
|
-
|
|
|
@Override
|
|
|
public Result upload(FileDto param) {
|
|
|
|
|
|
String type = param.getType();
|
|
|
boolean isPingYing = false;
|
|
|
- if ("model".equals(type)){
|
|
|
+ if ("model".equals(type)) {
|
|
|
isPingYing = true;
|
|
|
}
|
|
|
String path = "/goods/" + type;
|