This commit is contained in:
Administrator
2017-07-29 10:18:35 +08:00
committed by wangkang
parent e39c997fb5
commit 60954d8cbb
11 changed files with 419 additions and 1 deletions
+1
View File
@@ -28,6 +28,7 @@
<module>udf-starter-rms</module>
<module>udf-starter-cors</module>
<module>udf-starter-amqp-rabbitmq</module>
<module>udf-starter-file</module>
</modules>
<!-- 依赖管理 -->
<dependencyManagement>
@@ -4,7 +4,7 @@
* Created by Administrator
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
package com.egridcloud.udf.core.cors;
package com.egridcloud.udf.cors;
import java.util.Iterator;
import java.util.Map;
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="true">
<fileset name="all" enabled="true" check-config-name="checkstyle.egridcloud.com" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
+4
View File
@@ -0,0 +1,4 @@
/target/
/bin/
/.classpath
/.project
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<!-- maven坐标 -->
<artifactId>udf-starter-file</artifactId>
<name>udf-starter-file</name>
<packaging>jar</packaging>
<url>http://www.egridcloud.com</url>
<!-- 父依赖 -->
<parent>
<groupId>com.egridcloud.udf</groupId>
<artifactId>udf-starter</artifactId>
<version>1.0</version>
</parent>
<!-- 依赖 -->
<dependencies>
<!-- udf-core-starter -->
<dependency>
<groupId>com.egridcloud.udf</groupId>
<artifactId>udf-starter-core</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,66 @@
/**
* FileException.java
* Created at 2016-03-01
* Created by wangkang
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
package com.egridcloud.udf.file;
/**
* <p>
* ClassName: FileException
* </p>
* <p>
* Description: 文件异常
* </p>
* <p>
* Author: wangkang
* </p>
* <p>
* Date: 2016年3月23日
* </p>
*/
public class FileException extends RuntimeException {
/**
* <p>
* Field serialVersionUID: 序列号
* </p>
*/
private static final long serialVersionUID = 1L;
/**
* <p>
* Description: 构造函数
* </p>
*
* @param message 异常信息
*/
public FileException(String message) {
super(message);
}
/**
* <p>
* Description: 构造函数
* </p>
*
* @param cause 堆栈
*/
public FileException(Throwable cause) {
super(cause);
}
/**
* <p>
* Description: 构造函数
* </p>
*
* @param message 异常信息
* @param cause 堆栈
*/
public FileException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -0,0 +1,83 @@
/**
* Config.java
* Created at 2016-11-19
* Created by Administrator
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
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;
/**
* 描述 : Config
*
* @author Administrator
*
*/
@Component
@ConfigurationProperties(prefix = "com.egridcloud.file.properties")
@Validated
public class FileProperties implements Serializable {
/**
* 描述 : ID
*/
private static final long serialVersionUID = 1L;
/**
* 描述 : 根路径
*/
@NotNull
private String rootPath;
/**
* 描述 : 文件路径 ( key : pathCode )
*/
private Map<String, PathMate> path;
/**
* 描述 : 获取rootPath
*
* @return the rootPath
*/
public String getRootPath() {
return rootPath;
}
/**
* 描述 : 设置rootPath
*
* @param rootPath the rootPath to set
*/
public void setRootPath(String rootPath) {
this.rootPath = rootPath;
}
/**
* 描述 : 获取path
*
* @return the path
*/
public Map<String, PathMate> getPath() {
return path;
}
/**
* 描述 : 设置path
*
* @param path the path to set
*/
public void setPath(Map<String, PathMate> path) {
this.path = path;
}
}
@@ -0,0 +1,93 @@
/**
* PathMate.java
* Created at 2017-05-26
* Created by Administrator
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
package com.egridcloud.udf.file.mate;
import java.io.Serializable;
/**
* 描述 : PathMate
*
* @author Administrator
*
*/
public class PathMate implements Serializable {
/**
* 描述 : ID
*/
private static final long serialVersionUID = 1L;
/**
* 描述 : 应用名称
*/
private String owner;
/**
* 描述 : 文件路径
*/
private String path;
/**
* 描述 : 描述
*/
private String description;
/**
* 描述 : 获取owner
*
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* 描述 : 设置owner
*
* @param owner the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* 描述 : 获取path
*
* @return the path
*/
public String getPath() {
return path;
}
/**
* 描述 : 设置path
*
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* 描述 : 获取description
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* 描述 : 设置description
*
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
}
@@ -0,0 +1,48 @@
/**
* FileService.java
* Created at 2017-05-26
* Created by Administrator
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
package com.egridcloud.udf.file.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.egridcloud.udf.file.FileException;
import com.egridcloud.udf.file.FileProperties;
/**
* 描述 : FileService
*
* @author Administrator
*
*/
@Service
public class FileService {
/**
* 描述 : fileProperties
*/
@Autowired
private FileProperties fileProperties;
/**
* 描述 : 验证
*
* @param pathCode 路径代码
* @param file 文件
*/
public void verification(String pathCode, MultipartFile file) {
//验证pathCode是否存在
if (!fileProperties.getPath().containsKey(pathCode)) {
throw new FileException("pathCode : " + pathCode + " not defined");
}
//文件是否为空
if (file.isEmpty()) {
throw new FileException("file is empty");
}
}
}
@@ -0,0 +1,36 @@
/**
* FileController.java
* Created at 2017-05-26
* Created by Administrator
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
package com.egridcloud.udf.file.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.egridcloud.udf.core.RestResponse;
import com.egridcloud.udf.file.service.FileService;
/**
* 描述 : FileController
*
* @author Administrator
*
*/
@RestController
public class FileController implements IFileController {
/**
* 描述 : fileService
*/
@Autowired
private FileService fileService;
@Override
public RestResponse<String> upload(String pathCode, Boolean cover, MultipartFile file) {
return new RestResponse<>(pathCode);
}
}
@@ -0,0 +1,56 @@
/**
* IFileController.java
* Created at 2017-05-26
* Created by Administrator
* Copyright (C) 2016 egridcloud.com, All rights reserved.
*/
package com.egridcloud.udf.file.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import com.egridcloud.udf.core.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
/**
* 描述 : IFileController
*
* @author Administrator
*
*/
@Api(value = "文件服务", consumes = "application/json", produces = "application/json",
protocols = "http")
@RequestMapping(value = "/service/file")
public interface IFileController {
/**
* 描述 : 上传文件
*
* @param pathCode 路径代码
* @param cover 是否覆盖
* @param file 文件
* @return 结果
*/
@ApiOperation(value = "FILE_1", 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"),
@ApiImplicitParam(paramType = "form", name = "pathCode", value = "路径代码", required = true,
dataType = "string"),
@ApiImplicitParam(paramType = "form", name = "cover", value = "是否覆盖", required = true,
dataType = "boolean"),
@ApiImplicitParam(paramType = "form", name = "file", value = "文件", required = true,
dataType = "__file") })
@RequestMapping(value = "upload", method = RequestMethod.POST)
public RestResponse<String> upload(String pathCode, Boolean cover, MultipartFile file);
}