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
1b1a775e
Commit
1b1a775e
authored
Oct 21, 2021
by
王亚雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/v2.2.9'
parents
914d0c9f
6767ae3d
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
262 additions
and
87 deletions
+262
-87
ThemeAndUserSearchResp.java
...anpu/community/api/beans/resp/ThemeAndUserSearchResp.java
+26
-0
UserSearchResp.java
...va/com/tanpu/community/api/beans/resp/UserSearchResp.java
+22
-0
ApolloRefresherConfig.java
...ava/com/tanpu/community/config/ApolloRefresherConfig.java
+1
-1
SearchController.java
...java/com/tanpu/community/controller/SearchController.java
+32
-4
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+12
-0
FeignClientForActivity.java
...anpu/community/feign/activity/FeignClientForActivity.java
+1
-2
FeignBackClientForCommunity.java
...ommunity/feign/community/FeignBackClientForCommunity.java
+7
-0
FeignClientForCommunity.java
...pu/community/feign/community/FeignClientForCommunity.java
+8
-1
FeignClientForCourse.java
...om/tanpu/community/feign/course/FeignClientForCourse.java
+1
-1
FeignClientForDiagnose.java
...anpu/community/feign/diagnose/FeignClientForDiagnose.java
+1
-1
FeignClientForFatools.java
.../tanpu/community/feign/fatools/FeignClientForFatools.java
+6
-1
FeignbackForFatools.java
...om/tanpu/community/feign/fatools/FeignbackForFatools.java
+6
-0
FeignClientForProducts.java
...tanpu/community/feign/product/FeignClientForProducts.java
+1
-2
FeignForFund.java
.../java/com/tanpu/community/feign/product/FeignForFund.java
+1
-1
FeignForPublicFund.java
...com/tanpu/community/feign/product/FeignForPublicFund.java
+1
-1
FeignClientForTanpuroom.java
...pu/community/feign/tanpuroom/FeignClientForTanpuroom.java
+1
-3
FeignClientForZhibo.java
.../com/tanpu/community/feign/zhibo/FeignClientForZhibo.java
+1
-3
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+12
-8
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+5
-6
TraceTestService.java
...in/java/com/tanpu/community/service/TraceTestService.java
+60
-0
ESHelper.java
.../main/java/com/tanpu/community/service/base/ESHelper.java
+34
-36
TencentcloudUtils.java
...main/java/com/tanpu/community/util/TencentcloudUtils.java
+5
-5
application-test.yml
community-service/src/main/resources/application-test.yml
+18
-11
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/resp/ThemeAndUserSearchResp.java
0 → 100644
View file @
1b1a775e
package
com
.
tanpu
.
community
.
api
.
beans
.
resp
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
io.swagger.annotations.ApiModel
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
@Builder
@AllArgsConstructor
@ApiModel
(
value
=
"主题搜索"
)
public
class
ThemeAndUserSearchResp
{
public
List
<
ThemeQo
>
themes
;
public
List
<
FollowQo
>
users
;
public
ThemeAndUserSearchResp
()
{
this
.
themes
=
new
ArrayList
<>();
this
.
users
=
new
ArrayList
<>();
}
}
community-api/src/main/java/com/tanpu/community/api/beans/resp/UserSearchResp.java
0 → 100644
View file @
1b1a775e
package
com
.
tanpu
.
community
.
api
.
beans
.
resp
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
io.swagger.annotations.ApiModel
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
@Builder
@AllArgsConstructor
@ApiModel
(
value
=
"主题搜索"
)
public
class
UserSearchResp
{
public
List
<
FollowQo
>
users
;
public
UserSearchResp
()
{
this
.
users
=
new
ArrayList
<>();
}
}
community-service/src/main/java/com/tanpu/community/config/ApolloRefresherConfig.java
View file @
1b1a775e
...
...
@@ -33,7 +33,7 @@ public class ApolloRefresherConfig implements ApplicationContextAware {
this
.
applicationContext
=
applicationContext
;
}
@ApolloConfigChangeListener
(
value
=
{
"application.yml"
})
@ApolloConfigChangeListener
(
value
=
{
"
common"
,
"
application.yml"
})
public
void
onChange
(
ConfigChangeEvent
changeEvent
)
{
refreshProperties
(
changeEvent
);
}
...
...
community-service/src/main/java/com/tanpu/community/controller/SearchController.java
View file @
1b1a775e
...
...
@@ -2,16 +2,21 @@ package com.tanpu.community.controller;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.common.auth.UserInfoHelper
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.qo.TopicDetailQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.req.search.ThemeFullSearchReq
;
import
com.tanpu.community.api.beans.resp.ThemeAndUserSearchResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.resp.UserSearchResp
;
import
com.tanpu.community.manager.HomePageManager
;
import
com.tanpu.community.manager.ThemeManager
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
...
...
@@ -27,6 +32,9 @@ public class SearchController {
@Autowired
private
ThemeManager
themeManager
;
@Autowired
private
HomePageManager
homePageManager
;
// 内容全文搜索
@ApiOperation
(
"全文搜索主题"
)
@PostMapping
(
value
=
"/themeFullText"
)
...
...
@@ -36,4 +44,24 @@ public class SearchController {
return
CommonResp
.
success
(
resp
);
}
// 用户+内容全文搜索
@ApiOperation
(
"综合搜索"
)
@PostMapping
(
value
=
"/muLtipuleSearch"
)
@ResponseBody
public
CommonResp
<
ThemeAndUserSearchResp
>
themeFullTextAndUserSearch
(
@RequestBody
ThemeFullSearchReq
req
)
{
ThemeFullSearchResp
themeFullSearch
=
themeManager
.
themeFullSearch
(
req
.
keyword
,
req
.
page
.
pageNumber
,
req
.
page
.
pageSize
,
req
.
ident
,
userHolder
.
getUserId
());
List
<
FollowQo
>
users
=
homePageManager
.
userNameSerach
(
req
.
keyword
,
1
,
3
,
req
.
ident
,
userHolder
.
getUserId
());
return
CommonResp
.
success
(
ThemeAndUserSearchResp
.
builder
().
themes
(
themeFullSearch
.
getThemes
()).
users
(
users
).
build
());
}
// 用户搜索
@ApiOperation
(
"用户姓名模糊查询"
)
@PostMapping
(
value
=
"/userNameFuzzy"
)
@ResponseBody
public
CommonResp
<
UserSearchResp
>
userNameSerach
(
@RequestBody
ThemeFullSearchReq
req
)
{
List
<
FollowQo
>
users
=
homePageManager
.
userNameSerach
(
req
.
keyword
,
req
.
page
.
pageNumber
,
req
.
page
.
pageSize
,
req
.
ident
,
userHolder
.
getUserId
());
return
CommonResp
.
success
(
UserSearchResp
.
builder
().
users
(
users
).
build
());
}
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
1b1a775e
...
...
@@ -8,11 +8,14 @@ import com.tanpu.community.api.beans.qo.ThemeQo;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.ThemeListResp
;
import
com.tanpu.community.feign.community.FeignClientForCommunity
;
import
com.tanpu.community.manager.ThemeManager
;
import
com.tanpu.community.service.TraceTestService
;
import
com.tanpu.community.util.HttpServletHelper
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -30,6 +33,9 @@ public class ThemeController {
private
UserHolder
userHolder
;
@Resource
private
HttpServletHelper
httpServletHelper
;
@Autowired
private
TraceTestService
traceTestService
;
@AuthLogin
@ApiOperation
(
"发表主题"
)
...
...
@@ -138,4 +144,10 @@ public class ThemeController {
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/testTrace"
)
@ResponseBody
public
CommonResp
<
Void
>
testTrace
()
{
traceTestService
.
testTraceId
();
return
CommonResp
.
success
();
}
}
community-service/src/main/java/com/tanpu/community/feign/activity/FeignClientForActivity.java
View file @
1b1a775e
...
...
@@ -10,8 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
@FeignClient
(
value
=
"service-jifen"
,
contextId
=
"jifen"
,
fallbackFactory
=
FeignBackClientForActivity
.
class
,
url
=
"${tanpu.jifen.svc:http://tp-jifen-svc}"
,
path
=
"/jifen"
)
// @FeignClient(value = "service-jifen", contextId = "jifen", fallbackFactory = FeignBackClientForActivity.class, url = "http://127.0.0.1:8202/community")
@FeignClient
(
value
=
"service-jifen"
,
contextId
=
"jifen"
,
url
=
"${tanpu.jifen.svc:}"
,
path
=
"/jifen"
)
public
interface
FeignClientForActivity
{
...
...
community-service/src/main/java/com/tanpu/community/feign/community/FeignBackClientForCommunity.java
View file @
1b1a775e
...
...
@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Slf4j
@Component
...
...
@@ -20,6 +21,12 @@ public class FeignBackClientForCommunity implements FallbackFactory<FeignClientF
return
null
;
}
@Override
public
CommonResp
testTraceId
(
@RequestParam
(
"no"
)
String
no
)
{
log
.
error
(
"请求信息"
,
throwable
);
log
.
error
(
"FeignBackClientForCommunity.testTraceId-测试traceId:{}"
,
no
);
return
null
;
}
};
}
}
community-service/src/main/java/com/tanpu/community/feign/community/FeignClientForCommunity.java
View file @
1b1a775e
...
...
@@ -4,9 +4,11 @@ import com.tanpu.common.api.CommonResp;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@FeignClient
(
value
=
"service-community"
,
contextId
=
"community"
,
fallbackFactory
=
FeignBackClientForCommunity
.
class
,
url
=
"http://tp-tamp-community-svc
"
,
path
=
"/community"
)
@FeignClient
(
value
=
"service-community"
,
url
=
"${tanpu.community.svc:}
"
,
path
=
"/community"
)
// @FeignClient(value = "service-community", contextId = "community", fallbackFactory = FeignBackClientForCommunity.class, url = "http://127.0.0.1:8202/community")
public
interface
FeignClientForCommunity
{
...
...
@@ -15,4 +17,9 @@ public interface FeignClientForCommunity {
@PostMapping
(
"/newsFeed/save4NewComm"
)
CommonResp
saveNewsFeed4NewComm
(
NewsFeedSave4NewCommReq
req
);
/**
* 测试用 traceId
*/
@GetMapping
(
"/newsFeed/testTraceId"
)
CommonResp
testTraceId
(
@RequestParam
(
"no"
)
String
no
);
}
community-service/src/main/java/com/tanpu/community/feign/course/FeignClientForCourse.java
View file @
1b1a775e
...
...
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
@FeignClient
(
value
=
"service-course"
,
contextId
=
"course"
,
fallbackFactory
=
FeignBackClientForCourse
.
class
,
url
=
"http://tp-course-svc
"
,
path
=
"/course"
)
@FeignClient
(
value
=
"service-course"
,
contextId
=
"course"
,
url
=
"${tanpu.course.svc:}
"
,
path
=
"/course"
)
//@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://172.20.1.249:8060/course")
public
interface
FeignClientForCourse
{
...
...
community-service/src/main/java/com/tanpu/community/feign/diagnose/FeignClientForDiagnose.java
View file @
1b1a775e
...
...
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
@FeignClient
(
value
=
"service-diagnose"
,
contextId
=
"diagnose"
,
fallbackFactory
=
FeignBackClientForDiagnose
.
class
,
url
=
"http://tp-diagnose-svc
"
,
path
=
"/diagnose"
)
@FeignClient
(
value
=
"service-diagnose"
,
url
=
"${tanpu.diagnose.svc:}
"
,
path
=
"/diagnose"
)
//@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, path = "http://172.20.1.249:8201/diagnose")
public
interface
FeignClientForDiagnose
{
...
...
community-service/src/main/java/com/tanpu/community/feign/fatools/FeignClientForFatools.java
View file @
1b1a775e
...
...
@@ -19,7 +19,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
@FeignClient
(
value
=
"fatools"
,
contextId
=
"fatools"
,
fallbackFactory
=
FeignbackForFatools
.
class
,
url
=
"${tanpu.fatools.svc:http://tp-fatools-svc
}"
,
path
=
"/fatools"
)
@FeignClient
(
value
=
"fatools"
,
url
=
"${tanpu.fatools.svc:
}"
,
path
=
"/fatools"
)
//@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public
interface
FeignClientForFatools
{
...
...
@@ -56,4 +56,9 @@ public interface FeignClientForFatools {
@GetMapping
(
value
=
"/queryChiefFinancialAdviserList"
)
CommonResp
<
Page
<
UserInfoNewChief
>>
queryChiefFinancialAdviserList
(
@RequestParam
(
"pageNumber"
)
Integer
pageNumber
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
);
@ApiOperation
(
value
=
"根据昵称模糊查询目标用户"
)
@GetMapping
(
value
=
"/queryByUserNameMp"
)
List
<
UserInfoResp
>
queryByUserNameMp
(
@RequestParam
(
"keyword"
)
String
keyword
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"pageNumber"
)
Integer
pageNumber
);
}
community-service/src/main/java/com/tanpu/community/feign/fatools/FeignbackForFatools.java
View file @
1b1a775e
...
...
@@ -71,6 +71,12 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
log
.
info
(
"FeignbackForFatools.queryChiefFinancialAdviserList"
,
throwable
);
return
CommonResp
.
error
();
}
@Override
public
List
<
UserInfoResp
>
queryByUserNameMp
(
String
keyword
,
Integer
pageSize
,
Integer
pageNumber
)
{
log
.
info
(
"FeignbackForFatools.queryByUserNameMp"
,
throwable
);
return
null
;
}
};
}
...
...
community-service/src/main/java/com/tanpu/community/feign/product/FeignClientForProducts.java
View file @
1b1a775e
...
...
@@ -3,7 +3,6 @@ package com.tanpu.community.feign.product;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO
;
import
com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO
;
import
com.tanpu.community.feign.fatools.FeignbackForFatools
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
...
@@ -12,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
@FeignClient
(
value
=
"service-product"
,
contextId
=
"product"
,
fallbackFactory
=
FeignBackClientForProducts
.
class
,
url
=
"http://tp-product-svc
"
,
path
=
"/product"
)
@FeignClient
(
value
=
"service-product"
,
url
=
"${tanpu.product.svc:}
"
,
path
=
"/product"
)
//@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://172.20.0.68:8194/product")
public
interface
FeignClientForProducts
{
...
...
community-service/src/main/java/com/tanpu/community/feign/product/FeignForFund.java
View file @
1b1a775e
...
...
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
//@FeignClient(value = "service-fund", url = "http://127.0.0.1:8194/fund")
@FeignClient
(
value
=
"service-fund"
,
contextId
=
"fund"
,
fallbackFactory
=
FeignbackForFund
.
class
,
url
=
"http://tp-fund-svc
"
,
path
=
"/fund"
)
@FeignClient
(
value
=
"service-fund"
,
url
=
"${tanpu.fund.svc:http://tp-fund-svc}
"
,
path
=
"/fund"
)
//@FeignClient(value = "service-fund", path = "/fund")
public
interface
FeignForFund
{
...
...
community-service/src/main/java/com/tanpu/community/feign/product/FeignForPublicFund.java
View file @
1b1a775e
...
...
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
@FeignClient
(
value
=
"service-fundpublic"
,
contextId
=
"fundpublic"
,
fallbackFactory
=
FeignbackForPublicFund
.
class
,
url
=
"http://tp-fundpublic-svc
"
,
path
=
"/fundpublic"
)
@FeignClient
(
value
=
"service-fundpublic"
,
contextId
=
"fundpublic"
,
url
=
"${tanpu.fundpublic.svc:}
"
,
path
=
"/fundpublic"
)
//@FeignClient(value = "service-fundpublic",path = "/fundpublic")
public
interface
FeignForPublicFund
{
...
...
community-service/src/main/java/com/tanpu/community/feign/tanpuroom/FeignClientForTanpuroom.java
View file @
1b1a775e
...
...
@@ -4,9 +4,7 @@ import com.tanpu.common.api.CommonResp;
import
com.tanpu.community.api.beans.vo.feign.course.CurriCulumInfoDetailDto
;
import
com.tanpu.community.api.beans.vo.feign.course.CurriculumDetailVo
;
import
com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp
;
import
com.tanpu.community.feign.product.FeignbackForPublicFund
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -15,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
java.util.List
;
@FeignClient
(
value
=
"service-tanpuroom"
,
contextId
=
"tanpuroom"
,
fallbackFactory
=
FeignBackClientForTanpuroom
.
class
,
url
=
"http://tp-tanpuroom-svc
"
,
path
=
"/tanpuroom"
)
@FeignClient
(
value
=
"service-tanpuroom"
,
url
=
"${tanpu.tanpuroom.svc:}
"
,
path
=
"/tanpuroom"
)
//@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://172.20.0.183:8086/tanpuroom")
public
interface
FeignClientForTanpuroom
{
...
...
community-service/src/main/java/com/tanpu/community/feign/zhibo/FeignClientForZhibo.java
View file @
1b1a775e
...
...
@@ -3,7 +3,6 @@ package com.tanpu.community.feign.zhibo;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboDetailVO
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp
;
import
com.tanpu.community.feign.tanpuroom.FeignBackClientForTanpuroom
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
...
@@ -14,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
java.util.List
;
//@FeignClient(value = "service-zhibo", url = "${tanpu.feo-zhibo.svc:}", fallbackFactory = FeignbackForZhibo.class, path = "/zhibo")
@FeignClient
(
value
=
"service-zhibo"
,
contextId
=
"zhibo"
,
fallbackFactory
=
FeignbackForZhibo
.
class
,
url
=
"http://tp-zhibo-svc"
,
path
=
"/zhibo"
)
@FeignClient
(
value
=
"service-zhibo"
,
url
=
"${tanpu.zhibo.svc:}"
,
path
=
"/zhibo"
)
//@FeignClient(value = "service-zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://172.20.0.169:8183/zhibo")
public
interface
FeignClientForZhibo
{
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
1b1a775e
...
...
@@ -48,14 +48,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -301,4 +294,15 @@ public class HomePageManager {
return
userInfoNewCommonResp
.
getData
();
}
public
List
<
FollowQo
>
userNameSerach
(
String
keyword
,
Integer
pageNumber
,
Integer
pageSize
,
String
ident
,
String
userId
)
{
if
(
StringUtils
.
isBlank
(
keyword
)){
return
Collections
.
emptyList
();
}
List
<
UserInfoResp
>
userInfoResps
=
feignClientForFatools
.
queryByUserNameMp
(
keyword
,
pageSize
,
pageNumber
);
List
<
FollowQo
>
followQos
=
userInfoResps
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
judgeFollowed
(
followQos
,
userId
);
}
return
followQos
;
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
1b1a775e
...
...
@@ -8,7 +8,6 @@ import com.tanpu.biz.common.enums.RelTypeEnum;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportTypeEnum
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.ResultCode
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.exception.BizException
;
...
...
@@ -828,17 +827,17 @@ public class ThemeManager {
String
content
=
sb
.
toString
();
// 腾讯云接口最多支持5000文字校验
// 检查内容是否涉黄违法
boolean
b
;
String
b
=
""
;
while
(
content
.
length
()
>
5000
)
{
b
=
TencentcloudUtils
.
textModeration
(
content
.
substring
(
0
,
5000
));
if
(
!
b
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
);
if
(
StringUtils
.
isNotBlank
(
b
)
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
.
getCode
(),
"疑似违规词汇:"
+
b
);
}
content
=
content
.
substring
(
5000
);
}
b
=
TencentcloudUtils
.
textModeration
(
content
);
if
(
!
b
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
);
if
(
StringUtils
.
isNotBlank
(
b
)
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
.
getCode
(),
"疑似违规词汇:"
+
b
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/TraceTestService.java
0 → 100644
View file @
1b1a775e
package
com
.
tanpu
.
community
.
service
;
import
com.tanpu.community.feign.community.FeignClientForCommunity
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.sleuth.instrument.async.LazyTraceAsyncTaskExecutor
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.concurrent.atomic.AtomicInteger
;
@Service
@Slf4j
public
class
TraceTestService
{
@Autowired
private
BeanFactory
beanFactory
;
@Autowired
private
FeignClientForCommunity
feignClientForCommunity
;
private
LazyTraceAsyncTaskExecutor
executor
;
private
AtomicInteger
count
;
@PostConstruct
private
void
init
()
{
ThreadPoolTaskExecutor
pool
=
new
ThreadPoolTaskExecutor
();
pool
.
setMaxPoolSize
(
3
);
pool
.
setCorePoolSize
(
1
);
pool
.
setKeepAliveSeconds
(
3600
);
pool
.
initialize
();
executor
=
new
LazyTraceAsyncTaskExecutor
(
beanFactory
,
pool
);
count
=
new
AtomicInteger
(
0
);
}
public
void
testTraceId
()
{
Integer
c
=
count
.
incrementAndGet
();
log
.
info
(
"parent count is "
+
c
);
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
int
subCount
=
i
;
executor
.
submit
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
1000
);
log
.
info
(
"child count is "
+
c
+
"-"
+
subCount
);
feignClientForCommunity
.
testTraceId
(
""
+
c
+
"-"
+
subCount
);
}
catch
(
Exception
e
)
{
}
}
});
}
}
}
community-service/src/main/java/com/tanpu/community/service/base/ESHelper.java
View file @
1b1a775e
package
com
.
tanpu
.
community
.
service
.
base
;
import
com.tanpu.common.util.JsonUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -9,15 +10,19 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.impl.client.BasicCredentialsProvider
;
import
org.apache.http.impl.nio.client.HttpAsyncClientBuilder
;
import
org.elasticsearch.action.ActionRequest
;
import
org.elasticsearch.action.delete.DeleteRequest
;
import
org.elasticsearch.action.delete.DeleteResponse
;
import
org.elasticsearch.action.index.IndexRequest
;
import
org.elasticsearch.action.index.IndexResponse
;
import
org.elasticsearch.action.search.SearchRequest
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RestClient
;
import
org.elasticsearch.client.RestClientBuilder
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.common.xcontent.XContentType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.MatchPhraseQueryBuilder
;
import
org.elasticsearch.index.query.MatchQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.rest.RestStatus
;
import
org.elasticsearch.search.SearchHit
;
...
...
@@ -25,12 +30,8 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.elasticsearch.client.*
;
import
javax.annotation.PostConstruct
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
...
...
@@ -99,20 +100,15 @@ public class ESHelper {
}
public
void
delete
(
String
type
,
String
id
)
{
try
{
DeleteRequest
req
=
new
DeleteRequest
(
esIndex
,
type
+
"_"
+
id
);
DeleteResponse
resp
=
client
.
delete
(
req
,
RequestOptions
.
DEFAULT
);
validStatus
(
resp
.
status
(),
RestStatus
.
OK
);
}
catch
(
IOException
e
)
{
log
.
error
(
"ES Helper error:{}"
,
ExceptionUtils
.
getStackTrace
(
e
));
}
}
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -133,8 +129,6 @@ public class ESHelper {
helper
.
client
=
highClient
;
SearchSourceBuilder
search
=
new
SearchSourceBuilder
();
BoolQueryBuilder
boolQb
=
QueryBuilders
.
boolQuery
();
...
...
@@ -153,23 +147,27 @@ public class ESHelper {
search
.
query
(
boolQb
).
from
(
0
).
size
(
50
);
try
{
DeleteRequest
req1
=
new
DeleteRequest
(
"new-community"
,
"2_88505497717006377"
);
DeleteResponse
resp1
=
helper
.
client
.
delete
(
req1
,
RequestOptions
.
DEFAULT
);
System
.
out
.
println
(
JsonUtil
.
toJson
(
resp1
));
try
{
SearchRequest
req
=
new
SearchRequest
(
"new-community"
);
req
.
source
(
search
);
SearchResponse
resp
=
helper
.
client
.
search
(
req
,
RequestOptions
.
DEFAULT
);
SearchRequest
req
=
new
SearchRequest
(
"new-community"
);
req
.
source
(
search
);
SearchResponse
resp
=
helper
.
client
.
search
(
req
,
RequestOptions
.
DEFAULT
);
SearchHit
[]
hits
=
resp
.
getHits
().
getHits
();
System
.
out
.
println
(
hits
.
length
);
for
(
SearchHit
hit
:
hits
)
{
System
.
out
.
println
(
hit
.
toString
());
System
.
out
.
println
(
hit
.
getFields
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
SearchHit
[]
hits
=
resp
.
getHits
().
getHits
();
System
.
out
.
println
(
hits
.
length
);
for
(
SearchHit
hit
:
hits
)
{
System
.
out
.
println
(
hit
.
toString
());
System
.
out
.
println
(
hit
.
getFields
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"done"
);
System
.
out
.
println
(
"done"
);
}
...
...
community-service/src/main/java/com/tanpu/community/util/TencentcloudUtils.java
View file @
1b1a775e
...
...
@@ -79,23 +79,23 @@ public class TencentcloudUtils {
* @param text
* @return
*/
public
static
boolean
textModeration
(
String
text
)
{
public
static
String
textModeration
(
String
text
)
{
TextModerationRequest
req
=
new
TextModerationRequest
();
req
.
setContent
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
)));
TextModerationResponse
res
=
null
;
try
{
res
=
getTmsClient
().
TextModeration
(
req
);
// suggestion Block 不通过
if
(
res
.
getSuggestion
().
equals
(
"Block"
))
{
return
false
;
if
(
res
.
getSuggestion
().
equals
(
"Block"
)
&&
res
.
getKeywords
().
length
>
0
)
{
return
":"
+
res
.
getKeywords
()[
0
]
;
}
}
catch
(
TencentCloudSDKException
e
)
{
log
.
error
(
"调用腾文本内容安全异常"
);
e
.
printStackTrace
();
//调用失败时,不影响用户发布主题
return
true
;
return
""
;
}
return
true
;
return
""
;
}
/**
...
...
community-service/src/main/resources/application-test.yml
View file @
1b1a775e
apollo.bootstrap.enabled
:
tru
e
apollo.bootstrap.enabled
:
fals
e
#app.id: tanpu-community
#apollo:
...
...
@@ -15,15 +15,7 @@ server:
spring.datasource
:
community
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
minIdle
:
2
initialSize
:
2
user
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
...
...
@@ -103,7 +95,22 @@ tmpfile:
tanpu
:
fatools
:
svc
:
127.0.0.1:8189
product
:
svc
:
https://testtamper.tanpuyun.com
jifen
:
svc
:
https://testtamper.tanpuyun.com
fund
:
svc
:
https://testtamper.tanpuyun.com
course
:
svc
:
https://testtamper.tanpuyun.com
community
:
svc
:
https://testtamper.tanpuyun.com
order
:
svc
:
https://testtamper.tanpuyun.com
tanpuroom
:
svc
:
https://testtamper.tanpuyun.com
zhibo
:
svc
:
https://testtamper.tanpuyun.com
diagnose
:
svc
:
https://testtamper.tanpuyun.com
\ No newline at end of file
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