Compare commits
2 Commits
4bd12e3761
...
dc7d061be2
| Author | SHA1 | Date |
|---|---|---|
|
|
dc7d061be2 | |
|
|
543d253ac4 |
|
|
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/data/ed/format")
|
@RequestMapping("/data/ed/file/format")
|
||||||
public class FileFormatController {
|
public class FileFormatController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -19,13 +19,13 @@ public class FileFormatController {
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@UserOperation(value = "新增文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "新增文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
public ElectromagneticResult<?> addFileFormat(@RequestBody FileFormat fileFormat) {
|
public ElectromagneticResult<?> addFileFormat(@RequestParam String suffixName) {
|
||||||
return ElectromagneticResultUtil.success(fileFormatService.addFileFormat(fileFormat));
|
return ElectromagneticResultUtil.success(fileFormatService.addFileFormat(suffixName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/delete/{id}")
|
@GetMapping("/delete")
|
||||||
@UserOperation(value = "删除文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "删除文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
public ElectromagneticResult<?> deleteFileFormat(@PathVariable String id) {
|
public ElectromagneticResult<?> deleteFileFormat(@RequestParam String id) {
|
||||||
return ElectromagneticResultUtil.success(fileFormatService.deleteFileFormat(id));
|
return ElectromagneticResultUtil.success(fileFormatService.deleteFileFormat(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,10 +34,10 @@ public class FileFormatController {
|
||||||
public ElectromagneticResult<?> list() {
|
public ElectromagneticResult<?> list() {
|
||||||
return ElectromagneticResultUtil.success(fileFormatService.getList());
|
return ElectromagneticResultUtil.success(fileFormatService.getList());
|
||||||
}
|
}
|
||||||
|
//
|
||||||
@PostMapping("/edit")
|
// @PostMapping("/edit")
|
||||||
@UserOperation(value = "修改文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
// @UserOperation(value = "修改文件格式", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
public ElectromagneticResult<?> editFileFormat(@RequestBody FileFormat fileFormat) {
|
// public ElectromagneticResult<?> editFileFormat(@RequestBody FileFormat fileFormat) {
|
||||||
return ElectromagneticResultUtil.success(fileFormatService.updateFileFormat(fileFormat));
|
// return ElectromagneticResultUtil.success(fileFormatService.updateFileFormat(fileFormat));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,26 +2,20 @@ package com.electromagnetic.industry.software.manage.pojo.models;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@TableName("ed_file_format")
|
@TableName("ed_file_format")
|
||||||
public class FileFormat {
|
public class FileFormat extends BaseModel {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_UUID)
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String fileSuffix;
|
private String suffixNo;
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
private String suffixName;
|
||||||
private Date createdTime;
|
|
||||||
|
|
||||||
private String createdBy;
|
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private Date updatedTime;
|
|
||||||
|
|
||||||
private String updatedBy;
|
|
||||||
|
|
||||||
|
private Integer effectFlag;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
||||||
public class FileFormatVO {
|
public class FileFormatVO {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String fileSuffix;
|
private String suffixNo;
|
||||||
|
|
||||||
private String systemNumber;
|
private String suffixName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileProjectVO;
|
import com.electromagnetic.industry.software.manage.pojo.resp.FileProjectVO;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO;
|
import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO;
|
||||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||||
|
|
@ -39,31 +40,8 @@ import static com.electromagnetic.industry.software.common.cons.ElectromagneticC
|
||||||
@Component
|
@Component
|
||||||
public class CommonService {
|
public class CommonService {
|
||||||
|
|
||||||
private static final Map<String, String> FILE_TYPE_ENUM = new HashMap<>();
|
|
||||||
|
|
||||||
private static final Map<Integer, String> PATH_MAP = new HashMap<>();
|
private static final Map<Integer, String> PATH_MAP = new HashMap<>();
|
||||||
|
|
||||||
static {
|
|
||||||
FILE_TYPE_ENUM.put(EleDataTypeEnum.FOLDER.desc, "01");
|
|
||||||
FILE_TYPE_ENUM.put("py", "02");
|
|
||||||
FILE_TYPE_ENUM.put("zip", "03");
|
|
||||||
FILE_TYPE_ENUM.put("jpg", "04");
|
|
||||||
FILE_TYPE_ENUM.put("jpeg", "05");
|
|
||||||
FILE_TYPE_ENUM.put("png", "06");
|
|
||||||
FILE_TYPE_ENUM.put("gif", "07");
|
|
||||||
FILE_TYPE_ENUM.put("bmp", "08");
|
|
||||||
FILE_TYPE_ENUM.put("tif", "09");
|
|
||||||
FILE_TYPE_ENUM.put("tiff", "10");
|
|
||||||
FILE_TYPE_ENUM.put("svg", "11");
|
|
||||||
FILE_TYPE_ENUM.put("psd", "12");
|
|
||||||
FILE_TYPE_ENUM.put("pdf", "13");
|
|
||||||
FILE_TYPE_ENUM.put("doc", "14");
|
|
||||||
FILE_TYPE_ENUM.put("docx", "15");
|
|
||||||
FILE_TYPE_ENUM.put("xls", "16");
|
|
||||||
FILE_TYPE_ENUM.put("xlsx", "17");
|
|
||||||
FILE_TYPE_ENUM.put("ppt", "18");
|
|
||||||
FILE_TYPE_ENUM.put("pptx", "19");
|
|
||||||
}
|
|
||||||
|
|
||||||
private final EleLog log = new EleLog(CommonService.class);
|
private final EleLog log = new EleLog(CommonService.class);
|
||||||
@Value("${prj.folder.max.length}")
|
@Value("${prj.folder.max.length}")
|
||||||
|
|
@ -78,6 +56,9 @@ public class CommonService {
|
||||||
@Resource
|
@Resource
|
||||||
private FileSystemService fileSystemService;
|
private FileSystemService fileSystemService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileFormatService fileFormatService;
|
||||||
|
|
||||||
public String getEleDataPath(int dataOwnCode) {
|
public String getEleDataPath(int dataOwnCode) {
|
||||||
return PATH_MAP.get(dataOwnCode);
|
return PATH_MAP.get(dataOwnCode);
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +122,9 @@ public class CommonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createFileCode(String parentId, String fileType, int version, String timeStr) {
|
public String createFileCode(String parentId, String fileType, int version, String timeStr) {
|
||||||
return parentId + FILE_TYPE_ENUM.getOrDefault(fileType, "00") + version + timeStr;
|
FileFormat fileFormat = fileFormatService.getBaseMapper().selectOne(Wrappers.lambdaQuery(FileFormat.class).eq(FileFormat::getSuffixNo, fileType));
|
||||||
|
Assert.notNull(fileFormat, "不支持当前格式 {}");
|
||||||
|
return parentId + fileFormat.getSuffixNo() + version + timeStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EdFileInfo> selectAllAdminFolder(String id, List<String> accessibleIds, int dataOwnCode) {
|
public List<EdFileInfo> selectAllAdminFolder(String id, List<String> accessibleIds, int dataOwnCode) {
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ public interface FileFormatService extends IService<FileFormat> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件格式
|
* 创建文件格式
|
||||||
* @param fileFormat
|
* @param suffixName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean addFileFormat(FileFormat fileFormat);
|
boolean addFileFormat(String suffixName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文件格式
|
* 删除文件格式
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,57 @@
|
||||||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.text.StrFormatter;
|
import cn.hutool.core.text.StrFormatter;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.FileFormatMapper;
|
import com.electromagnetic.industry.software.manage.mapper.FileFormatMapper;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
import com.electromagnetic.industry.software.manage.pojo.models.FileFormat;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileFormatVO;
|
import com.electromagnetic.industry.software.manage.pojo.resp.FileFormatVO;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFormat> implements FileFormatService {
|
public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFormat> implements FileFormatService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件格式
|
* 创建文件格式
|
||||||
* @param fileFormat
|
* @param suffixName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean addFileFormat(FileFormat fileFormat) {
|
public boolean addFileFormat(String suffixName) {
|
||||||
fileFormat.setCreatedBy(UserThreadLocal.getUserId());
|
|
||||||
Assert.notNull(fileFormat.getFileSuffix(), "文件格式不能为空");
|
Assert.isTrue(suffixName.matches("^[a-zA-Z0-9]+$"), "文件格式不符合规范");
|
||||||
boolean isSaved = this.save(fileFormat);
|
List<FileFormat> fileFormats = this.baseMapper.selectList(null);
|
||||||
if (isSaved) {
|
List<String> names = fileFormats.stream().map(FileFormat::getSuffixName).collect(Collectors.toList());
|
||||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("添加了文件格式 {} ", fileFormat.getFileSuffix()));
|
|
||||||
|
// 有可能是被废除了,现在恢复
|
||||||
|
if (names.contains(suffixName)) {
|
||||||
|
this.baseMapper.update(null, Wrappers.<FileFormat>lambdaUpdate().set(FileFormat::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||||
|
} else {
|
||||||
|
FileFormat fileFormat = new FileFormat();
|
||||||
|
fileFormat.setSuffixName(suffixName);
|
||||||
|
fileFormat.setEffectFlag(EffectFlagEnum.EFFECT.code);
|
||||||
|
fileFormat.setId(IdWorker.getSnowFlakeIdString());
|
||||||
|
fileFormat.setSuffixNo(createFileFormatNo(fileFormats.size()));
|
||||||
|
this.baseMapper.insert(fileFormat);
|
||||||
}
|
}
|
||||||
return isSaved;
|
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("添加了文件格式 {} ", suffixName));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createFileFormatNo(int size) {
|
||||||
|
if (size >= 0 && size <= 8) {
|
||||||
|
return "0" + (size + 1);
|
||||||
|
}
|
||||||
|
return (size + 1) + "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,30 +61,21 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteFileFormat(String id) {
|
public boolean deleteFileFormat(String id) {
|
||||||
FileFormat fileFormat = getById(id);
|
this.baseMapper.update(null, Wrappers.<FileFormat>lambdaUpdate().eq(FileFormat::getId, id).set(FileFormat::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("删除了文件格式 {} ", fileFormat.getFileSuffix()));
|
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("废除了文件格式,id {} ", id));
|
||||||
return removeById(id);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询了文件格式列表
|
* 查询了文件格式列表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FileFormatVO> getList() {
|
public List<FileFormatVO> getList() {
|
||||||
List<FileFormat> list = this.list();
|
List<FileFormat> fileFormats = this.baseMapper.selectList(Wrappers.<FileFormat>lambdaQuery().eq(FileFormat::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||||
List<FileFormatVO> result = new ArrayList<>();
|
List<FileFormatVO> fileFormatVOS = BeanUtil.copyToList(fileFormats, FileFormatVO.class);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
FileFormat fileFormat = list.get(i);
|
|
||||||
FileFormatVO fileFormatVO = new FileFormatVO();
|
|
||||||
BeanUtils.copyProperties(fileFormat, fileFormatVO);
|
|
||||||
// 生成系统编号
|
|
||||||
fileFormatVO.setSystemNumber(String.format("%02d", i + 1));
|
|
||||||
result.add(fileFormatVO);
|
|
||||||
}
|
|
||||||
UserThreadLocal.setSuccessInfo("","", "查询了文件格式列表");
|
UserThreadLocal.setSuccessInfo("","", "查询了文件格式列表");
|
||||||
return result;
|
return fileFormatVOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,14 +85,8 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean updateFileFormat(FileFormat fileFormat) {
|
public boolean updateFileFormat(FileFormat fileFormat) {
|
||||||
fileFormat.setUpdatedBy(UserThreadLocal.getUserId());
|
return true;
|
||||||
Assert.notNull(fileFormat.getId(), "文件格式ID不能为空");
|
|
||||||
Assert.notEmpty(fileFormat.getFileSuffix(), "文件格式不能为空");
|
|
||||||
boolean isUpdated = updateById(fileFormat);
|
|
||||||
if (isUpdated) {
|
|
||||||
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("修改了文件格式 {} ", fileFormat.getFileSuffix()));
|
|
||||||
}
|
|
||||||
return isUpdated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ public class BackupTask extends ServiceImpl<FileBackupLogMapper, FileBackupLog>
|
||||||
.accessSuccess(true)
|
.accessSuccess(true)
|
||||||
.operationMsg("从系统中物理删除了文件" + file.getName())
|
.operationMsg("从系统中物理删除了文件" + file.getName())
|
||||||
.createTime(new Date())
|
.createTime(new Date())
|
||||||
.operationModule(UserOperationModuleEnum.DATABASE.key)
|
.operationModule(UserOperationModuleEnum.TMP.key)
|
||||||
.dataId("")
|
.dataId("")
|
||||||
.parentId("")
|
.parentId("")
|
||||||
.response("")
|
.response("")
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ public enum UserOperationModuleEnum {
|
||||||
USER_PRJ("userPrj", "个人数据"),
|
USER_PRJ("userPrj", "个人数据"),
|
||||||
TAG("tag","标签管理"),
|
TAG("tag","标签管理"),
|
||||||
LOG("log", "操作记录审计"),
|
LOG("log", "操作记录审计"),
|
||||||
|
TMP("tmp", "临时文件"),
|
||||||
PERMISSION("permission", "权限管理");
|
PERMISSION("permission", "权限管理");
|
||||||
|
|
||||||
public final String key;
|
public final String key;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue