mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-28 19:13:46 +00:00
更新
This commit is contained in:
@@ -9,11 +9,8 @@ package com.egridcloud.udf.file;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.egridcloud.udf.file.mate.PathMate;
|
||||
|
||||
@@ -25,7 +22,6 @@ import com.egridcloud.udf.file.mate.PathMate;
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "com.egridcloud.file.properties")
|
||||
@Validated
|
||||
public class FileProperties implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -36,7 +32,6 @@ public class FileProperties implements Serializable {
|
||||
/**
|
||||
* 描述 : 根路径
|
||||
*/
|
||||
@NotNull
|
||||
private String rootPath;
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,6 +104,10 @@ public class FileService {
|
||||
* @param file 文件
|
||||
*/
|
||||
public void verification(String pathCode, MultipartFile file) {
|
||||
//验证根路径是否配置
|
||||
if (fileProperties.getRootPath() == null) {
|
||||
throw new FileException("rootPath not defined");
|
||||
}
|
||||
//验证pathCode是否存在
|
||||
if (!fileProperties.getPath().containsKey(pathCode)) {
|
||||
throw new FileException("pathCode : " + pathCode + " not defined");
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.egridcloud.udf.core.RestResponse;
|
||||
import com.egridcloud.udf.file.FileProperties;
|
||||
import com.egridcloud.udf.file.domain.FileInfo;
|
||||
import com.egridcloud.udf.file.service.FileService;
|
||||
|
||||
@@ -25,6 +26,12 @@ import com.egridcloud.udf.file.service.FileService;
|
||||
@RestController
|
||||
public class FileController implements IFileController {
|
||||
|
||||
/**
|
||||
* 描述 : fileProperties
|
||||
*/
|
||||
@Autowired
|
||||
private FileProperties fileProperties;
|
||||
|
||||
/**
|
||||
* 描述 : fileService
|
||||
*/
|
||||
@@ -37,4 +44,9 @@ public class FileController implements IFileController {
|
||||
return new RestResponse<>(fileService.upload(pathCode, file));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResponse<FileProperties> properties() {
|
||||
return new RestResponse<>(fileProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.egridcloud.udf.core.RestResponse;
|
||||
import com.egridcloud.udf.file.FileProperties;
|
||||
import com.egridcloud.udf.file.domain.FileInfo;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -31,6 +32,22 @@ import io.swagger.annotations.ApiOperation;
|
||||
@RequestMapping(value = "/service/file")
|
||||
public interface IFileController {
|
||||
|
||||
/**
|
||||
* 描述 : 文件配置
|
||||
*
|
||||
* @return 文件配置
|
||||
*/
|
||||
@ApiOperation(value = "FILE_2", notes = "文件配置")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(paramType = "header", name = "rmsApplicationName", value = "rms应用名称",
|
||||
required = true, dataType = "string"),
|
||||
@ApiImplicitParam(paramType = "header", name = "rmsSign", value = "rms认证秘钥", required = true,
|
||||
dataType = "string"),
|
||||
@ApiImplicitParam(paramType = "header", name = "rmsServiceCode", value = "rms接口编号",
|
||||
required = true, dataType = "string") })
|
||||
@RequestMapping(value = "properties", method = RequestMethod.GET)
|
||||
public RestResponse<FileProperties> properties();
|
||||
|
||||
/**
|
||||
* 描述 : 上传文件
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user