mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增添加余料板、提交保存优化结果文件、开始开料 接口
This commit is contained in:
+7
@@ -3,9 +3,11 @@ package com.cf.imes.module.infra.api.file;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.cf.imes.module.infra.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -57,4 +59,9 @@ public interface FileApi {
|
||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/deleteFileByPath")
|
||||
@Operation(summary = "根据文件地址删除文件")
|
||||
@Parameter(name = "path", description = "文件地址", example = "url", required = true)
|
||||
CommonResult<Boolean> deleteFileByPath(String path);
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1_001_003_000, "文件路径已存在");
|
||||
ErrorCode FILE_NOT_EXISTS = new ErrorCode(1_001_003_001, "文件不存在");
|
||||
ErrorCode FILE_IS_EMPTY = new ErrorCode(1_001_003_002, "文件为空");
|
||||
ErrorCode FILE_REMOVE_FAIL = new ErrorCode(1_001_003_003, "文件删除失败");
|
||||
|
||||
// ========== 代码生成器 1-001-004-000 ==========
|
||||
ErrorCode CODEGEN_TABLE_EXISTS = new ErrorCode(1_003_001_000, "表定义已经存在");
|
||||
|
||||
+5
@@ -23,4 +23,9 @@ public class FileApiImpl implements FileApi {
|
||||
createReqDTO.getContent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteFileByPath(String path) {
|
||||
return success(fileService.deleteFileByPath(path));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -45,4 +45,10 @@ public interface FileService {
|
||||
*/
|
||||
byte[] getFileContent(Long configId, String path) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param path 文件地址
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteFileByPath(String path);
|
||||
}
|
||||
|
||||
+25
@@ -6,6 +6,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.io.FileUtils;
|
||||
import com.cf.imes.framework.file.core.client.FileClient;
|
||||
import com.cf.imes.framework.file.core.utils.FileTypeUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||
import com.cf.imes.module.infra.dal.dataobject.file.FileDO;
|
||||
import com.cf.imes.module.infra.dal.mysql.file.FileMapper;
|
||||
@@ -14,8 +15,11 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
|
||||
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_REMOVE_FAIL;
|
||||
|
||||
/**
|
||||
* 文件 Service 实现类
|
||||
@@ -95,4 +99,25 @@ public class FileServiceImpl implements FileService {
|
||||
return client.getContent(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteFileByPath(String path) {
|
||||
// 校验存在
|
||||
FileDO fileDO = fileMapper.selectOne(new LambdaQueryWrapperX<FileDO>().eq(FileDO::getPath, path));
|
||||
if(Objects.isNull(fileDO)) {
|
||||
throw exception(FILE_NOT_EXISTS);
|
||||
}
|
||||
// 从文件存储器中删除
|
||||
FileClient client = fileConfigService.getFileClient(fileDO.getConfigId());
|
||||
Assert.notNull(client, "客户端({}) 不能为空", fileDO.getConfigId());
|
||||
try {
|
||||
client.delete(path);
|
||||
} catch (Exception e) {
|
||||
throw exception(FILE_REMOVE_FAIL);
|
||||
}
|
||||
|
||||
// 删除记录
|
||||
fileMapper.deleteById(fileDO.getId());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user