Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
9a1acb92
Commit
9a1acb92
authored
Aug 09, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步专栏
parent
83b257e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+15
-15
No files found.
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
9a1acb92
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
com.tanpu.biz.common.enums.RelTypeEnum
;
import
com.tanpu.biz.common.enums.RelTypeEnum
;
...
@@ -31,7 +30,11 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
...
@@ -31,7 +30,11 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.ThemeListTypeEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.entity.community.CollectionEntity
;
import
com.tanpu.community.dao.entity.community.CollectionEntity
;
...
@@ -269,16 +272,15 @@ public class ThemeManager {
...
@@ -269,16 +272,15 @@ public class ThemeManager {
private
NewsFeedResReq
convertImg
(
ImagesDTO
img
,
String
userId
)
{
private
NewsFeedResReq
convertImg
(
ImagesDTO
img
,
String
userId
)
{
String
imgUrl
=
img
.
getRemark
();
String
[]
arr
=
StringUtils
.
split
(
img
.
getRemark
()
,
"."
);
String
[]
arr
=
StringUtils
.
split
(
img
Url
,
"."
);
String
suffix
=
arr
[
arr
.
length
-
1
];
String
suffix
=
arr
[
arr
.
length
-
1
];
String
fileName
=
imgUrl
.
substring
(
imgUrl
.
lastIndexOf
(
'/'
)
+
1
);
ResponseEntity
<
byte
[]>
resp
=
restTemplate
.
getForEntity
(
img
.
getRemark
(),
byte
[].
class
);
ResponseEntity
<
byte
[]>
resp
=
restTemplate
.
getForEntity
(
img
.
getRemark
(),
byte
[].
class
);
byte
[]
rst
=
resp
.
getBody
();
byte
[]
rst
=
resp
.
getBody
();
// todo
String
fileName
=
tmpDir
+
System
.
currentTimeMillis
()
+
".jpg"
;
File
f
=
new
File
(
fileName
);
File
f
=
new
File
(
fileName
);
try
{
try
{
FileUtils
.
writeByteArrayToFile
(
f
,
rst
);
FileUtils
.
writeByteArrayToFile
(
f
,
rst
);
...
@@ -303,17 +305,15 @@ public class ThemeManager {
...
@@ -303,17 +305,15 @@ public class ThemeManager {
if
(
StringUtils
.
isBlank
(
response
.
getBody
()))
{
if
(
StringUtils
.
isBlank
(
response
.
getBody
()))
{
throw
new
RuntimeException
(
"response body is blank"
);
throw
new
RuntimeException
(
"response body is blank"
);
}
}
CommonResp
<
JSONObject
>
ret
=
JSON
.
parseObject
(
response
.
getBody
(),
CommonResp
.
class
);
CommonResp
<
LinkedHashMap
<
String
,
String
>>
responseBody
=
JsonUtil
.
toBean
(
response
.
getBody
(),
CommonResp
.
class
);
if
(!
re
t
.
isSuccess
())
{
if
(!
re
sponseBody
.
isSuccess
())
{
throw
new
RuntimeException
(
"reponse is not success"
);
throw
new
RuntimeException
(
"reponse is not success"
);
}
}
JSONObject
data
=
ret
.
getData
();
HashMap
<
String
,
String
>
data
=
responseBody
.
getData
();
NewsFeedResReq
newsFeedResReq
=
new
NewsFeedResReq
();
return
NewsFeedResReq
.
builder
().
relId
(
data
.
get
(
"fileId"
))
newsFeedResReq
.
setRelId
(
data
.
getString
(
"fileId"
));
.
relType
(
Integer
.
parseInt
(
RelTypeEnum
.
IMAGE_FILE
.
type
))
newsFeedResReq
.
setRelType
(
Integer
.
parseInt
(
RelTypeEnum
.
IMAGE_FILE
.
type
));
.
remark
(
data
.
get
(
"fileurl"
)).
build
();
newsFeedResReq
.
setRemark
(
data
.
getString
(
"fileurl"
));
return
newsFeedResReq
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"error in handleSyncImg for imgUrl: {}"
,
img
.
getRemark
(),
e
);
log
.
error
(
"error in handleSyncImg for imgUrl: {}"
,
img
.
getRemark
(),
e
);
...
...
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