Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop
This commit is contained in:
commit
1f0bff89ca
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.electromagnetic.industry.software.backup.pojo.BackupPro;
|
||||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.backup.service.FileService;
|
||||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -29,10 +31,10 @@ public class FileController {
|
|||
private BackupPro backupPro;
|
||||
|
||||
@RequestMapping("/upload")
|
||||
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file) {
|
||||
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file, @RequestParam("id") String id) {
|
||||
BackupFileResLog backupFileResLog = BackupFileResLog.builder().backupStartTime(new Date()).fileName(file.getOriginalFilename()).backupSuccess(true).build();
|
||||
try {
|
||||
fileService.upload(file);
|
||||
fileService.upload(file, id);
|
||||
} catch (Exception e) {
|
||||
String details = ExceptionUtil.stacktraceToString(e);
|
||||
backupFileResLog.setBackupSuccess(false);
|
||||
|
|
@ -50,4 +52,43 @@ public class FileController {
|
|||
FileUtil.appendUtf8String(info.toString(), backupPro.getLogPath());
|
||||
return ElectromagneticResultUtil.success(JSONUtil.toJsonStr(backupFileResLog, jsonConfig));
|
||||
}
|
||||
|
||||
@RequestMapping("/remove")
|
||||
public ElectromagneticResult<?> remove(@RequestParam("id") String id) {
|
||||
try {
|
||||
fileService.remove(id);
|
||||
} catch (Exception e) {
|
||||
log.error("删除文件失败, id-->{},原因-->{}", id, e.getMessage(), e);
|
||||
ElectromagneticResultUtil.fail("-1", e.getMessage());
|
||||
}
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@RequestMapping("/download")
|
||||
public ResponseEntity<InputStreamResource> download(@RequestParam("id") String id) throws Exception {
|
||||
return fileService.download(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/backupSql")
|
||||
public ElectromagneticResult<?> backupSql(@RequestParam("file") MultipartFile file) {
|
||||
BackupFileResLog backupFileResLog = BackupFileResLog.builder().backupStartTime(new Date()).fileName(file.getOriginalFilename()).backupSuccess(true).build();
|
||||
try {
|
||||
fileService.backupSql(file);
|
||||
} catch (Exception e) {
|
||||
String details = ExceptionUtil.stacktraceToString(e);
|
||||
backupFileResLog.setBackupSuccess(false);
|
||||
backupFileResLog.setFailInfoDetail(details);
|
||||
log.error("备份sql文件失败,原因--->{}", e.getMessage(), e);
|
||||
}
|
||||
JSONConfig jsonConfig = JSONConfig.create();
|
||||
jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
backupFileResLog.setBackupEndTime(new Date());
|
||||
StringBuffer info = new StringBuffer()
|
||||
.append("\n")
|
||||
.append("#")
|
||||
.append("\n")
|
||||
.append(JSONUtil.toJsonStr(backupFileResLog, jsonConfig));
|
||||
FileUtil.appendUtf8String(info.toString(), backupPro.getLogPath());
|
||||
return ElectromagneticResultUtil.success(JSONUtil.toJsonStr(backupFileResLog, jsonConfig));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,18 @@
|
|||
package com.electromagnetic.industry.software.backup.service;
|
||||
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface FileService {
|
||||
|
||||
void upload(MultipartFile file) throws IOException;
|
||||
void upload(MultipartFile file, String id) throws IOException;
|
||||
|
||||
void remove(String id);
|
||||
|
||||
ResponseEntity<InputStreamResource> download(String id) throws Exception;
|
||||
|
||||
void backupSql(MultipartFile file) throws Exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
package com.electromagnetic.industry.software.backup.serviceimp;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.electromagnetic.industry.software.backup.pojo.BackupPro;
|
||||
import com.electromagnetic.industry.software.backup.service.FileService;
|
||||
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
|
@ -10,6 +17,8 @@ import javax.annotation.Resource;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.FILE_SEC_PASSWD;
|
||||
|
||||
@Service
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
|
|
@ -17,12 +26,46 @@ public class FileServiceImpl implements FileService {
|
|||
private BackupPro backupPro;
|
||||
|
||||
@Override
|
||||
public void upload(MultipartFile file) throws IOException {
|
||||
String saveFolder = backupPro.getSaveFolder();
|
||||
String fileName = file.getOriginalFilename();
|
||||
String destPath = saveFolder + File.separator + File.separator + fileName;
|
||||
public void upload(MultipartFile file, String id) throws IOException {
|
||||
String destPath = getFileSysPathById(id);
|
||||
if (!FileUtil.exist(destPath)) {
|
||||
FileUtil.writeFromStream(file.getInputStream(), destPath);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String id) {
|
||||
String destPath = getFileSysPathById(id);
|
||||
FileUtil.del(destPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<InputStreamResource> download(String id) throws Exception {
|
||||
String destPath = getFileSysPathById(id);
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(destPath);
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.contentLength(fileSystemResource.contentLength())
|
||||
.contentType(MediaType.parseMediaType("application/octet-stream"))
|
||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void backupSql(MultipartFile file) throws IOException {
|
||||
String destPath = backupPro.getSaveFolder() + File.separator + "sqls" + File.separator + file.getOriginalFilename();
|
||||
if (!FileUtil.exist(destPath)) {
|
||||
FileUtil.writeFromStream(file.getInputStream(), destPath);
|
||||
}
|
||||
int index = destPath.lastIndexOf(".");
|
||||
String zipPath = destPath.substring(0, index) + ".zip";
|
||||
ZipUtil.zip(destPath, zipPath);
|
||||
EleCommonUtil.encryptFile(zipPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
||||
FileUtil.del(destPath);
|
||||
}
|
||||
|
||||
private String getFileSysPathById(String id) {
|
||||
String saveFolder = backupPro.getSaveFolder();
|
||||
return saveFolder + File.separator + "prj_files" + File.separator + id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
ele:
|
||||
backup:
|
||||
saveFolder: "/szsd/ele/data/backup/"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.electromagnetic.industry.software.manage;
|
|||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import org.aspectj.lang.annotation.Aspect;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
|
|
@ -27,7 +26,7 @@ public class FilePermissionCheckAspect {
|
|||
EdFileInfoService edFileInfoService;
|
||||
|
||||
@Around("@annotation(requiredPermission)")
|
||||
public Object requirePermission(ProceedingJoinPoint joinPoint, RequiredPermission requiredPermission) throws Throwable{
|
||||
public Object requirePermission(ProceedingJoinPoint joinPoint, RequiredPermission requiredPermission) throws Throwable {
|
||||
Object[] args = joinPoint.getArgs();
|
||||
|
||||
if (args.length == 0) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class ServiceAspect {
|
|||
String methodInfo = jp.getTarget().getClass().getSimpleName() + "."
|
||||
+ jp.getSignature().getName();
|
||||
Object[] args = jp.getArgs();
|
||||
String[] argNames = ((MethodSignature)jp.getSignature()).getParameterNames();
|
||||
String[] argNames = ((MethodSignature) jp.getSignature()).getParameterNames();
|
||||
String paramInfo = "";
|
||||
if (args != null && args.length > 0) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
|
@ -80,7 +80,7 @@ public class ServiceAspect {
|
|||
UserThreadLocal.setRes(ElectromagneticResultUtil.success(""));
|
||||
return rvt;
|
||||
}
|
||||
UserThreadLocal.setRes((ElectromagneticResult)rvt);
|
||||
UserThreadLocal.setRes((ElectromagneticResult) rvt);
|
||||
|
||||
String returnInfo = JSONUtil.toJsonStr(rvt);
|
||||
log.info("请求接口结束:{},返回参数:{},接口耗时:{}", methodInfo, returnInfo, (System.currentTimeMillis() - startTime) + "毫秒");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class EdMetaObjectHandler implements MetaObjectHandler {
|
|||
this.strictInsertFill(metaObject, "updatedAt", Date.class, new Date());
|
||||
}
|
||||
if (metaObject.hasGetter("createdBy")) {
|
||||
this.setFieldValByName("createdBy", Optional.of(UserThreadLocal.getUserId()).orElse(""), metaObject);
|
||||
this.setFieldValByName("createdBy", Optional.ofNullable(UserThreadLocal.getUserId()).orElse(""), metaObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ public class EdMetaObjectHandler implements MetaObjectHandler {
|
|||
this.setFieldValByName("updatedTime", new Date(), metaObject);
|
||||
}
|
||||
if (metaObject.hasGetter("updatedBy")) {
|
||||
this.setFieldValByName("updatedBy", Optional.of(UserThreadLocal.getUserId()).orElse(""), metaObject);
|
||||
this.setFieldValByName("updatedBy", Optional.ofNullable(UserThreadLocal.getUserId()).orElse(""), metaObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,153 @@
|
|||
package com.electromagnetic.industry.software.manage.config;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
@Getter
|
||||
public class ElePropertyConfig {
|
||||
|
||||
@Resource
|
||||
private Environment environment;
|
||||
@Value("${data.ele.tmp.path}")
|
||||
private String eleTmpPath;
|
||||
|
||||
private String downloadDataDir = "";
|
||||
private String uploadDataDir = "";
|
||||
private String tmpDir = "";
|
||||
private String eleDataPath;
|
||||
private String userDataPath;
|
||||
@Value("${data.sys.prj.path}")
|
||||
private String sysPrjPath;
|
||||
|
||||
private String prjDir;
|
||||
@Value("${data.sys.upload.path}")
|
||||
private String sysUploadPath;
|
||||
|
||||
@Value("${data.tmp.days:7}")
|
||||
@Value("${data.sys.download.path}")
|
||||
private String sysDownloadPath;
|
||||
|
||||
@Value("${data.user.prj.path}")
|
||||
private String userPrjPath;
|
||||
|
||||
@Value("${data.user.upload.path}")
|
||||
private String userUploadPath;
|
||||
|
||||
@Value("${data.user.download.path}")
|
||||
private String userDownloadPath;
|
||||
|
||||
@Value("${data.repo.prj.path}")
|
||||
private String repoPrjPath;
|
||||
|
||||
@Value("${data.repo.upload.path}")
|
||||
private String repoUploadPath;
|
||||
|
||||
@Value("${data.repo.download.path}")
|
||||
private String repoDownloadPath;
|
||||
|
||||
@Getter
|
||||
@Value("${backup.mysql.script.path}")
|
||||
private String backupMysqlScriptPath;
|
||||
|
||||
@Getter
|
||||
@Value("${tmp.file.store.days}")
|
||||
private int tmpFileStoreDays;
|
||||
|
||||
@Getter
|
||||
@Value("${backup.remote.host}")
|
||||
private String remoteHost = "";
|
||||
|
||||
@Getter
|
||||
@Value("${backup.remote.port}")
|
||||
private int remotePort;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
uploadDataDir = EleCommonUtil.isWinOs() ? environment.getProperty("data.upload.windows.tmp.path") : environment.getProperty("data.upload.linux.tmp.path");
|
||||
downloadDataDir = EleCommonUtil.isWinOs() ? environment.getProperty("data.download.windows.tmp.path") : environment.getProperty("data.download.linux.tmp.path");
|
||||
tmpDir = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.tmp.path") : environment.getProperty("data.linux.tmp.path");
|
||||
eleDataPath = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
|
||||
userDataPath = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.user.path") : environment.getProperty("data.linux.user.path");
|
||||
String tmp = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
|
||||
prjDir = FileUtil.getParent(tmp, 1);
|
||||
@Value("${winPrefix}")
|
||||
private String winPrefix = "";
|
||||
|
||||
@Getter
|
||||
@Value("${backup.mysql.path}")
|
||||
private String sqlDirs;
|
||||
|
||||
public String getEleTmpPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + eleTmpPath;
|
||||
}
|
||||
return eleTmpPath;
|
||||
}
|
||||
|
||||
public String getSysPrjPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + sysPrjPath;
|
||||
}
|
||||
return sysPrjPath;
|
||||
}
|
||||
|
||||
public String getSysUploadPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + sysUploadPath;
|
||||
}
|
||||
return sysUploadPath;
|
||||
}
|
||||
|
||||
public String getSysDownloadPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + sysDownloadPath;
|
||||
}
|
||||
return sysDownloadPath;
|
||||
}
|
||||
|
||||
public String getUserPrjPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + userPrjPath;
|
||||
}
|
||||
return userPrjPath;
|
||||
}
|
||||
|
||||
public String getUserUploadPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + userUploadPath;
|
||||
}
|
||||
return userUploadPath;
|
||||
}
|
||||
|
||||
public String getUserDownloadPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + userDownloadPath;
|
||||
}
|
||||
return userDownloadPath;
|
||||
}
|
||||
|
||||
public String getRepoPrjPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + repoPrjPath;
|
||||
}
|
||||
return repoPrjPath;
|
||||
}
|
||||
|
||||
public String getRepoUploadPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + repoUploadPath;
|
||||
}
|
||||
return repoUploadPath;
|
||||
}
|
||||
|
||||
public String getRepoDownloadPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + repoDownloadPath;
|
||||
}
|
||||
return repoDownloadPath;
|
||||
}
|
||||
|
||||
public String getUploadDataDir(int dataOwnCode) {
|
||||
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
return getSysUploadPath();
|
||||
} else if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
return getUserUploadPath();
|
||||
}
|
||||
return getRepoUploadPath();
|
||||
}
|
||||
|
||||
public String getDownloadDataDir(int dataOwnCode) {
|
||||
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
return getSysDownloadPath();
|
||||
} else if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
return getUserDownloadPath();
|
||||
}
|
||||
return getRepoDownloadPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,30 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|||
@Resource
|
||||
private UserAccessLogMapper userAccessLogMapper;
|
||||
|
||||
private static String getRealIp(HttpServletRequest request) {
|
||||
String ipAddress = request.getHeader("X-Forwarded-For");
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
// 回退到X-Real-IP或直接RemoteAddr
|
||||
ipAddress = request.getHeader("X-Real-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
}
|
||||
// 处理多级代理的情况(取第一个IP)
|
||||
if (ipAddress.contains(",")) {
|
||||
ipAddress = ipAddress.split(",")[0].trim();
|
||||
}
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
private static String parseIpFromUrl(String url) {
|
||||
|
||||
int start = url.indexOf("//");
|
||||
url = url.substring(start + 2);
|
||||
int end = url.indexOf("/");
|
||||
return url.substring(0, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
request.getSession().setAttribute("accessStartTime", System.currentTimeMillis());
|
||||
|
|
@ -104,7 +128,7 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|||
return;
|
||||
}
|
||||
|
||||
long accessStartTime = (long)request.getSession().getAttribute("accessStartTime");
|
||||
long accessStartTime = (long) request.getSession().getAttribute("accessStartTime");
|
||||
long accessEndTime = System.currentTimeMillis();
|
||||
UserOperation userOperation = ((HandlerMethod) handler).getMethod().getAnnotation(UserOperation.class);
|
||||
String reqArgs = UserThreadLocal.getReqArgs();
|
||||
|
|
@ -150,28 +174,4 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|||
return token != null && now.before(token.getExpireAt());
|
||||
}
|
||||
|
||||
private static String getRealIp(HttpServletRequest request) {
|
||||
String ipAddress = request.getHeader("X-Forwarded-For");
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
// 回退到X-Real-IP或直接RemoteAddr
|
||||
ipAddress = request.getHeader("X-Real-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
}
|
||||
// 处理多级代理的情况(取第一个IP)
|
||||
if (ipAddress.contains(",")) {
|
||||
ipAddress = ipAddress.split(",")[0].trim();
|
||||
}
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
private static String parseIpFromUrl(String url) {
|
||||
|
||||
int start = url.indexOf("//");
|
||||
url = url.substring(start + 2);
|
||||
int end = url.indexOf("/");
|
||||
return url.substring(0, end);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,33 +30,33 @@ public class EdFileInfoController {
|
|||
@Resource
|
||||
private EdFileInfoService edFileInfoService;
|
||||
|
||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequestMapping("tree")
|
||||
public ElectromagneticResult<?> tree() {
|
||||
return edFileInfoService.tree(PrjQuerySource.SYS_DB.value);
|
||||
}
|
||||
|
||||
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequestMapping("createFolder")
|
||||
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
|
||||
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "作废", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "作废", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.DELETE)
|
||||
@RequestMapping("delete")
|
||||
public ElectromagneticResult<?> delete(@RequestParam String id) {
|
||||
return edFileInfoService.delete(id, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查询文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping("info")
|
||||
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
||||
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "上传文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "上传文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.UPLOAD)
|
||||
@RequestMapping("upload")
|
||||
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||
|
|
@ -65,21 +65,21 @@ public class EdFileInfoController {
|
|||
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "下载文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "下载文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||
@RequestMapping("download")
|
||||
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
|
||||
return edFileInfoService.download(id, response, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "更新文件信息", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "更新文件信息", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.EDIT)
|
||||
@RequestMapping("updateFileInfo")
|
||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
|
||||
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "移动文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "移动文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.MOVE)
|
||||
@RequestMapping("moveFile")
|
||||
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
|
||||
|
|
@ -88,7 +88,7 @@ public class EdFileInfoController {
|
|||
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "复制文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "复制文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.MOVE)
|
||||
@RequestMapping("copyFile")
|
||||
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
|
||||
|
|
@ -97,27 +97,27 @@ public class EdFileInfoController {
|
|||
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查看文件历史版本信息", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查看文件历史版本信息", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping("versionView")
|
||||
public ElectromagneticResult<?> versionView(@RequestParam String fileId) {
|
||||
return edFileInfoService.versionView(fileId);
|
||||
}
|
||||
|
||||
@UserOperation(value = "回退版本", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "回退版本", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.EDIT)
|
||||
@RequestMapping("versionBack")
|
||||
public ElectromagneticResult<?> versionBack(@RequestParam String fileId, @RequestParam int targetVersion) {
|
||||
return edFileInfoService.versionBack(fileId, targetVersion);
|
||||
}
|
||||
|
||||
@UserOperation(value = "导出数据库", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "导出数据库", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequestMapping("batchExport")
|
||||
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String fileIds, HttpServletResponse response) throws IOException {
|
||||
return edFileInfoService.batchExport(fileIds, response, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
||||
@RequestParam String fileName,
|
||||
|
|
@ -125,39 +125,39 @@ public class EdFileInfoController {
|
|||
return edFileInfoService.mergeChunks(identifier, fileName, totalChunks, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.batchImport(fileChunkDTO);
|
||||
return edFileInfoService.batchImport(fileChunkDTO, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库")
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.checkChunkExist(fileChunkDTO);
|
||||
return edFileInfoService.checkChunkExist(fileChunkDTO, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询发布管理", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查询发布管理", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
|
||||
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询文件详细信息", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查询文件详细信息", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping(value = "/fileDetail", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> detail(@RequestParam String id) {
|
||||
return edFileInfoService.detail(id);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询子文件集", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查询子文件集", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
|
||||
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "预览文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "预览文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
||||
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
||||
|
|
@ -166,11 +166,12 @@ public class EdFileInfoController {
|
|||
|
||||
/**
|
||||
* 添加进收藏夹
|
||||
*
|
||||
* @param id 文件id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/collection")
|
||||
@UserOperation(value="收藏了文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "收藏了文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> addFavorite(@RequestParam String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.addFavorite(userId, id));
|
||||
|
|
@ -178,11 +179,12 @@ public class EdFileInfoController {
|
|||
|
||||
/**
|
||||
* 从收藏夹移除
|
||||
*
|
||||
* @param id 文件id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/removeCollection")
|
||||
@UserOperation(value="从收藏夹移除了文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "从收藏夹移除了文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> removeFavorite(@RequestParam String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.removeFavorite(userId, id));
|
||||
|
|
@ -190,10 +192,11 @@ public class EdFileInfoController {
|
|||
|
||||
/**
|
||||
* 展示当前用户收藏夹文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listCollection")
|
||||
@UserOperation(value="查看了收藏夹", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查看了收藏夹", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> listFavorite(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.findFavorite(userId, fileInfoQueryDTO));
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class EdFileRelationController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@UserOperation(value="创建了文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "创建了文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> createRelation(@RequestBody EdFileRelation relation) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.createRelation(relation));
|
||||
}
|
||||
|
|
@ -42,11 +42,11 @@ public class EdFileRelationController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@UserOperation(value="更新了文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "更新了文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> updateRelation(@RequestBody UpdateRelationDTO updateRelation) {
|
||||
LambdaUpdateWrapper<EdFileRelation> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.eq(EdFileRelation::getId, updateRelation.getRelationId()).set(EdFileRelation::getRelationship, updateRelation.getRelationship());
|
||||
boolean isUpdated = edFileRelationService.update(wrapper);
|
||||
boolean isUpdated = edFileRelationService.update(new EdFileRelation(), wrapper);
|
||||
if (isUpdated) {
|
||||
UserThreadLocal.setSuccessInfo("", updateRelation.getRelationId(), "更新了文件关系");
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ public class EdFileRelationController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/cancel/{relationId}", method = RequestMethod.GET)
|
||||
@UserOperation(value="取消了文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "取消了文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> cancelRelation(@PathVariable("relationId") String relationId) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.cancelRelation(relationId));
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public class EdFileRelationController {
|
|||
* 展示文件关系
|
||||
*/
|
||||
@RequestMapping(value = "listRelations/{id}", method = RequestMethod.GET)
|
||||
@UserOperation(value="查看了文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查看了文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> listRelations(@PathVariable("id") String id) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.listRelations(id));
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class EdFileRelationController {
|
|||
* 检验文件名是否唯一
|
||||
*/
|
||||
@RequestMapping(value = "/checkFileNameExist", method = RequestMethod.POST)
|
||||
@UserOperation(value="校验文件名唯一性", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "校验文件名唯一性", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> checkFileNameExist(@RequestBody CheckNameUniqueRequest checkNameUniqueRequest) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.checkNameExist(checkNameUniqueRequest));
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ public class EdFileRelationController {
|
|||
* 本地上传并建立关系
|
||||
*/
|
||||
@RequestMapping(value = "/upload", method = RequestMethod.POST)
|
||||
@UserOperation(value="上传了文件并创建了文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "上传了文件并创建了文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> uploadRelation(@RequestParam("parentId") String parentId,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("description") String description,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.electromagnetic.industry.software.manage.pojo.req.TagCreateDTO;
|
|||
import com.electromagnetic.industry.software.manage.service.EdTagLibraryService;
|
||||
import com.electromagnetic.industry.software.manage.service.FileTagRelationService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ public class EdTagLibraryController {
|
|||
|
||||
// 新建标签组
|
||||
@GetMapping("/createGroup")
|
||||
@UserOperation(value="创建了标签组", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "创建了标签组", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> createTagGroup(@RequestParam String tagName) {
|
||||
String createdBy = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.createTagGroup(tagName, createdBy));
|
||||
|
|
@ -32,7 +33,7 @@ public class EdTagLibraryController {
|
|||
|
||||
// 在标签组下新建标签
|
||||
@GetMapping("/createTag")
|
||||
@UserOperation(value="创建了标签", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "创建了标签", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> createTag(@RequestParam String parentId, @RequestParam String tagName) {
|
||||
String createdBy = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.createTag(parentId, tagName, createdBy));
|
||||
|
|
@ -40,58 +41,58 @@ public class EdTagLibraryController {
|
|||
|
||||
// 拖拽修改排序/分组
|
||||
@GetMapping("/updateOrder")
|
||||
@UserOperation(value="修改了标签顺序", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "修改了标签顺序", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> updateTagOrder(@RequestParam String tagId, @RequestParam String newTagId, @RequestParam String newParentId, @RequestParam Integer newOrderBy) {
|
||||
String updatedBy = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.updateTagOrder(tagId, newTagId, newParentId, newOrderBy,updatedBy));
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.updateTagOrder(tagId, newTagId, newParentId, newOrderBy, updatedBy));
|
||||
}
|
||||
|
||||
// 发布标签
|
||||
@PostMapping("/batchPublish")
|
||||
@UserOperation(value="发布了标签组", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "发布了标签组", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> publishTag(@RequestBody List<String> tagIds) {
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.batchPublishTagGroups(tagIds));
|
||||
}
|
||||
|
||||
// 废除标签
|
||||
@GetMapping("/delete")
|
||||
@UserOperation(value="废除了标签组/标签", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "废除了标签组/标签", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> deleteTag(@RequestParam String tagId) {
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.deleteTagOrGroup(tagId));
|
||||
}
|
||||
|
||||
//获取标签数据
|
||||
@GetMapping("/list")
|
||||
@UserOperation(value="查看了标签数据", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "查看了标签数据", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> listTags() {
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.listTagsWithGroups());
|
||||
}
|
||||
|
||||
// 修改标签组/标签
|
||||
@GetMapping ("/updateTag")
|
||||
@UserOperation(value="修改了标签组/标签", modelName = UserOperationModuleEnum.TAG)
|
||||
@GetMapping("/updateTag")
|
||||
@UserOperation(value = "修改了标签组/标签", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> updateTag(@RequestParam String tagId, @RequestParam String tagName) {
|
||||
String updatedBy = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.updateTagInfo(tagId, tagName, updatedBy));
|
||||
}
|
||||
|
||||
// 查看标签树
|
||||
@GetMapping ("/tree")
|
||||
@UserOperation(value="查看了标签树", modelName = UserOperationModuleEnum.TAG)
|
||||
@GetMapping("/tree")
|
||||
@UserOperation(value = "查看了标签树", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> listTagTree() {
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.listTagTree());
|
||||
}
|
||||
|
||||
// 查看所有标签
|
||||
@GetMapping ("/listAllTags")
|
||||
@UserOperation(value="查看了所有标签", modelName = UserOperationModuleEnum.TAG)
|
||||
@GetMapping("/listAllTags")
|
||||
@UserOperation(value = "查看了所有标签", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> listAllTags() {
|
||||
return ElectromagneticResultUtil.success(edTagLibraryService.listAllTags());
|
||||
}
|
||||
|
||||
// 批量添加标签到文件
|
||||
@PostMapping("/addTagsToFile")
|
||||
@UserOperation(value="批量添加了标签到文件", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "批量添加了标签到文件", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> addTagsToFile(@RequestBody TagCreateDTO dto) {
|
||||
String createdBy = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(fileTagRelationService.addTagsToFile(dto.getFileId(), dto.getTagIds(), createdBy));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ package com.electromagnetic.industry.software.manage.controller;
|
|||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -18,8 +20,15 @@ public class FileBackupLogController {
|
|||
private FileBackLogService fileBackLogService;
|
||||
|
||||
@RequestMapping(value = "list")
|
||||
@UserOperation(value="查询备份日志", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
@UserOperation(value = "查询备份日志", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
public ElectromagneticResult<?> list(@RequestParam int pageNum, @RequestParam int pageSize) {
|
||||
return fileBackLogService.query(pageNum, pageSize);
|
||||
}
|
||||
|
||||
@GetMapping(value = "restore")
|
||||
@UserOperation(value = "系统恢复", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
public ElectromagneticResult<?> restore() {
|
||||
fileBackLogService.restore();
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnu
|
|||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.FileFormatService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
|
@ -17,19 +20,19 @@ public class FileFormatController {
|
|||
private FileFormatService fileFormatService;
|
||||
|
||||
@GetMapping("/add")
|
||||
@UserOperation(value = "新增文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "新增文件格式", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> addFileFormat(@RequestParam String suffixName) {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.addFileFormat(suffixName));
|
||||
}
|
||||
|
||||
@GetMapping("/delete")
|
||||
@UserOperation(value = "删除文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "删除文件格式", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> deleteFileFormat(@RequestParam String id) {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.deleteFileFormat(id));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@UserOperation(value = "查询文件格式列表", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查询文件格式列表", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> list() {
|
||||
return ElectromagneticResultUtil.success(fileFormatService.getList());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.RecycleFileQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileRecycleService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
|
@ -20,20 +23,22 @@ public class FileRecycleController {
|
|||
private FileRecycleService fileRecycleService;
|
||||
|
||||
@RequestMapping("list")
|
||||
@UserOperation(value = "查看回收站", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查看回收站", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> list(@RequestBody RecycleFileQueryDTO pars) {
|
||||
return fileRecycleService.list(pars);
|
||||
}
|
||||
|
||||
@RequestMapping("remove")
|
||||
@UserOperation(value = "彻底清除文件", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "彻底清除文件", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> remove(@RequestParam String fileId) {
|
||||
Assert.isTrue(UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue()), "当前用户没有删除文件权限");
|
||||
return fileRecycleService.remove(fileId);
|
||||
}
|
||||
|
||||
@RequestMapping("recover")
|
||||
@UserOperation(value = "文件恢复", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "文件恢复", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> recover(@RequestParam String fileId) {
|
||||
Assert.isTrue(UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue()), "当前用户没有文件恢复权限");
|
||||
return fileRecycleService.recover(fileId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -22,7 +21,7 @@ public class PermissionController {
|
|||
private PermissionService permissionService;
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
@UserOperation(value="查询了在当前目录的功能权限", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "查询了在当前目录的功能权限", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
public ElectromagneticResult<?> getUserPermission(@PathVariable("id") String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(permissionService.getUserPermission(userId, id, false));
|
||||
|
|
|
|||
|
|
@ -28,55 +28,55 @@ public class ProjectController {
|
|||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
@UserOperation(value = "创建层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "创建层级", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("create")
|
||||
public ElectromagneticResult<?> create(@RequestParam String prjName) {
|
||||
return edPrjService.createNewPrj(prjName, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "删除层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "删除层级", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("delete")
|
||||
public ElectromagneticResult<?> delete(@RequestParam String prjId) {
|
||||
return edPrjService.delete(prjId, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "修改层级名", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "修改层级名", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("modify")
|
||||
public ElectromagneticResult<?> modifyPrjName(@RequestParam String newPrjName, @RequestParam String prjId) {
|
||||
return edPrjService.modifyPrjName(prjId, newPrjName, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("queryAll")
|
||||
public ElectromagneticResult<?> queryAll() {
|
||||
return edPrjService.queryAllPrjInfo(PrjQuerySource.SYS_PRJ.value);
|
||||
}
|
||||
|
||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("addFolder")
|
||||
public ElectromagneticResult<?> addFolder(@RequestParam String folderName, @RequestParam String parentId) {
|
||||
return edPrjService.addFolder(parentId, folderName, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "修改子集名称", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "修改子集名称", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("modifyFolder")
|
||||
public ElectromagneticResult<?> modifyFolder(@RequestParam String newFolderName, @RequestParam String id) {
|
||||
return edPrjService.modifyFolder(id, newFolderName, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "废除子集", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "废除子集", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("deleteFolder")
|
||||
public ElectromagneticResult<?> deleteFolder(@RequestParam String id) {
|
||||
return edPrjService.deleteFolder(id, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "更改层级顺序", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "更改层级顺序", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("folderResort")
|
||||
public ElectromagneticResult<?> folderResort(@RequestBody List<FolderResortDTO> folderResortDTOList) {
|
||||
return edPrjService.folderResort(folderResortDTOList);
|
||||
}
|
||||
|
||||
@UserOperation(value = "发布层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "发布层级", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("publish")
|
||||
public ElectromagneticResult<?> publish(@RequestParam String prjId) {
|
||||
edPrjService.publish(prjId, DataOwnEnum.SYS_PRJ.code);
|
||||
|
|
@ -85,13 +85,13 @@ public class ProjectController {
|
|||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@UserOperation(value = "引用层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "引用层级", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("follow")
|
||||
public ElectromagneticResult<?> follow(@RequestParam String sourceId, @RequestParam String targetId) {
|
||||
return edPrjService.follow(sourceId, targetId, DataOwnEnum.SYS_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询层级发布状态", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||
@UserOperation(value = "查询层级发布状态", modelName = UserOperationModuleEnum.SYS_PRJ_SETTING)
|
||||
@RequestMapping("publishStatus")
|
||||
public ElectromagneticResult<?> publishStatus(@RequestBody QueryPublishStatus queryPublishStatus) {
|
||||
return edPrjService.publishStatus(queryPublishStatus, DataOwnEnum.SYS_PRJ.code);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,204 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.annotations.RequiredPermission;
|
||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.FilePermission;
|
||||
import com.electromagnetic.industry.software.common.enums.PrjQuerySource;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/repo/file")
|
||||
public class RepoEdFileInfoController {
|
||||
|
||||
@Resource
|
||||
private EdFileInfoService edFileInfoService;
|
||||
|
||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequestMapping("tree")
|
||||
public ElectromagneticResult<?> tree() {
|
||||
return edFileInfoService.tree(PrjQuerySource.REPO_DB.value);
|
||||
}
|
||||
|
||||
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequestMapping("createFolder")
|
||||
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
|
||||
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "作废", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.DELETE)
|
||||
@RequestMapping("delete")
|
||||
public ElectromagneticResult<?> delete(@RequestParam String id) {
|
||||
return edFileInfoService.delete(id, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping("info")
|
||||
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
||||
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "上传文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.UPLOAD)
|
||||
@RequestMapping("upload")
|
||||
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("strategy") Integer strategy) {
|
||||
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "下载文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||
@RequestMapping("download")
|
||||
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
|
||||
return edFileInfoService.download(id, response, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "更新文件信息", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.EDIT)
|
||||
@RequestMapping("updateFileInfo")
|
||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
|
||||
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "移动文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.MOVE)
|
||||
@RequestMapping("moveFile")
|
||||
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
|
||||
@RequestParam("targetFolderId") String targetFolderId,
|
||||
@RequestParam("strategy") Integer strategy) {
|
||||
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "复制文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.MOVE)
|
||||
@RequestMapping("copyFile")
|
||||
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
|
||||
@RequestParam("targetFolderId") String targetFolderId,
|
||||
@RequestParam("strategy") Integer strategy) {
|
||||
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查看文件历史版本信息", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping("versionView")
|
||||
public ElectromagneticResult<?> versionView(@RequestParam String fileId) {
|
||||
return edFileInfoService.versionView(fileId);
|
||||
}
|
||||
|
||||
@UserOperation(value = "回退版本", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.EDIT)
|
||||
@RequestMapping("versionBack")
|
||||
public ElectromagneticResult<?> versionBack(@RequestParam String fileId, @RequestParam int targetVersion) {
|
||||
return edFileInfoService.versionBack(fileId, targetVersion);
|
||||
}
|
||||
|
||||
@UserOperation(value = "导出数据库", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequestMapping("batchExport")
|
||||
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String fileIds, HttpServletResponse response) throws IOException {
|
||||
return edFileInfoService.batchExport(fileIds, response, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
||||
@RequestParam String fileName,
|
||||
@RequestParam Integer totalChunks) {
|
||||
return edFileInfoService.mergeChunks(identifier, fileName, totalChunks, DataOwnEnum.SYS_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.batchImport(fileChunkDTO, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库")
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.checkChunkExist(fileChunkDTO, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询发布管理", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
|
||||
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询文件详细信息", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping(value = "/fileDetail", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> detail(@RequestParam String id) {
|
||||
return edFileInfoService.detail(id);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询子文件集", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.VIEW)
|
||||
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
|
||||
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "预览文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
||||
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
||||
return edFileInfoService.preview(id, response, DataOwnEnum.REPO_FILE.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加进收藏夹
|
||||
*
|
||||
* @param id 文件id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/collection")
|
||||
@UserOperation(value = "收藏了文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> addFavorite(@RequestParam String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.addFavorite(userId, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从收藏夹移除
|
||||
*
|
||||
* @param id 文件id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/removeCollection")
|
||||
@UserOperation(value = "从收藏夹移除了文件", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> removeFavorite(@RequestParam String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.removeFavorite(userId, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示当前用户收藏夹文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listCollection")
|
||||
@UserOperation(value = "查看了收藏夹", modelName = UserOperationModuleEnum.REPO_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> listFavorite(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.findFavorite(userId, fileInfoQueryDTO));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.PrjQuerySource;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
|
||||
import com.electromagnetic.industry.software.manage.service.EdPrjService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/repo/prj")
|
||||
public class RepoPrjController {
|
||||
|
||||
@Resource
|
||||
private EdPrjService edPrjService;
|
||||
|
||||
@UserOperation(value = "创建层级", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("create")
|
||||
public ElectromagneticResult<?> create(@RequestParam String prjName) {
|
||||
return edPrjService.createNewPrj(prjName, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "删除层级", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("delete")
|
||||
public ElectromagneticResult<?> delete(@RequestParam String prjId) {
|
||||
return edPrjService.delete(prjId, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "修改层级名", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("modify")
|
||||
public ElectromagneticResult<?> modifyPrjName(@RequestParam String newPrjName, @RequestParam String prjId) {
|
||||
return edPrjService.modifyPrjName(prjId, newPrjName, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("queryAll")
|
||||
public ElectromagneticResult<?> queryAll() {
|
||||
return edPrjService.queryAllPrjInfo(PrjQuerySource.REPO_PRJ.value);
|
||||
}
|
||||
|
||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("addFolder")
|
||||
public ElectromagneticResult<?> addFolder(@RequestParam String folderName, @RequestParam String parentId) {
|
||||
return edPrjService.addFolder(parentId, folderName, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "修改子集名称", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("modifyFolder")
|
||||
public ElectromagneticResult<?> modifyFolder(@RequestParam String newFolderName, @RequestParam String id) {
|
||||
return edPrjService.modifyFolder(id, newFolderName, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "废除子集", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("deleteFolder")
|
||||
public ElectromagneticResult<?> deleteFolder(@RequestParam String id) {
|
||||
return edPrjService.deleteFolder(id, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "更改层级顺序", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("folderResort")
|
||||
public ElectromagneticResult<?> folderResort(@RequestBody List<FolderResortDTO> folderResortDTOList) {
|
||||
return edPrjService.folderResort(folderResortDTOList);
|
||||
}
|
||||
|
||||
@UserOperation(value = "发布层级", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("publish")
|
||||
public ElectromagneticResult<?> publish(@RequestParam String prjId) {
|
||||
return edPrjService.publish(prjId, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "引用层级", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("follow")
|
||||
public ElectromagneticResult<?> follow(@RequestParam String sourceId, @RequestParam String targetId) {
|
||||
return edPrjService.follow(sourceId, targetId, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询层级发布状态", modelName = UserOperationModuleEnum.REPO_PRJ_SETTING)
|
||||
@RequestMapping("publishStatus")
|
||||
public ElectromagneticResult<?> publishStatus(@RequestBody QueryPublishStatus queryPublishStatus) {
|
||||
return edPrjService.publishStatus(queryPublishStatus, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,56 +21,56 @@ public class RoleController {
|
|||
private RoleService roleService;
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="新建角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "新建角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@RequestMapping(value = "/createRole", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> createRole(@RequestBody RoleDTO roleDTO) {
|
||||
return ElectromagneticResultUtil.success(roleService.createRole(roleDTO));
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="更新角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "更新角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@RequestMapping(value = "/updateRole", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> updateRole(@RequestBody RoleDTO roleDTO) {
|
||||
return ElectromagneticResultUtil.success(roleService.updateRole(roleDTO));
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="删除角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "删除角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@GetMapping(value = "/deleteRole/{roleId}")
|
||||
public ElectromagneticResult<?> deleteRole(@PathVariable("roleId") String roleId) {
|
||||
return ElectromagneticResultUtil.success(roleService.deleteRole(roleId));
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="查看指定角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "查看指定角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@GetMapping(value = "/getSingleRole/{roleId}")
|
||||
public ElectromagneticResult<?> getRole(@PathVariable("roleId") String roleId) {
|
||||
return ElectromagneticResultUtil.success(roleService.getRole(roleId));
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="查看角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "查看角色", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> getRoles(@RequestBody RolePageDTO rolePageDTO) {
|
||||
return ElectromagneticResultUtil.success(roleService.getRoles(rolePageDTO));
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="查看某一角色的权限", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "查看某一角色的权限", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@GetMapping(value = "/getRoleByName")
|
||||
public ElectromagneticResult<?> getRoleByName(@RequestParam("roleName") String roleName) {
|
||||
return ElectromagneticResultUtil.success(roleService.getRoleByName(roleName));
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="获取角色名列表", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "获取角色名列表", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@GetMapping(value = "/getRoleNames")
|
||||
public ElectromagneticResult<?> getRoleNames() {
|
||||
return ElectromagneticResultUtil.success(roleService.getAllRoleNames());
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@UserOperation(value="获取角色配置模版", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@UserOperation(value = "获取角色配置模版", modelName = UserOperationModuleEnum.PERMISSION)
|
||||
@GetMapping(value = "/getRoleTemplate")
|
||||
public ElectromagneticResult<?> getRoleTemplate() {
|
||||
return ElectromagneticResultUtil.success(roleService.getRoleTemplate());
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import com.electromagnetic.industry.software.common.util.ElectromagneticResultUt
|
|||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||
import com.electromagnetic.industry.software.manage.service.UserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -24,68 +23,68 @@ public class UserController {
|
|||
private UserService userService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@UserOperation(value="登陆", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "登陆", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> login(@RequestBody UserLoginRequest loginRequest) {
|
||||
return userService.login(loginRequest);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@PostMapping("/createUser")
|
||||
@UserOperation(value="新增用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "新增用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> createUser(@RequestBody UserRequest userRequest) {
|
||||
return userService.createUser(userRequest);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@PutMapping("/updateUser")
|
||||
@UserOperation(value="编辑用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "编辑用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> updateUser(@RequestBody UserModiRequest userModiRequest) {
|
||||
return userService.modifyUser(userModiRequest);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@RequestMapping(value = "/publish", method = RequestMethod.POST)
|
||||
@UserOperation(value="发布用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "发布用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> publishUser(@RequestBody UserPublishRequest userPublishRequest) {
|
||||
return userService.publishUser(userPublishRequest);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@RequestMapping(value = "/getInfo", method = RequestMethod.GET)
|
||||
@UserOperation(value="获取某一用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "获取某一用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> getSingleUser(GetSingleUserRequest getSingleUserRequest) {
|
||||
return userService.getSingleUser(getSingleUserRequest);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@UserOperation(value="查询用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "查询用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> searchUser(@RequestBody SearchUserRequest searchUserRequest) {
|
||||
return userService.searchUser(searchUserRequest);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/validateWorkNumber", method = RequestMethod.POST)
|
||||
@UserOperation(value="校验工号唯一性", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "校验工号唯一性", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> validateWorkNum(@RequestBody UserWorkNumRequest userWorkNumRequest) {
|
||||
return userService.validateWorkNum(userWorkNumRequest);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@PostMapping(value = "/deleteUser")
|
||||
@UserOperation(value="删除用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "删除用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> deleteUser(@RequestBody UserDeleteRequest userDeleteRequest) {
|
||||
return userService.deleteUser(userDeleteRequest);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
||||
@UserOperation(value="登出", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "登出", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> logout(@RequestHeader("Authorization") String token) {
|
||||
return userService.logout(token);
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@RequestMapping(value = "/bindRole/list", method = RequestMethod.POST)
|
||||
@UserOperation(value="查询用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "查询用户信息", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> getPublishedUsers(@RequestBody SearchUserRequest searchUserRequest) {
|
||||
searchUserRequest.setIsPublished(PublishEnum.PUBLISHED.getCode().toString());
|
||||
return userService.searchUser(searchUserRequest);
|
||||
|
|
@ -93,7 +92,7 @@ public class UserController {
|
|||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@RequestMapping(value = "/bindRoles", method = RequestMethod.POST)
|
||||
@UserOperation(value="绑定人员与角色", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "绑定人员与角色", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> bindRoles(@RequestBody List<UserBindRoleDTO> list) {
|
||||
if (userService.bindRoles(list)) {
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
|
|
@ -104,28 +103,29 @@ public class UserController {
|
|||
|
||||
@RequiredRole(AdminTypeEnum.SYSTEM)
|
||||
@PutMapping("/changePassword")
|
||||
@UserOperation(value="修改用户密码", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "修改用户密码", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> changePassword(@RequestBody ChangePasswordRequest request) {
|
||||
return userService.changePassword(request.getUserId(), request.getNewPassword());
|
||||
}
|
||||
|
||||
@RequiredRole(AdminTypeEnum.SECURITY)
|
||||
@GetMapping(value = "/resetPassword/{userId}")
|
||||
@UserOperation(value="重置密码", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "重置密码", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> resetPassword(@PathVariable("userId") String userId) {
|
||||
return ElectromagneticResultUtil.success(userService.resetPassword(userId));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getAdminType")
|
||||
@UserOperation(value="获取当前用户的管理员类型", modelName = UserOperationModuleEnum.USER)
|
||||
@UserOperation(value = "获取当前用户的管理员类型", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> getAdminType() {
|
||||
String adminType = UserThreadLocal.getAdminType();
|
||||
if (adminType == null || adminType.isEmpty()) {
|
||||
return ElectromagneticResultUtil.fail("500","当前用户未登录");
|
||||
return ElectromagneticResultUtil.fail("500", "当前用户未登录");
|
||||
} else {
|
||||
return ElectromagneticResultUtil.success(adminType);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/validateOldPassword")
|
||||
@UserOperation(value = "校验原始密码", modelName = UserOperationModuleEnum.USER)
|
||||
public ElectromagneticResult<?> validateOldPassword(@RequestBody ValidateOldPasswordRequest request) {
|
||||
|
|
|
|||
|
|
@ -31,31 +31,31 @@ public class UserEdFileInfoController {
|
|||
@Resource
|
||||
private EdFileFavoriteService edFileFavoriteService;
|
||||
|
||||
@UserOperation(value = "查看工程树", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("tree")
|
||||
public ElectromagneticResult<?> tree() {
|
||||
return edFileInfoService.tree(PrjQuerySource.USER_DB.value);
|
||||
}
|
||||
|
||||
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("createFolder")
|
||||
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
|
||||
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "作废文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "作废文件夹", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("delete")
|
||||
public ElectromagneticResult<?> delete(@RequestParam String id) {
|
||||
return edFileInfoService.delete(id, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询文件", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "查询文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("info")
|
||||
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
|
||||
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "上传文件", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "上传文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("upload")
|
||||
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
|
|
@ -63,7 +63,7 @@ public class UserEdFileInfoController {
|
|||
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "下载文件", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "下载文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("download")
|
||||
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
|
||||
return edFileInfoService.download(id, response, DataOwnEnum.USER_FILE.code);
|
||||
|
|
@ -86,22 +86,22 @@ public class UserEdFileInfoController {
|
|||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.batchImport(fileChunkDTO);
|
||||
return edFileInfoService.batchImport(fileChunkDTO, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库")
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.checkChunkExist(fileChunkDTO);
|
||||
return edFileInfoService.checkChunkExist(fileChunkDTO, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "更新文件信息", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "更新文件信息", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("updateFileInfo")
|
||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
|
||||
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "移动文件", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "移动文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("moveFile")
|
||||
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
|
||||
@RequestParam("targetFolderId") String targetFolderId,
|
||||
|
|
@ -109,7 +109,7 @@ public class UserEdFileInfoController {
|
|||
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "复制文件", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "复制文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("copyFile")
|
||||
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
|
||||
@RequestParam("targetFolderId") String targetFolderId,
|
||||
|
|
@ -117,37 +117,37 @@ public class UserEdFileInfoController {
|
|||
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查看文件历史版本信息", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "查看文件历史版本信息", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("versionView")
|
||||
public ElectromagneticResult<?> versionView(@RequestParam String fileId) {
|
||||
return edFileInfoService.versionView(fileId);
|
||||
}
|
||||
|
||||
@UserOperation(value = "回退版本", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "回退版本", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("versionBack")
|
||||
public ElectromagneticResult<?> versionBack(@RequestParam String fileId, @RequestParam int targetVersion) {
|
||||
return edFileInfoService.versionBack(fileId, targetVersion);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询发布管理", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "查询发布管理", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
|
||||
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询文件详细信息", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "查询文件详细信息", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "/fileDetail", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> detail(@RequestParam String id) {
|
||||
return edFileInfoService.detail(id);
|
||||
}
|
||||
|
||||
@UserOperation(value = "查询子文件集", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "查询子文件集", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
|
||||
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "预览文件", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "预览文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
||||
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
||||
return edFileInfoService.preview(id, response, DataOwnEnum.USER_FILE.code);
|
||||
|
|
@ -155,11 +155,12 @@ public class UserEdFileInfoController {
|
|||
|
||||
/**
|
||||
* 添加进收藏夹
|
||||
*
|
||||
* @param id 文件id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/collection")
|
||||
@UserOperation(value="收藏文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "收藏文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
public ElectromagneticResult<?> addFavorite(@RequestParam String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.addFavorite(userId, id));
|
||||
|
|
@ -167,11 +168,12 @@ public class UserEdFileInfoController {
|
|||
|
||||
/**
|
||||
* 从收藏夹移除
|
||||
*
|
||||
* @param id 文件id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/removeCollection")
|
||||
@UserOperation(value="从收藏夹移除文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@UserOperation(value = "从收藏夹移除文件", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
public ElectromagneticResult<?> removeFavorite(@RequestParam String id) {
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.removeFavorite(userId, id));
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class UserEdFileRelationController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@UserOperation(value="创建文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "创建文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> createRelation(@RequestBody EdFileRelation relation) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.createRelation(relation));
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class UserEdFileRelationController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@UserOperation(value="更新文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "更新文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> updateRelation(@RequestBody UpdateRelationDTO updateRelation) {
|
||||
LambdaUpdateWrapper<EdFileRelation> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.eq(EdFileRelation::getId, updateRelation.getRelationId()).set(EdFileRelation::getRelationship, updateRelation.getRelationship());
|
||||
|
|
@ -60,7 +60,7 @@ public class UserEdFileRelationController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/cancel/{relationId}", method = RequestMethod.GET)
|
||||
@UserOperation(value="取消文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "取消文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> cancelRelation(@PathVariable("relationId") String relationId) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.cancelRelation(relationId));
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public class UserEdFileRelationController {
|
|||
* 展示文件关系
|
||||
*/
|
||||
@RequestMapping(value = "listRelations/{id}", method = RequestMethod.GET)
|
||||
@UserOperation(value="查看文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "查看文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> listRelations(@PathVariable("id") String id) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.listRelations(id));
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class UserEdFileRelationController {
|
|||
* 检验文件名是否唯一
|
||||
*/
|
||||
@RequestMapping(value = "/checkFileNameExist", method = RequestMethod.POST)
|
||||
@UserOperation(value="校验文件名唯一性", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "校验文件名唯一性", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> checkFileNameExist(@RequestBody CheckNameUniqueRequest checkNameUniqueRequest) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.checkNameExist(checkNameUniqueRequest));
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ public class UserEdFileRelationController {
|
|||
* 本地上传并建立关系
|
||||
*/
|
||||
@RequestMapping(value = "/upload", method = RequestMethod.POST)
|
||||
@UserOperation(value="上传了文件并创建文件关系", modelName = UserOperationModuleEnum.DATABASE)
|
||||
@UserOperation(value = "上传了文件并创建文件关系", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> uploadRelation(@RequestParam("parentId") String parentId,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("description") String description,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class UserEdFileTagController {
|
|||
|
||||
// 批量添加标签到文件
|
||||
@PostMapping("/addTagsToFile")
|
||||
@UserOperation(value="批量添加了标签到文件", modelName = UserOperationModuleEnum.TAG)
|
||||
@UserOperation(value = "批量添加了标签到文件", modelName = UserOperationModuleEnum.TAG)
|
||||
public ElectromagneticResult<?> addTagsToFile(@RequestBody TagCreateDTO dto) {
|
||||
String createdBy = UserThreadLocal.getUserId();
|
||||
return ElectromagneticResultUtil.success(fileTagRelationService.addTagsToFile(dto.getFileId(), dto.getTagIds(), createdBy));
|
||||
|
|
|
|||
|
|
@ -18,14 +18,15 @@ public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {
|
|||
|
||||
/**
|
||||
* 收藏页 数据查询
|
||||
*
|
||||
* @param page
|
||||
* @param ids
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
IPage<FileInfoVO> queryFileList (Page<FileInfoVO> page,
|
||||
@Param("ids")List<String> ids,
|
||||
@Param("pars") FileInfoQueryDTO queryDTO,
|
||||
@Param("saveStatus") int saveStatus,
|
||||
@Param("effectFlag") int effectFlag);
|
||||
IPage<FileInfoVO> queryFileList(Page<FileInfoVO> page,
|
||||
@Param("ids") List<String> ids,
|
||||
@Param("pars") FileInfoQueryDTO queryDTO,
|
||||
@Param("saveStatus") int saveStatus,
|
||||
@Param("effectFlag") int effectFlag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.common.enums.TagTypeEnum;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.electromagnetic.industry.software.manage.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface FileFormatMapper extends BaseMapper<FileFormat> {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public interface TokenMapper extends BaseMapper<Token> {
|
|||
* @param token
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
int insert(Token token);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public interface UserMapper extends BaseMapper<User> {
|
|||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
int insert(User user);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -113,10 +113,12 @@ public class EdFileInfo extends BaseModel {
|
|||
/**
|
||||
* 数据的归属:0-》上传的文件或者新建的文件夹 1-》系统管理员创建的层级 2-》用户自定义的层级
|
||||
*/
|
||||
@TableField(value = "prj_dir")
|
||||
@TableField(value = "data_own")
|
||||
private Integer dataOwn;
|
||||
|
||||
/** 当一个文件作废时,其所有的历史文件也会跟着作废,此时该文件及其历史文件的all_deleted=true**/
|
||||
/**
|
||||
* 当一个文件作废时,其所有的历史文件也会跟着作废,此时该文件及其历史文件的all_deleted=true
|
||||
**/
|
||||
@TableField(value = "all_deleted")
|
||||
private Boolean allDeleted;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("ed_file_format")
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@TableName("ed_role_permission")
|
||||
@AllArgsConstructor
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,5 +58,5 @@ public class FileInfoVO {
|
|||
private Integer isPersonal;
|
||||
|
||||
// 文件权限
|
||||
private Map<String,Boolean> permissions;
|
||||
private Map<String, Boolean> permissions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ public class AccessLogQueryDTO {
|
|||
|
||||
private int pageSize;
|
||||
|
||||
private String keyword;
|
||||
private String keyWord;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class AccessLogQueryVO {
|
|||
|
||||
private String userId;
|
||||
|
||||
private String username;
|
||||
private String userName;
|
||||
|
||||
// 进行的操作
|
||||
private String action;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package com.electromagnetic.industry.software.manage.service;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.FileInfoVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.FileInfoVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
||||
|
|
@ -79,7 +79,7 @@ public interface EdFileInfoService {
|
|||
* @param fileChunkDTO
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO);
|
||||
ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO, int dataOwnCode);
|
||||
|
||||
/**
|
||||
* 批量导入
|
||||
|
|
@ -87,7 +87,7 @@ public interface EdFileInfoService {
|
|||
* @param fileChunkDTO
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO);
|
||||
ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO, int dataOwnCode);
|
||||
|
||||
/**
|
||||
* 合并分片
|
||||
|
|
@ -161,10 +161,11 @@ public interface EdFileInfoService {
|
|||
/**
|
||||
* 获取文件的层级Id
|
||||
*/
|
||||
String getCategoryId (String id);
|
||||
String getCategoryId(String id);
|
||||
|
||||
/**
|
||||
* 根据父id查询其下自定义的文件夹
|
||||
*
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -173,6 +174,7 @@ public interface EdFileInfoService {
|
|||
|
||||
/**
|
||||
* 文件预览
|
||||
*
|
||||
* @param id
|
||||
* @param response
|
||||
*/
|
||||
|
|
@ -180,21 +182,24 @@ public interface EdFileInfoService {
|
|||
|
||||
/**
|
||||
* 收藏页 数据查询
|
||||
*
|
||||
* @param page
|
||||
* @param ids
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
IPage<FileInfoVO> queryFileList (Page<FileInfoVO> page, List<String> ids, FileInfoQueryDTO queryDTO, int saveStatus, int effectFlag);
|
||||
IPage<FileInfoVO> queryFileList(Page<FileInfoVO> page, List<String> ids, FileInfoQueryDTO queryDTO, int saveStatus, int effectFlag);
|
||||
|
||||
/**
|
||||
* 处理重名文件,文件名后+_1
|
||||
*
|
||||
* @param fileInfo
|
||||
*/
|
||||
void resetFileInfoName(EdFileInfo fileInfo);
|
||||
|
||||
/**
|
||||
* 判断是否是文件夹
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -202,6 +207,7 @@ public interface EdFileInfoService {
|
|||
|
||||
/**
|
||||
* 添加收藏
|
||||
*
|
||||
* @param userId
|
||||
* @param fileId
|
||||
* @return
|
||||
|
|
@ -210,6 +216,7 @@ public interface EdFileInfoService {
|
|||
|
||||
/**
|
||||
* 判断是否已收藏
|
||||
*
|
||||
* @param userId
|
||||
* @param fileId
|
||||
* @return
|
||||
|
|
@ -218,6 +225,7 @@ public interface EdFileInfoService {
|
|||
|
||||
/**
|
||||
* 移除收藏
|
||||
*
|
||||
* @param userId
|
||||
* @param fileId
|
||||
* @return
|
||||
|
|
@ -226,7 +234,8 @@ public interface EdFileInfoService {
|
|||
|
||||
/**
|
||||
* 查询当前用户收藏文件信息
|
||||
* @param userId 用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param fileInfoQueryDTO 分页信息
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ public interface EdFileRelationService {
|
|||
* 文件上传并建立关系
|
||||
*
|
||||
* @param parentId
|
||||
* @param id 主文件Id
|
||||
* @param id 主文件Id
|
||||
* @param file
|
||||
* @param desc 关系描述
|
||||
* @param desc 关系描述
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> uploadFileAndRelation(String parentId, String id, MultipartFile file, String desc, int dataOwnCode);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.FileTagInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
|
||||
|
||||
import javax.swing.text.html.HTML;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
||||
|
||||
/**
|
||||
* 新建分组
|
||||
*
|
||||
* @param tagName
|
||||
* @param createdBy
|
||||
*/
|
||||
|
|
@ -21,6 +20,7 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
|||
|
||||
/**
|
||||
* 新建标签
|
||||
*
|
||||
* @param parentId
|
||||
* @param tagName
|
||||
* @param createdBy
|
||||
|
|
@ -29,6 +29,7 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
|||
|
||||
/**
|
||||
* 拖拽标签顺序
|
||||
*
|
||||
* @param tagId
|
||||
* @param newOrderBy
|
||||
*/
|
||||
|
|
@ -36,11 +37,14 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
|||
|
||||
/**
|
||||
* 发布标签
|
||||
*
|
||||
* @param tagGroupIds
|
||||
*/
|
||||
Boolean batchPublishTagGroups(List<String> tagGroupIds);
|
||||
|
||||
/** 废除标签
|
||||
/**
|
||||
* 废除标签
|
||||
*
|
||||
* @param tagId
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -48,12 +52,14 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
|||
|
||||
/**
|
||||
* 标签数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TagListVO> listTagsWithGroups();
|
||||
|
||||
/**
|
||||
* 更新标签信息
|
||||
*
|
||||
* @param tagId
|
||||
* @param tagName
|
||||
* @return 更新结果
|
||||
|
|
@ -62,12 +68,14 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
|||
|
||||
/**
|
||||
* 构建标签树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> listTagTree();
|
||||
|
||||
/**
|
||||
* 获取所有标签
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<FileTagInfo> listAllTags();
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ public interface FileBackLogService {
|
|||
|
||||
ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize);
|
||||
|
||||
void restore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.electromagnetic.industry.software.manage.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileTagRelation;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileTagInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -11,6 +10,7 @@ public interface FileTagRelationService extends IService<FileTagRelation> {
|
|||
|
||||
/**
|
||||
* 批量添加标签到文件
|
||||
*
|
||||
* @param fileId
|
||||
* @param tagIds
|
||||
* @param createdBy
|
||||
|
|
@ -20,13 +20,15 @@ public interface FileTagRelationService extends IService<FileTagRelation> {
|
|||
|
||||
/**
|
||||
* 获取文件标签
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
List<FileTagInfo> getFileTags (String fileId);
|
||||
List<FileTagInfo> getFileTags(String fileId);
|
||||
|
||||
/**
|
||||
* 根据标签id获取文件id
|
||||
*
|
||||
* @param tagIds
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.enums.FilePermission;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -9,6 +7,7 @@ public interface PermissionService {
|
|||
|
||||
/**
|
||||
* 用户对个人数据拥有所有权限
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Boolean> getPersonalPermission();
|
||||
|
|
@ -48,6 +47,7 @@ public interface PermissionService {
|
|||
|
||||
/**
|
||||
* 过滤有导出权限的文件id
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
Map<String, Boolean> filterExportIds(String[] ids);
|
||||
|
|
@ -55,14 +55,15 @@ public interface PermissionService {
|
|||
/**
|
||||
* 同步权限
|
||||
*/
|
||||
void syncPermissions (String prjId);
|
||||
void syncPermissions(String prjId);
|
||||
|
||||
/**
|
||||
* 判断用户有无权限
|
||||
*
|
||||
* @param permissionCode 权限
|
||||
* @param userId 用户编码
|
||||
* @param fileId 文件编码
|
||||
* @param userId 用户编码
|
||||
* @param fileId 文件编码
|
||||
* @return
|
||||
*/
|
||||
boolean isPermitted (String permissionCode, String userId, String fileId);
|
||||
boolean isPermitted(String permissionCode, String userId, String fileId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -13,13 +11,15 @@ public interface RolePermissionService extends IService<RolePermission> {
|
|||
|
||||
/**
|
||||
* 同步新权限
|
||||
*
|
||||
* @param currentPermission
|
||||
* @param infoId
|
||||
*/
|
||||
void syncNewPermissions (List<RolePermission> currentPermission, String infoId);
|
||||
void syncNewPermissions(List<RolePermission> currentPermission, String infoId);
|
||||
|
||||
/**
|
||||
* 获取新权限
|
||||
*
|
||||
* @param publishedFileDTO
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -27,7 +27,8 @@ public interface RolePermissionService extends IService<RolePermission> {
|
|||
|
||||
/**
|
||||
* 在树形结构变动后同步权限
|
||||
*
|
||||
* @param prjId
|
||||
*/
|
||||
void syncPermissionsAfterTreeUpdate (List<EdFileInfo> files, String prjId);
|
||||
void syncPermissionsAfterTreeUpdate(List<EdFileInfo> files, String prjId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ public interface UserAccessLogService {
|
|||
|
||||
/**
|
||||
* 分页查询操作记录(审计)
|
||||
*
|
||||
* @param accessLogQueryDTO
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -93,8 +93,7 @@ public interface UserService {
|
|||
Boolean resetPassword(String userId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userId 用户ID
|
||||
* @param newPassword
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -103,7 +102,7 @@ public interface UserService {
|
|||
/**
|
||||
* 校验原始密码是否正确
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userId 用户ID
|
||||
* @param oldInputPassword 输入的原始密码
|
||||
* @return 如果密码正确返回成功结果,否则返回失败结果
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
|
|
@ -58,16 +59,70 @@ public class CommonService {
|
|||
@Resource
|
||||
private FileFormatService fileFormatService;
|
||||
|
||||
public String getEleDataPath(int dataOwnCode) {
|
||||
return PATH_MAP.get(dataOwnCode);
|
||||
private static String createTree(List<EdFileInfo> edFileInfos, Object object) {
|
||||
|
||||
TreeNodeConfig config = new TreeNodeConfig();
|
||||
if (object instanceof ProjectVO) {
|
||||
// 转换为树
|
||||
config.setIdKey(EdFileInfo.Fields.id);
|
||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||
config.setWeightKey(EdFileInfo.Fields.sort);
|
||||
List<Tree<String>> trees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
|
||||
treeNode.putExtra(ProjectVO.Fields.id, obj.getId());
|
||||
treeNode.putExtra(ProjectVO.Fields.parentId, obj.getParentId());
|
||||
treeNode.putExtra(ProjectVO.Fields.sort, obj.getSort());
|
||||
treeNode.putExtra(ProjectVO.Fields.fileName, obj.getFileName());
|
||||
treeNode.putExtra(ProjectVO.Fields.title, obj.getFileName());
|
||||
treeNode.putExtra(ProjectVO.Fields.dataStatus, obj.getDataStatus());
|
||||
}));
|
||||
return JSONUtil.toJsonStr(trees);
|
||||
}
|
||||
|
||||
config.setIdKey(FileProjectVO.Fields.categoryId);
|
||||
config.setParentIdKey(FileProjectVO.Fields.parentId);
|
||||
config.setWeightKey(FileProjectVO.Fields.sort);
|
||||
List<Tree<String>> fileTrees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
|
||||
treeNode.putExtra(FileProjectVO.Fields.categoryId, obj.getId());
|
||||
treeNode.putExtra(FileProjectVO.Fields.parentId, obj.getParentId());
|
||||
treeNode.putExtra(FileProjectVO.Fields.sort, obj.getSort());
|
||||
treeNode.putExtra(FileProjectVO.Fields.categoryName, obj.getFileName());
|
||||
treeNode.putExtra(FileProjectVO.Fields.dataStatus, obj.getDataStatus());
|
||||
}));
|
||||
return JSONUtil.toJsonStr(fileTrees);
|
||||
|
||||
}
|
||||
|
||||
private static List<FileProjectVO> getLeafNodes(FileProjectVO root) {
|
||||
List<FileProjectVO> leafNodes = new ArrayList<>();
|
||||
if (root == null) {
|
||||
return leafNodes;
|
||||
}
|
||||
findLeafNodes(root, leafNodes);
|
||||
return leafNodes;
|
||||
}
|
||||
|
||||
private static void findLeafNodes(FileProjectVO node, List<FileProjectVO> leafNodes) {
|
||||
if (node.getChildren().isEmpty()) {
|
||||
leafNodes.add(node);
|
||||
} else {
|
||||
for (FileProjectVO child : node.getChildren()) {
|
||||
findLeafNodes(child, leafNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
PATH_MAP.put(DataOwnEnum.SYS_FILE.code, elePropertyConfig.getPrjDir());
|
||||
PATH_MAP.put(DataOwnEnum.SYS_PRJ.code, elePropertyConfig.getPrjDir());
|
||||
PATH_MAP.put(DataOwnEnum.USER_PRJ.code, elePropertyConfig.getUserDataPath());
|
||||
PATH_MAP.put(DataOwnEnum.USER_FILE.code, elePropertyConfig.getUserDataPath());
|
||||
PATH_MAP.put(DataOwnEnum.SYS_FILE.code, elePropertyConfig.getSysPrjPath());
|
||||
PATH_MAP.put(DataOwnEnum.SYS_PRJ.code, elePropertyConfig.getSysPrjPath());
|
||||
PATH_MAP.put(DataOwnEnum.USER_PRJ.code, elePropertyConfig.getUserPrjPath());
|
||||
PATH_MAP.put(DataOwnEnum.USER_FILE.code, elePropertyConfig.getUserPrjPath());
|
||||
PATH_MAP.put(DataOwnEnum.REPO_FILE.code, elePropertyConfig.getRepoPrjPath());
|
||||
PATH_MAP.put(DataOwnEnum.REPO_PRJ.code, elePropertyConfig.getRepoPrjPath());
|
||||
}
|
||||
|
||||
public String getEleDataPath(int dataOwnCode) {
|
||||
return PATH_MAP.get(dataOwnCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -121,25 +176,28 @@ public class CommonService {
|
|||
}
|
||||
|
||||
public String createFileCode(String parentId, String fileType, int version, String timeStr) {
|
||||
if (fileType.equals(EleDataTypeEnum.FOLDER.desc)) {
|
||||
if (fileType.equals(EleDataTypeEnum.FOLDER.desc) || StrUtil.isEmpty(fileType)) {
|
||||
return parentId + "00" + version + timeStr;
|
||||
}
|
||||
FileFormat fileFormat = fileFormatService.getBaseMapper().selectOne(Wrappers.lambdaQuery(FileFormat.class).eq(FileFormat::getSuffixName, fileType));
|
||||
FileFormat fileFormat = fileFormatService.getBaseMapper().selectOne(Wrappers.lambdaQuery(FileFormat.class)
|
||||
.eq(FileFormat::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(FileFormat::getSuffixName, fileType));
|
||||
Assert.notNull(fileFormat, "不支持当前格式 {}", fileType);
|
||||
return parentId + fileFormat.getSuffixNo() + version + timeStr;
|
||||
}
|
||||
|
||||
public List<EdFileInfo> selectAllAdminFolder(String id, List<String> accessibleIds, int dataOwnCode) {
|
||||
public List<EdFileInfo> selectAllPrjFolder(String id, int dataOwnCode) {
|
||||
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||
.likeRight(EdFileInfo::getFilePath, id);
|
||||
if (dataOwnCode == DataOwnEnum.SYS_FILE.code) {
|
||||
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
||||
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||
} else {
|
||||
} else if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
||||
} else {
|
||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
return edFileInfoMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
|
@ -160,7 +218,7 @@ public class CommonService {
|
|||
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT));
|
||||
if (maxLengthCheck) {
|
||||
if (paths.size() >= prjFolderMaxLength) {
|
||||
String info = StrFormatter.format( "当前子集已达到最大层级,禁止创建子集,{} 创建失败。", folderName);
|
||||
String info = StrFormatter.format("当前子集已达到最大层级,禁止创建子集,{} 创建失败。", folderName);
|
||||
log.error(info);
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
|
|
@ -204,15 +262,15 @@ public class CommonService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1.询管理员从层级定义处查。2.用户从数据库管理界面查询。
|
||||
* @param querySource 0:询管理员从层级定义处查。 2.用户从数据库管理界面查询。
|
||||
*
|
||||
* @param querySource 0:询管理员从层级定义处查。 2.用户从数据库管理界面查询。
|
||||
* @param accessibleIds
|
||||
* @param obj
|
||||
* @param returnType
|
||||
* @return
|
||||
*/
|
||||
public Map<Integer, List<String>> querySysPrjTree(int querySource, List<String> accessibleIds, Object obj) {
|
||||
public Map<Integer, List<String>> querySysPrjTree(int querySource, List<String> accessibleIds, Object returnType) {
|
||||
|
||||
/**
|
||||
* querySource=SYS_PRJ(从层级定义处查询) querySource=SYS_DB(从数据库界面处查询)
|
||||
|
|
@ -237,6 +295,9 @@ public class CommonService {
|
|||
|
||||
// 如果是数据库界面查询,此处需要进行权限筛选
|
||||
if (querySource == PrjQuerySource.SYS_DB.value) {
|
||||
if (CollUtil.isEmpty(accessibleIds)) {
|
||||
return map;
|
||||
}
|
||||
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||
}
|
||||
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
|
|
@ -256,7 +317,7 @@ public class CommonService {
|
|||
prjQueryWrapper.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code);
|
||||
}
|
||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(prjQueryWrapper);
|
||||
String jsonTree = createTree(edFileInfos, obj);
|
||||
String jsonTree = createTree(edFileInfos, returnType);
|
||||
List<String> list = map.getOrDefault(querySource, new ArrayList<>());
|
||||
list.add(jsonTree);
|
||||
map.put(querySource, list);
|
||||
|
|
@ -269,7 +330,7 @@ public class CommonService {
|
|||
return map;
|
||||
}
|
||||
|
||||
public Map<Integer, List<String>> queryUserPrjTree(int querySource, Object object) {
|
||||
public Map<Integer, List<String>> queryUserPrjTree(int querySource, Object returnType) {
|
||||
|
||||
Map<Integer, List<String>> map = new HashMap<>();
|
||||
try {
|
||||
|
|
@ -277,6 +338,7 @@ public class CommonService {
|
|||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code)
|
||||
.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId())
|
||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
||||
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
|
|
@ -297,7 +359,7 @@ public class CommonService {
|
|||
}
|
||||
|
||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(prjQueryWrapper);
|
||||
String jsonTree = createTree(edFileInfos, object);
|
||||
String jsonTree = createTree(edFileInfos, returnType);
|
||||
List<String> list = map.getOrDefault(querySource, new ArrayList<>());
|
||||
list.add(jsonTree);
|
||||
map.put(querySource, list);
|
||||
|
|
@ -310,56 +372,61 @@ public class CommonService {
|
|||
return map;
|
||||
}
|
||||
|
||||
private static String createTree(List<EdFileInfo> edFileInfos, Object object) {
|
||||
public Map<Integer, List<String>> queryRepoPrjTree(int querySource, Object returnType) {
|
||||
|
||||
TreeNodeConfig config = new TreeNodeConfig();
|
||||
if (object instanceof ProjectVO) {
|
||||
// 转换为树
|
||||
config.setIdKey(EdFileInfo.Fields.id);
|
||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||
config.setWeightKey(EdFileInfo.Fields.sort);
|
||||
List<Tree<String>> trees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
|
||||
treeNode.putExtra(ProjectVO.Fields.id, obj.getId());
|
||||
treeNode.putExtra(ProjectVO.Fields.parentId, obj.getParentId());
|
||||
treeNode.putExtra(ProjectVO.Fields.sort, obj.getSort());
|
||||
treeNode.putExtra(ProjectVO.Fields.fileName, obj.getFileName());
|
||||
treeNode.putExtra(ProjectVO.Fields.title, obj.getFileName());
|
||||
treeNode.putExtra(ProjectVO.Fields.dataStatus, obj.getDataStatus());
|
||||
}));
|
||||
return JSONUtil.toJsonStr(trees);
|
||||
Map<Integer, List<String>> map = new HashMap<>();
|
||||
try {
|
||||
// 首先查出所有的工程id
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
||||
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
|
||||
for (String id : prjIds) {
|
||||
LambdaQueryWrapper<EdFileInfo> prjQueryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||
.likeRight(EdFileInfo::getFilePath, id);
|
||||
|
||||
if (querySource == PrjQuerySource.REPO_DB.value) {
|
||||
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||
.or()
|
||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
||||
} else {
|
||||
prjQueryWrapper.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code);
|
||||
}
|
||||
|
||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(prjQueryWrapper);
|
||||
String jsonTree = createTree(edFileInfos, returnType);
|
||||
List<String> list = map.getOrDefault(querySource, new ArrayList<>());
|
||||
list.add(jsonTree);
|
||||
map.put(querySource, list);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String info = "查询用户层级信息失败";
|
||||
log.error(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
|
||||
config.setIdKey(FileProjectVO.Fields.categoryId);
|
||||
config.setParentIdKey(FileProjectVO.Fields.parentId);
|
||||
config.setWeightKey(FileProjectVO.Fields.sort);
|
||||
List<Tree<String>> fileTrees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
|
||||
treeNode.putExtra(FileProjectVO.Fields.categoryId, obj.getId());
|
||||
treeNode.putExtra(FileProjectVO.Fields.parentId, obj.getParentId());
|
||||
treeNode.putExtra(FileProjectVO.Fields.sort, obj.getSort());
|
||||
treeNode.putExtra(FileProjectVO.Fields.categoryName, obj.getFileName());
|
||||
treeNode.putExtra(FileProjectVO.Fields.dataStatus, obj.getDataStatus());
|
||||
}));
|
||||
return JSONUtil.toJsonStr(fileTrees);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public ElectromagneticResult<?> deleteFolder(String id, int dataOwnCode) {
|
||||
// 如果文件夹下存在文件(包括文件夹和已经逻辑删除的文件),则不允许删除。后面管理员选择会有物理删除文件夹和文件的功能,此时MySQL和文件系统则会进行物理删除该文件。
|
||||
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
|
||||
String srcPrjName = srcFileInfo.getFileName();
|
||||
String srcFilePath = getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
||||
EdFileInfo fileInfo = edFileInfoMapper.selectOne(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getId, id));
|
||||
try {
|
||||
// 这里要分两种情况,1是删除层级目录,2是删除用户创建的文件夹
|
||||
String parentId = fileInfo.getParentId();
|
||||
if (fileInfo.getDataOwn().equals(DataOwnEnum.SYS_PRJ.code)) { // 删除的是层级目录
|
||||
String parentId = srcFileInfo.getParentId();
|
||||
if (DataOwnEnum.isPrjCode(srcFileInfo.getDataOwn())) { // 删除的是层级目录
|
||||
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_FILE.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT));
|
||||
if (count > 0) {
|
||||
String info = StrFormatter.format("删除层级 {} 失败,目录非空。", fileInfo.getFileName());
|
||||
String info = StrFormatter.format("删除层级 {} 失败,目录非空。", srcFileInfo.getFileName());
|
||||
log.info(info);
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
} else {
|
||||
|
|
@ -389,7 +456,7 @@ public class CommonService {
|
|||
.eq(EdFileInfo::getParentId, id)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
if (count > 0) {
|
||||
String info = StrFormatter.format("删除文件夹 {} 失败,目录非空。", fileInfo.getFileName());
|
||||
String info = StrFormatter.format("删除文件夹 {} 失败,目录非空。", srcFileInfo.getFileName());
|
||||
log.info(info);
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
} else {
|
||||
|
|
@ -397,14 +464,13 @@ public class CommonService {
|
|||
edFileInfoMapper.update(new EdFileInfo(), Wrappers.<EdFileInfo>lambdaUpdate()
|
||||
.eq(EdFileInfo::getId, id)
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||
fileSystemService.renameFile(srcFilePath, srcPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
fileSystemService.renameFile(srcFilePath, srcFileInfo.getFileName() + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
}
|
||||
}
|
||||
// fileSystemService.renameFile(srcFilePath, srcPrjName + "." + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
UserThreadLocal.setSuccessInfo(srcFileInfo.getParentId(), id, "删除目录 {} 成功", fileInfo.getFileName());
|
||||
UserThreadLocal.setSuccessInfo(srcFileInfo.getParentId(), id, "删除目录 {} 成功", srcFileInfo.getFileName());
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("删除 {} 失败,原因 {}", fileInfo.getFileName(), e.getMessage());
|
||||
String info = StrFormatter.format("删除 {} 失败,原因 {}", srcFileInfo.getFileName(), e.getMessage());
|
||||
log.error(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
|
|
@ -431,41 +497,30 @@ public class CommonService {
|
|||
|
||||
Set<String> res = new HashSet<>();
|
||||
|
||||
// List<String> prjInfo = (dataOwnCode == DataOwnEnum.SYS_FILE.code) ?
|
||||
// querySysPrjTree(PrjQuerySource.USER_INTERFACE.value, null, new FileProjectVO()).get(PrjQuerySource.USER_INTERFACE.value):
|
||||
// queryUserPrjTree(PrjQuerySource.USER_INTERFACE.value, new FileProjectVO()).get(PrjQuerySource.USER_INTERFACE.value);
|
||||
//
|
||||
// prjInfo.forEach(e -> {
|
||||
// FileProjectVO projectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
|
||||
// Set<String> leafIds = getLeafNodes(projectVO).stream().map(FileProjectVO::getCategoryId).collect(Collectors.toSet());
|
||||
// res.addAll(leafIds);
|
||||
// });
|
||||
return res;
|
||||
}
|
||||
|
||||
private static List<FileProjectVO> getLeafNodes(FileProjectVO root) {
|
||||
List<FileProjectVO> leafNodes = new ArrayList<>();
|
||||
if (root == null) {
|
||||
return leafNodes;
|
||||
}
|
||||
findLeafNodes(root, leafNodes);
|
||||
return leafNodes;
|
||||
}
|
||||
|
||||
private static void findLeafNodes(FileProjectVO node, List<FileProjectVO> leafNodes) {
|
||||
if (node.getChildren().isEmpty()) {
|
||||
leafNodes.add(node);
|
||||
List<String> prjInfo;
|
||||
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
prjInfo = querySysPrjTree(PrjQuerySource.SYS_DB.value, null, new FileProjectVO()).getOrDefault(PrjQuerySource.SYS_DB.value, new ArrayList<>());
|
||||
} else if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
prjInfo = queryUserPrjTree(PrjQuerySource.USER_DB.value, new FileProjectVO()).getOrDefault(PrjQuerySource.USER_DB.value, new ArrayList<>());
|
||||
} else {
|
||||
for (FileProjectVO child : node.getChildren()) {
|
||||
findLeafNodes(child, leafNodes);
|
||||
}
|
||||
prjInfo = queryRepoPrjTree(PrjQuerySource.REPO_DB.value, new FileProjectVO()).getOrDefault(PrjQuerySource.REPO_DB.value, new ArrayList<>());
|
||||
}
|
||||
|
||||
for (String info : prjInfo) {
|
||||
FileProjectVO projectVO = JSONUtil.toList(info, FileProjectVO.class).get(0);
|
||||
Set<String> leafIds = getLeafNodes(projectVO).stream().map(FileProjectVO::getCategoryId).collect(Collectors.toSet());
|
||||
res.addAll(leafIds);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void deletePrjSysDir(List<String> paths) {
|
||||
for (String path : paths) {
|
||||
String preDirName = new File(path).getParentFile().getName();
|
||||
fileSystemService.renameFile(path, preDirName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
if (!FileUtil.exist(path)) {
|
||||
continue;
|
||||
}
|
||||
String fileName = new File(path).getName();
|
||||
fileSystemService.renameFile(path, fileName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -479,10 +534,4 @@ public class CommonService {
|
|||
return "";
|
||||
}
|
||||
|
||||
public String getFileCode(String path) {
|
||||
int index = path.lastIndexOf(".");
|
||||
return path.substring(index + 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.electromagnetic.industry.software.common.enums.*;
|
||||
import com.electromagnetic.industry.software.common.enums.FilePermission;
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.exception.PermissionDeniedException;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
|
|
@ -92,14 +91,16 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Override
|
||||
public ElectromagneticResult<?> queryEdFileInfo(FileInfoQueryDTO pars, int dataOwnCode) {
|
||||
|
||||
String parentId = pars.getParentId();
|
||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||
if ((dataOwnCode != DataOwnEnum.USER_FILE.code) && (!accessibleTree.contains(parentId) && parentId.length() == PRJ_ID_LENGTH)) {
|
||||
throw new PermissionDeniedException();
|
||||
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
String parentId = pars.getParentId();
|
||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||
if ((dataOwnCode != DataOwnEnum.USER_FILE.code) && (!accessibleTree.contains(parentId) && parentId.length() == PRJ_ID_LENGTH)) {
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getSaveStatus, EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getParentId, pars.getParentId())
|
||||
|
|
@ -129,7 +130,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.orderByAsc(ObjUtil.equals(pars.getFileTypeSort(), 0), EdFileInfo::getSort)
|
||||
.orderByDesc(ObjUtil.equals(pars.getFileTypeSort(), 1), EdFileInfo::getSort);
|
||||
|
||||
if (dataOwnCode == DataOwnEnum.USER_FILE.code) {
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
queryWrapper.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId());
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +180,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 项目层级结构查询
|
||||
*
|
||||
* @return
|
||||
|
|
@ -188,7 +188,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
public ElectromagneticResult<?> tree(int querySource) {
|
||||
|
||||
/**
|
||||
* 都是从用户界面处进来,一个是从数据库的用户界面(SYS_DB),一个是从用户自己的工程界面处(USER_DB)。
|
||||
* 都是从用户界面处进来,一个是从数据库的用户界面(SYS_DB),一个是从用户自己的工程界面处(USER_DB),一个是从库工程界面进入(REPO_DB)。
|
||||
*/
|
||||
|
||||
List<String> accessibleIds;
|
||||
|
|
@ -205,16 +205,22 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId())
|
||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Map<Integer, List<String>> map = (querySource == PrjQuerySource.SYS_DB.value) ?
|
||||
commonService.querySysPrjTree(querySource, accessibleIds, new FileProjectVO()) :
|
||||
commonService.queryUserPrjTree(querySource, new FileProjectVO());
|
||||
|
||||
Map<Integer, List<String>> map;
|
||||
if (querySource == PrjQuerySource.SYS_DB.value) {
|
||||
map = commonService.querySysPrjTree(querySource, accessibleIds, new FileProjectVO());
|
||||
} else if (querySource == PrjQuerySource.USER_DB.value) {
|
||||
map = commonService.queryUserPrjTree(querySource, new FileProjectVO());
|
||||
} else {
|
||||
map = commonService.queryRepoPrjTree(querySource, new FileProjectVO());
|
||||
}
|
||||
List<String> strings = map.getOrDefault(querySource, new ArrayList<>());
|
||||
List<FileProjectVO> res = new ArrayList<>();
|
||||
strings.forEach(e -> {
|
||||
FileProjectVO fileProjectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
|
||||
res.add(fileProjectVO);
|
||||
List<FileProjectVO> list = JSONUtil.toList(e, FileProjectVO.class);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
FileProjectVO fileProjectVO = list.get(0);
|
||||
res.add(fileProjectVO);
|
||||
}
|
||||
});
|
||||
res.sort(Comparator.comparing(FileProjectVO::getSort));
|
||||
UserThreadLocal.setSuccessInfo("", "", "查询项目层级结构成功");
|
||||
|
|
@ -374,9 +380,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO, int dataOwnCode) {
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String userUploadFolder = elePropertyConfig.getUploadDataDir() + File.separator + currentUserId;
|
||||
String userUploadFolder = elePropertyConfig.getUploadDataDir(dataOwnCode) + File.separator + currentUserId;
|
||||
String identifier = fileChunkDTO.getIdentifier();
|
||||
List<Integer> uploadedChunks = getUploadedChunks(identifier, userUploadFolder);
|
||||
return ElectromagneticResultUtil.success(new FileChunkResultDTO(false, new HashSet<>(uploadedChunks)));
|
||||
|
|
@ -402,11 +408,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO, int dataOwnCode) {
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String identifier = fileChunkDTO.getIdentifier();
|
||||
// 首先检查该分片有没被上传,如果有则禁止上传
|
||||
String destPath = elePropertyConfig.getUploadDataDir() + File.separator + currentUserId + File.separator + identifier + File.separator + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
String destPath = elePropertyConfig.getUploadDataDir(dataOwnCode) + File.separator + currentUserId + File.separator + identifier + File.separator + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
boolean exist = FileUtil.exist(destPath);
|
||||
if (exist) {
|
||||
return ElectromagneticResultUtil.fail("-1", "文件已经存在,请勿重复上传");
|
||||
|
|
@ -436,7 +442,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> mergeChunks(String identifier, String fileName, Integer totalChunks, int dataOwnCode) {
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String destColibPath = doSysFileMerge(identifier, fileName, totalChunks);
|
||||
String destColibPath = doSysFileMerge(identifier, fileName, totalChunks, dataOwnCode);
|
||||
String mainName = FileUtil.mainName(destColibPath);
|
||||
String parentDir = FileUtil.getParent(destColibPath, 1);
|
||||
String zipDirPath = parentDir + File.separator + mainName + ".zip";
|
||||
|
|
@ -452,7 +458,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
throw new BizException(info);
|
||||
}
|
||||
String uuid = IdUtil.fastSimpleUUID();
|
||||
String tmpDir = elePropertyConfig.getUploadDataDir() + currentUserId + File.separator + uuid + File.separator;
|
||||
String tmpDir = elePropertyConfig.getUploadDataDir(dataOwnCode) + currentUserId + File.separator + uuid + File.separator;
|
||||
ZipUtil.unzip(zipDirPath, tmpDir);
|
||||
update2Database(tmpDir, dataOwnCode);
|
||||
fileSystemService.deleteFile(zipDirPath, destColibPath);
|
||||
|
|
@ -541,7 +547,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
if (ObjUtil.isNull(dbEffectFile)) {
|
||||
effectId = importEffectFile.getId();
|
||||
} else {
|
||||
effectId = importEffectFile.getUpdatedTime().after(dbEffectFile.getUpdatedTime())? importEffectFile.getId() : dbEffectFile.getId();
|
||||
effectId = importEffectFile.getUpdatedTime().after(dbEffectFile.getUpdatedTime()) ? importEffectFile.getId() : dbEffectFile.getId();
|
||||
}
|
||||
Map<String, String> importVersionRelation = getVersionRelation(deepCopyV);
|
||||
Map<String, String> dbVersionRelation = getVersionRelation(deepCopyDb);
|
||||
|
|
@ -656,7 +662,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
*/
|
||||
@Override
|
||||
public ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response, int dataOwnCode) throws IOException {
|
||||
String userDownloadDataDir = elePropertyConfig.getDownloadDataDir() + File.separator + UserThreadLocal.getUserId();
|
||||
String userDownloadDataDir = elePropertyConfig.getDownloadDataDir(dataOwnCode) + File.separator + UserThreadLocal.getUserId();
|
||||
String[] ids = dataIdArr.split(",");
|
||||
if (dataOwnCode == DataOwnEnum.SYS_FILE.code) {
|
||||
Map<String, Boolean> map = permissionService.filterExportIds(ids);
|
||||
|
|
@ -665,7 +671,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
Map<String, EdFileInfo> maps = new HashMap<>();
|
||||
for (String id : ids) {
|
||||
Map<String, EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT))
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT))
|
||||
.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
|
||||
maps.putAll(edFileInfos);
|
||||
}
|
||||
|
|
@ -674,7 +680,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
List<EdFileInfo> prjFolders = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||
.eq(EdFileInfo::getDataOwn, dataOwnCode == DataOwnEnum.SYS_FILE.code ? DataOwnEnum.SYS_PRJ.code : DataOwnEnum.USER_PRJ.code)
|
||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.getPrjCodeByFileCode(dataOwnCode))
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
EdFileInfo prjFileInfo = this.baseMapper.selectById(prjId);
|
||||
Map<String, EdFileInfo> prjFoldersMap = prjFolders.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
|
||||
|
|
@ -691,7 +697,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
fileSystemService.createDirectory(destFolderPath);
|
||||
}
|
||||
for (EdFileInfo edFileInfo : files) {
|
||||
String filePath = commonService.getFileSysPath(edFileInfo.getFilePath(), dataOwnCode == DataOwnEnum.SYS_FILE.code ? DataOwnEnum.SYS_PRJ.code : DataOwnEnum.USER_PRJ.code); // file
|
||||
String filePath = commonService.getFileSysPath(edFileInfo.getFilePath(), dataOwnCode); // file
|
||||
String destPath = userDownloadDataDir + File.separator + prjName + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
|
||||
fileSystemService.copyFile(filePath, destPath);
|
||||
}
|
||||
|
|
@ -750,7 +756,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> upload(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) {
|
||||
|
||||
Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误");
|
||||
String destPath = commonService.getDbPathById(parentId);
|
||||
String fileName = file.getOriginalFilename();
|
||||
String strategyStr = FileRepeatEnum.getDesc(strategy);
|
||||
|
|
@ -761,10 +767,12 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code);
|
||||
if (dataOwnCode == DataOwnEnum.USER_FILE.code) {
|
||||
if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
||||
} else {
|
||||
} else if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
||||
} else {
|
||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
long dirCount = this.baseMapper.selectCount(queryWrapper);
|
||||
Assert.isTrue(dirCount == 0, "文件 {} 上传到 {} 失败,层级结构不允许上传文件,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr);
|
||||
|
|
@ -806,7 +814,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.setDataOwn(dataOwnCode);
|
||||
this.saveOrUpdate(newEdFileInfo);
|
||||
String fileDestPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode == DataOwnEnum.SYS_FILE.code ? DataOwnEnum.SYS_PRJ.code : DataOwnEnum.USER_PRJ.code);
|
||||
String fileDestPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
||||
FileUtil.writeFromStream(file.getInputStream(), fileDestPath);
|
||||
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
||||
finalEdFileInfo = newEdFileInfo;
|
||||
|
|
@ -829,7 +837,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
log.error(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo(finalEdFileInfo.getParentId(), finalEdFileInfo.getFileId(), "文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}", fileName, destPath, strategyStr, finalEdFileInfo.getFileName()+ "." + finalEdFileInfo.getFileType());
|
||||
UserThreadLocal.setSuccessInfo(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getParentId).orElse(""),
|
||||
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileId).orElse(""),
|
||||
"文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}",
|
||||
fileName,
|
||||
destPath,
|
||||
strategyStr,
|
||||
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileName).orElse(fileName) + "." + Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileType).orElse(suffix));
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
|
|
@ -860,6 +874,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> moveFile(String id, String targetFolderId, Integer strategy, int dataOwnCode) {
|
||||
|
||||
Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误");
|
||||
// 获取原文件mysql模型
|
||||
EdFileInfo srcFileInfo = this.baseMapper.selectById(id);
|
||||
String srcFilePath = commonService.getFileSysPath(srcFileInfo.getFilePath(), dataOwnCode);
|
||||
|
|
@ -904,9 +919,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
throw new BizException(info);
|
||||
}
|
||||
|
||||
if (strategy == 1) {
|
||||
if (strategy == FileRepeatEnum.IGNORE.code) {
|
||||
return srcFileInfo;
|
||||
} else if (strategy == 2) {
|
||||
} else if (strategy == FileRepeatEnum.REVERSION.code) {
|
||||
// 做版本更新
|
||||
List<EdFileInfo> sameFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getParentId, targetFolderId)
|
||||
|
|
@ -967,6 +982,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> copyFile(String id, String targetFolderId, Integer strategy, int dataOwnCode) {
|
||||
Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误");
|
||||
// 获取原文件mysql模型
|
||||
EdFileInfo srcFileInfo = this.baseMapper.selectById(id);
|
||||
String srcFileDbPath = srcFileInfo.getFilePath();
|
||||
|
|
@ -1071,10 +1087,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
log.info(info);
|
||||
throw new BizException(info);
|
||||
}
|
||||
if (strategy == 1) {
|
||||
if (strategy == FileRepeatEnum.IGNORE.code) {
|
||||
return destFolderInfo;
|
||||
}
|
||||
if (strategy == 2) {
|
||||
if (strategy == FileRepeatEnum.REVERSION.code) {
|
||||
// 做版本更新
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getParentId, targetFolderId)
|
||||
|
|
@ -1102,7 +1118,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String destFilePath = commonService.getFileSysPath(destSaveFileInfo.getFilePath(), dataOwnCode);
|
||||
fileSystemService.copyFile(srcFilePath, destFilePath);
|
||||
return destSaveFileInfo;
|
||||
} else if (strategy == 3) {
|
||||
} else {
|
||||
// 文件名加“_1”,版本号从100开始
|
||||
// 处理MySQL相关逻辑
|
||||
EdFileInfo newEdFileInfo = BeanUtil.copyProperties(srcFileInfo, EdFileInfo.class);
|
||||
|
|
@ -1121,16 +1137,14 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
fileSystemService.copyFile(srcFileSysPath, destFileSysPath);
|
||||
return newEdFileInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public EdFileInfo handUploadRepeatFile(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) throws IOException {
|
||||
Assert.isTrue(Arrays.asList(1, 2, 3).contains(strategy), "解决同名文件参数错误");
|
||||
String fileName = file.getOriginalFilename();
|
||||
String mainName = FileUtil.mainName(fileName);
|
||||
String suffix = FileUtil.getSuffix(fileName);
|
||||
if (strategy == 2) {
|
||||
if (strategy == FileRepeatEnum.REVERSION.code) {
|
||||
// 版本更新
|
||||
// step1:找到同名文件的MySQL对象
|
||||
List<EdFileInfo> parentFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
|
|
@ -1174,7 +1188,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String fileDestPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
||||
fileSystemService.save(file.getInputStream(), fileDestPath);
|
||||
return newEdFileInfo;
|
||||
} else if (strategy == 3) {
|
||||
} else if (strategy == FileRepeatEnum.NEW.code) {
|
||||
// 文件名加”_1“,存为新文件
|
||||
EdFileInfo parentFileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getId, parentId)
|
||||
|
|
@ -1207,10 +1221,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
return null;
|
||||
}
|
||||
|
||||
private String doSysFileMerge(String identifier, String fileName, Integer totalChunks) {
|
||||
private String doSysFileMerge(String identifier, String fileName, Integer totalChunks, int dataOwnCode) {
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
for (int i = 1; i <= totalChunks; i++) {
|
||||
String tmpPath = elePropertyConfig.getUploadDataDir() + File.separator + currentUserId + File.separator + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
String tmpPath = elePropertyConfig.getUploadDataDir(dataOwnCode) + File.separator + currentUserId + File.separator + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
if (!FileUtil.exist(new File(tmpPath))) {
|
||||
String info = StrFormatter.format("第{}个分片没有上传完成,请上传完成后再合并。", i);
|
||||
log.error(info);
|
||||
|
|
@ -1218,8 +1232,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
}
|
||||
}
|
||||
// 合并分片
|
||||
String destColibPath = elePropertyConfig.getUploadDataDir() + File.separator + currentUserId + File.separator + fileName;
|
||||
String path = elePropertyConfig.getUploadDataDir() + File.separator + currentUserId + File.separator + identifier;
|
||||
String destColibPath = elePropertyConfig.getUploadDataDir(dataOwnCode) + File.separator + currentUserId + File.separator + fileName;
|
||||
String path = elePropertyConfig.getUploadDataDir(dataOwnCode) + File.separator + currentUserId + File.separator + identifier;
|
||||
BufferedOutputStream outputStream = FileUtil.getOutputStream(destColibPath);
|
||||
for (int i = 1; i <= totalChunks; i++) {
|
||||
try (BufferedInputStream inputStream = FileUtil.getInputStream(path + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX)) {
|
||||
|
|
@ -1237,18 +1251,19 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
/**
|
||||
* 获取文件的层级Id
|
||||
*
|
||||
* @param id 文件id
|
||||
*/
|
||||
@Override
|
||||
public String getCategoryId (String id){
|
||||
public String getCategoryId(String id) {
|
||||
EdFileInfo file = this.baseMapper.selectById(id);
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("此ID未查询到文件:"+id);
|
||||
throw new IllegalArgumentException("此ID未查询到文件:" + id);
|
||||
}
|
||||
if(file.getId().length() < 6){
|
||||
throw new StringIndexOutOfBoundsException("此文件的FILE_CODE小于六位:"+id);
|
||||
if (file.getId().length() < 6) {
|
||||
throw new StringIndexOutOfBoundsException("此文件的FILE_CODE小于六位:" + id);
|
||||
}
|
||||
if(file.getDataOwn().equals(DataOwnEnum.SYS_PRJ.code) || file.getDataOwn().equals(DataOwnEnum.USER_PRJ.code)){
|
||||
if (file.getDataOwn().equals(DataOwnEnum.SYS_PRJ.code) || file.getDataOwn().equals(DataOwnEnum.USER_PRJ.code)) {
|
||||
return id;
|
||||
}
|
||||
return file.getFileCode().substring(0, 6);
|
||||
|
|
@ -1285,12 +1300,12 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||
Assert.isTrue(Objects.nonNull(fileInfo), "文件不存在");
|
||||
String fileSysPath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
|
||||
String fileSaveTmpPath = elePropertyConfig.getTmpDir() + File.separator + IdUtil.fastSimpleUUID() + "." + fileInfo.getFileType();
|
||||
String fileSaveTmpPath = elePropertyConfig.getEleTmpPath() + File.separator + IdUtil.fastSimpleUUID() + "." + fileInfo.getFileType();
|
||||
FileUtil.copy(fileSysPath, fileSaveTmpPath, true);
|
||||
EleCommonUtil.decryptFile(fileSaveTmpPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
||||
|
||||
if (Arrays.asList("doc", "docx").contains(fileInfo.getFileType())) {
|
||||
String pdfTmpPath = elePropertyConfig.getTmpDir() + File.separator + fileInfo.getFileName() + "_" + IdUtil.fastSimpleUUID() + ".pdf";
|
||||
String pdfTmpPath = elePropertyConfig.getEleTmpPath() + File.separator + fileInfo.getFileName() + "_" + IdUtil.fastSimpleUUID() + ".pdf";
|
||||
OfficeFileUtil.doc2pdf(fileSaveTmpPath, pdfTmpPath);
|
||||
fileSaveTmpPath = pdfTmpPath;
|
||||
}
|
||||
|
|
@ -1320,7 +1335,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.contentType(MediaType.parseMediaType("application/octet-stream;charset=UTF-8"))
|
||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("文件预览错误,文件id是--->{},错误信息--->{}", id,e.getMessage());
|
||||
String info = StrFormatter.format("文件预览错误,文件id是--->{},错误信息--->{}", id, e.getMessage());
|
||||
log.error(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
|
|
@ -1328,18 +1343,20 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
/**
|
||||
* 收藏页 数据查询
|
||||
*
|
||||
* @param page
|
||||
* @param ids
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<FileInfoVO> queryFileList (Page<FileInfoVO> page, List<String> ids, FileInfoQueryDTO queryDTO, int saveStatus, int effectFlag) {
|
||||
public IPage<FileInfoVO> queryFileList(Page<FileInfoVO> page, List<String> ids, FileInfoQueryDTO queryDTO, int saveStatus, int effectFlag) {
|
||||
return this.baseMapper.queryFileList(page, ids, queryDTO, saveStatus, effectFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是文件夹
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -1352,6 +1369,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
/**
|
||||
* 添加收藏
|
||||
*
|
||||
* @param userId
|
||||
* @param fileId
|
||||
* @return
|
||||
|
|
@ -1380,6 +1398,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
/**
|
||||
* 判断是否已收藏
|
||||
*
|
||||
* @param userId
|
||||
* @param fileId
|
||||
* @return
|
||||
|
|
@ -1394,6 +1413,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
/**
|
||||
* 移除收藏
|
||||
*
|
||||
* @param userId
|
||||
* @param fileId
|
||||
* @return
|
||||
|
|
@ -1412,7 +1432,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
/**
|
||||
* 查询当前用户收藏文件信息
|
||||
* @param userId 用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param fileInfoQueryDTO 分页信息
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequ
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.FileRelationViewVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileSimpleInfoVO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileRelationService;
|
||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -73,9 +71,9 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
|
|||
|
||||
edFileRelation.setId(IdWorker.getSnowFlakeIdString());
|
||||
edFileRelation.setCreatedBy(UserThreadLocal.getUserId());
|
||||
boolean isSaved = this.save(edFileRelation);
|
||||
boolean isSaved = this.save(edFileRelation);
|
||||
if (isSaved) {
|
||||
UserThreadLocal.setSuccessInfo("", edFileRelation.getId(), StrFormatter.format("关联了文件"));
|
||||
UserThreadLocal.setSuccessInfo("", edFileRelation.getId(), StrFormatter.format("关联了文件"));
|
||||
}
|
||||
return isSaved;
|
||||
}
|
||||
|
|
@ -89,7 +87,7 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
|
|||
@Override
|
||||
public Boolean cancelRelation(String id) {
|
||||
|
||||
boolean isRemoved = this.removeById(id);
|
||||
boolean isRemoved = this.removeById(id);
|
||||
if (isRemoved) {
|
||||
UserThreadLocal.setSuccessInfo("", id, StrFormatter.format("取消了文件关联"));
|
||||
}
|
||||
|
|
@ -142,7 +140,7 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
|
|||
nodes.add(fileSimpleInfoVO);
|
||||
}
|
||||
fileRelationViewVO.setNodes(nodes);
|
||||
UserThreadLocal.setSuccessInfo("", startId, StrFormatter.format("查询了文件{}的关联关系",startId));
|
||||
UserThreadLocal.setSuccessInfo("", startId, StrFormatter.format("查询了文件{}的关联关系", startId));
|
||||
return fileRelationViewVO;
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +160,8 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
|
|||
EdFileInfo newEdFileInfo = new EdFileInfo();
|
||||
newEdFileInfo.newInit();
|
||||
// 首先检查是否是同名文件
|
||||
Assert.isTrue(EleCommonUtil.isFileNameValid(mainName + "." +suffix), NAME_VALID_MSG);
|
||||
Long count = edFileInfoService.count(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
Assert.isTrue(EleCommonUtil.isFileNameValid(mainName + "." + suffix), NAME_VALID_MSG);
|
||||
long count = edFileInfoService.count(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.eq(EdFileInfo::getFileName, mainName)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
|
|
@ -192,9 +190,9 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
|
|||
* 文件上传
|
||||
*
|
||||
* @param parentId
|
||||
* @param id 主文件Id
|
||||
* @param id 主文件Id
|
||||
* @param file
|
||||
* @param desc 关系描述
|
||||
* @param desc 关系描述
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
|
@ -86,6 +88,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
EdFileInfo fileInfo = new EdFileInfo();
|
||||
String nowTimeStr = EleCommonUtil.getNowTimeStr();
|
||||
fileInfo.setId(newPrjId)
|
||||
.setFileType("文件夹")
|
||||
.setFileId(newPrjId)
|
||||
.setFileName(prjName)
|
||||
.setFileVersion(FILE_START_VERSION)
|
||||
|
|
@ -187,7 +190,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids));
|
||||
// 对原文件进行处理
|
||||
EdFileInfo prjFile = this.getById(prjId);
|
||||
fileSystemService.renameFile(commonService.getFileSysPath(prjId, dataOwnCode), prjFile + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
fileSystemService.renameFile(commonService.getFileSysPath(prjId, dataOwnCode), prjFile.getFileName() + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
|
||||
UserThreadLocal.setSuccessInfo("", prjId, "废除 {} 项目成功。", prjFile.getFileName());
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -232,13 +235,16 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
public ElectromagneticResult<?> queryAllPrjInfo(int querySource) {
|
||||
|
||||
/**
|
||||
* querySource=SYS_PRJ(管理员从层级定义处查询) querySource=USER_PRJ(用户从自定义层级结构处查询
|
||||
* querySource=SYS_PRJ(管理员从层级定义处查询) querySource=USER_PRJ(用户从自定义层级结构处查询 querySource=REPO_PRJ
|
||||
*/
|
||||
|
||||
Map<Integer, List<String>> map = (querySource == PrjQuerySource.SYS_PRJ.value) ?
|
||||
commonService.querySysPrjTree(querySource, null, new ProjectVO()) :
|
||||
commonService.queryUserPrjTree(querySource, new ProjectVO());
|
||||
|
||||
Map<Integer, List<String>> map;
|
||||
if (querySource == PrjQuerySource.SYS_PRJ.value) {
|
||||
map = commonService.querySysPrjTree(querySource, null, new ProjectVO());
|
||||
} else if (querySource == PrjQuerySource.USER_PRJ.value) {
|
||||
map = commonService.queryUserPrjTree(querySource, new ProjectVO());
|
||||
} else {
|
||||
map = commonService.queryRepoPrjTree(querySource, new ProjectVO());
|
||||
}
|
||||
List<String> res = map.getOrDefault(querySource, new ArrayList<>());
|
||||
List<ProjectVO> projectVOS = new ArrayList<>();
|
||||
res.forEach(e -> {
|
||||
|
|
@ -259,8 +265,6 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList) {
|
||||
Date now = new Date();
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
try {
|
||||
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
|
||||
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
|
|
@ -346,51 +350,41 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
try {
|
||||
// 把source工程的层级结构copy到目标工程
|
||||
// 查找source的全部目录
|
||||
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, null, dataOwnCode);
|
||||
List<String> needSavePaths = new ArrayList<>();
|
||||
// 确定层级最大为prjFolderMaxLength层,现在逐层来处理。
|
||||
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllPrjFolder(sourceId, dataOwnCode);
|
||||
List<EdFileInfo> targetEdFileInfos = commonService.selectAllPrjFolder(targetId, dataOwnCode);
|
||||
//
|
||||
Set<String> sourceNames = sourceEdFileInfos.stream().filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == 1).map(EdFileInfo::getFileName).collect(Collectors.toSet());
|
||||
Set<String> targetNames = targetEdFileInfos.stream().filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == 1).map(EdFileInfo::getFileName).collect(Collectors.toSet());
|
||||
|
||||
Collection<String> intersection = CollectionUtil.intersection(sourceNames, targetNames);
|
||||
if (CollUtil.isNotEmpty(intersection)) {
|
||||
String info = StrFormatter.format("层级沿用失败,源工程 {},目标工程 {},原因 存在相同子集", sourceId, targetId);
|
||||
log.error(info);
|
||||
return ElectromagneticResultUtil.fail("-1", info);
|
||||
}
|
||||
|
||||
Map<String, String> idMaps = new HashMap<>();
|
||||
idMaps.put(sourceId, targetId);
|
||||
List<String> sysFilePaths = new ArrayList<>();
|
||||
for (int i = 1; i <= prjFolderMaxLength; ++i) {
|
||||
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, null, dataOwnCode);
|
||||
// 先查找source第i层下有那些子集
|
||||
final int count = i;
|
||||
// 取source当前层
|
||||
List<EdFileInfo> sourceTmpEdFiles = sourceEdFileInfos.stream()
|
||||
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
|
||||
.collect(Collectors.toList());
|
||||
// 取target父层
|
||||
List<EdFileInfo> targetTmpEdFiles = targetEdFileInfos.stream()
|
||||
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count - 1)
|
||||
.collect(Collectors.toList());
|
||||
// 获取source名称的map
|
||||
Map<String, EdFileInfo> sourceFileNameMap = sourceTmpEdFiles.stream()
|
||||
.collect(Collectors.toMap(EdFileInfo::getFileName, e -> e));
|
||||
// 获取target当前层级的子集名称
|
||||
List<String> targetFileNames = targetEdFileInfos.stream()
|
||||
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
|
||||
.map(EdFileInfo::getFileName)
|
||||
.collect(Collectors.toList());
|
||||
int sort = targetTmpEdFiles.size();
|
||||
for (EdFileInfo edFileInfo : sourceTmpEdFiles) {
|
||||
String sourceFileName = edFileInfo.getFileName();
|
||||
|
||||
String sourceFileParentName = sourceEdFileInfos.stream().filter(e -> e.getId().equals(edFileInfo.getParentId())).findFirst().get().getFileName();
|
||||
EdFileInfo targetParentFile = i == 1 ? targetTmpEdFiles.stream().filter(e -> e.getId().equals(targetId)).findFirst().get() : targetTmpEdFiles.stream().filter(e -> e.getFileName().equals(sourceFileParentName)).findFirst().get();
|
||||
|
||||
if (!targetFileNames.contains(sourceFileName)) {
|
||||
EdFileInfo sourceFile = sourceFileNameMap.get(sourceFileName);
|
||||
EdFileInfo targetFile = new EdFileInfo();
|
||||
int layerIndex = i;
|
||||
List<EdFileInfo> currentSourceLayerDirs = sourceEdFileInfos.stream().filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == layerIndex).collect(Collectors.toList());
|
||||
if (layerIndex == 1) {
|
||||
targetEdFileInfos = commonService.selectAllPrjFolder(targetId, dataOwnCode);
|
||||
EdFileInfo prjFileInfo = targetEdFileInfos.stream().filter(e -> e.getParentId().equals(PRJ_PARENT_ID)).findFirst().get();
|
||||
List<EdFileInfo> targetChildLayerDirs = targetEdFileInfos.stream().filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == 1).collect(Collectors.toList());
|
||||
int size = targetChildLayerDirs.size();
|
||||
for (EdFileInfo edFileInfo : currentSourceLayerDirs) {
|
||||
int maxFolderId = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||
|
||||
String newFolderId = String.valueOf(maxFolderId + 1);
|
||||
String nowTimeStr = EleCommonUtil.getNowTimeStr();
|
||||
String fileCode = commonService.createFileCode(targetParentFile.getId(), EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr);
|
||||
Date now = new Date();
|
||||
targetFile.setId(newFolderId)
|
||||
String fileCode = commonService.createFileCode(targetId, EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr);
|
||||
EdFileInfo targetFile = new EdFileInfo().setId(newFolderId)
|
||||
.setFileId(newFolderId)
|
||||
.setFileName(sourceFile.getFileName())
|
||||
.setFileName(edFileInfo.getFileName())
|
||||
.setFileVersion(FILE_START_VERSION)
|
||||
.setDataOwn(dataOwnCode)
|
||||
.setParentId(targetParentFile.getId())
|
||||
.setParentId(idMaps.get(edFileInfo.getParentId()))
|
||||
.setFileTime(nowTimeStr)
|
||||
.setDataType(EleDataTypeEnum.FOLDER.code)
|
||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||
|
|
@ -398,20 +392,50 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
.setFileCode(fileCode)
|
||||
.setFileType("文件夹")
|
||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.setFilePath(targetParentFile.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId)
|
||||
.setSort(++sort);
|
||||
.setFilePath(prjFileInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId)
|
||||
.setSort(++size);
|
||||
this.save(targetFile);
|
||||
targetEdFileInfos.add(targetFile);
|
||||
idMaps.put(edFileInfo.getFileId(), newFolderId);
|
||||
String targetSysFilePath = commonService.getFileSysPath(targetFile.getFilePath(), dataOwnCode);
|
||||
needSavePaths.add(targetSysFilePath);
|
||||
} else {
|
||||
String info = StrFormatter.format("层级沿用失败,源工程 {},目标工程 {},原因 存在相同子集", sourceId, targetId);
|
||||
log.error(info);
|
||||
throw new BizException(info);
|
||||
sysFilePaths.add(targetSysFilePath);
|
||||
}
|
||||
} else {
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class).in(EdFileInfo::getId, idMaps.values()));
|
||||
Map<String, EdFileInfo> map = edFileInfos.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
|
||||
for (EdFileInfo edFileInfo : currentSourceLayerDirs) {
|
||||
String targetDirParentId = idMaps.get(edFileInfo.getParentId());
|
||||
EdFileInfo parentFileInfo = map.get(targetDirParentId);
|
||||
|
||||
int maxFolderId = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||
String newFolderId = String.valueOf(maxFolderId + 1);
|
||||
String nowTimeStr = EleCommonUtil.getNowTimeStr();
|
||||
|
||||
String fileCode = commonService.createFileCode(targetId, EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr);
|
||||
EdFileInfo targetFile = new EdFileInfo().setId(newFolderId)
|
||||
.setFileId(newFolderId)
|
||||
.setFileName(edFileInfo.getFileName())
|
||||
.setFileVersion(FILE_START_VERSION)
|
||||
.setDataOwn(dataOwnCode)
|
||||
.setParentId(targetDirParentId)
|
||||
.setFileTime(nowTimeStr)
|
||||
.setDataType(EleDataTypeEnum.FOLDER.code)
|
||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
||||
.setFileCode(fileCode)
|
||||
.setFileType("文件夹")
|
||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.setFilePath(parentFileInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId)
|
||||
.setSort(edFileInfo.getSort());
|
||||
this.save(targetFile);
|
||||
targetEdFileInfos.add(targetFile);
|
||||
idMaps.put(edFileInfo.getFileId(), newFolderId);
|
||||
String targetSysFilePath = commonService.getFileSysPath(targetFile.getFilePath(), dataOwnCode);
|
||||
sysFilePaths.add(targetSysFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String path : needSavePaths) {
|
||||
for (String path : sysFilePaths) {
|
||||
fileSystemService.createDirectory(path);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo("", targetId, "层级沿用成功");
|
||||
|
|
@ -419,7 +443,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
|||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("层级沿用失败,源工程 {},目标工程 {},原因 {}", sourceId, targetId, e.getMessage());
|
||||
log.error(info, e);
|
||||
throw new BizException(info, e);
|
||||
throw new BizException(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 新建标签组
|
||||
*
|
||||
* @param tagName
|
||||
* @param createdBy
|
||||
* @return
|
||||
|
|
@ -36,7 +37,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
@Override
|
||||
public Boolean createTagGroup(String tagName, String createdBy) {
|
||||
|
||||
Assert.isTrue(!checkNameExist(tagName),StrFormatter.format("该标签组 {} 已存在",tagName));
|
||||
Assert.isTrue(!checkNameExist(tagName), StrFormatter.format("该标签组 {} 已存在", tagName));
|
||||
// 查询当前最大排序值
|
||||
Integer maxOrder = selectMaxOrder(TagTypeEnum.GROUP.getCode(), "0");
|
||||
EdTagLibrary tagGroup = new EdTagLibrary();
|
||||
|
|
@ -44,7 +45,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
tagGroup.setParentId("0"); // 标签组父节点为"0"
|
||||
tagGroup.setType(TagTypeEnum.GROUP.getCode());
|
||||
tagGroup.setTagName(tagName);
|
||||
tagGroup.setOrderBy(maxOrder+1); // 排在最后
|
||||
tagGroup.setOrderBy(maxOrder + 1); // 排在最后
|
||||
tagGroup.setIsPublished(PublishEnum.UNPUBLISHED.getCode());
|
||||
tagGroup.setCreatedBy(createdBy);
|
||||
boolean isSuccess = this.save(tagGroup);
|
||||
|
|
@ -56,13 +57,14 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 新建标签
|
||||
*
|
||||
* @param parentId
|
||||
* @param tagName
|
||||
* @param createdBy
|
||||
*/
|
||||
@Override
|
||||
public Boolean createTag(String parentId, String tagName, String createdBy) {
|
||||
Assert.isTrue(!checkNameExist(tagName),StrFormatter.format("该标签名 {} 已存在",tagName));
|
||||
Assert.isTrue(!checkNameExist(tagName), StrFormatter.format("该标签名 {} 已存在", tagName));
|
||||
// 查询当前组内最大排序值
|
||||
Integer maxOrder = selectMaxOrder(TagTypeEnum.TAG.getCode(), parentId);
|
||||
EdTagLibrary tag = new EdTagLibrary();
|
||||
|
|
@ -70,10 +72,10 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
tag.setParentId(parentId);
|
||||
tag.setType(TagTypeEnum.TAG.getCode()); // 标签
|
||||
tag.setTagName(tagName);
|
||||
tag.setOrderBy(maxOrder+1); // 默认排序
|
||||
tag.setOrderBy(maxOrder + 1); // 默认排序
|
||||
tag.setIsPublished(PublishEnum.UNPUBLISHED.getCode()); // 默认未发布
|
||||
tag.setCreatedBy(createdBy);
|
||||
boolean isSuccess =this.save(tag);
|
||||
boolean isSuccess = this.save(tag);
|
||||
if (isSuccess) {
|
||||
UserThreadLocal.setSuccessInfo("", tag.getTagId(), StrFormatter.format("新建了标签{}", tagName));
|
||||
}
|
||||
|
|
@ -82,6 +84,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 更新标签顺序
|
||||
*
|
||||
* @param tagId
|
||||
* @param newOrderBy
|
||||
*/
|
||||
|
|
@ -99,7 +102,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
EdTagLibrary newTag = this.getOne(new LambdaQueryWrapper<EdTagLibrary>()
|
||||
.eq(EdTagLibrary::getTagId, newTagId));
|
||||
|
||||
Assert.notNull(tag,"此标签/标签组不存在");
|
||||
Assert.notNull(tag, "此标签/标签组不存在");
|
||||
Assert.notNull(newTag, "无法将标签/标签组移动到此位置");
|
||||
|
||||
// 若标签挪到空标签组下,newTagId为新标签组Id
|
||||
|
|
@ -119,11 +122,11 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
if (isMoveToNewGroup) {
|
||||
// 旧组重新排序
|
||||
int max = selectMaxOrder(tag.getType(),oldParentId)+1;
|
||||
int max = selectMaxOrder(tag.getType(), oldParentId) + 1;
|
||||
reorderTagGroup(oldParentId, oldOrderBy, max);
|
||||
|
||||
// 新组重新排序
|
||||
max = selectMaxOrder(tag.getType(), newParentId)+1;
|
||||
max = selectMaxOrder(tag.getType(), newParentId) + 1;
|
||||
reorderTagGroup(newParentId, max, newOrderBy);
|
||||
} else {
|
||||
// 仅更新同组内的排序
|
||||
|
|
@ -131,7 +134,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
}
|
||||
|
||||
// 更新当前标签的新排序值
|
||||
boolean isUpdated = this.update(new LambdaUpdateWrapper<EdTagLibrary>()
|
||||
boolean isUpdated = this.update(new LambdaUpdateWrapper<EdTagLibrary>()
|
||||
.eq(EdTagLibrary::getTagId, tagId)
|
||||
.set(EdTagLibrary::getParentId, newParentId)
|
||||
.set(EdTagLibrary::getOrderBy, newOrderBy)
|
||||
|
|
@ -144,6 +147,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 发布标签批量
|
||||
*
|
||||
* @param tagGroupIds
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -166,6 +170,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 废除标签
|
||||
*
|
||||
* @param tagId
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -179,7 +184,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
this.remove(new LambdaQueryWrapper<EdTagLibrary>().eq(EdTagLibrary::getParentId, tagId));
|
||||
}
|
||||
// 删除本身
|
||||
boolean isDeleted = this.removeById(tagId);
|
||||
boolean isDeleted = this.removeById(tagId);
|
||||
if (isDeleted) {
|
||||
UserThreadLocal.setSuccessInfo("", tagId, StrFormatter.format("删除了标签 {} ", tag.getTagName()));
|
||||
}
|
||||
|
|
@ -188,6 +193,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 标签数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -220,6 +226,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 更新标签信息
|
||||
*
|
||||
* @param tagId
|
||||
* @param tagName
|
||||
* @param updatedBy
|
||||
|
|
@ -227,7 +234,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
*/
|
||||
@Override
|
||||
public Boolean updateTagInfo(String tagId, String tagName, String updatedBy) {
|
||||
Assert.isTrue(!checkNameExist(tagName), StrFormatter.format("该标签/标签组名 {} 已存在" , tagName));
|
||||
Assert.isTrue(!checkNameExist(tagName), StrFormatter.format("该标签/标签组名 {} 已存在", tagName));
|
||||
LambdaUpdateWrapper<EdTagLibrary> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(EdTagLibrary::getTagId, tagId)
|
||||
.set(EdTagLibrary::getTagName, tagName)
|
||||
|
|
@ -263,6 +270,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 构建标签树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -282,7 +290,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
.key(tag.getTagId())
|
||||
.children(new ArrayList<>())
|
||||
.build();
|
||||
} else if(tag.getType().equals(TagTypeEnum.TAG.getCode())) {
|
||||
} else if (tag.getType().equals(TagTypeEnum.TAG.getCode())) {
|
||||
node = TreeNode.builder()
|
||||
.title(tag.getTagName())
|
||||
.key(tag.getTagId())
|
||||
|
|
@ -308,6 +316,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 获取所有标签
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -325,6 +334,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 校验名字是否重复
|
||||
*
|
||||
* @param tagName
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -336,6 +346,7 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
|||
|
||||
/**
|
||||
* 计算顺序
|
||||
*
|
||||
* @return maxOrder
|
||||
*/
|
||||
private int selectMaxOrder(int typeCode, String parentId) {
|
||||
|
|
|
|||
|
|
@ -3,25 +3,39 @@ package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.FileBackupLogMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileBackLogVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
||||
import com.electromagnetic.industry.software.manage.tasks.BackupHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, FileBackupLog> implements FileBackLogService {
|
||||
|
||||
@Resource
|
||||
private EdFileInfoMapper edFileInfoMapper;
|
||||
@Resource
|
||||
private BackupHandler backupHandler;
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize) {
|
||||
|
|
@ -41,6 +55,21 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
|||
fileBackLogVO.setBackEndTime(DateUtil.date(fileBackupLog.getEndTime()));
|
||||
list.add(fileBackLogVO);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo("", "", "查询备份日志成功");
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore() {
|
||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getPermanentDeleted, false)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
|
||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
|
||||
String destPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn());
|
||||
FileUtil.writeBytes(bytes, destPath);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo("", "", "数据库恢复成功");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public interface FileFormatService extends IService<FileFormat> {
|
|||
|
||||
/**
|
||||
* 创建文件格式
|
||||
*
|
||||
* @param suffixName
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -17,6 +18,7 @@ public interface FileFormatService extends IService<FileFormat> {
|
|||
|
||||
/**
|
||||
* 删除文件格式
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -24,12 +26,14 @@ public interface FileFormatService extends IService<FileFormat> {
|
|||
|
||||
/**
|
||||
* 查询文件格式列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<FileFormatVO> getList();
|
||||
|
||||
/**
|
||||
* 更新文件格式
|
||||
*
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
|
|||
|
||||
/**
|
||||
* 创建文件格式
|
||||
*
|
||||
* @param suffixName
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -43,7 +44,7 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
|
|||
fileFormat.setCreatedBy(UserThreadLocal.getUserId());
|
||||
this.baseMapper.insert(fileFormat);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("添加了文件格式 {} ", suffixName));
|
||||
UserThreadLocal.setSuccessInfo("", "", StrFormatter.format("添加了文件格式 {} ", suffixName));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -57,30 +58,33 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
|
|||
|
||||
/**
|
||||
* 删除文件格式
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteFileFormat(String id) {
|
||||
this.baseMapper.update(new FileFormat(), Wrappers.<FileFormat>lambdaUpdate().eq(FileFormat::getId, id).set(FileFormat::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("废除了文件格式,id {} ", id));
|
||||
UserThreadLocal.setSuccessInfo("", "", StrFormatter.format("废除了文件格式,id {} ", id));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询了文件格式列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<FileFormatVO> getList() {
|
||||
List<FileFormat> fileFormats = this.baseMapper.selectList(Wrappers.<FileFormat>lambdaQuery().eq(FileFormat::getEffectFlag, EffectFlagEnum.EFFECT.code).orderByDesc(FileFormat::getCreatedTime));
|
||||
List<FileFormatVO> fileFormatVOS = BeanUtil.copyToList(fileFormats, FileFormatVO.class);
|
||||
UserThreadLocal.setSuccessInfo("","", "查询了文件格式列表");
|
||||
UserThreadLocal.setSuccessInfo("", "", "查询了文件格式列表");
|
||||
return fileFormatVOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件格式
|
||||
*
|
||||
* @param fileFormat
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,27 +2,24 @@ package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.electromagnetic.industry.software.common.enums.*;
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.FileBackupLogMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.UserMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.RecycleFileQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileRecycleQueryVO;
|
||||
|
|
@ -30,19 +27,20 @@ import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
|
|||
import com.electromagnetic.industry.software.manage.service.FileRecycleService;
|
||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import com.electromagnetic.industry.software.manage.tasks.BackupTask;
|
||||
import com.electromagnetic.industry.software.manage.tasks.BackupHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FileRecycleServiceImpl implements FileRecycleService {
|
||||
|
||||
@Resource
|
||||
|
|
@ -54,19 +52,17 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
@Resource
|
||||
private CommonService commonService;
|
||||
@Resource
|
||||
private FileBackupLogMapper fileBackupLogMapper;
|
||||
@Resource
|
||||
private FileSystemService fileSystemService;
|
||||
@Resource
|
||||
private ElePropertyConfig elePropertyConfig;
|
||||
@Resource
|
||||
private BackupTask backupTask;
|
||||
private BackupHandler backupHandler;
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> list(RecycleFileQueryDTO pars) {
|
||||
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getAllDeleted, true)
|
||||
.eq(EdFileInfo::getPermanentDeleted, false)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code)
|
||||
|
|
@ -75,7 +71,6 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
.orderByAsc(ObjUtil.equals(pars.getCreatedTime(), 0), EdFileInfo::getCreatedTime)
|
||||
.orderByDesc(ObjUtil.equals(pars.getCreatedTime(), 1), EdFileInfo::getCreatedTime)
|
||||
.orderByDesc(ObjUtil.isAllEmpty(pars.getCreatedTime(), pars.getVersionSort(), pars.getFileSizeSort(), pars.getFileNameSort(), pars.getUpdatedTime(), pars.getFileTypeSort()), EdFileInfo::getCreatedTime)
|
||||
.orderByDesc(ObjUtil.isAllEmpty(pars.getCreatedTime(), pars.getVersionSort(), pars.getFileSizeSort(), pars.getFileNameSort(), pars.getUpdatedTime(), pars.getFileTypeSort()), EdFileInfo::getCreatedTime)
|
||||
.orderByAsc(ObjUtil.equals(pars.getVersionSort(), 0), EdFileInfo::getFileVersion)
|
||||
.orderByDesc(ObjUtil.equals(pars.getVersionSort(), 1), EdFileInfo::getFileVersion)
|
||||
|
||||
|
|
@ -100,9 +95,10 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
.or()
|
||||
.like(EdFileInfo::getFileContent, pars.getKeyword()));
|
||||
}
|
||||
|
||||
// TODO 要考虑数据是个人数据还是库数据,如果是管理员,则展示全部数据,其他用户则展示有权限的系统数据+用户个人数据+库数据
|
||||
if (!UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue())) {
|
||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||
queryWrapper.and(qr -> qr.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId()).eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_FILE.code));
|
||||
if (CollUtil.isNotEmpty(accessibleTree)) {
|
||||
for (String permission : accessibleTree) {
|
||||
queryWrapper.or().likeRight(EdFileInfo::getFileCode, permission);
|
||||
|
|
@ -116,90 +112,32 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
resetRes(records);
|
||||
UserThreadLocal.setSuccessInfo("", "", "查询所有删除文件成功");
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, records));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> remove(String fileId) {
|
||||
|
||||
// 备份该文件
|
||||
List<EdFileInfo> edFileInfos = this.edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getFileId, fileId));
|
||||
List<String> fileSysPaths = new ArrayList<>();
|
||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||
String fileSysPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn());
|
||||
FileBackupLog fileBackupLog = fileBackupLogMapper.selectOne(Wrappers.lambdaQuery(FileBackupLog.class).eq(FileBackupLog::getFileId, edFileInfo.getId()));
|
||||
|
||||
String saveFileName = edFileInfo.getFileName() + "." + edFileInfo.getFileType() + "." + edFileInfo.getFileCode();
|
||||
|
||||
// 表示从没有备份过该文件
|
||||
if (fileBackupLog == null) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
BackupFileResLog backup = backupTask.backup(fileSysPath);
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
FileBackupLog backupLog = new FileBackupLog()
|
||||
.setId(IdWorker.getSnowFlakeIdString())
|
||||
.setFileId(edFileInfo.getId())
|
||||
.setStartTime(startTime)
|
||||
.setEndTime(endTime)
|
||||
.setDuration(endTime - startTime)
|
||||
.setFileTime(FileUtil.lastModifiedTime(fileSysPath).getTime())
|
||||
.setCreateTime(new Date())
|
||||
.setFileName(saveFileName)
|
||||
.setFileCode(commonService.getFileCode(fileSysPath))
|
||||
.setFileCreateTime(edFileInfo.getCreatedTime())
|
||||
.setSource(FileBackupSource.SYS_BACKUP.code);
|
||||
|
||||
if (backup.getBackupSuccess()) {
|
||||
backupLog.setBackupSuccess(true);
|
||||
fileBackupLogMapper.insert(backupLog);
|
||||
} else {
|
||||
backupLog.setBackupSuccess(false);
|
||||
backupLog.setFailInfoDetail(backup.getFailInfoDetail());
|
||||
fileBackupLogMapper.insert(backupLog);
|
||||
throw new BizException(StrFormatter.format("删除文件 {} 失败,原因 备份该文件出现错误,联系管理员查看日志", saveFileName));
|
||||
}
|
||||
|
||||
} else {
|
||||
long startTime = System.currentTimeMillis();
|
||||
BackupFileResLog backup = backupTask.backup(fileSysPath);
|
||||
long endTime = System.currentTimeMillis();
|
||||
fileBackupLog.setStartTime(startTime)
|
||||
.setEndTime(endTime)
|
||||
.setDuration(endTime - startTime)
|
||||
.setFileTime(FileUtil.lastModifiedTime(fileSysPath).getTime())
|
||||
.setCreateTime(new Date())
|
||||
.setFileCode(commonService.getFileCode(fileSysPath))
|
||||
.setFileCreateTime(edFileInfo.getCreatedTime())
|
||||
.setFileName(saveFileName);
|
||||
if (backup.getBackupSuccess()) {
|
||||
fileBackupLog.setBackupSuccess(true);
|
||||
fileBackupLogMapper.update(fileBackupLog, null);
|
||||
} else {
|
||||
fileBackupLog.setBackupSuccess(false);
|
||||
fileBackupLog.setFailInfoDetail(backup.getFailInfoDetail());
|
||||
fileBackupLogMapper.update(fileBackupLog, null);
|
||||
throw new BizException(StrFormatter.format("删除文件 {} 失败,原因 备份该文件出现错误,联系管理员查看日志", saveFileName));
|
||||
}
|
||||
// 移动到tmp目录,七天后删除
|
||||
fileSystemService.moveFile(fileSysPath, elePropertyConfig.getEleTmpPath() + File.separator + new File(fileSysPath).getName());
|
||||
// 更新MySQL数据库
|
||||
this.edFileInfoMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getFileId, fileId)
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.set(EdFileInfo::getPermanentDeleted, true)
|
||||
.set(EdFileInfo::getAllDeleted, true));
|
||||
UserThreadLocal.setSuccessInfo("", "", "删除文件 {} 成功,文件id {}", edFileInfos.get(0).getFileName() + "." + edFileInfos.get(0).getFileType(), fileId);
|
||||
BackupFileResLog resLog = backupHandler.deleteFile(edFileInfo.getId());
|
||||
if (!Optional.ofNullable(resLog).map(BackupFileResLog::getBackupSuccess).orElse(false)) {
|
||||
log.warn("删除备份文件异常");
|
||||
}
|
||||
fileSysPaths.add(fileSysPath);
|
||||
return ElectromagneticResultUtil.success("删除文件成功");
|
||||
}
|
||||
|
||||
// 移动到tmp目录,七天后删除
|
||||
for (String fileSysPath : fileSysPaths) {
|
||||
fileSystemService.moveFile(fileSysPath, elePropertyConfig.getTmpDir() + File.separator + new File(fileSysPath).getName());
|
||||
}
|
||||
|
||||
// 更新MySQL数据库
|
||||
this.edFileInfoMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.eq(EdFileInfo::getFileId, fileId)
|
||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.set(EdFileInfo::getPermanentDeleted, true)
|
||||
.set(EdFileInfo::getAllDeleted, true));
|
||||
UserThreadLocal.setSuccessInfo("", "", "删除文件 {} 成功,文件id {}", edFileInfos.get(0).getFileName() + "." + edFileInfos.get(0).getFileType(), fileId);
|
||||
return ElectromagneticResultUtil.success("删除文件成功");
|
||||
}
|
||||
|
||||
|
|
@ -208,18 +146,23 @@ public class FileRecycleServiceImpl implements FileRecycleService {
|
|||
public ElectromagneticResult<?> recover(String fileId) {
|
||||
|
||||
List<EdFileInfo> edFileInfos = this.edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.orderByDesc(EdFileInfo::getUpdatedTime)
|
||||
.eq(EdFileInfo::getFileId, fileId)
|
||||
.last("limit 1"));
|
||||
EdFileInfo edFileInfo = edFileInfos.get(0);
|
||||
edFileInfo.setEffectFlag(EffectFlagEnum.EFFECT.code);
|
||||
this.edFileInfoMapper.update(edFileInfo, null);
|
||||
this.edFileInfoMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getAllDeleted, false).eq(EdFileInfo::getFileId, fileId));
|
||||
this.edFileInfoMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code).eq(EdFileInfo::getId, edFileInfo.getId()));
|
||||
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "还原文件 {} 成功,文件id为 {}", edFileInfo.getFileName() + "." + edFileInfo.getFileType(), fileId);
|
||||
return ElectromagneticResultUtil.success("还原文件成功");
|
||||
}
|
||||
|
||||
private void resetRes(List<FileRecycleQueryVO> records) {
|
||||
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> userIds = records.stream().map(FileRecycleQueryVO::getUpdatedBy).collect(Collectors.toList());
|
||||
Map<String, String> idNameMap = userMapper.selectList(Wrappers.<User>lambdaQuery().in(User::getId, userIds)).stream().collect(Collectors.toMap(User::getUserId, User::getUserName));
|
||||
records.forEach(e -> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -10,11 +11,9 @@ import com.electromagnetic.industry.software.manage.mapper.FileTagRelationMapper
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileTagRelation;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileTagInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileTagRelationService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -26,6 +25,7 @@ import java.util.stream.Collectors;
|
|||
public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMapper, FileTagRelation> implements FileTagRelationService {
|
||||
@Autowired
|
||||
private EdTagLibraryMapper edTagLibraryMapper;
|
||||
|
||||
private boolean addTagToFile(String fileId, String tagId, String createdBy) {
|
||||
// 检查标签是否存在并且已发布
|
||||
EdTagLibrary tag = edTagLibraryMapper.selectOne(new LambdaQueryWrapper<EdTagLibrary>()
|
||||
|
|
@ -48,6 +48,7 @@ public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMappe
|
|||
|
||||
/**
|
||||
* 批量添加标签到文件
|
||||
*
|
||||
* @param fileId
|
||||
* @param tagIds
|
||||
* @param createdBy
|
||||
|
|
@ -68,10 +69,12 @@ public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMappe
|
|||
|
||||
/**
|
||||
* 获取文件标签
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
public List<FileTagInfo> getFileTags (String fileId) {
|
||||
@Override
|
||||
public List<FileTagInfo> getFileTags(String fileId) {
|
||||
LambdaQueryWrapper<FileTagRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(FileTagRelation::getFileId, fileId);
|
||||
List<FileTagRelation> relations = this.list(queryWrapper);
|
||||
|
|
@ -88,6 +91,7 @@ public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMappe
|
|||
|
||||
/**
|
||||
* 根据 tagIds 获取文件 ID 列表
|
||||
*
|
||||
* @param tagIds
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.electromagnetic.industry.software.common.enums.*;
|
||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.FilePermission;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.UserRoleMapper;
|
||||
|
|
@ -31,6 +34,7 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
|
||||
/**
|
||||
* 用户对个人数据拥有所有权限
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -73,7 +77,7 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
String userId = UserThreadLocal.getUserId();
|
||||
List<String> roleIds = getRoles(userId);
|
||||
|
||||
if (roleIds ==null || roleIds.isEmpty()) {
|
||||
if (roleIds == null || roleIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
|
@ -148,16 +152,17 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
|
||||
/**
|
||||
* 过滤有导出权限的文件id
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Boolean> filterExportIds(String[] ids) {
|
||||
Map<String, Boolean> map = new HashMap<>();
|
||||
if (ids.length==0) {
|
||||
if (ids.length == 0) {
|
||||
return map;
|
||||
}
|
||||
|
||||
String userId=UserThreadLocal.getUserId();
|
||||
String userId = UserThreadLocal.getUserId();
|
||||
List<String> roleIds = getRoles(userId);
|
||||
for (String id : ids) {
|
||||
LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
|
@ -165,10 +170,10 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
.eq(RolePermission::getPermissionCode, FilePermission.EXPORT.getCode())
|
||||
.in(RolePermission::getRoleId, roleIds);
|
||||
long count = rolePermissionService.count(queryWrapper);
|
||||
map.put(id, count>0);
|
||||
map.put(id, count > 0);
|
||||
|
||||
// 添加父节点
|
||||
if ( count>0 ) {
|
||||
if (count > 0) {
|
||||
EdFileInfo file = edFileInfoMapper.selectById(id);
|
||||
String[] parentIds = file.getFilePath().split("_");
|
||||
for (String parentId : parentIds) {
|
||||
|
|
@ -184,7 +189,7 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
* 同步权限
|
||||
*/
|
||||
@Override
|
||||
public void syncPermissions (String prjId) {
|
||||
public void syncPermissions(String prjId) {
|
||||
|
||||
// 获取当前项目所有已逻辑删除的节点,删除其权限
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
|
@ -213,13 +218,14 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
|
||||
/**
|
||||
* 判断用户有无权限
|
||||
*
|
||||
* @param permissionCode 权限
|
||||
* @param userId 用户编码
|
||||
* @param fileId 文件编码
|
||||
* @param userId 用户编码
|
||||
* @param fileId 文件编码
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermitted (String permissionCode, String userId, String fileId) {
|
||||
public boolean isPermitted(String permissionCode, String userId, String fileId) {
|
||||
LambdaQueryWrapper<UserRole> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(UserRole::getUserId, userId);
|
||||
List<String> roleIds = Optional.ofNullable(userRoleMapper.selectList(queryWrapper))
|
||||
|
|
@ -234,6 +240,6 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
queryWrapper1.eq(RolePermission::getPermissionCode, permissionCode)
|
||||
.eq(RolePermission::getFileId, fileId)
|
||||
.in(RolePermission::getRoleId, roleIds);
|
||||
return rolePermissionService.count(queryWrapper1)>0;
|
||||
return rolePermissionService.count(queryWrapper1) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,12 +27,13 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
|
||||
/**
|
||||
* 同步新权限
|
||||
*
|
||||
* @param currentPermission
|
||||
* @param infoId
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void syncNewPermissions (List<RolePermission> currentPermission, String infoId) {
|
||||
public void syncNewPermissions(List<RolePermission> currentPermission, String infoId) {
|
||||
|
||||
if (currentPermission == null) {
|
||||
throw new IllegalArgumentException("currentPermission must not be null");
|
||||
|
|
@ -50,7 +51,7 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
.filter(p -> !newPermissionSet.contains(p.getRoleId() + "_" + p.getPermissionCode()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
log.info ("删除旧权限: {}", permissionsToDelete);
|
||||
log.info("删除旧权限: {}", permissionsToDelete);
|
||||
|
||||
// 删除不需要的权限
|
||||
if (!permissionsToDelete.isEmpty()) {
|
||||
|
|
@ -77,6 +78,7 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
|
||||
/**
|
||||
* 获取新权限
|
||||
*
|
||||
* @param publishedFileDTO
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -87,11 +89,12 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
|
||||
/**
|
||||
* 在树形结构变动后同步权限
|
||||
*
|
||||
* @param prjId
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void syncPermissionsAfterTreeUpdate (List<EdFileInfo> files, String prjId) {
|
||||
public void syncPermissionsAfterTreeUpdate(List<EdFileInfo> files, String prjId) {
|
||||
|
||||
log.info("开始同步项目权限:{}", prjId);
|
||||
|
||||
|
|
@ -102,13 +105,13 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper,
|
|||
levelMap.computeIfAbsent(len, k -> new ArrayList<>()).add(file);
|
||||
}
|
||||
|
||||
System.out.println("levelMap:"+levelMap);
|
||||
System.out.println("levelMap:" + levelMap);
|
||||
|
||||
// 获取叶子节点
|
||||
int maxLen = levelMap.lastKey();
|
||||
|
||||
// 从最底层的叶子节点的上级节点开始遍历,更新权限
|
||||
for (int i=maxLen-1; i>0;i--) {
|
||||
for (int i = maxLen - 1; i > 0; i--) {
|
||||
for (EdFileInfo fileInfo : levelMap.get(i)) {
|
||||
String infoId = fileInfo.getId();
|
||||
if (isLeafNode(infoId, files)) {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
@Override
|
||||
public Boolean createRole(RoleDTO roleDTO) {
|
||||
|
||||
Assert.isTrue(checkRoleNameUnique(roleDTO),StrFormatter.format("角色名称 {} 已存在" , roleDTO.getRoleName()));
|
||||
Assert.isTrue(checkRoleNameUnique(roleDTO), StrFormatter.format("角色名称 {} 已存在", roleDTO.getRoleName()));
|
||||
|
||||
// 创建角色
|
||||
Role role = new Role();
|
||||
|
|
@ -96,7 +96,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
@Override
|
||||
public Boolean updateRole(RoleDTO roleDTO) {
|
||||
|
||||
Assert.isTrue(checkRoleNameUnique(roleDTO),StrFormatter.format("角色名称 {} 已存在" , roleDTO.getRoleName()));
|
||||
Assert.isTrue(checkRoleNameUnique(roleDTO), StrFormatter.format("角色名称 {} 已存在", roleDTO.getRoleName()));
|
||||
|
||||
// 更新角色信息
|
||||
LambdaUpdateWrapper<Role> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
|
@ -184,12 +184,12 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
dataAuth.put("data", false);
|
||||
rolePermissionDTO.setDataAuth(dataAuth);
|
||||
}
|
||||
rolePermissionDTO.setPermission(permissionService.transToMap(permissionCodes,false));
|
||||
rolePermissionDTO.setPermission(permissionService.transToMap(permissionCodes, false));
|
||||
nodes.add(rolePermissionDTO);
|
||||
}
|
||||
|
||||
roleDTO.setData(buildTree(nodes));
|
||||
UserThreadLocal.setSuccessInfo("",roleId,"查询了角色详情");
|
||||
UserThreadLocal.setSuccessInfo("", roleId, "查询了角色详情");
|
||||
return roleDTO;
|
||||
}
|
||||
|
||||
|
|
@ -229,14 +229,14 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
if (StringUtils.isNotBlank(rolePageDTO.getRoleName())) {
|
||||
queryWrapper.eq("r.role_name", rolePageDTO.getRoleName());
|
||||
}
|
||||
IPage<RoleDTO> result = roleMapper.getPageRoleDTO(page, queryWrapper);
|
||||
IPage<RoleDTO> result = roleMapper.getPageRoleDTO(page, queryWrapper);
|
||||
for (RoleDTO roleDTO : result.getRecords()) {
|
||||
if (roleDTO.getAllowedActions() != null ) {
|
||||
if (roleDTO.getAllowedActions() != null) {
|
||||
String chineseString = Arrays.stream(roleDTO.getAllowedActions().split(",")).map(FilePermission::toDescription).collect(Collectors.joining(","));
|
||||
roleDTO.setAllowedActions(chineseString);
|
||||
}
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo("","", "查询了角色列表");
|
||||
UserThreadLocal.setSuccessInfo("", "", "查询了角色列表");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
dataAuth.put("data", false);
|
||||
rolePermissionDTO.setDataAuth(dataAuth);
|
||||
|
||||
rolePermissionDTO.setPermission(permissionService.transToMap(permissionCodes,false));
|
||||
rolePermissionDTO.setPermission(permissionService.transToMap(permissionCodes, false));
|
||||
nodes.add(rolePermissionDTO);
|
||||
}
|
||||
roleDTO.setData(buildTree(nodes));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
|
@ -16,7 +17,6 @@ import com.electromagnetic.industry.software.manage.pojo.models.UserAccessLog;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.AccessLogQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.AccessLogQueryVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import com.electromagnetic.industry.software.manage.service.UserAccessLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -44,20 +44,22 @@ public class UserAccessLogServiceImpl extends ServiceImpl<UserAccessLogMapper, U
|
|||
LambdaQueryWrapper<UserAccessLog> queryWrapper = Wrappers.lambdaQuery(UserAccessLog.class);
|
||||
if (!adminQuery) {
|
||||
queryWrapper.eq(UserAccessLog::getDataId, pars.getDataId());
|
||||
} else {
|
||||
queryWrapper.ne(UserAccessLog::getOperationModule, UserOperationModuleEnum.TMP.key);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(pars.getKeyword())) {
|
||||
queryWrapper.and(qr -> qr.like(UserAccessLog::getAction, pars.getKeyword())
|
||||
if (StrUtil.isNotEmpty(pars.getKeyWord())) {
|
||||
queryWrapper.and(qr -> qr.like(UserAccessLog::getAction, pars.getKeyWord())
|
||||
.or()
|
||||
.like(UserAccessLog::getRequestUrl, pars.getKeyword())
|
||||
.like(UserAccessLog::getRequestUrl, pars.getKeyWord())
|
||||
.or()
|
||||
.like(UserAccessLog::getRequestIp, pars.getKeyword())
|
||||
.like(UserAccessLog::getRequestIp, pars.getKeyWord())
|
||||
.or()
|
||||
.like(UserAccessLog::getRemoteAddr, pars.getKeyword())
|
||||
.like(UserAccessLog::getRemoteAddr, pars.getKeyWord())
|
||||
.or()
|
||||
.like(UserAccessLog::getOperationMsg, pars.getKeyword())
|
||||
.like(UserAccessLog::getOperationMsg, pars.getKeyWord())
|
||||
.or()
|
||||
.like(UserAccessLog::getOperationModule, pars.getKeyword()));
|
||||
.like(UserAccessLog::getOperationModule, pars.getKeyWord()));
|
||||
}
|
||||
|
||||
Page<UserAccessLog> logs = this.baseMapper.selectPage(new Page<>(pars.getPageNum(), pars.getPageSize()), queryWrapper);
|
||||
|
|
@ -70,11 +72,14 @@ public class UserAccessLogServiceImpl extends ServiceImpl<UserAccessLogMapper, U
|
|||
private void setOtherInfo(List<AccessLogQueryVO> res) {
|
||||
|
||||
List<String> userIds = res.stream().map(AccessLogQueryVO::getUserId).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
LambdaQueryWrapper<User> wrapper = Wrappers.lambdaQuery(User.class).select(User::getUserId, User::getUserName).in(User::getUserId, userIds);
|
||||
Map<String, String> idNameMap = userMapper.selectList(wrapper).stream().collect(Collectors.toMap(User::getUserId, User::getUserName));
|
||||
|
||||
res.forEach(e -> {
|
||||
e.setUsername(idNameMap.get(e.getUserId()));
|
||||
e.setUserName(idNameMap.get(e.getUserId()));
|
||||
e.setOperationModule(UserOperationModuleEnum.getDesc(e.getOperationModule()));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
||||
import com.electromagnetic.industry.software.common.enums.ActiveEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.ElectromagneticErrorEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.PublishEnum;
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
|
|
@ -168,7 +167,7 @@ public class UserServiceImpl implements UserService {
|
|||
PublishParam model = UserMappers.INSTANCE.getUserPublishRequestToModel(userPublishRequest);
|
||||
model.setModifier(UserThreadLocal.getUserId());
|
||||
model.setModifierName(UserThreadLocal.getUsername());
|
||||
UserThreadLocal.setSuccessInfo("","",StrFormatter.format("批量发布了用户"));
|
||||
UserThreadLocal.setSuccessInfo("", "", StrFormatter.format("批量发布了用户"));
|
||||
return ElectromagneticResultUtil.success(userMapper.publish(model) > 0);
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +292,7 @@ public class UserServiceImpl implements UserService {
|
|||
/**
|
||||
* 修改用户密码
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userId 用户ID
|
||||
* @param newPassword 新密码
|
||||
* @return 修改结果
|
||||
*/
|
||||
|
|
@ -365,7 +364,7 @@ public class UserServiceImpl implements UserService {
|
|||
User user = userMapper.getSingleUser(userId);
|
||||
Assert.notNull(user, StrFormatter.format("用户不存在,ID为 {}", userId));
|
||||
String decodeOldPwd = AESUtils.decrypt(oldInputPassword, UserConstants.SECRET_KEY);
|
||||
Assert.isTrue(matchPassword(user,decodeOldPwd), StrFormatter.format("旧密码错误,ID为 {}", userId));
|
||||
Assert.isTrue(matchPassword(user, decodeOldPwd), StrFormatter.format("旧密码错误,ID为 {}", userId));
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package com.electromagnetic.industry.software.manage.tasks;
|
||||
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class BackupHandler {
|
||||
|
||||
@Resource
|
||||
private ElePropertyConfig elePropertyConfig;
|
||||
|
||||
public BackupFileResLog backupFiles(String filePath, String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("file", new File(filePath));
|
||||
map.put("id", id);
|
||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/upload", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort());
|
||||
String res = HttpUtil.post(url, map);
|
||||
ElectromagneticResult<?> resObj = JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
String data = JSONUtil.toJsonStr(resObj.getData());
|
||||
return JSONUtil.toBean(data, BackupFileResLog.class);
|
||||
}
|
||||
|
||||
public BackupFileResLog backupSql(String filePath) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("file", new File(filePath));
|
||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/backupSql", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort());
|
||||
String res = HttpUtil.post(url, map);
|
||||
ElectromagneticResult<?> resObj = JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
String data = JSONUtil.toJsonStr(resObj.getData());
|
||||
return JSONUtil.toBean(data, BackupFileResLog.class);
|
||||
}
|
||||
|
||||
public BackupFileResLog deleteFile(String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", id);
|
||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/remove", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort());
|
||||
String res = HttpUtil.get(url, map);
|
||||
ElectromagneticResult<?> resObj = JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
String data = JSONUtil.toJsonStr(resObj.getData());
|
||||
return JSONUtil.toBean(data, BackupFileResLog.class);
|
||||
}
|
||||
|
||||
public byte[] downloadFile(String id) {
|
||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/download?id={}", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort(), id);
|
||||
return HttpUtil.downloadBytes(url);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,19 @@
|
|||
package com.electromagnetic.industry.software.manage.tasks;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||
|
|
@ -23,18 +24,21 @@ import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.UserAccessLog;
|
||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.CommonService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BackupTask {
|
||||
|
||||
@Resource
|
||||
|
|
@ -49,24 +53,21 @@ public class BackupTask {
|
|||
private EdFileInfoMapper edFileInfoMapper;
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
@Resource
|
||||
private BackupHandler backupHandler;
|
||||
|
||||
private static List<File> filter(long time, String dir) {
|
||||
FileFilter filter = file -> file.lastModified() < time;
|
||||
return FileUtil.loopFiles(dir, filter);
|
||||
}
|
||||
|
||||
// @Scheduled(cron = "0 0 1 * * ?")
|
||||
@Scheduled(cron = "0 0 * * * ?")
|
||||
public void backup() {
|
||||
|
||||
// 首先查看备份失败的文件
|
||||
List<String> failBackFailFileIds = getFailBackFile();
|
||||
for (String id : failBackFailFileIds) {
|
||||
EdFileInfo fileInfo = this.edFileInfoMapper.selectOne(Wrappers.<EdFileInfo>lambdaQuery()
|
||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getId, id));
|
||||
String sysFilePath = commonService.getFileSysPath(fileInfo.getFilePath(), fileInfo.getDataOwn());
|
||||
long startTime = System.currentTimeMillis();
|
||||
BackupFileResLog resLog = backup(sysFilePath);
|
||||
BackupFileResLog resLog = backupHandler.backupFiles(sysFilePath, id);
|
||||
long endTime = System.currentTimeMillis();
|
||||
fileBackupLogMapper.update(null, Wrappers.<FileBackupLog>lambdaUpdate()
|
||||
.eq(FileBackupLog::getFileId, id)
|
||||
|
|
@ -83,7 +84,7 @@ public class BackupTask {
|
|||
fileMaxCreateTime = DateUtil.offsetHour(fileMaxCreateTime, -1);
|
||||
// 需要备份的文件
|
||||
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code)
|
||||
.gt(EdFileInfo::getCreatedTime, fileMaxCreateTime));
|
||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||
|
|
@ -93,7 +94,7 @@ public class BackupTask {
|
|||
}
|
||||
String fileSysPath = commonService.getFileSysPath(edFileInfo.getFilePath(), edFileInfo.getDataOwn());
|
||||
long startTime = System.currentTimeMillis();
|
||||
BackupFileResLog resLog = backup(fileSysPath);
|
||||
BackupFileResLog resLog = backupHandler.backupFiles(fileSysPath, edFileInfo.getId());
|
||||
long endTime = System.currentTimeMillis();
|
||||
FileBackupLog backupLog = new FileBackupLog()
|
||||
.setId(IdWorker.getSnowFlakeIdString())
|
||||
|
|
@ -114,11 +115,15 @@ public class BackupTask {
|
|||
}
|
||||
|
||||
private Date getFileMaxCreateTime() {
|
||||
List<FileBackupLog> fileBackupLogs = fileBackupLogMapper.selectList(Wrappers.<FileBackupLog>lambdaQuery().orderByDesc(FileBackupLog::getFileCreateTime).last("limit 1"));
|
||||
List<FileBackupLog> fileBackupLogs = fileBackupLogMapper.selectList(Wrappers.<FileBackupLog>lambdaQuery()
|
||||
.eq(FileBackupLog::getSource, FileBackupSource.SYS_BACKUP.code)
|
||||
.orderByDesc(FileBackupLog::getFileCreateTime)
|
||||
.last("limit 1"));
|
||||
if (CollUtil.isNotEmpty(fileBackupLogs)) {
|
||||
return fileBackupLogs.get(0).getFileCreateTime();
|
||||
}
|
||||
return new Date();
|
||||
// 此处先写一个魔鬼字段值
|
||||
return DateUtil.parse("2000-1-1 01:00:00");
|
||||
}
|
||||
|
||||
public List<String> getFailBackFile() {
|
||||
|
|
@ -128,11 +133,11 @@ public class BackupTask {
|
|||
return fileBackupLogs.stream().map(FileBackupLog::getFileId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// @Scheduled(cron = "0 0 3 * * ?")
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void deleteTmpFile() {
|
||||
DateTime backDaysTime = DateUtil.offsetDay(new Date(), -elePropertyConfig.getTmpFileStoreDays());
|
||||
FileFilter filter = file -> file.lastModified() < backDaysTime.getTime();
|
||||
List<File> files = FileUtil.loopFiles(elePropertyConfig.getTmpDir(), filter);
|
||||
List<File> files = FileUtil.loopFiles(elePropertyConfig.getEleTmpPath(), filter);
|
||||
for (File file : files) {
|
||||
fileSystemService.deleteFile(file.getAbsolutePath());
|
||||
UserAccessLog userAccessLog = new UserAccessLog()
|
||||
|
|
@ -154,16 +159,82 @@ public class BackupTask {
|
|||
.setParentId("")
|
||||
.setResponse("");
|
||||
userAccessLogMapper.insert(userAccessLog);
|
||||
log.info("删除文件成功,路径 {}", file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
public BackupFileResLog backup(String filePath) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("file", new File(filePath));
|
||||
String url = StrFormatter.format("http://{}:{}/data/file/backup/upload", elePropertyConfig.getRemoteHost(), elePropertyConfig.getRemotePort());
|
||||
String res = HttpUtil.post(url, map);
|
||||
ElectromagneticResult<?> resObj = JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
String data = JSONUtil.toJsonStr(resObj.getData());
|
||||
return JSONUtil.toBean(data, BackupFileResLog.class);
|
||||
@Scheduled(cron = "0 0 * * * ?")
|
||||
public void backupSql() {
|
||||
try {
|
||||
dumpMysql();
|
||||
String sqlDirs = elePropertyConfig.getSqlDirs();
|
||||
File[] files = new File(sqlDirs).listFiles((file, name) -> name.endsWith(".sql"));
|
||||
if (ArrayUtil.isEmpty(files)) {
|
||||
log.info("SQL文件没有找到。");
|
||||
return;
|
||||
}
|
||||
|
||||
File maxModifyTimeFile = Arrays.stream(files).filter(File::isFile).filter(File::exists).max(Comparator.comparingLong(File::lastModified)).orElse(null);
|
||||
if (maxModifyTimeFile == null) {
|
||||
log.info("没有找到最新的SQL文件");
|
||||
return;
|
||||
}
|
||||
String fileName = maxModifyTimeFile.getName();
|
||||
List<FileBackupLog> fileBackupLogs = fileBackupLogMapper.selectList(Wrappers.<FileBackupLog>lambdaQuery()
|
||||
.eq(FileBackupLog::getFileName, fileName)
|
||||
.eq(FileBackupLog::getSource, FileBackupSource.SQL.code));
|
||||
List<FileBackupLog> successBacks = fileBackupLogs.stream().filter(FileBackupLog::isBackupSuccess).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(successBacks)) {
|
||||
log.info("最新的SQL文件已经备份过。");
|
||||
return;
|
||||
}
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
BackupFileResLog resLog = backupHandler.backupSql(maxModifyTimeFile.getAbsolutePath());
|
||||
long endTime = System.currentTimeMillis();
|
||||
List<FileBackupLog> failBacks = fileBackupLogs.stream().filter(FileBackupLog::isBackupSuccess).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(failBacks)) {
|
||||
FileBackupLog backupLog = new FileBackupLog()
|
||||
.setId(IdWorker.getSnowFlakeIdString())
|
||||
.setFileId(Base64.encode(fileName))
|
||||
.setFileCode(Base64.encode(fileName))
|
||||
.setBackupSuccess(resLog.getBackupSuccess())
|
||||
.setCreateTime(new Date())
|
||||
.setStartTime(startTime)
|
||||
.setEndTime(endTime)
|
||||
.setDuration(endTime - startTime)
|
||||
.setFailInfoDetail(resLog.getFailInfoDetail())
|
||||
.setFileTime(FileUtil.lastModifiedTime(maxModifyTimeFile).getTime())
|
||||
.setFileName(fileName)
|
||||
.setFileCreateTime(FileUtil.lastModifiedTime(maxModifyTimeFile))
|
||||
.setSource(FileBackupSource.SQL.code);
|
||||
fileBackupLogMapper.insert(backupLog);
|
||||
} else {
|
||||
fileBackupLogMapper.update(new FileBackupLog(), Wrappers.<FileBackupLog>lambdaUpdate()
|
||||
.eq(FileBackupLog::getSource, FileBackupSource.SQL.code)
|
||||
.eq(FileBackupLog::getFileName, fileName)
|
||||
.set(FileBackupLog::getFailInfoDetail, resLog.getFailInfoDetail())
|
||||
.set(FileBackupLog::isBackupSuccess, resLog.getBackupSuccess()));
|
||||
}
|
||||
log.info("备份SQL文件成功,文件路径 {}", maxModifyTimeFile.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
log.error("备份SQL文件异常,原因 {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpMysql() {
|
||||
try {
|
||||
String sqlScript = elePropertyConfig.getBackupMysqlScriptPath();
|
||||
String command = StrFormatter.format("bash {}", sqlScript);
|
||||
Process exec = RuntimeUtil.exec(command);
|
||||
int i = exec.waitFor();
|
||||
if (i != 0) {
|
||||
log.warn("导出MySQL数据异常");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("导出MySQL数据异常,原因 {}", e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,39 @@
|
|||
#required
|
||||
# spring framework
|
||||
spring.application.name=electromagnetic-data
|
||||
spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
|
||||
spring.datasource.url=jdbc:mysql://139.196.179.195:3306/em_data_dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||
spring.datasource.username=em_user_dev
|
||||
spring.datasource.password=Szsd#2O25$dev
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
spring.jackson.time-zone=GMT+8
|
||||
spring.servlet.multipart.max-file-size=500MB
|
||||
spring.servlet.multipart.max-request-size=500MB
|
||||
# mybatis
|
||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
pagehelper.helperDialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
|
||||
# app
|
||||
server.port=12396
|
||||
#windows文件存储目录,用于测试
|
||||
data.windows.path=D:/tmp/szsd/data/eleData/dev/project/
|
||||
data.upload.windows.tmp.path=D:/tmp/szsd/data/eleData/dev/upload/
|
||||
data.download.windows.tmp.path=D:/tmp/szsd/data/eleData/dev/download/
|
||||
data.windows.tmp.path=D:/tmp/szsd/data/eleData/dev/tmp
|
||||
|
||||
data.windows.user.path=D:/tmp/szsd/data/eleData/dev/user_project/
|
||||
data.upload.windows.user.tmp.path=D:/tmp/szsd/data/eleData/dev/user_upload/
|
||||
data.download.windows.user.tmp.path=D:/tmp/szsd/data/eleData/dev/usr_download/
|
||||
data.windows.usere.tmp.path=D:/tmp/szsd/data/eleData/dev/user_tmp
|
||||
|
||||
data.linux.path=/szsd/data/eleData/dev/project/
|
||||
data.upload.linux.tmp.path=/szsd/data/eleData/dev/upload/
|
||||
data.download.linux.tmp.path=/szsd/data/eleData/dev/download/
|
||||
data.linux.tmp.path=/szsd/data/eleData/dev/tmp
|
||||
|
||||
winPrefix:D:/tmp
|
||||
data.ele.tmp.path=/szsd/data/eleData/dev/tmp
|
||||
# sys path
|
||||
data.sys.prj.path=/szsd/data/eleData/dev/sys_project/
|
||||
data.sys.upload.path=/szsd/data/eleData/dev/sys_upload/
|
||||
data.sys.download.path=/szsd/data/eleData/dev/sys_download/
|
||||
# user path
|
||||
data.linux.user.path=/szsd/data/eleData/dev/user_project/
|
||||
data.upload.linux.user.tmp.path=/szsd/data/eleData/dev/user_upload/
|
||||
data.download.linux.user.tmp.path=/szsd/data/eleData/dev/usr_download/
|
||||
data.linux.user.tmp.path=/szsd/data/eleData/dev/user_tmp
|
||||
|
||||
data.user.prj.path=/szsd/data/eleData/dev/user_project/
|
||||
data.user.upload.path=/szsd/data/eleData/dev/user_upload/
|
||||
data.user.download.path=/szsd/data/eleData/dev/user_download/
|
||||
# repo path
|
||||
data.repo.prj.path=/szsd/data/eleData/dev/repo_project/
|
||||
data.repo.upload.path=/szsd/data/eleData/dev/repo_upload/
|
||||
data.repo.download.path=/szsd/data/eleData/dev/repo_download/
|
||||
prj.folder.max.length=6
|
||||
|
||||
spring.jackson.time-zone=GMT+8
|
||||
|
||||
# backupFiles
|
||||
tmp.file.store.days=7
|
||||
|
||||
backup.remote.host=127.0.0.1
|
||||
backup.remote.port=1111
|
||||
backup.remote.port=1111
|
||||
backup.mysql.path=/workspace/mysqlbak/test
|
||||
backup.mysql.script.path=/workspace/mysqlbak/back_dev.sh
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
where length(id) = 6
|
||||
</select>
|
||||
|
||||
<select id="queryFileList" resultMap="FileInfoResultMap" >
|
||||
<select id="queryFileList" resultMap="FileInfoResultMap">
|
||||
SELECT *, LEFT(file_code, 6 ) as category_id
|
||||
FROM ed_file_info
|
||||
<where>
|
||||
|
|
|
|||
|
|
@ -9,23 +9,23 @@
|
|||
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getCurrentPermission" parameterType="com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO" resultMap="RolePermissionMap">
|
||||
SELECT f.parent_id as file_id , rp.permission_code, rp.role_id
|
||||
<select id="getCurrentPermission"
|
||||
parameterType="com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO"
|
||||
resultMap="RolePermissionMap">
|
||||
SELECT f.parent_id as file_id, rp.permission_code, rp.role_id
|
||||
FROM ed_role_permission rp
|
||||
JOIN ed_file_info f ON rp.file_id = f.id
|
||||
JOIN ed_file_info f ON rp.file_id = f.id
|
||||
WHERE f.parent_id = #{fileId}
|
||||
AND f.prj_dir = #{prjDir}
|
||||
AND f.data_status = #{dataStatus}
|
||||
AND f.effect_flag = #{effectFlag}
|
||||
AND f.data_own = #{prjDir}
|
||||
AND f.data_status = #{dataStatus}
|
||||
AND f.effect_flag = #{effectFlag}
|
||||
GROUP BY rp.role_id, rp.permission_code
|
||||
HAVING COUNT(f.id) = (
|
||||
SELECT COUNT(f2.id)
|
||||
FROM ed_file_info f2
|
||||
WHERE f2.parent_id = #{fileId}
|
||||
AND f2.prj_dir = #{prjDir}
|
||||
AND f2.data_status = #{dataStatus}
|
||||
AND f2.effect_flag = #{effectFlag}
|
||||
)
|
||||
HAVING COUNT(f.id) = (SELECT COUNT(f2.id)
|
||||
FROM ed_file_info f2
|
||||
WHERE f2.parent_id = #{fileId}
|
||||
AND f2.data_own = #{prjDir}
|
||||
AND f2.data_status = #{dataStatus}
|
||||
AND f2.effect_flag = #{effectFlag})
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -18,5 +18,5 @@ public interface ElectromagneticConstants {
|
|||
|
||||
int PRJ_ID_LENGTH = 6;
|
||||
|
||||
String DELETE_FLAG = "delete";
|
||||
String DELETE_FLAG = "deleted";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ package com.electromagnetic.industry.software.common.enums;
|
|||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum DataOwnEnum {
|
||||
|
||||
|
|
@ -12,10 +15,17 @@ public enum DataOwnEnum {
|
|||
REPO_FILE(3, "库文件"),
|
||||
REPO_PRJ(5, "库工程");
|
||||
|
||||
private static final Map<Integer, Integer> FILE_PRJ_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
FILE_PRJ_MAP.put(DataOwnEnum.SYS_FILE.code, DataOwnEnum.SYS_PRJ.code);
|
||||
FILE_PRJ_MAP.put(DataOwnEnum.USER_FILE.code, DataOwnEnum.USER_PRJ.code);
|
||||
FILE_PRJ_MAP.put(DataOwnEnum.REPO_FILE.code, DataOwnEnum.REPO_PRJ.code);
|
||||
}
|
||||
|
||||
public final int code;
|
||||
public final String desc;
|
||||
|
||||
|
||||
public static boolean isPrjCode(int code) {
|
||||
return code == SYS_PRJ.code || code == USER_PRJ.code || code == REPO_PRJ.code;
|
||||
}
|
||||
|
|
@ -24,5 +34,19 @@ public enum DataOwnEnum {
|
|||
return code == SYS_FILE.code || code == USER_FILE.code || code == REPO_FILE.code;
|
||||
}
|
||||
|
||||
public static int getPrjCodeByFileCode(int fileCode) {
|
||||
return FILE_PRJ_MAP.get(fileCode);
|
||||
}
|
||||
|
||||
public static boolean isSysCode(int code) {
|
||||
return code == SYS_FILE.code || code == SYS_PRJ.code;
|
||||
}
|
||||
|
||||
public static boolean isUserCode(int code) {
|
||||
return code == USER_FILE.code || code == USER_PRJ.code;
|
||||
}
|
||||
|
||||
public static boolean isRepoCode(int code) {
|
||||
return code == REPO_FILE.code || code == REPO_PRJ.code;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,203 +0,0 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ElectromagneticErrorEnum implements ErrorEnum {
|
||||
/**
|
||||
* 系统
|
||||
*/
|
||||
SYSTEM_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "000", "SYSTEM_ERROR", "系统异常"),
|
||||
PARAMS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "001", "PARAMS_ERROR", "参数异常"),
|
||||
/*****************业务级*****************/
|
||||
|
||||
|
||||
//111
|
||||
INPUT_PARAMETER_IS_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "53001", "INPUT_PARAMETER_IS_EMPTY", "入参为空"),
|
||||
NAME_IS_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "53002", "NAME_IS_EMPTY", "名字为空"),
|
||||
CREATOR_IS_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "53003", "CREATOR_IS_EMPTY", "创建人不能为空"),
|
||||
NAME_IS_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53004", "NAME_IS_REPEAT", "名字重复"),
|
||||
NAME_FORM_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53005", "NAME_FORM_ERROR", "名字格式不正确"),
|
||||
PARENT_CATEGORY_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53006", "PARENT_CATEGORY_NOT_EXIST", "父类目不存在"),
|
||||
DEPT_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53007", "DEPT_NOT_EXIST", "属主部门不存在"),
|
||||
|
||||
CATEGORY_BUILD_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53008", "CATEGORY_BUILD_ERROR", "类目代码生成失败"),
|
||||
CATEGORY_INSERT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53009", "CATEGORY_INSERT_ERROR", "类目新增异常"),
|
||||
CATEGORY_NOT_EXIST_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53010", "CATEGORY_NOT_EXIST_ERROR", "类目不存在"),
|
||||
CATEGORY_DELETE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53011", "CATEGORY_DELETE_ERROR", "类目删除异常"),
|
||||
REPORT_STATUS_CREATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53012", "REPORT_STATUS_CREATE", "新建状态可以编辑"),
|
||||
REPORT_STATUS_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53013", "REPORT_STATUS_CREATE", "新建状态可以删除"),
|
||||
REPORT_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53014", "REPORT_DELETE", "删除失败"),
|
||||
REPORT_UPDATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53015", "REPORT_UPDATE", "更新失败"),
|
||||
REPORT_CREATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53016", "REPORT_CREATE", "创建失败"),
|
||||
REPORT_STATUS(ErrorLevels.ERROR, ErrorTypes.BIZ, "53017", "REPORT_STATUS",
|
||||
"传入对应更新状态:●状态为“新增”,可操作“上架:3”;●状态为“使用中”,可传入“下架:4”;●状态为“将下架”,可操作“取消下架:6”"),
|
||||
REPORT_GINSENG_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53018", "REPORT_GINSENG_NULL", "入参为空"),
|
||||
REPORT_CHECK_NAME(ErrorLevels.ERROR, ErrorTypes.BIZ, "53019", "REPORT_GINSENG_NULL", "名称重复,请重新输入"),
|
||||
GETSEQUENCEID_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53020", "GETSEQUENCEID_ERROR", "序列化ID生成错误"),
|
||||
GET_DEPT_CODE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53020", "GET_DEPT_CODE_ERROR", "部门编码获取异常"),
|
||||
REPORT_NO_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53021", "REPORT_NO_ERROR", "ID生成不能为空"),
|
||||
DEPT_INSERT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53022", "DEPT_INSERT_ERROR", "新增异常"),
|
||||
DEPT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53023", "DEPT_EXIST", "属主部门已存在"),
|
||||
DEPT_ENUM_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53024", "DEPT_ENUM_NOT_EXIST", "属主部门枚举映射不存在"),
|
||||
DEPT_DELETE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53025", "DEPT_DELETE_ERROR", "部门删除异常"),
|
||||
REPORT_UN_SHELVE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53026", "REPORT_UN_SHELVE_ERROR", "下架數據为空"),
|
||||
|
||||
REPORT_ID_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53027", "REPORT_ID_NULL", "ID对应数据不存在"),
|
||||
REPORT_UN_SHELVE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53028", "REPORT_ID_NULL", "沒有下架數據"),
|
||||
REPORT_CATEOGRYLV1_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53029", "REPORT_ID_NULL", "一級類目为空"),
|
||||
REPORT_CATEOGRYLV2_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53030", "REPORT_ID_NULL", "二級類目为空"),
|
||||
CATEGORY_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53031", "CATEGORY_EXIST", "类目已存在"),
|
||||
CATEGORY_EXIST_REPORT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53032", "CATEGORY_EXIST_REPORT", "类目下已挂在数据"),
|
||||
REPORT_URL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53033", "REPORT_URL_ERROR", "FR报表地址错误"),
|
||||
REPORT_OFF_DESC_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53034", "REPORT_URL_ERROR", "下架原因不能为空"),
|
||||
REPORT_CANCEL_OFF_DESC_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53035", "REPORT_URL_ERROR", "取消下架原因不能为空"),
|
||||
DEPT_EXIST_REPORT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53036", "DEPT_EXIST_REPORT", "部门下已挂在数据"),
|
||||
FINE_CREATE_USER_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53037", "FINE_CREATE_USER_ERROR", "创建用户失败"),
|
||||
FINE_CONNECT_LIST_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53038", "FINE_CONNECT_LIST_ERROR", "获取finebi数据库连接列表错误"),
|
||||
FINE_CONNECT_TABLE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53039", "FINE_CONNECT_TABLE_ERROR", "获取finebi数据库对应表列表错误"),
|
||||
FINE_ADD_GROUP_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53040", "FINE_ADD_GROUP_ERROR", "添加分组报错"),
|
||||
FINE_ADD_PACK_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53041", "FINE_ADD_PACK_ERROR", "添加业务包报错"),
|
||||
FINE_DELETE_USER_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53042", "FINE_DELETE_USER_ERROR", "删除用户失败"),
|
||||
FINE_ADD_DB_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53043", "FINE_ADD_DB_ERROR", "数据集已存在,请不要重复添加"),
|
||||
FINE_GET_TABLE_INFO_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53044", "FINE_GET_TABLE_INFO_ERROR", "数据集表信息错误"),
|
||||
LABEL_OBJNAME_IS_CHINESE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53045", "LABEL_OSS_ANALYSIS_FAIL", "名称不能包含特殊字符(下划线,横杠,加号 除外)"),
|
||||
MEASURE_EXCEL_READ_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53046", "MEASURE_EXCEL_READ_ERROR", "文件读取失败,请按照模板重新上传!(是否有空值或重复数据或数据超过指定长度)"),
|
||||
MEASURE_UPDATE_STATUS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53047", "MEASURE_UPDATE_STATUS_ERROR", "当前状态不允许更新指标"),
|
||||
FINE_ADD_TABLE_ROW_AUTHORITY_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53048", "FINE_ADD_TABLE_ROW_AUTHORITY_ERROR", "数据集添加行权限错误"),
|
||||
FINE_GET_ENTRY_TREE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53049", "fine_get_entry_tree_error", "bi获取目录报错"),
|
||||
FINE_ENTRY_AUTH_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53050", "FINE_ENTRY_AUTH_ERROR", "目录授权失败"),
|
||||
OAR_ORG_AUTH_LIST_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53051", "oar_org_auth_list_repeat", "适用机构重复"),
|
||||
|
||||
ACCOUNT_INFO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630005", "ACCOUNT_INFO_BY_ACC_ID_NULL", "调用运营支撑域获取信息为空"),
|
||||
ROLE_CODE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630005", "ACCOUNT_INFO_BY_ACC_ID_NULL", "用户对应角色为空"),
|
||||
ROLE_ORG_CODE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630005", "ACCOUNT_INFO_BY_ACC_ID_NULL", "工作组对应組员为空"),
|
||||
USER_ROLE_ORG_CODE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630008", "ACCOUNT_INFO_BY_ACC_ID_NULL", "角色对应机构为空"),
|
||||
OSS_ANALYSIS_FAIL(ErrorLevels.ERROR, ErrorTypes.BIZ, "50", "OSS_ANALYSIS_FAIL", "excel不能为空"),
|
||||
OAR_OFFLINE_CONFIG_NAME_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "630009", "OAR_OFFLINE_CONFIG_NAME_REPEAT", "名称重复"),
|
||||
OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR1(ErrorLevels.ERROR, ErrorTypes.BIZ, "630009", "OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR1", "统计报表维度和度量不能为空"),
|
||||
OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR2(ErrorLevels.ERROR, ErrorTypes.BIZ, "630009", "OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR2", "清单报表维度和度量至少一个不能为空"),
|
||||
OAR_OFFLINE_CONFIG_CONDITION_VALUE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "6300010", "OAR_OFFLINE_CONFIG_CONDITION_VALUE_NULL", "筛选条件值不能为空"),
|
||||
OAR_OFFLINE_CONFIG_NAME_NOT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630006", "OAR_OFFLINE_CONFIG_NAME_NOT_NULL", "任务名称不能为空"),
|
||||
OAR_OFFLINET_SQL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "6300013", "OAR_OFFLINET_SQL_ERROR", "离线任务运行报错"),
|
||||
|
||||
OFFLINE_ERRORL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630011", "OFFLINE_ERRORL", "更新失敗"),
|
||||
SEND_MESSAGE(ErrorLevels.ERROR, ErrorTypes.BIZ, "630012", "SEND_MESSAGE", "获取对应wrapper 异常"),
|
||||
OAR_OFFLINE_CONFIG_DETAIL_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "630014", "oar_offline_config_detail_repeat", "该模板所选字段并无更改,请通过原模板 \"离线取数\" 功能提交离线任务!"),
|
||||
|
||||
EXCEL_TYPE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "100", "EXCEL_TYPE_ERROR", "报表类型不正确"),
|
||||
EXCEL_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "101", "EXCEL_DELETE", "行业数据删除失败"),
|
||||
DATA_EXCEL_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "102", "DATA_EXCEL_DELETE", "业务数据删除失败"),
|
||||
IMPORT_DATA_EXCEL(ErrorLevels.ERROR, ErrorTypes.BIZ, "103", "IMPORT_DATA_EXCEL", "业务数据导入失败"),
|
||||
UPDATE_DATA_EXCEL(ErrorLevels.ERROR, ErrorTypes.BIZ, "104", "UPDATE_DATA_EXCEL", "业务数据更新失败"),
|
||||
INSTITUTION_CODE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "105", "INSTITUTION_CODE_ERROR", "行机构编码错误!"),
|
||||
DATA_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "106", "DATA_EMPTY", "模板存在空值,请检查并补充完整;"),
|
||||
NUMBER_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "107", "NUMBER_EMPTY", "电融(万元)&网销(万元)&车商(万元)&线下(万元)&中介(万元)&重客(万元)总和不等于该行合计值"),
|
||||
DATA_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "108", "DATA_EXIST", "模板存在重复项,请检查更新!"),
|
||||
VELOCITY_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "109", "VELOCITY_ERROR", "模板转换失败"),
|
||||
PLAN_TYPE_DATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "110", "PLAN_TYPE_DATE", "计划周期格式错误!"),
|
||||
WEEK_XUN_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "111", "WEEK_XUN_ERROR", "你所传的文件不是周旬报"),
|
||||
TOPIC_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "112", "TOPIC_ERROR", "主题不匹配"),
|
||||
CALIBER_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "113", "CALIBER_ERROR", "指标口径不匹配"),
|
||||
DATA_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "114", "DATA_ERROR", "报表缺失月份数据"),
|
||||
DATA_IS_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "115", "DATA_IS_EXIST", "数据已存在"),
|
||||
|
||||
DEPT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53049", "DEPT_NULL", "当前该账户尚未授权,请联系管理员申请权限!"),
|
||||
MEMBER_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53050", "MEMBER_NULL", "对应组员为空"),
|
||||
ORG_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53050", "MEMBER_NULL", "用戶对应机构权限为空"),
|
||||
DATA_AUTHRIZATION(ErrorLevels.ERROR, ErrorTypes.BIZ, "53051", "DATA_AUTHRIZATION", "数据集授权"),
|
||||
GROUP_FLAG(ErrorLevels.ERROR, ErrorTypes.BIZ, "53052", "DATA_AUTHRIZATION", "工作组失效"),
|
||||
DATA_USER_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53053", "DATA_AUTHRIZATION", "数据为空"),
|
||||
DATA_UPDATE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53054", "DATA_AUTHRIZATION", "数据为空。"),
|
||||
DATA_COLLECT_AUTH_IS(ErrorLevels.ERROR, ErrorTypes.BIZ, "53055", "DATA_COLLECT_AUTH_IS", "对应数据集和仪表板已经授权完成"),
|
||||
DATA_COLLECT_AUTH_IS_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53056", "DATA_COLLECT_AUTH_IS_NULL", "对应数据为空"),
|
||||
DATA_PRODUCT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53057", "DATA_PRODUCT_NULL", "产品权限为空"),
|
||||
IMPORT_DATA_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53058", "IMPORT_DATA_NULL", "导入数据为空"),
|
||||
IMPORT_DATA_IS_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53059", "IMPORT_DATA_IS_NULL", "对应数据为空"),
|
||||
IMPORT_REPEAT_DATA(ErrorLevels.ERROR, ErrorTypes.BIZ, "53060", "IMPORT_REPEAT_DATA", "重复数据"),
|
||||
DATA_IS_INVALID(ErrorLevels.ERROR, ErrorTypes.BIZ, "53061", "DATA_IS_INVALID", "对应清单失效,请创建新的模板"),
|
||||
DATA_AUTH_USER_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53062", "data_auth_user_null", "用户组没有匹配到有权限的数据集"),
|
||||
FILE_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53063", "FILE_NOT_EXIST", "字段文件下载失败"),
|
||||
EXCEL_FIELD_ANALYTICS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53066", "EXCEL_FIELD_ANALYTICS_ERROR", "excel解析异常,请检查内容"),
|
||||
TASK_TIME_ROLE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53067", "TASK_TIME_ROLE", "请设置定时任务日期滚动规则后再提交"),
|
||||
TASK_TEMPLATE_CREATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53067", "TASK_TIME_ROLE", "支持1~50个字符!"),
|
||||
IMPORT_DATA_LENGTH(ErrorLevels.ERROR, ErrorTypes.BIZ, "53068", "IMPORT_DATA_LENGTH", "字段说明长度支持100个字符!"),
|
||||
FILE_NAME_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53069", "FILE_NAME_ERROR", "文件命名错误"),
|
||||
FILE_NAME_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53070", "FILE_NAME_REPEAT", "存在相同命名的文件,请检查后重更新上传!"),
|
||||
INDICATORCARD_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53071", "INDICATORCARD_NULL", "指标卡为空!"),
|
||||
INDICATORCARD_DATA_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53072", "INDICATORCARD_DATA_ERROR", "指标数据请求异常!"),
|
||||
ANALYSISITEMPLATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53073", "ANALYSISITEMPLATE_ERROR", "模板创建DB失败!"),
|
||||
INDICATORCARD_DB_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53074", "INDICATORCARD_DB_ERROR", "指标卡DB操作异常!"),
|
||||
INDICATORCARD_WARNING_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53075", "INDICATORCARD_WARNING_NULL", "预警已存在!"),
|
||||
RESOURCE_NO_GENERATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53076", "RESOURCE_NO_GENERATE_ERROR", "业务编码生成异常,请联系管理员"),
|
||||
INDICATOR_DATASERVICE_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53077", "INDICATOR_DATASERVICE_NO_NULL", "服务编码不能为空!"),
|
||||
INDICATOR_DT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53078", "INDICATOR_DT_NULL", "指标数据DT时间为空!"),
|
||||
INDICATOR_HOST_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53079", "INDICATOR_HOST_NULL", "主指标不能为空!"),
|
||||
INDICATOR_CARD_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53080", "INDICATOR_CARD_NO_NULL", "指标卡编码不能为空!"),
|
||||
INDICATOR_CARD_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53081", "INDICATOR_CARD_NULL", "无匹配的指标卡!"),
|
||||
INDICATOR_DATAFILE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53082", "INDICATOR_DATAFILE_NULL", "返回数据中没有指标字段!"),
|
||||
INDICATOR_DT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53083", "INDICATOR_DT_ERROR", "请选择正确的DT或者服务编码!"),
|
||||
DRILLINGCONFIG_INDICATOR_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53084", "DRILLINGCONFIG_INDICATOR_NULL", "下钻配置字段未匹配到指标字段!"),
|
||||
DUTIES_UPDATE_IDS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53085", "DUTIES_UPDATE_IDS_ERROR", "入参ids不能为空"),
|
||||
DUTIES_MEASURES_UPDATE_LIST_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53086", "DUTIES_MEASURES_UPDATE_LIST_ERROR", "举措信息不能为空"),
|
||||
INDICATOR_WARN_CREATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53087", "INDICATOR_WARN_CREATE_ERROR", "保存指标预警规则失败"),
|
||||
INDICATOR_WARN_UPDATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53088", "INDICATOR_WARN_UPDATE_ERROR", "指标预警规则更新失败"),
|
||||
INDICATOR_WARN_RESULT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53089", "INDICATOR_WARN_RESULT_ERROR", "指标预警结果查询失败"),
|
||||
INDICATOR_WARN_DEL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53090", "INDICATOR_WARN_DEL_ERROR", "指标预警删除失败"),
|
||||
INDICATOR_WARN_NULL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53091", "INDICATOR_WARN_NULL_ERROR", "请求预警中心参数为空"),
|
||||
MESSAGE_DING_PUSH_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53092", "MESSAGE_DING_PUSH_ERROR", "钉钉消息推送失败"),
|
||||
INDICATORCARD_UPDATESTATUSOREFFECT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53093", "INDICATORCARD_UPDATESTATUSOREFFECT_ERROR", "指标卡状态更新或删除失败"),
|
||||
INDICATORCARD_INVALID_OPERATION(ErrorLevels.ERROR, ErrorTypes.BIZ, "53094", "INDICATORCARD_INVALID_OPERATION", "指标卡状态更新或删除无效的操作"),
|
||||
DUTIES_CREATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53095", "DUTIES_CREATE_ERROR", "一键通知失败!"),
|
||||
DUTIES_MEASURES_SOLVETIME_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53096", "DUTIES_MEASURES_SOLVETIME_ERROR", "请选择正确的举措时间"),
|
||||
USER_INFO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53097", "USER_INFO_NULL", "用户信息不能为空!"),
|
||||
EXIST_GOAL_CONFIG(ErrorLevels.ERROR, ErrorTypes.BIZ, "53098", "EXIST_GOAL_CONFIG", "已存在该年度的目标计划!"),
|
||||
DATASERVICE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53099", "DATASERVICE_NULL", "数据服务不存在!"),
|
||||
DATASERVICE_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53100", "DATASERVICE_NO_NULL", "服务编码不存在!"),
|
||||
ANALYSISTEMPLATE_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53101", "ANALYSISTEMPLATE_NO_NULL", "模板不存在!"),
|
||||
INDICATORCARWRAINGONE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53102", "INDICATORCARWRAINGONE", "一个指标卡只支持一个预警指标!"),
|
||||
TESTDRILLINGDATA_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53103", "TESTDRILLINGDATA_ERROR", "下钻服务测试失败!"),
|
||||
DRILLINGCONFIG_ORGLEVE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53104", " DRILLINGCONFIG_ORGLEVE_ERROR", "下钻机构权限勾选不正确!"),
|
||||
BRANCH_ORGANIZATION_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53105", "BRANCH_ORGANIZATION_ERROR", "获取用户配置机构信息!"),
|
||||
USER_NOT_FOUND(ErrorLevels.ERROR, ErrorTypes.BIZ, "53106", "USER_NOT_FOUND", "用户不存在"),
|
||||
OLD_PASSWORD_INCORRECT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53107", "OLD_PASSWORD_INCORRECT", "旧密码不正确"),
|
||||
;
|
||||
|
||||
|
||||
private String codeType;
|
||||
|
||||
private String codeLevel;
|
||||
|
||||
private String code;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
private String errorDesc;
|
||||
|
||||
/**
|
||||
* DataplatformLabelErrorEnum
|
||||
*
|
||||
* @param codeLevel
|
||||
* @param codeType
|
||||
* @param code
|
||||
* @param errorMessage
|
||||
* @param errorDesc
|
||||
*/
|
||||
ElectromagneticErrorEnum(String codeLevel, String codeType, String code, String errorMessage, String errorDesc) {
|
||||
|
||||
this.codeType = codeType;
|
||||
this.codeLevel = codeLevel;
|
||||
this.code = code;
|
||||
this.errorMessage = errorMessage;
|
||||
this.errorDesc = errorDesc;
|
||||
}
|
||||
|
||||
public void setErrorDesc(String errorDesc) {
|
||||
this.errorDesc = errorDesc;
|
||||
}
|
||||
|
||||
public ElectromagneticErrorEnum changeErrorDesc(String str) {
|
||||
this.setErrorDesc(str);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
public interface ErrorEnum {
|
||||
|
||||
String getCodeType();
|
||||
|
||||
String getCodeLevel();
|
||||
|
||||
String getCode();
|
||||
|
||||
String getErrorMessage();
|
||||
|
||||
String getErrorDesc();
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
/**
|
||||
* @author wsk
|
||||
* @version $Id: ErrorLevels.java, v 0.1 2024-10-17 17:44 wsk
|
||||
*/
|
||||
public interface ErrorLevels {
|
||||
|
||||
/**
|
||||
* INFO级别
|
||||
*/
|
||||
public static final String INFO = "1";
|
||||
|
||||
/**
|
||||
* WARN级别
|
||||
*/
|
||||
public static final String WARN = "3";
|
||||
|
||||
/**
|
||||
* ERROR级别
|
||||
*/
|
||||
public static final String ERROR = "5";
|
||||
|
||||
/**
|
||||
* FATAL级别
|
||||
*/
|
||||
public static final String FATAL = "7";
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
public interface ErrorTypes {
|
||||
|
||||
/**
|
||||
* 系统错误
|
||||
*/
|
||||
public static final String SYSTEM = "0";
|
||||
|
||||
/**
|
||||
* 业务错误
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String BIZ = "1";
|
||||
|
||||
/**
|
||||
* 第三方错误
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String THIRD_PARTY = "2";
|
||||
|
||||
/**
|
||||
* 业务错误,客户感知
|
||||
*/
|
||||
public static final String BIZ_CUSTOMER = "9";
|
||||
}
|
||||
|
|
@ -6,7 +6,8 @@ import lombok.AllArgsConstructor;
|
|||
public enum FileBackupSource {
|
||||
|
||||
SYS_BACKUP(0, "系统备份"),
|
||||
REMOVE(1, "删除文件");
|
||||
REMOVE(1, "删除文件"),
|
||||
SQL(2, "sql文件");
|
||||
|
||||
public int code;
|
||||
public String desc;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -48,13 +50,18 @@ public enum FilePermission {
|
|||
public static List<String> getAllCodesExcludeView() {
|
||||
List<String> codes = new ArrayList<>();
|
||||
for (FilePermission permission : FilePermission.values()) {
|
||||
if (!permission.getCode().equals("view")) {
|
||||
if (StrUtil.equals(permission.getCode(), "view")) {
|
||||
codes.add(permission.getCode());
|
||||
}// 获取每个枚举实例的 code
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
|
||||
// 转换成权限描述
|
||||
public static String toDescription(String code) {
|
||||
return fromCode(code).getDescription();
|
||||
}
|
||||
|
||||
// 获取权限代码
|
||||
public String getCode() {
|
||||
return code;
|
||||
|
|
@ -64,10 +71,5 @@ public enum FilePermission {
|
|||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
// 转换成权限描述
|
||||
public static String toDescription(String code) {
|
||||
return fromCode(code).getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ import lombok.AllArgsConstructor;
|
|||
public enum FileRepeatEnum {
|
||||
|
||||
IGNORE(1, "跳过所有冲突文件"),
|
||||
VERSION(2, "所有冲突文件版本更新"),
|
||||
REVERSION(2, "所有冲突文件版本更新"),
|
||||
NEW(3, "重命名所有冲突文件, 文件后加“_1”");
|
||||
|
||||
public int code;
|
||||
public String desc;
|
||||
|
||||
|
|
@ -20,4 +21,13 @@ public enum FileRepeatEnum {
|
|||
return "";
|
||||
}
|
||||
|
||||
public static boolean contains(int code) {
|
||||
for (FileRepeatEnum e : FileRepeatEnum.values()) {
|
||||
if (e.code == code) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ public enum PrjQuerySource {
|
|||
SYS_PRJ(0),
|
||||
SYS_DB(1),
|
||||
USER_PRJ(2),
|
||||
USER_DB(3);
|
||||
USER_DB(3),
|
||||
REPO_PRJ(4),
|
||||
REPO_DB(5);
|
||||
|
||||
public final int value;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ public enum TagTypeEnum {
|
|||
/**
|
||||
* 标签组
|
||||
*/
|
||||
GROUP (0),
|
||||
GROUP(0),
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
TAG (1);
|
||||
TAG(1);
|
||||
|
||||
private final Integer code;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,22 +7,26 @@ import java.util.Objects;
|
|||
@AllArgsConstructor
|
||||
public enum UserOperationModuleEnum {
|
||||
|
||||
PRJ_SETTING("prjSetting", "层级定义"),
|
||||
SYS_PRJ_SETTING("sys_prj_setting", "数据库层级定义"),
|
||||
SYS_PRJ_DATABASE("sys_prj_database", "数据库管理"),
|
||||
|
||||
REPO_PRJ_DATABASE("repo_prj_database", "库数据管理"),
|
||||
REPO_PRJ_SETTING("repo_prj_setting", "库数据层级定义"),
|
||||
|
||||
USER_PRJ("user_prj", "个人数据"),
|
||||
UNKNOWN("unknown", "未分组"),
|
||||
DATABASE("database", "数据库管理"),
|
||||
|
||||
USER("user", "人员管理"),
|
||||
USER_PRJ("userPrj", "个人数据"),
|
||||
TAG("tag","标签管理"),
|
||||
|
||||
TAG("tag", "标签管理"),
|
||||
LOG("log", "操作记录审计"),
|
||||
TMP("tmp", "临时文件"),
|
||||
BACKUP_FILE("backupFile", "系统文件备份"),
|
||||
BACKUP_FILE("backup_file", "系统文件备份"),
|
||||
PERMISSION("permission", "权限管理");
|
||||
|
||||
|
||||
public final String key;
|
||||
public final String desc;
|
||||
|
||||
|
||||
public static String getDesc(String key) {
|
||||
for (UserOperationModuleEnum e : UserOperationModuleEnum.values()) {
|
||||
if (Objects.equals(e.key, key)) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class ExcelParse extends FileParse {
|
|||
}
|
||||
return OfficeFileUtil.parseXlsAllText(fileTmpPath);
|
||||
} catch (Exception e) {
|
||||
log.error("解析{}格式的excel错误,具体为{}",fileType, e.getMessage(), e);
|
||||
log.error("解析{}格式的excel错误,具体为{}", fileType, e.getMessage(), e);
|
||||
} finally {
|
||||
FileUtil.del(fileTmpPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,16 @@ import cn.hutool.core.util.IdUtil;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class FileParse {
|
||||
|
||||
private static String tmpPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
|
||||
private static String tmpPath = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("")).getPath();
|
||||
|
||||
public abstract String parseAllText(InputStream stream, String fileType);
|
||||
|
||||
protected String createFileTmpPath(String fileType) {
|
||||
tmpPath = FileUtil.getParent(tmpPath, 3) + File.separator + "tmp" + File.separator + IdUtil.simpleUUID() + "." + fileType;
|
||||
tmpPath = FileUtil.getParent(tmpPath, 3) + File.separator + "tmp" + File.separator + IdUtil.simpleUUID() + "." + fileType;
|
||||
return tmpPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class PptParse extends FileParse {
|
|||
FileUtil.writeFromStream(stream, fileTmpPath);
|
||||
res = fileType.endsWith("pptx") ? OfficeFileUtil.parsePptxAllText(fileTmpPath) : OfficeFileUtil.parsePptAllText(fileTmpPath);
|
||||
} catch (Exception e) {
|
||||
log.error("解析{}格式的ppt错误,具体为{}",fileType, e.getMessage(), e);
|
||||
log.error("解析{}格式的ppt错误,具体为{}", fileType, e.getMessage(), e);
|
||||
} finally {
|
||||
FileUtil.del(fileTmpPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ public class TextParse extends FileParse {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ import java.util.regex.Pattern;
|
|||
public final class EleCommonUtil {
|
||||
|
||||
private static final Map<String, FileParse> PARSE_MAP = new HashMap<>();
|
||||
// 正则表达式模式,匹配中文字符、下划线、连字符、加号、数字和英文字符
|
||||
private static final String PATTERN = "^[\\u4e00-\\u9fa5a-zA-Z0-9._\\-+]+$";
|
||||
private static final String TIME_FORMAT1 = "yyMMddHHmmssSSS";
|
||||
// 编译正则表达式
|
||||
private static final Pattern pattern = Pattern.compile(PATTERN);
|
||||
private static EleLog log = new EleLog(EleCommonUtil.class);
|
||||
|
||||
static {
|
||||
PARSE_MAP.put("doc", new WordParse());
|
||||
|
|
@ -39,16 +45,6 @@ public final class EleCommonUtil {
|
|||
PARSE_MAP.put("pdf", new PdfParse());
|
||||
}
|
||||
|
||||
// 正则表达式模式,匹配中文字符、下划线、连字符、加号、数字和英文字符
|
||||
private static final String PATTERN = "^[\\u4e00-\\u9fa5a-zA-Z0-9._\\-+]+$";
|
||||
|
||||
private static final String TIME_FORMAT1 = "yyMMddHHmmssSSS";
|
||||
|
||||
// 编译正则表达式
|
||||
private static final Pattern pattern = Pattern.compile(PATTERN);
|
||||
|
||||
private static EleLog log = new EleLog(EleCommonUtil.class);
|
||||
|
||||
public static boolean isFileNameValid(String fileFullName) {
|
||||
if (StrUtil.isEmpty(fileFullName) || fileFullName.length() > 32) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -15,27 +15,6 @@ public class EleLog {
|
|||
this.logger = LoggerFactory.getLogger(clazz);
|
||||
}
|
||||
|
||||
public void info(String msg, Object... args) {
|
||||
logger.info(format(msg, args));
|
||||
}
|
||||
|
||||
public void debug(String msg, Object... args) {
|
||||
logger.debug(format(msg, args));
|
||||
}
|
||||
|
||||
public void warn(String msg, Object... args) {
|
||||
logger.warn(format(msg, args));
|
||||
}
|
||||
|
||||
public void error(String msg, Object... args) {
|
||||
logger.error(format(msg, args));
|
||||
}
|
||||
|
||||
public void error(String msg, Throwable e, Object... args) {
|
||||
String info = format(msg, args);
|
||||
logger.error(info, e);
|
||||
}
|
||||
|
||||
private static String format(String strPattern, Object... argArray) {
|
||||
if (!StrUtil.isBlank(strPattern) && !StrUtil.isBlank(PLACE_HOLDER) && !ArrayUtil.isEmpty(argArray)) {
|
||||
int strPatternLength = strPattern.length();
|
||||
|
|
@ -43,7 +22,7 @@ public class EleLog {
|
|||
StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
|
||||
int handledPosition = 0;
|
||||
|
||||
for(int argIndex = 0; argIndex < argArray.length; ++argIndex) {
|
||||
for (int argIndex = 0; argIndex < argArray.length; ++argIndex) {
|
||||
int delimIndex = strPattern.indexOf(PLACE_HOLDER, handledPosition);
|
||||
if (delimIndex == -1) {
|
||||
if (handledPosition == 0) {
|
||||
|
|
@ -78,4 +57,25 @@ public class EleLog {
|
|||
return strPattern;
|
||||
}
|
||||
}
|
||||
|
||||
public void info(String msg, Object... args) {
|
||||
logger.info(format(msg, args));
|
||||
}
|
||||
|
||||
public void debug(String msg, Object... args) {
|
||||
logger.debug(format(msg, args));
|
||||
}
|
||||
|
||||
public void warn(String msg, Object... args) {
|
||||
logger.warn(format(msg, args));
|
||||
}
|
||||
|
||||
public void error(String msg, Object... args) {
|
||||
logger.error(format(msg, args));
|
||||
}
|
||||
|
||||
public void error(String msg, Throwable e, Object... args) {
|
||||
String info = format(msg, args);
|
||||
logger.error(info, e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
import com.electromagnetic.industry.software.common.enums.ErrorEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
|
||||
public class ElectromagneticResultUtil {
|
||||
|
|
@ -21,14 +20,4 @@ public class ElectromagneticResultUtil {
|
|||
return electromagneticResult;
|
||||
}
|
||||
|
||||
public static <T> ElectromagneticResult fail(ErrorEnum errorEnum) {
|
||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||
electromagneticResult.setSuccess(false);
|
||||
electromagneticResult.setErrorCode(errorEnum.getCode());
|
||||
electromagneticResult.setErrorMessage(errorEnum.getErrorMessage());
|
||||
return electromagneticResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
|
|
@ -37,8 +40,8 @@ public class OfficeFileUtil {
|
|||
if (EleCommonUtil.isWinOs()) {
|
||||
File inputWord = new File(wordPath);
|
||||
File outputFile = new File(pdfPath);
|
||||
try(InputStream docxInputStream = Files.newInputStream(inputWord.toPath());
|
||||
OutputStream outputStream = Files.newOutputStream(outputFile.toPath())) {
|
||||
try (InputStream docxInputStream = Files.newInputStream(inputWord.toPath());
|
||||
OutputStream outputStream = Files.newOutputStream(outputFile.toPath())) {
|
||||
IConverter build = LocalConverter.builder().build();
|
||||
boolean execute = build.convert(docxInputStream)
|
||||
.as(DocumentType.DOCX)
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ public class UserThreadLocal {
|
|||
}
|
||||
|
||||
public static String getUserId() {
|
||||
|
||||
// return "1876888149980930048";
|
||||
return userThread.get().getUserId();
|
||||
}
|
||||
|
||||
|
|
@ -46,14 +44,14 @@ public class UserThreadLocal {
|
|||
return userThread.get().getResult();
|
||||
}
|
||||
|
||||
public static void setReqArgs(String args) {
|
||||
userThread.get().setReqArgs(args);
|
||||
}
|
||||
|
||||
public static String getReqArgs() {
|
||||
return userThread.get().getReqArgs();
|
||||
}
|
||||
|
||||
public static void setReqArgs(String args) {
|
||||
userThread.get().setReqArgs(args);
|
||||
}
|
||||
|
||||
public static void setSuccessInfo(String parentId, String dataId, String strPattern, Object... argArray) {
|
||||
parentId = StrUtil.isEmpty(parentId) ? "" : parentId;
|
||||
dataId = StrUtil.isEmpty(dataId) ? "" : dataId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue