Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-backend
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AutogeneralShanghai
yd-backend
Commits
7c43fd99
Commit
7c43fd99
authored
Mar 31, 2021
by
yao.xiao
Browse files
Options
Browse Files
Download
Plain Diff
解决冲突
parents
a781a4e0
001bb210
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
yd-api/src/main/java/com/yd/api/agms/AgmsController.java
+5
-1
yd-api/src/main/java/com/yd/api/agms/service/impl/AgmsSharingServiceImpl.java
+14
-13
yd-api/src/main/java/com/yd/rmi/ali/ossinterf/service/impl/AliOssInterfServiceImpl.java
+2
-1
No files found.
yd-api/src/main/java/com/yd/api/agms/AgmsController.java
View file @
7c43fd99
package
com
.
yd
.
api
.
agms
;
import
com.alibaba.fastjson.JSON
;
import
com.yd.api.agms.service.*
;
import
com.yd.api.agms.service.AgmsDashboardService
;
import
com.yd.api.agms.service.AgmsFortuneService
;
...
...
@@ -294,8 +295,11 @@ public class AgmsController {
}
@RequestMapping
(
value
=
"/controller"
)
public
Object
controller
(
@RequestParam
String
action
,
@RequestParam
(
value
=
"upfile"
,
required
=
false
)
MultipartFile
upfile
)
{
public
Object
controller
(
@RequestParam
String
action
,
@RequestParam
(
required
=
false
)
String
callback
,
@RequestParam
(
value
=
"upfile"
,
required
=
false
)
MultipartFile
upfile
)
{
ControllerResponseVO
responseVO
=
agmsSharingService
.
controller
(
action
,
upfile
);
if
(
"config"
.
equals
(
action
))
{
return
callback
+
"("
+
JSON
.
toJSONString
(
responseVO
)
+
")"
;
}
return
responseVO
;
}
/**
...
...
yd-api/src/main/java/com/yd/api/agms/service/impl/AgmsSharingServiceImpl.java
View file @
7c43fd99
...
...
@@ -8,6 +8,7 @@ import com.yd.rmi.ali.oss.service.OssService;
import
com.yd.rmi.ali.oss.vo.OssOperateTypeEnum
;
import
com.yd.rmi.ali.oss.vo.OssRequestVO
;
import
com.yd.rmi.ali.oss.vo.OssResponseVO
;
import
com.yd.rmi.ali.ossinterf.service.AliOssInterfService
;
import
com.yd.rmi.cache.SystemConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -33,7 +34,6 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
@Override
public
ControllerResponseVO
controller
(
String
action
,
MultipartFile
upfile
)
{
ControllerResponseVO
responseVO
=
new
ControllerResponseVO
();
String
aliOssBucketName
=
systemConfigService
.
getSingleConfigValue
(
"ALI_OSS_BUCKET_NAME"
);
String
[]
imageAllowFiles
=
new
String
[]{
".png"
,
".jpg"
,
".jpeg"
,
".gif"
,
".bmp"
};
String
[]
videoAllowFiles
=
new
String
[]{
".flv"
,
".swf"
,
".mkv"
,
".avi"
,
".rm"
,
".rmvb"
,
".mpeg"
,
".mpg"
,
".ogg"
,
".ogv"
,
".mov"
,
".wmv"
,
".mp4"
,
".webm"
,
".mp3"
,
".wav"
,
".mid"
};
...
...
@@ -43,6 +43,7 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
".rar"
,
".zip"
,
".tar"
,
".gz"
,
".7z"
,
".bz2"
,
".cab"
,
".iso"
,
".doc"
,
".docx"
,
".xls"
,
".xlsx"
,
".ppt"
,
".pptx"
,
".pdf"
,
".txt"
,
".md"
,
".xml"
};
if
(
"config"
.
equals
(
action
))
{
String
aliOssBucketName
=
systemConfigService
.
getSingleConfigValue
(
"ALI_OSS_BUCKET_NAME"
);
responseVO
.
setImageActionName
(
"uploadimage"
);
responseVO
.
setImageFieldName
(
"upfile"
);
responseVO
.
setImageMaxSize
(
2048000
);
...
...
@@ -51,46 +52,46 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
responseVO
.
setImageCompressBorder
(
1600
);
responseVO
.
setImageInsertAlign
(
"none"
);
responseVO
.
setImageUrlPrefix
(
aliOssBucketName
);
responseVO
.
setImagePathFormat
(
"/
sharing/
image/{time}{rand:6}"
);
responseVO
.
setImagePathFormat
(
"/image/{time}{rand:6}"
);
responseVO
.
setScrawlActionName
(
"uploadscrawl"
);
responseVO
.
setScrawlFieldName
(
"upfile"
);
responseVO
.
setScrawlPathFormat
(
"/
sharing/
image/{time}{rand:6}"
);
responseVO
.
setScrawlPathFormat
(
"/image/{time}{rand:6}"
);
responseVO
.
setScrawlMaxSize
(
2048000
);
responseVO
.
setScrawlUrlPrefix
(
aliOssBucketName
);
responseVO
.
setScrawlInsertAlign
(
"none"
);
responseVO
.
setSnapscreenActionName
(
"uploadimage"
);
responseVO
.
setSnapscreenPathFormat
(
"/
sharing/
image/{time}{rand:6}"
);
responseVO
.
setSnapscreenPathFormat
(
"/image/{time}{rand:6}"
);
responseVO
.
setSnapscreenUrlPrefix
(
aliOssBucketName
);
responseVO
.
setSnapscreenInsertAlign
(
"none"
);
String
[]
catcherLocalDomain
=
new
String
[]{
"127.0.0.1"
,
"localhost"
,
"img.baidu.com"
};
responseVO
.
setCatcherLocalDomain
(
Arrays
.
asList
(
catcherLocalDomain
));
responseVO
.
setCatcherActionName
(
"catchimage"
);
responseVO
.
setCatcherFieldName
(
"source"
);
responseVO
.
setCatcherPathFormat
(
"/
sharing/
image/{time}{rand:6}"
);
responseVO
.
setCatcherPathFormat
(
"/image/{time}{rand:6}"
);
responseVO
.
setCatcherUrlPrefix
(
aliOssBucketName
);
responseVO
.
setCatcherMaxSize
(
2048000
);
responseVO
.
setCatcherAllowFiles
(
Arrays
.
asList
(
imageAllowFiles
));
responseVO
.
setVideoActionName
(
"uploadvideo"
);
responseVO
.
setVideoFieldName
(
"upfile"
);
responseVO
.
setVideoPathFormat
(
"/
sharing/
video/{time}{rand:6}"
);
responseVO
.
setVideoPathFormat
(
"/video/{time}{rand:6}"
);
responseVO
.
setVideoUrlPrefix
(
aliOssBucketName
);
responseVO
.
setVideoMaxSize
(
102400000
);
responseVO
.
setVideoAllowFiles
(
Arrays
.
asList
(
videoAllowFiles
));
responseVO
.
setFileActionName
(
"uploadfile"
);
responseVO
.
setFileFieldName
(
"upfile"
);
responseVO
.
setFilePathFormat
(
"/
sharing/
file/{time}{rand:6}"
);
responseVO
.
setFilePathFormat
(
"/file/{time}{rand:6}"
);
responseVO
.
setFileUrlPrefix
(
aliOssBucketName
);
responseVO
.
setFileMaxSize
(
51200000
);
responseVO
.
setFileAllowFiles
(
Arrays
.
asList
(
fileAllowFiles
));
responseVO
.
setImageManagerActionName
(
"listimage"
);
responseVO
.
setImageManagerListPath
(
"/
sharing/
image/"
);
responseVO
.
setImageManagerListPath
(
"/image/"
);
responseVO
.
setImageManagerListSize
(
20
);
responseVO
.
setImageManagerUrlPrefix
(
aliOssBucketName
);
responseVO
.
setImageManagerInsertAlign
(
"none"
);
String
[]
imageManagerAllowFiles
=
new
String
[]{
".png"
,
".jpg"
,
".jpeg"
,
".gif"
,
".bmp"
};
responseVO
.
setImageManagerAllowFiles
(
Arrays
.
asList
(
imageManagerAllowFiles
));
responseVO
.
setFileManagerActionName
(
"listfile"
);
responseVO
.
setFileManagerListPath
(
"/
sharing/
file/"
);
responseVO
.
setFileManagerListPath
(
"/file/"
);
responseVO
.
setFileManagerUrlPrefix
(
aliOssBucketName
);
responseVO
.
setFileManagerListSize
(
20
);
responseVO
.
setFileManagerAllowFiles
(
Arrays
.
asList
(
fileAllowFiles
));
...
...
@@ -99,22 +100,22 @@ public class AgmsSharingServiceImpl implements AgmsSharingService {
String
type
=
upfile
.
getOriginalFilename
().
substring
(
upfile
.
getOriginalFilename
().
indexOf
(
"."
)
+
1
);
byte
[]
bytes
=
upfile
.
getBytes
();
InputStream
in
=
new
ByteArrayInputStream
(
bytes
);
StringBuilder
key
=
new
StringBuilder
(
"
/
sharing/"
);
StringBuilder
key
=
new
StringBuilder
(
"sharing/"
);
String
title
;
Date
date
=
new
Date
();
SimpleDateFormat
sd
=
new
SimpleDateFormat
(
"yyyyMMddHHmmssSSS"
);
String
nowTime
=
sd
.
format
(
date
);
if
(
Arrays
.
asList
(
imageAllowFiles
).
contains
(
type
)){
if
(
Arrays
.
asList
(
imageAllowFiles
).
contains
(
"."
+
type
)){
title
=
nowTime
+
(
int
)(
Math
.
random
()*
1000000
);
key
.
append
(
"image/"
).
append
(
title
);
}
else
if
(
Arrays
.
asList
(
videoAllowFiles
).
contains
(
type
)){
}
else
if
(
Arrays
.
asList
(
videoAllowFiles
).
contains
(
"."
+
type
)){
title
=
nowTime
+
(
int
)(
Math
.
random
()*
1000000
);
key
.
append
(
"video/"
).
append
(
title
);
}
else
{
title
=
nowTime
+
(
int
)(
Math
.
random
()*
1000000
);
key
.
append
(
"file/"
).
append
(
title
);
}
String
putFileToOss
=
ossService
.
putFileToOss
(
null
,
key
.
toString
(),
in
);
String
putFileToOss
=
ossService
.
putFileToOss
(
null
,
key
.
toString
()
+
"."
+
type
,
in
);
responseVO
.
setState
(
"SUCCESS"
);
responseVO
.
setUrl
(
putFileToOss
);
responseVO
.
setTitle
(
title
);
...
...
yd-api/src/main/java/com/yd/rmi/ali/ossinterf/service/impl/AliOssInterfServiceImpl.java
View file @
7c43fd99
...
...
@@ -273,7 +273,8 @@ public class AliOssInterfServiceImpl implements AliOssInterfService {
* @param key 对象名
* @return
*/
public
String
generateUrl
(
String
bucketName
,
String
key
){
@Override
public
String
generateUrl
(
String
bucketName
,
String
key
){
OSSClient
ossClient
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
String
url
=
null
;
try
{
...
...
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