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
83b257e0
Commit
83b257e0
authored
Aug 09, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步专栏
parent
44abacfc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
12 deletions
+34
-12
CreateThemeReq.java
...m/tanpu/community/api/beans/req/theme/CreateThemeReq.java
+1
-1
FeignConfiguration.java
...n/java/com/tanpu/community/config/FeignConfiguration.java
+6
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+23
-10
RecommendService.java
...in/java/com/tanpu/community/service/RecommendService.java
+4
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/CreateThemeReq.java
View file @
83b257e0
...
...
@@ -30,7 +30,7 @@ public class CreateThemeReq {
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
private
String
editThemeId
=
""
;
@ApiModelProperty
(
"是否同步到社区 0为
同步 1为不
同步 不传也为同步"
)
@ApiModelProperty
(
"是否同步到社区 0为
不同步 1为
同步 不传也为同步"
)
private
Integer
syncToNewComm
=
0
;
}
community-service/src/main/java/com/tanpu/community/config/FeignConfiguration.java
View file @
83b257e0
...
...
@@ -3,6 +3,7 @@ package com.tanpu.community.config;
import
feign.Logger
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.client.RestTemplate
;
/**
* @description:
...
...
@@ -16,4 +17,9 @@ public class FeignConfiguration {
//这里记录所有,根据实际情况选择合适的日志level
return
Logger
.
Level
.
FULL
;
}
@Bean
public
RestTemplate
restTemplate
()
{
return
new
RestTemplate
();
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
83b257e0
...
...
@@ -38,6 +38,7 @@ import com.tanpu.community.dao.entity.community.CollectionEntity;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeAttachmentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.feign.community.FeignClientForCommunity
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.base.ESService
;
...
...
@@ -50,6 +51,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -126,6 +128,10 @@ public class ThemeManager {
@Resource
private
RestTemplate
restTemplate
;
// 专栏
@Autowired
private
FeignClientForCommunity
feignClientForCommunity
;
public
ThemeFullSearchResp
themeFullSearch
(
String
keyword
,
Integer
pageNo
,
Integer
pageSize
,
String
ident
,
String
userId
)
{
List
<
String
>
excludeIds
;
if
(
pageNo
>
1
)
{
...
...
@@ -195,7 +201,7 @@ public class ThemeManager {
// 新建
themeService
.
insertTheme
(
themeEntity
);
// 同步到专栏
if
(
0
==
req
.
getSyncToNewComm
())
{
if
(
1
==
req
.
getSyncToNewComm
())
{
convertToNewsFeed
(
req
,
themeEntity
.
getThemeId
(),
userId
);
}
...
...
@@ -230,7 +236,7 @@ public class ThemeManager {
throw
new
BizException
(
"长文类型无法同步专栏"
);
}
NewsFeedSave4NewCommReq
convertReq
=
new
NewsFeedSave4NewCommReq
();
convertReq
.
setNewsFeedId
(
CommunityConstant
.
THEME_PREFIX
+
themeId
);
convertReq
.
setNewsFeedId
(
themeId
);
ArrayList
<
NewsFeedResReq
>
feedList
=
new
ArrayList
<>();
for
(
ThemeContentReq
themeContentReq
:
req
.
getContent
())
{
// 文字内容添加到content
...
...
@@ -252,16 +258,26 @@ public class ThemeManager {
}
}
convertReq
.
setNewsFeedResList
(
feedList
);
CommonResp
restResponse
=
feignClientForCommunity
.
saveNewsFeed4NewComm
(
convertReq
);
if
(
restResponse
.
isNotSuccess
()
||
!
ObjectUtils
.
anyNotNull
(
restResponse
.
getData
()))
{
throw
new
BizException
(
"同步圈子调用失败"
);
}
}
private
NewsFeedResReq
convertImg
(
ImagesDTO
img
,
String
userId
)
{
String
[]
arr
=
StringUtils
.
split
(
img
.
getRemark
(),
"."
);
String
suffix
=
arr
[
arr
.
length
-
1
];
ResponseEntity
<
byte
[]>
resp
=
restTemplate
.
getForEntity
(
img
.
getRemark
(),
byte
[].
class
);
byte
[]
rst
=
resp
.
getBody
();
String
fileName
=
tmpDir
+
System
.
currentTimeMillis
()
+
".tmp"
;
// todo
String
fileName
=
tmpDir
+
System
.
currentTimeMillis
()
+
".jpg"
;
File
f
=
new
File
(
fileName
);
try
{
FileUtils
.
writeByteArrayToFile
(
f
,
rst
);
...
...
@@ -272,8 +288,7 @@ public class ThemeManager {
headers
.
set
(
"uid"
,
userId
);
MultiValueMap
<
String
,
Object
>
params
=
new
LinkedMultiValueMap
<
String
,
Object
>();
HashMap
<
String
,
Object
>
item
=
new
HashMap
<>();
// todo 图片类型
item
.
put
(
"filetype"
,
"jpg"
);
item
.
put
(
"filetype"
,
suffix
);
item
.
put
(
"refid"
,
img
.
getRelId
());
item
.
put
(
"mode"
,
0
);
item
.
put
(
"userId"
,
userId
);
...
...
@@ -292,13 +307,11 @@ public class ThemeManager {
if
(!
ret
.
isSuccess
())
{
throw
new
RuntimeException
(
"reponse is not success"
);
}
JSONObject
commonResult
=
ret
.
getData
();
JSONObject
data
=
ret
.
getData
();
NewsFeedResReq
newsFeedResReq
=
new
NewsFeedResReq
();
newsFeedResReq
.
setRelId
(
commonResult
.
getString
(
"fileId"
));
newsFeedResReq
.
setRelId
(
data
.
getString
(
"fileId"
));
newsFeedResReq
.
setRelType
(
Integer
.
parseInt
(
RelTypeEnum
.
IMAGE_FILE
.
type
));
newsFeedResReq
.
setRemark
(
commonResult
.
getString
(
"fileurl"
));
newsFeedResReq
.
setRemark
(
data
.
getString
(
"fileurl"
));
return
newsFeedResReq
;
...
...
community-service/src/main/java/com/tanpu/community/service/RecommendService.java
View file @
83b257e0
...
...
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -40,6 +41,9 @@ public class RecommendService {
private
ThemeService
themeService
;
@Resource
private
RestTemplate
restTemplate
;
// 最新
private
List
<
ThemeAnalysDO
>
recentThemeList
=
new
ArrayList
<>();
// 推荐
...
...
@@ -101,7 +105,6 @@ public class RecommendService {
if
(!
"true"
.
equals
(
enablePython
))
{
return
Collections
.
emptyList
();
}
RestTemplate
restTemplate
=
new
RestTemplate
();
HashMap
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"user_id"
,
userId
);
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