wuweihao vor 3 Jahren
Ursprung
Commit
c454dca863

+ 7 - 19
gis_cms/src/main/java/com/gis/cms/controller/GoodsController.java

@@ -69,25 +69,13 @@ public class GoodsController {
         return entityService.upload(param);
     }
 
-//    @ApiOperation(value = "视频上传")
-//    @PostMapping("video/upload")
-//    public Result videoUpload(MultipartFile file) {
-//        String type = "video";
-//        return entityService.videoUpload(file, type);
-//    }
-
-
-//    @ApiOperation("删除")
-//    @GetMapping("remove/{id}")
-//    public Result remove(@PathVariable Long id) {
-//        return Result.success(entityService.removeById(id));
-//    }
-//
-//    @ApiOperation("删除图片")
-//    @GetMapping("imgRemove/{id}")
-//    public Result imgRemove(@PathVariable Long id) {
-//        return Result.success(fileService.removeById(id));
-//    }
+
+    @WebControllerLog(description = "文物管理-删除", addDb = true)
+    @ApiOperation("删除")
+    @GetMapping("remove/{id}")
+    public Result del(@PathVariable Long id) {
+        return entityService.del(id);
+    }
 
 
 

+ 32 - 0
gis_cms/src/main/java/com/gis/cms/controller/WebController.java

@@ -0,0 +1,32 @@
+package com.gis.cms.controller;
+
+import com.gis.cms.entity.dto.GoodsPageDto;
+import com.gis.cms.service.GoodsService;
+import com.gis.common.util.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * Created by owen on 2022/5/23 0008 9:54
+ */
+@Api(tags = "web-展示端")
+@RestController
+@RequestMapping("/web")
+public class WebController {
+
+    @Autowired
+    GoodsService entityService;
+
+    @ApiOperation(value = "列表")
+    @PostMapping("/goods/list")
+    public Result list(@Valid @RequestBody GoodsPageDto param) {
+        param.setDisplay(1);
+        return entityService.search(param);
+    }
+
+
+}

+ 2 - 0
gis_cms/src/main/java/com/gis/cms/service/GoodsService.java

@@ -32,4 +32,6 @@ public interface GoodsService extends IService<GoodsEntity> {
 //    Result imgIndex(Long fileId, Long id);
 
     void setVisit(Long id);
+
+    Result del(Long id);
 }

+ 23 - 17
gis_cms/src/main/java/com/gis/cms/service/impl/GoodsServiceImpl.java

@@ -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;

+ 3 - 0
gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -107,6 +107,9 @@ public class FileUtils {
      * @param path 参数是相对地址
      */
     public void del(String path){
+        if (StrUtil.isBlank(path)){
+            return;
+        }
         String delPath = configConstant.serverBasePath + path;
         FileUtil.del(delPath);
         log.info("真删除文件: {}", delPath);