Prechádzať zdrojové kódy

目录功能已完成

wuweihao 2 rokov pred
rodič
commit
3bb6b9b972
30 zmenil súbory, kde vykonal 598 pridanie a 136 odobranie
  1. 1 2
      720yun_fd_manage/gis_application/src/main/resources/application-dev.properties
  2. 1 1
      720yun_fd_manage/gis_application/src/main/resources/application-locSit.properties
  3. 1 1
      720yun_fd_manage/gis_application/src/main/resources/application.properties
  4. 1 0
      720yun_fd_manage/gis_common/src/main/java/com/gis/common/constant/ErrorEnum.java
  5. 3 0
      720yun_fd_manage/gis_common/src/main/java/com/gis/common/exception/BaseRuntimeException.java
  6. 3 0
      720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/ImageUtil.java
  7. 56 0
      720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/RegexUtil.java
  8. 0 35
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/CatalogSceneDto.java
  9. 1 7
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/CatalogDto.java
  10. 28 0
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/DirMoveDto.java
  11. 3 0
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/FodderPageDto.java
  12. 29 0
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/FodderUploadDto.java
  13. 7 14
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/CatalogEntity.java
  14. 8 0
      720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/FodderEntity.java
  15. 0 36
      720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/CatalogMapper.java
  16. 23 0
      720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/DirMapper.java
  17. 6 3
      720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/FodderMapper.java
  18. 0 24
      720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/provider/FodderProvider.java
  19. 17 0
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/DirService.java
  20. 8 1
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/FodderService.java
  21. 2 0
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/TestService.java
  22. 91 0
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/DirServiceImpl.java
  23. 82 7
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java
  24. 18 0
      720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java
  25. 44 0
      720yun_fd_manage/gis_service/src/main/java/com/gis/tree/DirTree.java
  26. 83 0
      720yun_fd_manage/gis_service/src/main/java/com/gis/tree/DirTreeUtil.java
  27. 51 0
      720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/DirController.java
  28. 20 3
      720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/FodderController.java
  29. 5 1
      720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java
  30. 6 1
      720yun_fd_manage/remark-m.md

+ 1 - 2
720yun_fd_manage/gis_application/src/main/resources/application-dev.properties

@@ -3,11 +3,10 @@
 #DB
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.druid.url=jdbc:mysql://127.0.0.1:3306/${project.name}?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.druid.username=root
+spring.datasource.druid.url=jdbc:mysql://8.135.106.227:3306/${project.name}?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
 spring.datasource.druid.password=4dkk2021testproject%
 
-
 # \u521D\u59CB\u8FDE\u63A5\u6570
 spring.datasource.druid.initial-size=5
 # \u6700\u5C0F\u8FDE\u63A5\u6C60\u6570\u91CF

+ 1 - 1
720yun_fd_manage/gis_application/src/main/resources/application-locSit.properties

@@ -101,7 +101,7 @@ oss.domain=https://ossxiaoan.4dage.com/
 
 # swagger2 \u8BBE\u7F6E\u5168\u5C40\u5B57\u4F53\u683C\u5F0F\u4E3Autf-8
 swagger.package=com.gis.web.controller
-swagger.title=\u5168\u666F\u770B\u770B loc
+swagger.title=\u5168\u666F\u770B\u770B-${spring.profiles.active}
 swagger.description=${swagger.title}
 swagger.version=1.0
 

+ 1 - 1
720yun_fd_manage/gis_application/src/main/resources/application.properties

@@ -2,7 +2,7 @@ server.port=8001
 server.servlet.context-path=/qjkankan
 
 #spring.profiles.active=locPro
-spring.profiles.active=locSitAws
+spring.profiles.active=locSit
 
 
 # \uFFFD\uFFFD\u013F\uFFFD\uFFFD\uFFFD\uFFFD

+ 1 - 0
720yun_fd_manage/gis_common/src/main/java/com/gis/common/constant/ErrorEnum.java

