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
33e75dd2
Commit
33e75dd2
authored
Jun 30, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HomePageController
parent
198af5af
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
265 additions
and
132 deletions
+265
-132
FollowQo.java
.../main/java/com/tanpu/community/api/beans/qo/FollowQo.java
+3
-0
HomePageReq.java
...n/java/com/tanpu/community/api/beans/req/HomePageReq.java
+30
-0
RedisConfig.java
...src/main/java/com/tanpu/community/config/RedisConfig.java
+43
-53
AdminController.java
.../java/com/tanpu/community/controller/AdminController.java
+93
-0
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+40
-13
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+0
-59
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+34
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+1
-1
FansRelService.java
...main/java/com/tanpu/community/service/FansRelService.java
+3
-3
HomePageService.java
...ain/java/com/tanpu/community/service/HomePageService.java
+18
-3
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/FollowQo.java
View file @
33e75dd2
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
FollowQo
{
public
class
FollowQo
{
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/HomePageReq.java
0 → 100644
View file @
33e75dd2
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
@Data
public
class
HomePageReq
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"头像url"
)
@NotEmpty
(
message
=
"头像不能为空"
)
private
String
headImg
;
@ApiModelProperty
(
value
=
"昵称"
)
@NotEmpty
(
message
=
"用户昵称不能为空"
)
private
String
nickName
;
@ApiModelProperty
(
value
=
"个人简介"
)
@NotEmpty
(
message
=
"个人简介不能为空"
)
private
String
introduction
;
@ApiModelProperty
(
value
=
"性别"
)
private
Integer
sex
;
@ApiModelProperty
(
value
=
"地址"
)
private
String
location
;
}
community-service/src/main/java/com/tanpu/community/config/RedisConfig.java
View file @
33e75dd2
package
com
.
tanpu
.
community
.
config
;
package
com
.
tanpu
.
community
.
config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.connection.RedisPassword
;
import
org.springframework.data.redis.connection.RedisStandaloneConfiguration
;
import
org.springframework.data.redis.connection.jedis.JedisClientConfiguration
;
import
org.springframework.data.redis.connection.jedis.JedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
redis.clients.jedis.JedisPoolConfig
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.time.Duration
;
@Configuration
@Configuration
@EnableCaching
@EnableCaching
...
@@ -38,49 +28,49 @@ public class RedisConfig {
...
@@ -38,49 +28,49 @@ public class RedisConfig {
@Value
(
"${spring.redis.max-idle}"
)
@Value
(
"${spring.redis.max-idle}"
)
private
int
maxIdle
;
private
int
maxIdle
;
@Bean
//
@Bean
public
JedisPoolConfig
jedisPoolConfig
()
{
//
public JedisPoolConfig jedisPoolConfig() {
JedisPoolConfig
jedisPoolConfig
=
new
JedisPoolConfig
();
//
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
// maximum connection
//
// maximum connection
jedisPoolConfig
.
setMaxTotal
(
maxActive
);
//
jedisPoolConfig.setMaxTotal(maxActive);
// Maximum wait time when no connection is available in the pool
//
// Maximum wait time when no connection is available in the pool
jedisPoolConfig
.
setMaxWaitMillis
(
maxWaitMillis
);
//
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
// Maximum number of idle connections
//
// Maximum number of idle connections
jedisPoolConfig
.
setMinIdle
(
maxIdle
);
//
jedisPoolConfig.setMinIdle(maxIdle);
// Other properties can be added by yourself
//
// Other properties can be added by yourself
return
jedisPoolConfig
;
//
return jedisPoolConfig;
}
//
}
//
@Bean
//
@Bean
public
JedisConnectionFactory
jedisConnectionFactory
(
JedisPoolConfig
jedisPoolConfig
)
{
//
public JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
JedisClientConfiguration
jedisClientConfiguration
=
JedisClientConfiguration
.
builder
().
usePooling
()
//
JedisClientConfiguration jedisClientConfiguration = JedisClientConfiguration.builder().usePooling()
.
poolConfig
(
jedisPoolConfig
).
and
().
readTimeout
(
Duration
.
ofMillis
(
timeout
)).
build
();
//
.poolConfig(jedisPoolConfig).and().readTimeout(Duration.ofMillis(timeout)).build();
RedisStandaloneConfiguration
redisStandaloneConfiguration
=
new
RedisStandaloneConfiguration
();
//
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration
.
setHostName
(
host
);
//
redisStandaloneConfiguration.setHostName(host);
redisStandaloneConfiguration
.
setPort
(
port
);
//
redisStandaloneConfiguration.setPort(port);
redisStandaloneConfiguration
.
setPassword
(
RedisPassword
.
of
(
password
));
//
redisStandaloneConfiguration.setPassword(RedisPassword.of(password));
return
new
JedisConnectionFactory
(
redisStandaloneConfiguration
,
jedisClientConfiguration
);
//
return new JedisConnectionFactory(redisStandaloneConfiguration, jedisClientConfiguration);
}
//
}
//
@Bean
//
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
()
{
//
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
//
RedisTemplate<String, Object> template = new RedisTemplate<>();
template
.
setConnectionFactory
(
jedisConnectionFactory
(
jedisPoolConfig
()));
//
template.setConnectionFactory(jedisConnectionFactory(jedisPoolConfig()));
//
return
template
;
//
return template;
}
//
}
//
/**
//
/**
* cache
//
* cache
*/
//
*/
@Bean
//
@Bean
public
RedisCacheManagerBuilderCustomizer
redisCacheManagerBuilderCustomizer
()
{
//
public RedisCacheManagerBuilderCustomizer redisCacheManagerBuilderCustomizer() {
return
(
builder
)
->
RedisCacheManager
.
RedisCacheManagerBuilder
.
fromConnectionFactory
(
jedisConnectionFactory
(
jedisPoolConfig
()))
//
return (builder) -> RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(jedisConnectionFactory(jedisPoolConfig()))
.
withCacheConfiguration
(
"tempCache"
,
//
.withCacheConfiguration("tempCache",
RedisCacheConfiguration
.
defaultCacheConfig
().
entryTtl
(
Duration
.
ofSeconds
(
10
)))
//
RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)))
.
withCacheConfiguration
(
"longCache"
,
//
.withCacheConfiguration("longCache",
RedisCacheConfiguration
.
defaultCacheConfig
().
entryTtl
(
Duration
.
ofDays
(
7
)));
//
RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofDays(7)));
}
//
}
@Bean
(
"communityKeyGenerator"
)
@Bean
(
"communityKeyGenerator"
)
public
KeyGenerator
keyGenerator
()
{
public
KeyGenerator
keyGenerator
()
{
...
...
community-service/src/main/java/com/tanpu/community/controller/AdminController.java
0 → 100644
View file @
33e75dd2
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.community.api.beans.TopicBriefInfoDTO
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.api.beans.TopicDataAnalysDTO
;
import
com.tanpu.community.api.beans.req.topic.TopicConcealReq
;
import
com.tanpu.community.api.beans.req.topic.TopicModifyMountReq
;
import
com.tanpu.community.api.beans.req.topic.TopicTopReq
;
import
com.tanpu.community.manager.TopicManager
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@RestController
@Slf4j
@RequestMapping
(
value
=
"/api/admin"
)
public
class
AdminController
{
@Autowired
private
TopicManager
topicManager
;
@Autowired
private
UserHolder
userHolder
;
@GetMapping
(
value
=
"/admin/queryTopicDetailList"
)
@ApiOperation
(
"查询所有的话题详情"
)
@ResponseBody
public
CommonResp
<
List
<
TopicBriefInfoDTO
>>
getAllTopicList
(){
List
<
TopicBriefInfoDTO
>
allTopic
=
topicManager
.
getAllTopicBriefInfo
();
return
CommonResp
.
success
(
allTopic
);
}
@PostMapping
(
value
=
"/admin/insertTopic"
)
@ApiOperation
(
"新增话题"
)
@ResponseBody
public
CommonResp
<
Void
>
addTopic
(
@RequestParam
String
topicTitle
){
String
userId
=
userHolder
.
getUserId
();
topicManager
.
insertTopic
(
topicTitle
,
userId
);
return
CommonResp
.
success
();
}
@ApiOperation
(
"单个话题详细数据"
)
@PostMapping
(
"/topic/detailData"
)
@ResponseBody
public
CommonResp
<
TopicDTO
>
selectOne
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"String"
);
}
TopicDTO
topicDTO
=
topicManager
.
getDetail
(
topicId
);
return
CommonResp
.
success
(
topicDTO
);
}
@PostMapping
(
value
=
"/topic/setTop"
)
@ApiOperation
(
"顶置/取消顶置话题"
)
@ResponseBody
public
CommonResp
<
Void
>
setTopTopic
(
@RequestBody
TopicTopReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
setTopTopic
(
req
.
getTopicId
(),
req
.
isTop
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/topic/setConceal"
)
@ApiOperation
(
"隐藏/显示话题"
)
@ResponseBody
public
CommonResp
<
Void
>
setConceal
(
@RequestBody
TopicConcealReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
setTopicConceal
(
req
.
getTopicId
(),
req
.
isConceal
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/topic/modifyViewNum"
)
@ApiOperation
(
"话题浏览数调整(后台管理)"
)
@ResponseBody
public
CommonResp
<
Void
>
modifyViewNum
(
@RequestBody
TopicModifyMountReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
modifyViewAmount
(
req
.
getTopicId
(),
req
.
getModifyMount
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/topic/dataAnalyse"
)
@ApiOperation
(
"话题数据分析"
)
@ResponseBody
public
CommonResp
<
TopicDataAnalysDTO
>
dataAnalyse
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
TopicDataAnalysDTO
result
=
topicManager
.
queryDataAnalysis
(
topicId
);
return
CommonResp
.
success
(
result
);
}
}
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
33e75dd2
package
com
.
tanpu
.
community
.
controller
;
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.req.HomePageReq
;
import
com.tanpu.community.api.beans.req.homepage.AddIdolReq
;
import
com.tanpu.community.api.beans.req.homepage.AddIdolReq
;
import
com.tanpu.community.manager.HomePageManager
;
import
com.tanpu.community.manager.HomePageManager
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@RestController
@RestController
@Slf4j
@Slf4j
@RequestMapping
(
value
=
"/api/homepage"
)
@RequestMapping
(
value
=
"/api/homepage"
)
public
class
HomePageController
{
public
class
HomePageController
{
@Autowired
@Autowired
private
HomePageManager
homePageManager
;
private
HomePageManager
homePageManager
;
@PostMapping
(
value
=
"/queryMyFans"
)
@PostMapping
(
value
=
"/editUserInfo"
)
@ApiModelProperty
(
"编辑个人资料"
)
@ResponseBody
public
CommonResp
<
String
>
editUserInfo
(
@Validated
@RequestBody
HomePageReq
req
){
String
userId
=
"liujm"
;
homePageManager
.
editUserInfo
(
req
,
userId
);
return
CommonResp
.
success
(
"修改成功"
);
}
@GetMapping
(
value
=
"/queryMyFans"
)
@ApiOperation
(
"查询自己的粉丝"
)
@ApiOperation
(
"查询自己的粉丝"
)
@ResponseBody
@ResponseBody
public
CommonResp
queryMyFans
()
{
public
CommonResp
<
List
<
FollowQo
>>
queryMyFans
()
{
String
userId
=
"123"
;
String
userId
=
"123"
;
return
CommonResp
.
success
(
homePageManager
.
queryFansByIdolId
(
userId
));
List
<
FollowQo
>
data
=
homePageManager
.
queryFansByIdolId
(
userId
);
homePageManager
.
judgeFollowed
(
data
,
userId
);
return
CommonResp
.
success
(
data
);
}
}
@
PostMapping
(
value
=
"/queryUserFans
"
)
@
GetMapping
(
value
=
"/queryFansByUserId
"
)
@ApiOperation
(
"查询他人的粉丝"
)
@ApiOperation
(
"查询他人的粉丝"
)
@ResponseBody
@ResponseBody
public
CommonResp
queryFans
(
@RequestParam
String
userId
)
{
public
CommonResp
<
List
<
FollowQo
>>
queryFans
(
@RequestParam
String
targetUser
)
{
return
CommonResp
.
success
(
homePageManager
.
queryFansByIdolId
(
userId
));
String
userId
=
"123"
;
List
<
FollowQo
>
data
=
homePageManager
.
queryFansByIdolId
(
targetUser
);
homePageManager
.
judgeFollowed
(
data
,
userId
);
return
CommonResp
.
success
(
data
);
}
}
@
Pos
tMapping
(
value
=
"/queryMyIdols"
)
@
Ge
tMapping
(
value
=
"/queryMyIdols"
)
@ApiOperation
(
"查询自己的关注"
)
@ApiOperation
(
"查询自己的关注"
)
@ResponseBody
@ResponseBody
public
CommonResp
queryMyIdols
()
{
public
CommonResp
<
List
<
FollowQo
>>
queryMyIdols
()
{
String
userId
=
"123"
;
String
userId
=
"123"
;
return
CommonResp
.
success
(
homePageManager
.
queryIdolsByFollowerId
(
userId
));
List
<
FollowQo
>
data
=
homePageManager
.
queryIdolsByFollowerId
(
userId
);
homePageManager
.
judgeFollowed
(
data
,
userId
);
return
CommonResp
.
success
(
data
);
}
}
@
PostMapping
(
value
=
"/queryUserIdols
"
)
@
GetMapping
(
value
=
"/queryIdolsByUserId
"
)
@ApiOperation
(
"查询他人的关注"
)
@ApiOperation
(
"查询他人的关注"
)
@ResponseBody
@ResponseBody
public
CommonResp
queryIdols
(
@RequestParam
String
userId
)
{
public
CommonResp
queryIdols
(
@RequestParam
String
targetUser
)
{
return
CommonResp
.
success
(
homePageManager
.
queryIdolsByFollowerId
(
userId
));
String
userId
=
"123"
;
List
<
FollowQo
>
data
=
homePageManager
.
queryIdolsByFollowerId
(
targetUser
);
homePageManager
.
judgeFollowed
(
data
,
userId
);
return
CommonResp
.
success
(
data
);
}
}
@PostMapping
(
value
=
"/addIdol"
)
@PostMapping
(
value
=
"/addIdol"
)
...
@@ -57,7 +84,7 @@ public class HomePageController {
...
@@ -57,7 +84,7 @@ public class HomePageController {
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@PostMapping
(
value
=
"/query/
likeThem
e"
)
@PostMapping
(
value
=
"/query/
queryMyLik
e"
)
@ApiOperation
(
"我的点赞"
)
@ApiOperation
(
"我的点赞"
)
@ResponseBody
@ResponseBody
public
CommonResp
likeList
(){
public
CommonResp
likeList
(){
...
...
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
33e75dd2
...
@@ -38,66 +38,7 @@ public class TopicController {
...
@@ -38,66 +38,7 @@ public class TopicController {
return
CommonResp
.
success
(
allTopic
);
return
CommonResp
.
success
(
allTopic
);
}
}
@GetMapping
(
value
=
"/admin/queryTopicDetailList"
)
@ApiOperation
(
"查询所有的话题详情"
)
@ResponseBody
public
CommonResp
<
List
<
TopicBriefInfoDTO
>>
getAllTopicList
(){
List
<
TopicBriefInfoDTO
>
allTopic
=
topicManager
.
getAllTopicBriefInfo
();
return
CommonResp
.
success
(
allTopic
);
}
@PostMapping
(
value
=
"/admin/insertTopic"
)
@ApiOperation
(
"新增话题"
)
@ResponseBody
public
CommonResp
addTopic
(
@RequestParam
String
topicTitle
){
String
userId
=
userHolder
.
getUserId
();
topicManager
.
insertTopic
(
topicTitle
,
userId
);
return
CommonResp
.
success
();
}
@ApiOperation
(
"单个话题数据总览"
)
@PostMapping
(
"/admin/selectOne"
)
@ResponseBody
public
CommonResp
selectOne
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"String"
);
}
TopicDTO
topicDTO
=
topicManager
.
getDetail
(
topicId
);
return
CommonResp
.
success
(
topicDTO
);
}
@PostMapping
(
value
=
"/admin/setTop"
)
@ApiOperation
(
"顶置/取消顶置话题"
)
@ResponseBody
public
CommonResp
setTopTopic
(
@RequestBody
TopicTopReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
setTopTopic
(
req
.
getTopicId
(),
req
.
isTop
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/admin/setConceal"
)
@ApiOperation
(
"隐藏/显示话题"
)
@ResponseBody
public
CommonResp
setConceal
(
@RequestBody
TopicConcealReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
setTopicConceal
(
req
.
getTopicId
(),
req
.
isConceal
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/admin/modifyViewNum"
)
@ApiOperation
(
"话题浏览数调整(后台管理)"
)
@ResponseBody
public
CommonResp
modifyViewNum
(
@RequestBody
TopicModifyMountReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
modifyViewAmount
(
req
.
getTopicId
(),
req
.
getModifyMount
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/admin/dataAnalys"
)
@ApiOperation
(
"话题数据分析(后台管理)"
)
@ResponseBody
public
CommonResp
<
TopicDataAnalysDTO
>
dataAnalys
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
TopicDataAnalysDTO
result
=
topicManager
.
queryDataAnalysis
(
topicId
);
return
CommonResp
.
success
(
result
);
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
33e75dd2
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.req.HomePageReq
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.service.FansRelService
;
import
com.tanpu.community.service.FansRelService
;
import
com.tanpu.community.service.HomePageService
;
import
com.tanpu.community.service.HomePageService
;
...
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
...
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -21,18 +23,50 @@ public class HomePageManager {
...
@@ -21,18 +23,50 @@ public class HomePageManager {
@Resource
@Resource
private
HomePageService
homePageService
;
private
HomePageService
homePageService
;
public
void
editUserInfo
(
HomePageReq
req
,
String
userId
)
{
HomePageEntity
entity
=
HomePageEntity
.
builder
()
.
userId
(
userId
)
.
nickName
(
req
.
getNickName
())
.
headImg
(
req
.
getHeadImg
())
.
introduction
(
req
.
getIntroduction
())
.
sex
(
req
.
getSex
())
.
location
(
req
.
getLocation
())
.
build
();
if
(
homePageService
.
selectByUserId
(
userId
)
==
null
){
homePageService
.
insert
(
entity
);
}
else
{
homePageService
.
update
(
entity
);
}
return
;
}
//获取用户的关注列表
public
List
<
FollowQo
>
queryIdolsByFollowerId
(
String
followerId
)
{
public
List
<
FollowQo
>
queryIdolsByFollowerId
(
String
followerId
)
{
List
<
String
>
idolIds
=
fansRelService
.
queryFansByFollowerId
(
followerId
);
List
<
String
>
idolIds
=
fansRelService
.
queryFansByFollowerId
(
followerId
);
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUserIds
(
idolIds
);
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUserIds
(
idolIds
);
return
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
return
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
}
}
//获取用户的粉丝列表
public
List
<
FollowQo
>
queryFansByIdolId
(
String
idolId
)
{
public
List
<
FollowQo
>
queryFansByIdolId
(
String
idolId
)
{
List
<
String
>
fanIds
=
fansRelService
.
queryFansByIdolId
(
idolId
);
List
<
String
>
fanIds
=
fansRelService
.
queryFansByIdolId
(
idolId
);
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUserIds
(
fanIds
);
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUserIds
(
fanIds
);
return
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
return
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
}
}
//判断返回列表中的用户是否被当前用户关注
public
List
<
FollowQo
>
judgeFollowed
(
List
<
FollowQo
>
followQos
,
String
followerId
){
Set
<
String
>
idolSet
=
fansRelService
.
queryFansByFollowerId
(
followerId
).
stream
().
collect
(
Collectors
.
toSet
());
return
followQos
.
stream
().
map
(
o
->{
if
(
idolSet
.
contains
(
o
.
getUserId
())){
o
.
setFollowed
(
true
);
}
return
o
;
}).
collect
(
Collectors
.
toList
());
}
public
void
addIdol
(
String
idolId
,
String
followerId
)
{
public
void
addIdol
(
String
idolId
,
String
followerId
)
{
fansRelService
.
addFans
(
idolId
,
followerId
);
fansRelService
.
addFans
(
idolId
,
followerId
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
33e75dd2
...
@@ -211,7 +211,7 @@ public class ThemeManager {
...
@@ -211,7 +211,7 @@ public class ThemeManager {
}
else
{
}
else
{
themeQO
.
setFollow
(
false
);
themeQO
.
setFollow
(
false
);
}
}
HomePageEntity
userEntity
=
homePageService
.
selectByUser
(
userId
);
HomePageEntity
userEntity
=
homePageService
.
selectByUser
Id
(
userId
);
themeQO
.
setUserImg
(
userEntity
.
getHeadImg
());
themeQO
.
setUserImg
(
userEntity
.
getHeadImg
());
themeQO
.
setNickName
(
userEntity
.
getNickName
());
themeQO
.
setNickName
(
userEntity
.
getNickName
());
...
...
community-service/src/main/java/com/tanpu/community/service/FansRelService.java
View file @
33e75dd2
...
@@ -3,7 +3,6 @@ package com.tanpu.community.service;
...
@@ -3,7 +3,6 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.dao.mapper.community.FansRelMapper
;
import
com.tanpu.community.dao.mapper.community.FansRelMapper
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -24,9 +23,10 @@ public class FansRelService {
...
@@ -24,9 +23,10 @@ public class FansRelService {
.
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
.
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
}
}
@Cacheable
(
value
=
"tempCache"
,
keyGenerator
=
"communityKeyGenerator"
)
//
@Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
return
fansRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FansRelEntity
>().
eq
(
FansRelEntity:
:
getIdolId
,
idolId
))
return
fansRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FansRelEntity
>()
.
eq
(
FansRelEntity:
:
getIdolId
,
idolId
))
.
stream
().
map
(
FansRelEntity:
:
getFollowerId
).
collect
(
Collectors
.
toList
());
.
stream
().
map
(
FansRelEntity:
:
getFollowerId
).
collect
(
Collectors
.
toList
());
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/HomePageService.java
View file @
33e75dd2
...
@@ -3,9 +3,11 @@ package com.tanpu.community.service;
...
@@ -3,9 +3,11 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.dao.mapper.community.HomePageMapper
;
import
com.tanpu.community.dao.mapper.community.HomePageMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
...
@@ -16,13 +18,26 @@ public class HomePageService {
...
@@ -16,13 +18,26 @@ public class HomePageService {
private
HomePageMapper
homePageMapper
;
private
HomePageMapper
homePageMapper
;
public
HomePageEntity
selectByUser
(
String
userId
){
public
HomePageEntity
selectByUserId
(
String
userId
){
return
homePageMapper
.
selectOne
(
new
LambdaQueryWrapper
<
HomePageEntity
>()
return
homePageMapper
.
selectOne
(
new
LambdaQueryWrapper
<
HomePageEntity
>()
.
in
(
HomePageEntity:
:
get
Id
,
userId
));
.
eq
(
HomePageEntity:
:
getUser
Id
,
userId
));
}
}
public
List
<
HomePageEntity
>
selectListByUserIds
(
List
<
String
>
userIds
){
public
List
<
HomePageEntity
>
selectListByUserIds
(
List
<
String
>
userIds
){
if
(
CollectionUtils
.
isEmpty
(
userIds
)){
return
Collections
.
emptyList
();
}
return
homePageMapper
.
selectList
(
new
LambdaQueryWrapper
<
HomePageEntity
>()
return
homePageMapper
.
selectList
(
new
LambdaQueryWrapper
<
HomePageEntity
>()
.
in
(
HomePageEntity:
:
getId
,
userIds
));
.
in
(
HomePageEntity:
:
getUserId
,
userIds
));
}
public
void
update
(
HomePageEntity
entity
)
{
homePageMapper
.
updateById
(
entity
);
}
public
void
insert
(
HomePageEntity
entity
)
{
homePageMapper
.
insert
(
entity
);
}
}
}
}
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