|
@@ -3,16 +3,12 @@ package com.gis.cms.service.impl;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
-import com.gis.cms.entity.dto.DocDto;
|
|
|
|
|
|
+import com.gis.cms.entity.dto.EditDto;
|
|
import com.gis.cms.entity.po.DocEntity;
|
|
import com.gis.cms.entity.po.DocEntity;
|
|
-import com.gis.cms.entity.po.FileEntity;
|
|
|
|
import com.gis.cms.entity.po.ProjectEntity;
|
|
import com.gis.cms.entity.po.ProjectEntity;
|
|
import com.gis.cms.mapper.DocMapper;
|
|
import com.gis.cms.mapper.DocMapper;
|
|
-import com.gis.cms.mapper.FileMapper;
|
|
|
|
import com.gis.cms.service.DocService;
|
|
import com.gis.cms.service.DocService;
|
|
-import com.gis.cms.service.FileService;
|
|
|
|
import com.gis.cms.service.ProjectService;
|
|
import com.gis.cms.service.ProjectService;
|
|
-import com.gis.common.base.exception.BaseRuntimeException;
|
|
|
|
import com.gis.common.base.mapper.IBaseMapper;
|
|
import com.gis.common.base.mapper.IBaseMapper;
|
|
import com.gis.common.base.service.impl.IBaseServiceImpl;
|
|
import com.gis.common.base.service.impl.IBaseServiceImpl;
|
|
import com.gis.common.constant.TypeCode;
|
|
import com.gis.common.constant.TypeCode;
|
|
@@ -24,12 +20,8 @@ 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 java.io.IOException;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,10 +55,10 @@ public class DocServiceImpl extends IBaseServiceImpl<DocEntity, Long> implements
|
|
}
|
|
}
|
|
|
|
|
|
// 判断类型合法性
|
|
// 判断类型合法性
|
|
- String [] typeCheck = {"video","model","doc","audio","img"};
|
|
|
|
- if (!Arrays.asList(typeCheck).contains(type)) {
|
|
|
|
- return Result.failure("非法类型");
|
|
|
|
- }
|
|
|
|
|
|
+// String [] typeCheck = {"video","model","doc","audio","img"};
|
|
|
|
+// if (!Arrays.asList(typeCheck).contains(type)) {
|
|
|
|
+// return Result.failure("非法类型");
|
|
|
|
+// }
|
|
|
|
|
|
// 文件目录
|
|
// 文件目录
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
@@ -119,25 +111,27 @@ public class DocServiceImpl extends IBaseServiceImpl<DocEntity, Long> implements
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result edit(DocDto param) {
|
|
|
|
|
|
+ public Result edit(EditDto param) {
|
|
// 删除文档
|
|
// 删除文档
|
|
String removeIds = param.getRemoveIds();
|
|
String removeIds = param.getRemoveIds();
|
|
if (StringUtils.isNotBlank(removeIds)){
|
|
if (StringUtils.isNotBlank(removeIds)){
|
|
entityMapper.removes(removeIds);
|
|
entityMapper.removes(removeIds);
|
|
}
|
|
}
|
|
// 绑定项目id
|
|
// 绑定项目id
|
|
- String docIds = param.getDocIds();
|
|
|
|
- if (StringUtils.isNotBlank(docIds)){
|
|
|
|
- ProjectEntity entity = projectService.findById(param.getProjectId());
|
|
|
|
- entity.setDocIds(docIds);
|
|
|
|
- projectService.update(entity);
|
|
|
|
- }
|
|
|
|
|
|
+ this.bindingProjectId(param.getEditIds(), param.getProjectId());
|
|
|
|
+
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void bindingProjectId(String ids, Long projectId){
|
|
public void bindingProjectId(String ids, Long projectId){
|
|
- String sql = String.format("update tb_doc set project_id={}, update_time=NOW() where is_delete=0 and id in ({})", projectId, ids);
|
|
|
|
|
|
+ if (StringUtils.isBlank(ids)){
|
|
|
|
+ log.warn("不需要更新");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 防止sql注入
|
|
|
|
+ RegexUtil.regSql(ids);
|
|
|
|
+ String sql = StrUtil.format("update tb_doc set project_id={}, update_time=NOW() where is_delete=0 and id in ({})", projectId, ids);
|
|
entityMapper.strSql(sql);
|
|
entityMapper.strSql(sql);
|
|
}
|
|
}
|
|
|
|
|