@@ -53,6 +53,7 @@ public enum ErrorEnum {
     FAILURE_CODE_3023(3023, "非法格式"),
     FAILURE_CODE_3024(3024, "存储空间已满"),
     FAILURE_CODE_3025(3025, "上传失败"),
+    FAILURE_CODE_3026(3026, "非法文件, 图片没有像素"),
 
 
     // 31XX -> 自定义异常

+ 3 - 0
720yun_fd_manage/gis_common/src/main/java/com/gis/common/exception/BaseRuntimeException.java

@@ -2,10 +2,12 @@ package com.gis.common.exception;
 
 import cn.hutool.core.util.StrUtil;
 import com.gis.common.constant.ErrorEnum;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.util.CollectionUtils;
 
 import java.util.List;
 
+@Slf4j
 public class BaseRuntimeException extends RuntimeException{
 
     private static final long serialVersionUID = -1518945670203783450L;
@@ -94,6 +96,7 @@ public class BaseRuntimeException extends RuntimeException{
     }
 
     public static void  getExc(Integer code, String msg){
+        log.error("出异常了:{}", msg);
         throw new BaseRuntimeException(code, msg);
     }
 

+ 3 - 0
720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/ImageUtil.java

@@ -1,6 +1,8 @@
 package com.gis.common.util;
 
 import cn.hutool.core.img.ImgUtil;
+import com.gis.common.constant.ErrorEnum;
+import com.gis.common.exception.BaseRuntimeException;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.imageio.ImageIO;
@@ -32,6 +34,7 @@ public class ImageUtil {
         try {
             // 直接传路径会出错
             read = ImageIO.read(file.getInputStream());
+            BaseRuntimeException.isNull(read, ErrorEnum.FAILURE_CODE_3026.code(), ErrorEnum.FAILURE_CODE_3026.message());
             int width = read.getWidth();
             int height = read.getHeight();
             dpi = width + "*" + height + "px";

+ 56 - 0
720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/RegexUtil.java

@@ -0,0 +1,56 @@
+package com.gis.common.util;
+
+import cn.hutool.extra.pinyin.PinyinUtil;
+import org.apache.commons.lang3.StringUtils;
+
+public class RegexUtil {
+
+    // 需要过滤的特殊字符
+    static String [] specialSql = {"%","or","=","and","'",";"};
+
+    /** 处理特殊符号,变空值*/
+    public static String specificSymbol(String str){
+
+        String regEx = "[\\s`~!@#$%^&*()+=|{}':;\\[\\]<>/?·~!@#¥%……&*()——+|{}【】‘;:“”。,、?]";
+        return str.replaceAll(regEx, "");
+    }
+
+
+    /** 中文转拼音*/
+    public static String getPinyinName(String str){
+        // 去除特殊符号
+        String pinyinName = RegexUtil.specificSymbol(str);
+        pinyinName = PinyinUtil.getPinyin(pinyinName, "");
+        // 转小写
+//        pinyinName =  StringUtils.lowerCase(pinyinName);
+        return pinyinName;
+
+    }
+
+
+    /**
+     * sql 过滤特殊字符
+     * @param str
+     * @return
+     */
+    public static String sqlReplaceSpecialStr(String str){
+        str = StringUtils.trim(str);
+        str = str.toLowerCase();
+        for (String s : specialSql) {
+            if (str.contains(s)) {
+                str = str.replaceAll(s, "");
+            }
+        }
+        return str;
+    }
+
+
+
+    public static void main(String[] args) {
+        String str = "我·是 中—国(人), 你-在{干嘛}--哈—哈。 ddd.jpg";
+        System.out.println(specificSymbol(str));
+    }
+
+}
+
+

+ 0 - 35
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/CatalogSceneDto.java

@@ -1,35 +0,0 @@
-package com.gis.domain.dto;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import java.util.List;
-
-/**
- * Created by owen on 2021/2/22 0022 10:24
- */
-@Data
-public class CatalogSceneDto {
-
-    @ApiModelProperty(value = "目录名称")
-    private String CatalogName;
-
-    @ApiModelProperty(value = "目录Id")
-    private Long CatalogId;
-
-    @ApiModelProperty(value = "父目录Id")
-    private Long parentId;
-
-    @ApiModelProperty(value = "父目录名称")
-    private String parentName;
-
-    @NotNull(message = "作品id不能为空")
-    @ApiModelProperty(value = "作品id")
-    private Long workId;
-
-    @ApiModelProperty(value = "场景")
-    private List<SceneDto> scenes;
-
-}

+ 1 - 7
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/CatalogDto.java

@@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull;
  * Created by owen on 2021/2/22 0022 10:24
  */
 @Data
-public class CatalogDto {
+public class DirDto {
 
     @ApiModelProperty(value = "id, 修改时必须传,新增忽略", name = "id")
     private Long id;
@@ -22,11 +22,5 @@ public class CatalogDto {
     @ApiModelProperty(value = "父目录Id")
     private Long parentId;
 
-    @NotNull(message = "作品id不能为空")
-    @ApiModelProperty(value = "作品id")
-    private Long workId;
-
-
-
 
 }

+ 28 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/DirMoveDto.java

@@ -0,0 +1,28 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by owen on 2021/2/22 0022 10:24
+ */
+@Data
+public class DirMoveDto {
+
+
+
+    @ApiModelProperty(value = "目录id, 多个以逗号隔开")
+    private String dirIds;
+
+    @ApiModelProperty(value = "素材id, 多个以逗号隔开")
+    private String fodderIds;
+
+    @NotNull(message = "父目录Id不能为空")
+    @ApiModelProperty(value = "父目录Id, 根目录:1", required = true)
+    private Long parentId;
+
+
+}

+ 3 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/FodderPageDto.java

@@ -12,6 +12,9 @@ public class FodderPageDto extends PageDto {
     @ApiModelProperty(value = "类型, 全景图:pano, 图片:image, 音频:audio, 视频:video")
     private String type;
 
+    @ApiModelProperty(value = "目录id, 不传:或者跟目录")
+    private Long dirId;
+
 
 
 }

+ 29 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/FodderUploadDto.java

@@ -0,0 +1,29 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.constraints.Size;
+
+/**
+ * Created by owen on 2021/2/23 0023 16:39
+ */
+@Data
+public class FodderUploadDto {
+
+
+
+    @ApiModelProperty(value = "文件", required = true)
+    private MultipartFile file;
+
+    @ApiModelProperty(value = "type:类型, 全景图:pano, 图片:image, 音频:audio, 视频:video", required = true)
+    private String type;
+
+    @ApiModelProperty(value = "前端临时Id", required = true)
+    private String temId;
+
+    @ApiModelProperty(value = "目录id, 跟目录传:1", required = true)
+    private Long dirId;
+}

+ 7 - 14
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/CatalogEntity.java

@@ -10,32 +10,25 @@ import java.io.Serializable;
 import java.util.List;
 
 /**
- * 场景分组目录
+ * 目录
  */
 @Data
 @Entity
-@Table(name = "tb_catalog")
-public class CatalogEntity extends BaseEntity implements Serializable {
+@Table(name = "tb_dir")
+public class DirEntity extends BaseEntity implements Serializable {
 
     private static final long serialVersionUID = 4942917362578018318L;
     @ApiModelProperty(value = "名称")
     private String name;
 
-    @ApiModelProperty(value = "作品Id")
-    private Long workId;
-
-    @ApiModelProperty(value = "排序(序号小排前面)")
-    private Integer sort;
-
-    @ApiModelProperty(value = "目录层级,最大二级")
-    private Integer level;
-
     @ApiModelProperty(value = "父目录Id")
     private Long parentId;
 
-    @Transient
-    private List<Long> children;
+    @ApiModelProperty(value = "创建人")
+    private String userId;
 
+//    @ApiModelProperty(value = "层级:第一级1, 最大5级")
+//    private Integer level;
 
 
 

+ 8 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/FodderEntity.java

@@ -61,6 +61,14 @@ public class FodderEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "tour.xml")
     private String tour;
 
+    @ApiModelProperty(value = "目录id, 1为跟目录")
+    private Long dirId;
+
+    @Transient
+    @ApiModelProperty(value = "目录名称")
+    private String dirName;
+
+
 
 
 

+ 0 - 36
720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/CatalogMapper.java

@@ -1,36 +0,0 @@
-package com.gis.mapper;
-
-
-import com.gis.domain.entity.CatalogEntity;
-import com.gis.domain.vo.CatalogSceneTree;
-import com.gis.domain.vo.CatalogVo;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-
-@Component
-@Mapper
-public interface CatalogMapper extends IBaseMapper<CatalogEntity, Long> {
-
-
-
-    @Select("select * from tb_catalog where is_delete = 0 and work_id = #{workId}")
-    List<CatalogEntity> findByWorkId(String workId);
-
-    @Select("select a.id,a.parent_id,a.name,a.work_id,a.is_delete,b.id as scene_id ,b.scene_code, b.scene_title,b.catalog_id" +
-            " from tb_catalog a LEFT JOIN tb_scene b on a.id = b.catalog_id and b.is_delete='0' WHERE a.is_delete = '0' and a.work_id = #{workId}")
-    List<CatalogSceneTree> afindByWorkId(String workId);
-
-    @Select("select * from tb_catalog where is_delete = 0 and parent_id = #{id}")
-    List<CatalogEntity> findByParentId(Long id);
-
-    @Update("UPDATE tb_catalog SET is_delete = 1 where is_delete = 0 and work_id = #{workId}")
-    void setDeleteByWorkId(String workId);
-
-    @Select("select a.id as catalogId, a.name as catalogName, b.id as parentId, b.name as parentName from tb_catalog a left join  tb_catalog b on a.parent_id = b.id where a.is_delete = 0 and a.id = #{catalogId}")
-    CatalogVo voFindById(Long catalogId);
-}

+ 23 - 0
720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/DirMapper.java

@@ -0,0 +1,23 @@
+package com.gis.mapper;
+
+
+import com.gis.common.mapper.provider.BaseProvider;
+import com.gis.domain.entity.DirEntity;
+import com.gis.domain.vo.CatalogSceneTree;
+import com.gis.domain.vo.CatalogVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectProvider;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+@Component
+@Mapper
+public interface DirMapper extends IBaseMapper<DirEntity, Long> {
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    void updateParentId(String sqlStr);
+}

+ 6 - 3
720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/FodderMapper.java

@@ -23,9 +23,6 @@ public interface FodderMapper extends IBaseMapper<FodderEntity, Long> {
     List<FodderEntity> search(FodderPageDto param, String userId);
 
 
-    @SelectProvider(type = FodderProvider.class, method = "searchPano")
-    List<FodderEntity> searchPano(PageDto param, String userId);
-
     @SelectProvider(type = FodderProvider.class, method = "checkStatus")
     List<FodderEntity> checkStatus(String ids, String userId);
 
@@ -34,4 +31,10 @@ public interface FodderMapper extends IBaseMapper<FodderEntity, Long> {
 
     @SelectProvider(type = BaseProvider.class, method = "selectSql")
     List<FodderEntity> batchBySceneCodes(String strSq);
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    List<FodderEntity> mapperFindAll(String strSq);
+
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    void updateDirId(String strSq);
 }

+ 0 - 24
720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/provider/FodderProvider.java

@@ -39,30 +39,6 @@ public class FodderProvider {
     }
 
 
-    /**
-     * 搜索全景图
-     * 只获取计算完成的全景图
-     * @param param
-     * @param userId
-     * @return
-     */
-    public String searchPano(PageDto param, String userId){
-        StringBuffer sql = new StringBuffer("select * from tb_fodder where is_delete = 0 and type = 'pano' and status = 3 ");
-
-        if(!StringUtils.isAllBlank(userId)){
-            sql.append(" and ( user_id = '").append(userId).append("' )");
-        }
-
-        String searchKey = param.getSearchKey();
-        if(!StringUtils.isAllBlank(searchKey)){
-            sql.append(" and ( name like '%").append(searchKey).append("%' )");
-        }
-
-        sql.append(" order by create_time desc");
-
-        log.info("sql: {}", sql.toString());
-        return sql.toString();
-    }
 
 
     public String checkStatus(String ids, String userId){

+ 17 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/DirService.java

@@ -0,0 +1,17 @@
+package com.gis.service;
+
+import com.gis.common.util.Result;
+import com.gis.domain.dto.DirDto;
+import com.gis.domain.dto.DirMoveDto;
+import com.gis.domain.entity.DirEntity;
+
+/**
+ * Created by owen on 2022/12/1 0001 15:22
+ */
+public interface DirService extends IBaseService<DirEntity, Long>{
+    Result saveEntity(DirDto param);
+
+    Result getMyTree();
+
+    Result move(DirMoveDto param);
+}

+ 8 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/FodderService.java

@@ -3,6 +3,7 @@ package com.gis.service;
 
 import com.gis.common.util.Result;
 import com.gis.domain.dto.FodderPageDto;
+import com.gis.domain.dto.FodderUploadDto;
 import com.gis.domain.dto.PageDto;
 import com.gis.domain.entity.FodderEntity;
 import org.springframework.web.multipart.MultipartFile;
@@ -18,7 +19,8 @@ public interface FodderService extends IBaseService<FodderEntity, Long> {
 
 
 
-    Result upload(MultipartFile file, String type, String tempId) ;
+
+    Result upload(FodderUploadDto param);
 
     Result search(FodderPageDto param);
 
@@ -34,4 +36,9 @@ public interface FodderService extends IBaseService<FodderEntity, Long> {
     List<FodderEntity> findByType(String type);
 
     Result checkUserSize();
+
+
+    Result listAndDir(FodderPageDto param);
+
+    void updateDirId(Long parentId, String fodderIds);
 }

+ 2 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/TestService.java

@@ -23,4 +23,6 @@ public interface TestService  {
     Result awsUpload(MultipartFile file);
 
     Result sh(TestShDto param);
+
+    Result createToken(String userId);
 }

+ 91 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/DirServiceImpl.java

@@ -0,0 +1,91 @@
+package com.gis.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.gis.common.constant.ErrorEnum;
+import com.gis.common.exception.BaseRuntimeException;
+import com.gis.common.util.Result;
+import com.gis.domain.dto.DirDto;
+import com.gis.domain.dto.DirMoveDto;
+import com.gis.domain.entity.DirEntity;
+import com.gis.mapper.DirMapper;
+import com.gis.mapper.IBaseMapper;
+import com.gis.service.DirService;
+import com.gis.service.FodderService;
+import com.gis.tree.DirTreeUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import tk.mybatis.mapper.entity.Condition;
+
+import java.util.List;
+
+/**
+ * Created by owen on 2022/12/1 0001 15:23
+ */
+@Slf4j
+@Service
+public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements DirService {
+
+    @Autowired
+    DirMapper entityMapper;
+
+    @Autowired
+    FodderService fodderService;
+
+    @Override
+    public IBaseMapper<DirEntity, Long> getBaseMapper() {
+        return this.entityMapper;
+    }
+
+
+    @Override
+    public Result saveEntity(DirDto param) {
+        Long id = param.getId();
+        DirEntity entity = null;
+        if (id == null){
+            String phone = getUserNameForToken();
+            log.info("该用户:{} 创建了新目录, 名字为:{}", phone, param.getName());
+            entity = new DirEntity();
+            BeanUtils.copyProperties(param, entity);
+            entity.setUserId(phone);
+            this.save(entity);
+        } else {
+            entity = this.findById(id);
+            BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_3001.code(), ErrorEnum.FAILURE_SYS_3001.message());
+            BeanUtils.copyProperties(param, entity);
+            this.update(entity);
+        }
+        return Result.success(entity);
+    }
+
+    @Override
+    public Result getMyTree() {
+        DirTreeUtil tree = new DirTreeUtil(getMyList());
+        return Result.success(tree.buildTree());
+    }
+
+    @Override
+    public Result move(DirMoveDto param) {
+
+        this.updateParentId(param.getParentId(), param.getDirIds());
+        fodderService.updateDirId(param.getParentId(), param.getFodderIds());
+
+        return Result.success();
+    }
+
+    private void updateParentId(Long parentId, String dirIds){
+        if (StrUtil.isNotBlank(dirIds)){
+            log.info("移动目录: {} 到 {}", dirIds, parentId);
+            entityMapper.updateParentId(StrUtil.format("update tb_dir set parent_id={} where is_delete=0 and id in ({}) ", parentId, dirIds));
+        }
+
+    }
+
+    private List<DirEntity> getMyList(){
+        String phone = getUserNameForToken();
+        Condition condition = new Condition(DirEntity.class);
+        condition.and().andEqualTo("userId", phone);
+        return this.findAll(condition);
+    }
+}

+ 82 - 7
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -11,28 +11,28 @@ import com.gis.common.constant.ErrorEnum;
 import com.gis.common.exception.BaseRuntimeException;
 import com.gis.common.util.*;
 import com.gis.domain.dto.*;
+import com.gis.domain.entity.DirEntity;
 import com.gis.domain.entity.FodderEntity;
 import com.gis.domain.entity.WorkEntity;
 import com.gis.mapper.FodderMapper;
 import com.gis.mapper.IBaseMapper;
 import com.gis.oss.util.FileAndOssUtil;
 import com.gis.oss.util.FileUtils;
+import com.gis.service.DirService;
 import com.gis.service.FodderService;
 import com.gis.service.WorkService;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import tk.mybatis.mapper.entity.Condition;
 
 import javax.transaction.Transactional;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 /**
@@ -65,6 +65,9 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     @Autowired
     FileAndOssUtil fileAndOssUtil;
 
+    @Autowired
+    DirService dirService;
+
 
 
     // 用户最大空间3G
@@ -81,7 +84,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
 
 
     @Override
-    public Result upload(MultipartFile file, String type, String tempId) {
+    public Result upload(FodderUploadDto param) {
 
         long start = System.currentTimeMillis();
         String phone = getUserNameForToken();
@@ -92,6 +95,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         if (!FREE_SIZE_USER.contains(phone)){
             checkUserSize(phone);
         }
+        MultipartFile file = param.getFile();
         // 检查非法文件上传
         boolean checkFile = fileUtils.checkFile(file);
         if (!checkFile) {
@@ -122,6 +126,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         String ossPreviewIcon = null;
 
         FodderEntity entity = new FodderEntity();
+        String type = param.getType();
         try {
             if (type.equals("pano")) {
 
@@ -198,7 +203,8 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
             entity.setFileSize(size + "");
             entity.setDpi(getDpi(file, type));
             entity.setPreviewIcon(ossPreviewIcon);
-            entity.setTempId(tempId);
+            entity.setTempId(param.getTemId());
+            entity.setDirId(param.getDirId());
 
             save(entity);
 
@@ -255,7 +261,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
             // 上传oss
             String ossPath = ossBasePath + imgName;
             log.info("ossPath: " + ossPath);
-//            aliyunOssUtil.upload(saveCompressImgPath, ossPath);
             fileAndOssUtil.upload(saveCompressImgPath, ossPath);
             ossUrl = ossDomain + ossPath;
             log.info("图片上传成功: " + ossUrl);
@@ -363,6 +368,76 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         return Result.success(size);
     }
 
+    @Override
+    public Result listAndDir(FodderPageDto param) {
+        
+        // 目录数据
+        this.startPage(param);
+        List<FodderEntity> dirs = findDirAndConvertEntity(param);
+
+        List<FodderEntity> list = myMapperFindAll(param);
+        list.addAll(0, dirs); // 加到队列最前面
+
+
+        return Result.success(new PageInfo<>(list));
+    }
+
+    @Override
+    public void updateDirId(Long parentId, String fodderIds) {
+        if (StrUtil.isNotBlank(fodderIds)){
+            log.info("移动素材: {} 到 {} 目录id", fodderIds, parentId);
+            entityMapper.updateDirId(StrUtil.format("update tb_fodder set dir_id={} where is_delete=0 and id in ({})  ", parentId, fodderIds));
+        }
+    }
+
+
+
+    private List<FodderEntity> myMapperFindAll(FodderPageDto param){
+        StringBuilder builder = new StringBuilder();
+        builder.append("select a.*, b.name as dirName from tb_fodder a left join tb_dir b on b.id=a.dir_id where a.is_delete=0");
+
+        String userName = getUserNameForToken();
+        builder.append(" and a.user_id='").append(userName).append("'");
+        builder.append(" and a.type='").append(param.getType()).append("'");
+        String searchKey = param.getSearchKey();
+        if (StrUtil.isNotBlank(searchKey)){
+            searchKey = RegexUtil.sqlReplaceSpecialStr(searchKey);
+          builder.append(" and a.name like '%").append(searchKey).append("%'");
+        }
+
+
+        return entityMapper.mapperFindAll(builder.toString());
+    }
+
+    // 查询目录并转换实体数据
+    private List<FodderEntity> findDirAndConvertEntity(FodderPageDto param){
+
+        // 查询目录表
+        String userName = getUserNameForToken();
+        String searchKey = param.getSearchKey();
+        Condition condition = new Condition(DirEntity.class);
+        condition.and().andEqualTo("userId", userName);
+        if (StrUtil.isNotBlank(searchKey)){
+            searchKey = RegexUtil.sqlReplaceSpecialStr(searchKey);
+            condition.and().andLike("name", "%"+searchKey+"%");
+        }
+        List<DirEntity> dirs = dirService.findAll(condition, "create_time");
+        
+        // 转换实体数据
+        List<FodderEntity> list = new ArrayList<>();
+        FodderEntity entity = null;
+        for (DirEntity dir : dirs) {
+            entity = new FodderEntity();
+            BeanUtils.copyProperties(dir, entity);
+            entity.setType("dir");
+            entity.setDirId(dir.getParentId());
+
+            list.add(entity);
+        }
+
+        return list;
+    }
+
 
     /**
      * 2022-05-31 by owen

+ 18 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java

@@ -9,7 +9,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.gis.common.constant.ConfigConstant;
 import com.gis.common.constant.ErrorEnum;
 import com.gis.common.exception.BaseRuntimeException;
+import com.gis.common.shiro.JwtUtil;
 import com.gis.common.util.CmdUtils;
+import com.gis.common.util.RedisUtil;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.TestShDto;
 import com.gis.domain.entity.FodderEntity;
@@ -30,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 
 /**
@@ -61,6 +64,9 @@ public class TestServiceImpl implements TestService {
     @Autowired
     FileAndOssUtil fileAndOssUtil;
 
+    @Autowired
+    RedisUtil redisUtil;
+
 
 
 
@@ -202,6 +208,18 @@ public class TestServiceImpl implements TestService {
         return Result.success();
     }
 
+    @Override
+    public Result createToken(String userId) {
+
+        // 创建新token
+        HashMap<String, Object> tokenMap = new HashMap<>();
+        tokenMap.put("userName", userId);
+        String token = JwtUtil.createJWT(1000 * 60 * 60 * 24, tokenMap);
+        String tokenKey = "token#" + token;
+        redisUtil.set(tokenKey, token, 6, TimeUnit.HOURS);
+
+        return Result.success(token);
+    }
 
 
     /**

+ 44 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/tree/DirTree.java

@@ -0,0 +1,44 @@
+package com.gis.tree;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * Created by owen on 2022/12/1 0001 15:54
+ */
+@Data
+public class DirTree {
+
+    private Long id;
+
+    private String name;
+
+    private Long parentId;
+
+//    private String content;
+//
+//    private LocalDateTime createTime;
+//
+//    private LocalDateTime updateTime;
+//
+//    private String nickName;
+//
+//    private String unit;
+//
+//    private Integer display;
+//
+//    @ApiModelProperty(value = "是否显示真实姓名: 1:是, 0:否")
+//    private Integer isRealName;
+
+
+    // 子菜单/或按钮
+    private List<DirTree> children;
+
+    @JSONField(serialize = false)
+    private int level;
+
+}

+ 83 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/tree/DirTreeUtil.java

@@ -0,0 +1,83 @@
+package com.gis.tree;
+
+
+import com.gis.domain.entity.DirEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DirTreeUtil {
+
+    private List<DirTree> resultNodes = new ArrayList<DirTree>();//树形结构排序之后list内容
+
+    private List<DirTree> nodes = new ArrayList<DirTree>();
+    //传入list参数
+
+    public DirTreeUtil(List<DirEntity> nodesList) {//通过构造函数初始化
+        for (DirEntity n : nodesList) {
+            DirTree treeGrid = new DirTree();
+            treeGrid.setId(n.getId());
+            treeGrid.setName(n.getName());
+
+            if (n.getParentId() != null) {
+                treeGrid.setParentId(n.getParentId());
+            }
+            nodes.add(treeGrid);
+        }
+    }
+
+    public DirTreeUtil() {
+    }
+
+    /**
+     * 构建树形结构list
+     *
+     * @return 返回树形结构List列表
+     */
+    public List<DirTree> buildTree() {
+        for (DirTree node : nodes) {
+            Long id = node.getParentId();
+            if (id == null) {//通过循环一级节点 就可以通过递归获取二级以下节点
+                resultNodes.add(node);//添加一级节点
+                node.setLevel(1);
+                build(node, node.getLevel());//递归获取二级、三级、。。。节点
+            }
+        }
+        return resultNodes;
+    }
+
+    /**
+     * 递归循环子节点
+     *
+     * @param node 当前节点
+     */
+    private void build(DirTree node, int level) {
+        List<DirTree> children = getChildren(node);
+        if (!children.isEmpty()) {//如果存在子节点
+            node.setChildren(children);
+//        	level++;
+            for (DirTree child : children) {//将子节点遍历加入返回值中
+        		child.setLevel(level);
+                build(child, child.getLevel());
+            }
+        }
+    }
+
+    /**
+     * @param node
+     * @return 返回
+     */
+    private List<DirTree> getChildren(DirTree node) {
+        List<DirTree> children = new ArrayList<DirTree>();
+        Long id = node.getId();
+        for (DirTree child : nodes) {
+            if (id.equals(child.getParentId())) {//如果id等于父id
+                children.add(child);//将该节点加入循环列表中
+            }
+        }
+        return children;
+    }
+
+
+
+}

+ 51 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/DirController.java

@@ -0,0 +1,51 @@
+package com.gis.web.controller;
+
+import com.gis.common.util.Result;
+import com.gis.domain.dto.DirDto;
+import com.gis.domain.dto.DirMoveDto;
+import com.gis.service.DirService;
+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/12/1 0001 15:29
+ */
+@Api(tags = "目录管理")
+@RestController
+@RequestMapping("/manage/dir")
+public class DirController {
+
+    @Autowired
+    DirService dirService;
+
+    @ApiOperation(value = "获取树")
+    @GetMapping("/getTree")
+    public Result getMyTree() {
+        return dirService.getMyTree();
+    }
+
+    @ApiOperation(value = "新增|修改")
+    @PostMapping("/save")
+    public Result saveEntity(@Valid @RequestBody DirDto param) {
+        return dirService.saveEntity(param);
+    }
+
+
+    @ApiOperation(value = "详情")
+    @GetMapping("/detail/{id}")
+    public Result detail(@PathVariable Long id) {
+        return Result.success(dirService.findById(id));
+    }
+
+
+    @ApiOperation(value = "移动目录|文件")
+    @PostMapping("/move")
+    public Result move(@Valid @RequestBody DirMoveDto param) {
+        return dirService.move(param);
+    }
+
+}

+ 20 - 3
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/FodderController.java

@@ -25,16 +25,28 @@ import java.util.Date;
 @Api(tags = "我的素材")
 @RestController
 @RequestMapping("/manage/fodder")
-//@RequestMapping("a/fodder")
 public class FodderController extends BaseController {
 
     @Autowired
-    private FodderService fodderService;
+    FodderService fodderService;
 
 
     @Autowired
     WorkService workService;
 
+    @ApiOperation(value = "v1.3-上传素材(有目录码)")
+    @PostMapping("/uploadDir")
+    public Result uploadDir(FodderUploadDto param) {
+        return fodderService.upload(param);
+    }
+
+    @ApiOperation(value = "v1.3-目录列表和数据")
+    @PostMapping("listAndDir")
+    public Result listAndDir(@RequestBody FodderPageDto param) {
+        return fodderService.listAndDir(param);
+    }
+
+
     @ApiOperation(value = "上传素材", notes = "type:类型, 全景图:pano, 图片:image, 音频:audio, 视频:video, temId: 前端临时Id")
     @PostMapping("upload/{type}/{tempId}")
     public Result upload(MultipartFile file, @PathVariable String type, @PathVariable String tempId) {
@@ -43,7 +55,12 @@ public class FodderController extends BaseController {
             log.error("文件不能为空");
             return Result.failure(ErrorEnum.FAILURE_CODE_3020.code(),"文件不能为空");
         }
-        return fodderService.upload(file, type, tempId);
+        FodderUploadDto dto = new FodderUploadDto();
+        dto.setFile(file);
+        dto.setTemId(tempId);
+        dto.setType(type);
+        dto.setDirId(1L); // 默认跟目录
+        return fodderService.upload(dto);
     }
 
 

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

@@ -266,7 +266,11 @@ public class TestController extends BaseController {
 
 
 
-
+    @ApiOperation(value = "v1.3-创建token")
+    @GetMapping("/createToken/{userId}")
+    public Result createToken(@PathVariable String userId)  {
+        return testService.createToken(userId);
+    }
 
 
 

+ 6 - 1
720yun_fd_manage/remark-m.md

@@ -112,7 +112,12 @@
 # deploy 注意
  2022-3-22  修改workId 使用雪花id, 需要更新数据库字段, sit已更新
  
-
+# 版本需求
+### v1.3 
+   添加文件的疑问:
+   1. 分页问题
+   2. 目录层级最大5层
+   3. 拖动文件到目录
  
 ## doc
     aws: https://docs.aws.amazon.com/zh_cn/lambda/latest/dg/with-s3-tutorial.html