瀏覽代碼

删除分组、场景,最少保留一个场景

wuweihao 4 年之前
父節點
當前提交
fb379ebf10

+ 1 - 1
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/WorkEntity.java

@@ -67,6 +67,6 @@ public class WorkEntity extends BaseEntity implements Serializable {
     private String share;
 
     @ApiModelProperty(value = "初始场景id(场景id)")
-    private Long sceneIndex;
+    private String sceneIndex;
 
 }

+ 2 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/SceneService.java

@@ -26,7 +26,7 @@ public interface SceneService extends IBaseService<SceneEntity, Long> {
 
     Result editSomeData(EditSomeDataDto param);
 
-    Result setIndex(Long id, Long workId);
+    Result setIndex(String id, Long workId);
 
     Result getIndex(Long workId);
 
@@ -49,4 +49,5 @@ public interface SceneService extends IBaseService<SceneEntity, Long> {
 
     Result saveUseHots(UseHotsDto param);
 
+    List<SceneEntity> findByWorkId(Long workId);
 }

+ 16 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/CatalogServiceImpl.java

@@ -3,11 +3,13 @@ package com.gis.service.impl;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.CatalogDto;
 import com.gis.domain.entity.CatalogEntity;
+import com.gis.domain.entity.SceneEntity;
 import com.gis.domain.vo.CatalogSceneTree;
 import com.gis.mapper.CatalogMapper;
 import com.gis.mapper.IBaseMapper;
 import com.gis.mapper.SceneMapper;
 import com.gis.service.CatalogService;
+import com.gis.service.SceneService;
 import com.gis.tree.CatalogTreeUtil;
 import com.gis.tree.SceneTreeUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -34,6 +36,9 @@ public class CatalogServiceImpl extends IBaseServiceImpl<CatalogEntity, Long> im
     @Autowired
     private SceneMapper sceneMapper;
 
+    @Autowired
+    SceneService sceneService;
+
 
 
 
@@ -93,6 +98,17 @@ public class CatalogServiceImpl extends IBaseServiceImpl<CatalogEntity, Long> im
     @Override
     public Result remove(Long id) {
 
+        CatalogEntity entity = this.findById(id);
+        if (entity == null) {
+            return Result.success();
+        }
+
+        List<SceneEntity> workScenes = sceneService.findByWorkId(entity.getWorkId());
+        List<SceneEntity> catalogScenes = sceneService.findByCatalogId(id);
+        if ((workScenes.size()-catalogScenes.size()) <= 0) {
+            return Result.failure(3003,"请至少保留一个场景");
+        }
+
         // 递归删除
         this.delete(id);
 

+ 4 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -79,6 +79,9 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
         String fileName = file.getOriginalFilename();
         String suffix = StringUtils.substringAfterLast(fileName, ".");
+        if (suffix.length() > 200) {
+            return Result.failure(3003, "文件名称不允许超过200个字节");
+        }
         String newName = time  + "."  +suffix;
         String dirType = "fodder/";
         long size = file.getSize();
@@ -108,7 +111,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
 
                 // 全景图的预览图
                 ossPreviewIcon = fileUtils.compressImgAndUploadOss2(
-                       savePath, configConstant.ossBasePath + sceneCode , configConstant.ossDomain, 1920, 960, "preview.jpg");
+                       savePath, configConstant.ossBasePath + sceneCode , configConstant.ossDomain, 1920, 960, "/preview.jpg");
 
 
                 ossUrl = configConstant.ossDomain+configConstant.ossBasePath + sceneCode;

+ 8 - 5
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -37,7 +37,7 @@ import java.util.*;
  */
 @Slf4j
 @Service
-@Transactional
+//@Transactional
 public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implements SceneService {
 
     @Autowired
@@ -187,7 +187,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
 
 
     @Override
-    public Result setIndex(Long id, Long workId) {
+    public Result setIndex(String id, Long workId) {
         WorkEntity entity = workService.findById(workId);
 
         if (entity == null) {
@@ -209,10 +209,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
             log.error("作品不存在,id:  {}", workId);
             return Result.failure("作品不存在");
         }
-        Long sceneIndex = entity.getSceneIndex();
+        String sceneIndex = entity.getSceneIndex();
         SceneEntity sceneEntity = null;
         if (sceneIndex != null) {
-             sceneEntity = this.findById(sceneIndex);
+             sceneEntity = this.findById(Long.valueOf(sceneIndex));
         }
         return Result.success(sceneEntity);
     }
@@ -432,7 +432,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
         return Result.success() ;
     }
 
-
+    @Override
+    public List<SceneEntity> findByWorkId(Long workId) {
+        return entityMapper.findByWorkId(workId);
+    }
 
 
 }

+ 0 - 11
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/CatalogController.java

@@ -39,17 +39,6 @@ public class CatalogController extends BaseController {
     }
 
 
-    /**
-     * 测试,还没成功,感觉是数据结构没有定好
-     * @return
-     */
-//    @ApiOperation(value = "test场景列表", position = 1)
-//    @PostMapping("testListTree/{workId}")
-//    public Result testListTree(@PathVariable Long workId) {
-//        return catalogService.webListTree(workId);
-//    }
-
-
     @ApiOperation(value = "新增/修改分组", position = 1)
     @PostMapping("save")
     public Result save(@Valid @RequestBody CatalogDto param) {

+ 17 - 3
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -81,6 +81,13 @@ public class SceneController extends BaseController {
         return sceneService.saves(param);
     }
 
+    @ApiOperation(value = "查询该作品是否存在场景")
+    @GetMapping("findByWork/{workId}")
+    public Result findByWorkId(@PathVariable Long workId) {
+        List<SceneEntity> list = sceneService.findByWorkId(workId);
+        return Result.success(list);
+    }
+
 
     @ApiOperation(value = "上传-图标", position = 2)
     @PostMapping(value = "upload")
@@ -109,7 +116,7 @@ public class SceneController extends BaseController {
 
     @ApiOperation(value = "初始场景-设置", position = 3)
     @PostMapping("setIndex/{id}/{workId}")
-    public Result setIndex(@PathVariable Long id, @PathVariable Long workId) {
+    public Result setIndex(@PathVariable String id, @PathVariable Long workId) {
         return sceneService.setIndex(id, workId);
     }
 
@@ -123,7 +130,7 @@ public class SceneController extends BaseController {
     @GetMapping("removeIndex/{workId}")
     public Result removeIndex(@PathVariable Long workId) {
         WorkEntity entity = workService.findById(workId);
-        entity.setSceneIndex(null);
+        entity.setSceneIndex("");
         entity.setUpdateTime(new Date());
         workService.update(entity);
         return Result.success();
@@ -167,7 +174,14 @@ public class SceneController extends BaseController {
     @GetMapping("remove/{id}")
     public Result remove(@PathVariable Long id) {
         log.info("场景删除");
+
+        // 最后一个场景不能删除
         SceneEntity entity = sceneService.findById(id);
+        List<SceneEntity> list = sceneService.findByWorkId(entity.getWorkId());
+        if (list.size() == 1) {
+            return Result.failure(3003,"请至少保留一个场景");
+        }
+
 
         Long workId = entity.getWorkId();
         entity.setIsDelete(1);
@@ -178,7 +192,7 @@ public class SceneController extends BaseController {
         WorkEntity workEntity = workService.findById(workId);
 
         if (workEntity != null  || workEntity.getSceneIndex().equals(id) ) {
-            workEntity.setSceneIndex(null);
+            workEntity.setSceneIndex("");
             workEntity.setUpdateTime(new Date());
             workService.update(workEntity);
         }

+ 0 - 13
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/WorkController.java

@@ -31,7 +31,6 @@ import java.util.Date;
 @Api(tags = "我的作品")
 @RestController
 @RequestMapping("manage/work")
-//@RequestMapping("aa/work")
 public class WorkController extends BaseController {
 
     @Autowired
@@ -71,18 +70,6 @@ public class WorkController extends BaseController {
         return workService.entitySave(param);
     }
 
-//    @ApiOperation(value = "删除", position = 1)
-//    @PostMapping("remove/{id}")
-//    public Result remove( @PathVariable Long id) {
-//        WorkEntity entity = workService.findById(id);
-//        if (entity == null) {
-//            return Result.success();
-//        }
-//        entity.setIsDelete(1);
-//        entity.setUpdateTime(new Date());
-//        workService.update(entity);
-//        return Result.success();
-//    }
 
     @ApiOperation(value = "删除", position = 1)
     @PostMapping("remove/{id}")