Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周健威
rs-cloud-platform
Commits
fcde211d
Commit
fcde211d
authored
Jun 25, 2024
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
45b44dd0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
9 deletions
+66
-9
UploadController.java
...ns/platform/rs/universal/controller/UploadController.java
+17
-7
UploadService.java
...m/upyuns/platform/rs/universal/service/UploadService.java
+36
-0
FileData.java
.../java/com/upyuns/platform/rs/website/entity/FileData.java
+2
-1
GainData.java
.../java/com/upyuns/platform/rs/website/entity/GainData.java
+11
-1
No files found.
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/controller/UploadController.java
View file @
fcde211d
...
@@ -14,6 +14,8 @@ import com.upyuns.platform.rs.universal.service.UploadZipService;
...
@@ -14,6 +14,8 @@ import com.upyuns.platform.rs.universal.service.UploadZipService;
import
com.upyuns.platform.rs.universal.utils.ImgBase64Util
;
import
com.upyuns.platform.rs.universal.utils.ImgBase64Util
;
import
com.upyuns.platform.rs.universal.utils.PublicMsg
;
import
com.upyuns.platform.rs.universal.utils.PublicMsg
;
import
com.upyuns.platform.rs.universal.vo.Ueditor
;
import
com.upyuns.platform.rs.universal.vo.Ueditor
;
import
com.upyuns.platform.rs.website.entity.FileData
;
import
com.upyuns.platform.rs.website.entity.GainData
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -141,16 +143,24 @@ public class UploadController{
...
@@ -141,16 +143,24 @@ public class UploadController{
@RequestParam
(
value
=
"prefix"
,
defaultValue
=
"admin"
)
String
prefix
@RequestParam
(
value
=
"prefix"
,
defaultValue
=
"admin"
)
String
prefix
)
throws
Exception
{
)
throws
Exception
{
String
contentType
=
file
.
getContentType
();
//图片文件类型
String
contentType
=
file
.
getContentType
();
//图片文件类型
// String fileName = file.getOriginalFilename(); //图片名字
/* if (!contentType.equals("image/jpeg") && !contentType.equals("image/gif")&&!contentType.equals("image/png")) {
return JsonResultUtil.createFailedResult(2001,"格式不对!!!");
}*/
// if (file.getSize() > MAX_DRIVING_LICENSE_SIZE) {
// return JsonResultUtil.createFailedResult(2002,"大小超过限制!!!");
// }
return
JsonResultUtil
.
createSuccessResultWithObj
(
uploadService
.
uploadFileAndGetFileInfo
(
file
,
prefix
));
return
JsonResultUtil
.
createSuccessResultWithObj
(
uploadService
.
uploadFileAndGetFileInfo
(
file
,
prefix
));
}
}
/**
* 上传成果文件
* @param file
* @param prefix gainDataId
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/app/unauth/admin/uploadGainFile"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
uploadGainFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"prefix"
,
defaultValue
=
"admin"
)
String
prefix
)
throws
Exception
{
FileData
data
=
uploadService
.
uploadGainFile
(
file
,
prefix
);
return
ObjectRestResponse
.
succ
(
data
);
}
// @PostMapping("/app/unauth/download")
// @PostMapping("/app/unauth/download")
// public byte[] downloadFile(@RequestBody String fileUrl) {
// public byte[] downloadFile(@RequestBody String fileUrl) {
...
...
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/service/UploadService.java
View file @
fcde211d
...
@@ -38,8 +38,13 @@ import java.util.concurrent.TimeUnit;
...
@@ -38,8 +38,13 @@ import java.util.concurrent.TimeUnit;
public
class
UploadService
{
public
class
UploadService
{
public
static
final
DateTimeFormatter
DEFAULT_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
public
static
final
DateTimeFormatter
DEFAULT_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
public
static
final
DateTimeFormatter
GAINFILE_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyMMdd"
);
@Value
(
"${universal.baseUploadPath}"
)
@Value
(
"${universal.baseUploadPath}"
)
private
String
baseUploadPath
;
private
String
baseUploadPath
;
@Value
(
"${universal.gaindataPath}"
)
private
String
gaindataPath
;
@Value
(
"${universal.videoUploadPath}"
)
@Value
(
"${universal.videoUploadPath}"
)
private
String
videoUploadPath
;
private
String
videoUploadPath
;
...
@@ -138,6 +143,37 @@ public class UploadService {
...
@@ -138,6 +143,37 @@ public class UploadService {
return
fileData
;
return
fileData
;
}
}
public
FileData
uploadGainFile
(
MultipartFile
file
,
String
prefix
)
throws
Exception
{
//创建本日存放目录
DateTime
now
=
DateTime
.
now
();
String
dirPath
=
"/"
+
prefix
;
String
todayStr
=
now
.
toString
(
GAINFILE_DATE_TIME_FORMATTER
);
String
redisNoKey
=
RedisKey
.
UPLOAD_FILE_NO_PREFIX
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
Long
no
=
redisTemplate
.
opsForValue
().
increment
(
redisNoKey
);
if
(
no
.
equals
(
1
l
)){
redisTemplate
.
expire
(
redisNoKey
,
1
,
TimeUnit
.
DAYS
);
}
String
noStr
=
todayStr
+
"_"
+
no
;
String
fileName
=
file
.
getOriginalFilename
();
String
realFileRelPath
=
gaindataPath
+
dirPath
+
"/"
+
noStr
+
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
String
filetype
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
long
fileSize
=
file
.
getSize
();
double
fileSizeInMB
=
(
double
)
fileSize
/
(
1024
*
1024
);
// 转换为 MB
double
roundedFileSizeInMB
=
Math
.
round
(
fileSizeInMB
*
100.0
)
/
100.0
;
// 保留两位小数
String
fileSizeString
=
String
.
format
(
"%.2f MB"
,
roundedFileSizeInMB
);
//文件存放路径
String
filePath
=
baseUploadPath
+
realFileRelPath
;
//将文件写入指定位置
FileUtils
.
copyInputStreamToFile
(
file
.
getInputStream
(),
new
File
(
filePath
));
realFileRelPath
=
xx_url
+
SystemConfig
.
XXMP_URL
+
realFileRelPath
;
FileData
fileData
=
new
FileData
();
fileData
.
setFilename
(
fileName
);
fileData
.
setFiletype
(
filetype
);
fileData
.
setFilesize
(
fileSizeString
);
fileData
.
setFileurl
(
realFileRelPath
);
fileData
.
setFilepath
(
filePath
);
return
fileData
;
}
// public String uploadFile250(MultipartFile file, String prefix) throws Exception {
// public String uploadFile250(MultipartFile file, String prefix) throws Exception {
//// // 创建本日存放目录
//// // 创建本日存放目录
...
...
rs-website/rs-website-api/src/main/java/com/upyuns/platform/rs/website/entity/FileData.java
View file @
fcde211d
...
@@ -72,5 +72,6 @@ public class FileData implements Serializable {
...
@@ -72,5 +72,6 @@ public class FileData implements Serializable {
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
private
Date
crtTime
;
private
Date
crtTime
;
@ApiModelProperty
(
value
=
"文件服务器路径"
)
private
String
filepath
;
}
}
rs-website/rs-website-api/src/main/java/com/upyuns/platform/rs/website/entity/GainData.java
View file @
fcde211d
...
@@ -104,5 +104,15 @@ public class GainData implements Serializable {
...
@@ -104,5 +104,15 @@ public class GainData implements Serializable {
@ApiModelProperty
(
value
=
"菜单id"
)
@ApiModelProperty
(
value
=
"菜单id"
)
private
Integer
menuId
;
private
Integer
menuId
;
@Column
(
name
=
"data_path"
)
@ApiModelProperty
(
value
=
"数据路径"
)
private
String
dataPath
;
@Column
(
name
=
"gtdata_path"
)
@ApiModelProperty
(
value
=
"gtdata路径"
)
private
String
gtdataPath
;
@Column
(
name
=
"has_gtdata"
)
@ApiModelProperty
(
value
=
"是否已经存储gtdata 0--未处理;1--已处理;2--已更新"
)
private
Integer
hasGtdata
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment