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
c3af7513
Commit
c3af7513
authored
Jan 12, 2021
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
1634a984
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
UploadController.java
...ns/platform/rs/universal/controller/UploadController.java
+29
-1
UploadService.java
...m/upyuns/platform/rs/universal/service/UploadService.java
+5
-4
No files found.
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/controller/UploadController.java
View file @
c3af7513
...
@@ -15,6 +15,7 @@ import com.upyuns.platform.rs.universal.utils.ImgBase64Util;
...
@@ -15,6 +15,7 @@ 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
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.awt.*
;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -46,6 +48,31 @@ public class UploadController{
...
@@ -46,6 +48,31 @@ public class UploadController{
@Autowired
@Autowired
UploadZipService
uploadZipService
;
UploadZipService
uploadZipService
;
@Data
static
public
class
DisposeDTO
{
private
String
context
=
"人民星云"
;
private
Integer
size
=
36
;
private
Integer
x
=
0
;
private
Integer
y
=
0
;
private
Integer
style
=
Font
.
BOLD
;
private
String
styleName
=
"宋体"
;
private
Float
alpha
=
0.5f
;
private
Float
scaleHight
=
320
f
;
private
Color
color
=
Color
.
WHITE
;
private
Integer
colorNum
;
public
void
setColorNum
(
Integer
colorNum
)
{
this
.
colorNum
=
colorNum
;
if
(
1
==
colorNum
)
{
this
.
color
=
Color
.
WHITE
;
}
else
if
(
2
==
colorNum
)
{
this
.
color
=
Color
.
BLACK
;
}
else
if
(
3
==
colorNum
)
{
this
.
color
=
Color
.
GRAY
;
}
}
}
@RequestMapping
(
value
=
"/app/unauth/upload"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/app/unauth/upload"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
upload
(
public
JSONObject
upload
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"file"
)
MultipartFile
file
,
...
@@ -58,7 +85,8 @@ public class UploadController{
...
@@ -58,7 +85,8 @@ public class UploadController{
@RequestMapping
(
value
=
"/app/unauth/uploadDispose"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/app/unauth/uploadDispose"
,
method
=
RequestMethod
.
POST
)
public
JSONObject
uploadDispose
(
public
JSONObject
uploadDispose
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"prefix"
,
defaultValue
=
"app"
)
String
prefix
@RequestParam
(
value
=
"prefix"
,
defaultValue
=
"app"
)
String
prefix
,
DisposeDTO
dto
)
throws
Exception
{
)
throws
Exception
{
String
contentType
=
file
.
getContentType
();
//图片文件类型
String
contentType
=
file
.
getContentType
();
//图片文件类型
return
JsonResultUtil
.
createSuccessResultWithObj
(
uploadService
.
uploadFileDispose
(
file
,
prefix
));
return
JsonResultUtil
.
createSuccessResultWithObj
(
uploadService
.
uploadFileDispose
(
file
,
prefix
));
...
...
rs-universal/rs-universal-server/src/main/java/com/upyuns/platform/rs/universal/service/UploadService.java
View file @
c3af7513
...
@@ -5,6 +5,7 @@ import cn.hutool.core.img.ImgUtil;
...
@@ -5,6 +5,7 @@ import cn.hutool.core.img.ImgUtil;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.upyuns.platform.rs.universal.constant.RedisKey
;
import
com.upyuns.platform.rs.universal.constant.RedisKey
;
import
com.upyuns.platform.rs.universal.controller.UploadController
;
import
com.upyuns.platform.rs.universal.utils.ImgBase64Util
;
import
com.upyuns.platform.rs.universal.utils.ImgBase64Util
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTime
;
...
@@ -72,7 +73,7 @@ public class UploadService {
...
@@ -72,7 +73,7 @@ public class UploadService {
* @param file
* @param file
* @return
* @return
*/
*/
public
String
uploadFileDispose
(
MultipartFile
file
,
String
prefix
)
throws
Exception
{
public
String
uploadFileDispose
(
MultipartFile
file
,
String
prefix
,
UploadController
.
DisposeDTO
dto
)
throws
Exception
{
//创建本日存放目录
//创建本日存放目录
DateTime
now
=
DateTime
.
now
();
DateTime
now
=
DateTime
.
now
();
String
dirPathToday
=
"/"
+
prefix
+
"/"
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
dirPathToday
=
"/"
+
prefix
+
"/"
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
...
@@ -88,11 +89,11 @@ public class UploadService {
...
@@ -88,11 +89,11 @@ public class UploadService {
//缩略
//缩略
BufferedImage
bufferedImage
=
ImgUtil
.
read
(
file
.
getInputStream
());
BufferedImage
bufferedImage
=
ImgUtil
.
read
(
file
.
getInputStream
());
Float
scale
=
320
f
/
bufferedImage
.
getHeight
();
Float
scale
=
dto
.
getScaleHight
()
/
bufferedImage
.
getHeight
();
Image
newImage
=
ImgUtil
.
scale
(
bufferedImage
,
scale
);
Image
newImage
=
ImgUtil
.
scale
(
bufferedImage
,
scale
);
//加水印
//加水印
Font
font
=
new
Font
(
"宋体"
,
Font
.
BOLD
,
32
);
Font
font
=
new
Font
(
dto
.
getStyleName
(),
dto
.
getStyle
(),
dto
.
getSize
()
);
Image
newImage2
=
ImgUtil
.
pressText
(
newImage
,
"人民星云"
,
Color
.
WHITE
,
font
,
0
,
0
,
0.8f
);
Image
newImage2
=
ImgUtil
.
pressText
(
newImage
,
dto
.
getContext
(),
dto
.
getColor
(),
font
,
dto
.
getX
(),
dto
.
getY
(),
dto
.
getAlpha
()
);
//将文件写入指定位置
//将文件写入指定位置
ImgUtil
.
write
(
newImage2
,
new
File
(
filePath
));
ImgUtil
.
write
(
newImage2
,
new
File
(
filePath
));
...
...
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