记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
dae4f2d0
Commit
dae4f2d0
authored
Dec 09, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改文件
parent
3e419dfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
50 deletions
+44
-50
AlOssController.java
...ce/platform/controller/basicServices/AlOssController.java
+39
-44
MaoDengImageHandler.java
.../liquidnet/service/sweet/handler/MaoDengImageHandler.java
+5
-6
No files found.
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/controller/basicServices/AlOssController.java
View file @
dae4f2d0
...
...
@@ -146,52 +146,47 @@ public class AlOssController {
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
String
pathName
,
@RequestParam
(
defaultValue
=
"0"
,
required
=
false
)
String
picUrl
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
File
fileNew
=
FilesUtils
.
inputStreamToFile
(
"http://mmbiz.qpic.cn/mmbiz_jpg/Ek5ncx8aHajn48x4aaqcNaIS5p7EJsMJaD7OtXdh8pFqY1GPuPSaMiaNSCL3YJHnOfERmOVy54zOKkjs5vtxjww/0"
,
System
.
currentTimeMillis
()
+
".png"
);
// file md5
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
List
<
PlatformOssFiles
>
platformOssFiles
=
platformOssFilesMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
PlatformOssFiles
.
class
)
.
eq
(
PlatformOssFiles:
:
getMd5str
,
fileMD5
)
);
UploadVo
uploadVo
=
new
UploadVo
();
if
(
CollectionUtils
.
isEmpty
(
platformOssFiles
))
{
String
filename
;
if
(
pathName
.
contains
(
"."
)){
filename
=
pathName
;
}
else
{
filename
=
"other.jpeg"
;
}
//这里文件名用了uuid 防止重复,可以根据自己的需要来写
String
uploadName
=
UUID
.
randomUUID
()
+
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
// 078a77e0-cf80-481b-824c-5935247cff15.jpeg
uploadName
=
uploadName
.
replace
(
"-"
,
""
);
// 078a77e0cf80481b824c5935247cff15.jpeg
String
uploadpath
=
pathName
+
"/"
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyy_MM_dd2
)
+
"/"
+
uploadName
;
String
buckName
=
"img-zhengzai-tv"
;
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
buckName
,
uploadpath
,
fileNew
);
ossClient
.
putObject
(
putObjectRequest
);
ossClient
.
shutdown
();
// 入库
PlatformOssFiles
platformOssFilesDate
=
new
PlatformOssFiles
();
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssPath
(
uploadpath
);
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setCreatedAt
(
DateUtil
.
getNowTime
());
platformOssFilesMapper
.
insert
(
platformOssFilesDate
);
BeanUtils
.
copyProperties
(
platformOssFilesDate
,
uploadVo
);
}
else
{
PlatformOssFiles
platformOssFilesOne
=
platformOssFiles
.
get
(
0
);
BeanUtils
.
copyProperties
(
platformOssFilesOne
,
uploadVo
);
}
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
File
fileNew
=
FilesUtils
.
inputStreamToFile
(
"http://mmbiz.qpic.cn/mmbiz_jpg/Ek5ncx8aHajn48x4aaqcNaIS5p7EJsMJaD7OtXdh8pFqY1GPuPSaMiaNSCL3YJHnOfERmOVy54zOKkjs5vtxjww/0"
,
System
.
currentTimeMillis
()
+
".png"
);
// file md5
String
fileMD5
=
FilesUtils
.
getFileMD5
(
fileNew
);
List
<
PlatformOssFiles
>
platformOssFiles
=
platformOssFilesMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
PlatformOssFiles
.
class
)
.
eq
(
PlatformOssFiles:
:
getMd5str
,
fileMD5
)
);
UploadVo
uploadVo
=
new
UploadVo
();
if
(
CollectionUtils
.
isEmpty
(
platformOssFiles
))
{
String
filename
=
pathName
;
//这里文件名用了uuid 防止重复,可以根据自己的需要来写
String
uploadName
=
UUID
.
randomUUID
()
+
filename
.
substring
(
filename
.
lastIndexOf
(
"."
));
// 078a77e0-cf80-481b-824c-5935247cff15.jpeg
uploadName
=
uploadName
.
replace
(
"-"
,
""
);
// 078a77e0cf80481b824c5935247cff15.jpeg
String
uploadpath
=
pathName
.
replaceAll
(
".jepg"
,
""
)
+
"/"
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
DateUtil
.
Formatter
.
yyyy_MM_dd2
)
+
"/"
+
uploadName
;
String
buckName
=
"img-zhengzai-tv"
;
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
buckName
,
uploadpath
,
fileNew
);
ossClient
.
putObject
(
putObjectRequest
);
ossClient
.
shutdown
();
FilesUtils
.
delteTempFile
(
fileNew
);
// 删除临时文件
// 入库
PlatformOssFiles
platformOssFilesDate
=
new
PlatformOssFiles
();
String
ossFilesId
=
IDGenerator
.
nextSnowId
();
platformOssFilesDate
.
setOssFilesId
(
ossFilesId
);
platformOssFilesDate
.
setOssPath
(
uploadpath
);
platformOssFilesDate
.
setFileName
(
filename
);
platformOssFilesDate
.
setMd5str
(
fileMD5
);
platformOssFilesDate
.
setCreatedAt
(
DateUtil
.
getNowTime
());
platformOssFilesMapper
.
insert
(
platformOssFilesDate
);
return
ResponseDto
.
success
(
uploadVo
);
BeanUtils
.
copyProperties
(
platformOssFilesDate
,
uploadVo
);
}
else
{
PlatformOssFiles
platformOssFilesOne
=
platformOssFiles
.
get
(
0
);
BeanUtils
.
copyProperties
(
platformOssFilesOne
,
uploadVo
);
}
FilesUtils
.
delteTempFile
(
fileNew
);
// 删除临时文件
return
ResponseDto
.
success
(
uploadVo
);
}
}
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/handler/MaoDengImageHandler.java
View file @
dae4f2d0
...
...
@@ -3,9 +3,7 @@ package com.liquidnet.service.sweet.handler;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.liquidnet.common.third.shumei.util.ShumeiUtil
;
import
com.liquidnet.commons.lang.util.HttpUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.service.adam.dto.vo.AdamUserInfoVo
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.kylin.dto.vo.basicServices.UploadVo
;
...
...
@@ -45,7 +43,7 @@ public class MaoDengImageHandler implements WxMpMessageHandler {
@Override
public
WxMpXmlOutMessage
handle
(
WxMpXmlMessage
wxMessage
,
Map
<
String
,
Object
>
map
,
WxMpService
wxMpService
,
WxSessionManager
wxSessionManager
)
throws
WxErrorException
{
String
fromUser
=
wxMessage
.
getFromUser
();
//用户id
String
picUrl
=
wxMessage
.
getPicUrl
().
replace
(
"http"
,
"https"
);
//图片urlmao
String
picUrl
=
wxMessage
.
getPicUrl
().
replace
(
"http"
,
"https"
);
//图片urlmao
log
.
debug
(
"[openId] = "
+
wxMessage
.
getOpenId
());
log
.
debug
(
"[unionId] = "
+
wxMessage
.
getUnionId
());
...
...
@@ -66,15 +64,16 @@ public class MaoDengImageHandler implements WxMpMessageHandler {
try
{
if
(
picUrl
!=
null
&&
!
picUrl
.
equals
(
""
))
{
log
.
debug
(
"[OLD PIC] = "
+
picUrl
);
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
();
params
.
add
(
"pathName"
,
"other.jpeg"
);
params
.
add
(
"pathName"
,
IDGenerator
.
nextTimeId
().
concat
(
".jpeg"
)
);
params
.
add
(
"picUrl"
,
picUrl
);
String
returnData
=
HttpUtil
.
post
(
platformUrl
.
concat
(
"/platform/basicServices/alOss/uploadUrl"
),
params
);
ResponseDto
<
UploadVo
>
dto
=
JsonUtils
.
fromJson
(
returnData
,
new
TypeReference
<
ResponseDto
<
UploadVo
>>()
{
});
picUrl
=
"https://img.zhengzai.tv/"
.
concat
(
dto
.
getData
().
getOssPath
());
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
getMessage
();
}
sweetMaoDengVo
.
setPicUrl
(
picUrl
);
...
...
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