Bläddra i källkod

修改:新增场景时处理目录层次结构问题

wuweihao 4 år sedan
förälder
incheckning
7bdca106e6

+ 13 - 4
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/SceneDto.java

@@ -25,8 +25,8 @@ public class SceneDto {
     @ApiModelProperty(value = "封面图")
     private String icon;
 
-    @ApiModelProperty(value = "分组Id")
-    private Long catalogId;
+//    @ApiModelProperty(value = "分组Id")
+//    private Long catalogId;
 
     @ApiModelProperty(value = "作品Id")
     private Long workId;
@@ -34,7 +34,16 @@ public class SceneDto {
     @ApiModelProperty(value = "类型:pano/4dkk")
     private String type;
 
-//    @ApiModelProperty(value = "场景密码")
-//    private String password;
+    @ApiModelProperty(value = "目录名称")
+    private String CatalogName;
+
+    @ApiModelProperty(value = "目录Id")
+    private Long CatalogId;
+
+    @ApiModelProperty(value = "父目录Id")
+    private Long parentId;
+
+    @ApiModelProperty(value = "父目录名称")
+    private String parentName;
 
 }

+ 69 - 13
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -18,6 +18,7 @@ import com.gis.mapper.SceneMapper;
 import com.gis.service.CatalogService;
 import com.gis.service.SceneService;
 import com.gis.service.WorkService;
+import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
@@ -47,9 +48,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
     @Autowired
     WorkService workService;
 
-
-
-
+    @Autowired
+    CatalogService catalogService;
 
     @Autowired
     ConfigConstant configConstant;
@@ -57,8 +57,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
     @Autowired
     FileUtils fileUtils;
 
-    @Autowired
-    AliyunOssUtil aliyunOssUtil;
+//    @Autowired
+//    AliyunOssUtil aliyunOssUtil;
 
 
     @Override
@@ -149,6 +149,28 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
 
     }
 
+//    @Override
+//    public Result saves(List<SceneDto> params) {
+//        SceneEntity entity = null;
+//        for (SceneDto sceneDto : params) {
+//            Long id = sceneDto.getId();
+//            if (id == null) {
+//                entity = new SceneEntity();
+//                BeanUtils.copyProperties(sceneDto, entity);
+//                this.save(entity);
+//            } else {
+//                entity = findById(id);
+//                BeanUtils.copyProperties(sceneDto, entity);
+//                entity.setUpdateTime(new Date());
+//                this.update(entity);
+//
+//            }
+//        }
+//
+//        return Result.success();
+//    }
+
+
     @Override
     public Result saves(List<SceneDto> params) {
         SceneEntity entity = null;
@@ -157,6 +179,13 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
             if (id == null) {
                 entity = new SceneEntity();
                 BeanUtils.copyProperties(sceneDto, entity);
+
+                // 创建分组
+                Long catalogId = sceneDto.getCatalogId();
+                if (catalogId == null) {
+                    entity.setCatalogId(createCatalog(sceneDto));
+                }
+
                 this.save(entity);
             } else {
                 entity = findById(id);
@@ -170,7 +199,38 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
         return Result.success();
     }
 
+    /**
+     * 创建分组
+     * @param sceneDto
+     * @return
+     */
+    private Long createCatalog(SceneDto sceneDto) {
+        Long parentId = sceneDto.getParentId();
+        String parentName = sceneDto.getParentName();
+        Long workId = sceneDto.getWorkId();
+
+        CatalogEntity entity = new CatalogEntity();
+        entity.setName(sceneDto.getCatalogName());
+        entity.setWorkId(workId);
+        // 当父id不为空时
+        if (parentId != null) {
+            entity.setParentId(parentId);
+        }
+
+        // 创建父目录
+        if (parentId == null && parentName != null) {
+            CatalogEntity parentEntity = new CatalogEntity();
+            parentEntity.setWorkId(workId);
+            parentEntity.setName(parentName);
+            catalogService.save(parentEntity);
 
+            entity.setParentId(parentEntity.getParentId());
+
+        }
+        // 创建目录
+        catalogService.save(entity);
+        return entity.getId();
+    }
 
     @Override
     public List<String> strFindByWorkId(Long workId, String type) {
@@ -184,9 +244,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
     }
 
 
-
-
-
     @Override
     public Result setIndex(String id, Long workId) {
         WorkEntity entity = workService.findById(workId);
@@ -214,7 +271,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
         SceneEntity sceneEntity = null;
         // 字符串判断需要用isNotBlank
         if (StringUtils.isNotBlank(sceneIndex)) {
-             sceneEntity = this.findById(Long.valueOf(sceneIndex));
+            sceneEntity = this.findById(Long.valueOf(sceneIndex));
         }
         return Result.success(sceneEntity);
     }
@@ -416,7 +473,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
     }
 
 
-
     @Override
     public Result saveUseHots(UseHotsDto param) {
         Long id = param.getId();
@@ -431,7 +487,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
         entity.setUseHots(jsonObject.toJSONString());
         entity.setUpdateTime(new Date());
         this.update(entity);
-        return Result.success() ;
+        return Result.success();
     }
 
     @Override
@@ -452,9 +508,9 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
         // 字符串判断需要用isNotBlank
         if (StringUtils.isNotBlank(sceneIndex)) {
             Long sceneId = Long.valueOf(sceneIndex);
-            vo =entityMapper.findVoById(sceneId);
+            vo = entityMapper.findVoById(sceneId);
         }
-        return Result.success(vo) ;
+        return Result.success(vo);
     }
 
 

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

@@ -76,7 +76,7 @@ public class SceneController extends BaseController {
 
 
 
-    @ApiOperation(value = "批量场景新增/修改", position = 1)
+    @ApiOperation(value = "批量场景新增/修改", position = 1, notes = "注意创建目录层次问题")
     @PostMapping("saves")
     public Result saves(@RequestBody List<SceneDto> param) {
         return sceneService.saves(param);