|
@@ -11,28 +11,28 @@ import com.gis.common.constant.ErrorEnum;
|
|
import com.gis.common.exception.BaseRuntimeException;
|
|
import com.gis.common.exception.BaseRuntimeException;
|
|
import com.gis.common.util.*;
|
|
import com.gis.common.util.*;
|
|
import com.gis.domain.dto.*;
|
|
import com.gis.domain.dto.*;
|
|
|
|
+import com.gis.domain.entity.DirEntity;
|
|
import com.gis.domain.entity.FodderEntity;
|
|
import com.gis.domain.entity.FodderEntity;
|
|
import com.gis.domain.entity.WorkEntity;
|
|
import com.gis.domain.entity.WorkEntity;
|
|
import com.gis.mapper.FodderMapper;
|
|
import com.gis.mapper.FodderMapper;
|
|
import com.gis.mapper.IBaseMapper;
|
|
import com.gis.mapper.IBaseMapper;
|
|
import com.gis.oss.util.FileAndOssUtil;
|
|
import com.gis.oss.util.FileAndOssUtil;
|
|
import com.gis.oss.util.FileUtils;
|
|
import com.gis.oss.util.FileUtils;
|
|
|
|
+import com.gis.service.DirService;
|
|
import com.gis.service.FodderService;
|
|
import com.gis.service.FodderService;
|
|
import com.gis.service.WorkService;
|
|
import com.gis.service.WorkService;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
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
|
|
@Autowired
|
|
FileAndOssUtil fileAndOssUtil;
|
|
FileAndOssUtil fileAndOssUtil;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ DirService dirService;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
// 用户最大空间3G
|
|
// 用户最大空间3G
|
|
@@ -81,7 +84,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result upload(MultipartFile file, String type, String tempId) {
|
|
|
|
|
|
+ public Result upload(FodderUploadDto param) {
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
long start = System.currentTimeMillis();
|
|
String phone = getUserNameForToken();
|
|
String phone = getUserNameForToken();
|
|
@@ -92,6 +95,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
if (!FREE_SIZE_USER.contains(phone)){
|
|
if (!FREE_SIZE_USER.contains(phone)){
|
|
checkUserSize(phone);
|
|
checkUserSize(phone);
|
|
}
|
|
}
|
|
|
|
+ MultipartFile file = param.getFile();
|
|
// 检查非法文件上传
|
|
// 检查非法文件上传
|
|
boolean checkFile = fileUtils.checkFile(file);
|
|
boolean checkFile = fileUtils.checkFile(file);
|
|
if (!checkFile) {
|
|
if (!checkFile) {
|
|
@@ -122,6 +126,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
String ossPreviewIcon = null;
|
|
String ossPreviewIcon = null;
|
|
|
|
|
|
FodderEntity entity = new FodderEntity();
|
|
FodderEntity entity = new FodderEntity();
|
|
|
|
+ String type = param.getType();
|
|
try {
|
|
try {
|
|
if (type.equals("pano")) {
|
|
if (type.equals("pano")) {
|
|
|
|
|
|
@@ -198,7 +203,8 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
entity.setFileSize(size + "");
|
|
entity.setFileSize(size + "");
|
|
entity.setDpi(getDpi(file, type));
|
|
entity.setDpi(getDpi(file, type));
|
|
entity.setPreviewIcon(ossPreviewIcon);
|
|
entity.setPreviewIcon(ossPreviewIcon);
|
|
- entity.setTempId(tempId);
|
|
|
|
|
|
+ entity.setTempId(param.getTemId());
|
|
|
|
+ entity.setDirId(param.getDirId());
|
|
|
|
|
|
save(entity);
|
|
save(entity);
|
|
|
|
|
|
@@ -255,7 +261,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
// 上传oss
|
|
// 上传oss
|
|
String ossPath = ossBasePath + imgName;
|
|
String ossPath = ossBasePath + imgName;
|
|
log.info("ossPath: " + ossPath);
|
|
log.info("ossPath: " + ossPath);
|
|
-// aliyunOssUtil.upload(saveCompressImgPath, ossPath);
|
|
|
|
fileAndOssUtil.upload(saveCompressImgPath, ossPath);
|
|
fileAndOssUtil.upload(saveCompressImgPath, ossPath);
|
|
ossUrl = ossDomain + ossPath;
|
|
ossUrl = ossDomain + ossPath;
|
|
log.info("图片上传成功: " + ossUrl);
|
|
log.info("图片上传成功: " + ossUrl);
|
|
@@ -363,6 +368,76 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
return Result.success(size);
|
|
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
|
|
* 2022-05-31 by owen
|