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
52f1b37f
Commit
52f1b37f
authored
Jun 29, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
req和resp封装
parent
98e0f115
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
458 additions
and
249 deletions
+458
-249
CommunityApi.java
...i/src/main/java/com/tanpu/community/api/CommunityApi.java
+1
-1
FollowQo.java
.../main/java/com/tanpu/community/api/beans/qo/FollowQo.java
+25
-0
ThemeQo.java
...c/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
+5
-11
AlertReq.java
...main/java/com/tanpu/community/api/beans/req/AlertReq.java
+1
-1
CreateCommentReq.java
...a/com/tanpu/community/api/beans/req/CreateCommentReq.java
+2
-2
CreateThemeReq.java
...ava/com/tanpu/community/api/beans/req/CreateThemeReq.java
+33
-0
AddIdolReq.java
...om/tanpu/community/api/beans/req/homepage/AddIdolReq.java
+1
-1
TopicConcealReq.java
.../tanpu/community/api/beans/req/topic/TopicConcealReq.java
+1
-1
TopicModifyMountReq.java
...pu/community/api/beans/req/topic/TopicModifyMountReq.java
+1
-1
TopicTopReq.java
.../com/tanpu/community/api/beans/req/topic/TopicTopReq.java
+1
-1
RedisConfig.java
...src/main/java/com/tanpu/community/config/RedisConfig.java
+98
-99
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+32
-12
MetricsController.java
...ava/com/tanpu/community/controller/MetricsController.java
+3
-1
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+25
-24
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+27
-23
CodeAutoGenerator.java
.../main/java/com/tanpu/community/dao/CodeAutoGenerator.java
+1
-1
HomePageEntity.java
.../tanpu/community/dao/entity/community/HomePageEntity.java
+34
-3
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+15
-10
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+44
-28
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+12
-4
FansRelService.java
...main/java/com/tanpu/community/service/FansRelService.java
+8
-4
HomePageService.java
...ain/java/com/tanpu/community/service/HomePageService.java
+28
-0
ThemeAttachmentService.java
...a/com/tanpu/community/service/ThemeAttachmentService.java
+7
-0
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+4
-0
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+47
-21
create.sql
docs/create.sql
+2
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/CommunityApi.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
api
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.AlertReq
;
import
com.tanpu.community.api.beans.
req.
AlertReq
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/FollowQo.java
0 → 100644
View file @
52f1b37f
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
public
class
FollowQo
{
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
@ApiModelProperty
(
value
=
"头像url"
)
private
String
headImg
;
@ApiModelProperty
(
value
=
"昵称"
)
private
String
nickName
;
@ApiModelProperty
(
value
=
"个人简介"
)
private
String
introduction
;
@ApiModelProperty
(
value
=
"是否关注"
)
private
boolean
followed
;
}
community-api/src/main/java/com/tanpu/community/api/beans/
ThemeDTO
.java
→
community-api/src/main/java/com/tanpu/community/api/beans/
qo/ThemeQo
.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
api
.
beans
;
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -7,7 +7,7 @@ import java.time.LocalDateTime;
import
java.util.List
;
@Data
public
class
Theme
DTO
{
public
class
Theme
Qo
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -29,8 +29,8 @@ public class ThemeDTO {
@ApiModelProperty
(
value
=
"所属的话题"
)
private
String
topicId
;
@ApiModelProperty
(
value
=
"
用户名
"
)
private
String
user
Name
;
@ApiModelProperty
(
value
=
"
昵称
"
)
private
String
nick
Name
;
@ApiModelProperty
(
value
=
"用户头像"
)
private
String
userImg
;
...
...
@@ -59,15 +59,9 @@ public class ThemeDTO {
@ApiModelProperty
(
"附件"
)
private
List
<
Object
>
attachment
;
private
String
createBy
;
private
Object
attachmentInfo
;
private
LocalDateTime
createTime
;
private
String
updateBy
;
private
LocalDateTime
updateTime
;
private
Integer
deleteTag
;
private
Object
attachmentInfo
;
}
community-api/src/main/java/com/tanpu/community/api/beans/AlertReq.java
→
community-api/src/main/java/com/tanpu/community/api/beans/
req/
AlertReq.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
api
.
beans
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
io.swagger.annotations.ApiModel
;
import
lombok.AllArgsConstructor
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/CommentReq.java
→
community-api/src/main/java/com/tanpu/community/api/beans/
req/Create
CommentReq.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
api
.
beans
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
...
...
@@ -7,7 +7,7 @@ import javax.validation.constraints.NotEmpty;
@ApiModel
@Data
public
class
CommentReq
{
public
class
C
reateC
ommentReq
{
@NotEmpty
(
message
=
"主题id不能为空"
)
private
String
themeId
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/CreateThemeReq.java
0 → 100644
View file @
52f1b37f
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Map
;
@Data
public
class
CreateThemeReq
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"类型 1:讨论无标题 2:长文有标题"
)
private
Integer
themeType
;
@ApiModelProperty
(
value
=
"标题"
)
private
String
title
;
@ApiModelProperty
(
value
=
"文本内容"
)
private
String
content
;
@ApiModelProperty
(
value
=
"所属的话题"
)
private
String
topicId
;
@ApiModelProperty
(
value
=
"被转发的主题"
)
private
String
formerThemeId
;
@ApiModelProperty
(
"附件"
)
private
Map
<
String
,
String
>
attachment
;
}
community-
service/src/main/java/com/tanpu/community/model
/req/homepage/AddIdolReq.java
→
community-
api/src/main/java/com/tanpu/community/api/beans
/req/homepage/AddIdolReq.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
model
.
req
.
homepage
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
homepage
;
import
lombok.Data
;
...
...
community-
service/src/main/java/com/tanpu/community/model
/req/topic/TopicConcealReq.java
→
community-
api/src/main/java/com/tanpu/community/api/beans
/req/topic/TopicConcealReq.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
model
.
req
.
topic
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
topic
;
import
lombok.Data
;
...
...
community-
service/src/main/java/com/tanpu/community/model
/req/topic/TopicModifyMountReq.java
→
community-
api/src/main/java/com/tanpu/community/api/beans
/req/topic/TopicModifyMountReq.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
model
.
req
.
topic
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
topic
;
import
lombok.Data
;
...
...
community-
service/src/main/java/com/tanpu/community/model
/req/topic/TopicTopReq.java
→
community-
api/src/main/java/com/tanpu/community/api/beans
/req/topic/TopicTopReq.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
model
.
req
.
topic
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
topic
;
import
lombok.Data
;
...
...
community-service/src/main/java/com/tanpu/community/config/RedisConfig.java
View file @
52f1b37f
//package com.tanpu.community.config;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer;
//import org.springframework.cache.annotation.EnableCaching;
//import org.springframework.cache.interceptor.KeyGenerator;
//import org.springframework.context.annotation.Bean;
//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.RedisConnectionFactory;
//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 redis.clients.jedis.JedisPoolConfig;
//
//import java.lang.reflect.Method;
//import java.time.Duration;
//
//@Configuration
//@EnableCaching
//public class RedisConfig {
//
// @Value("${spring.redis.host}")
// private String host;
// @Value("${spring.redis.port}")
// private int port;
// @Value("${spring.redis.password}")
// private String password;
// @Value("${spring.redis.timeout}")
// private int timeout;
// @Value("${spring.redis.max-active}")
// private int maxActive;
// @Value("${spring.redis.max-wait}")
// private long maxWaitMillis;
// @Value("${spring.redis.max-idle}")
// private int maxIdle;
//
// @Bean
// public JedisPoolConfig jedisPoolConfig() {
// JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
// // maximum connection
// jedisPoolConfig.setMaxTotal(maxActive);
// // Maximum wait time when no connection is available in the pool
// jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
// // Maximum number of idle connections
// jedisPoolConfig.setMinIdle(maxIdle);
// // Other properties can be added by yourself
// return jedisPoolConfig;
// }
//
// @Bean
// public JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
// JedisClientConfiguration jedisClientConfiguration = JedisClientConfiguration.builder().usePooling()
// .poolConfig(jedisPoolConfig).and().readTimeout(Duration.ofMillis(timeout)).build();
// RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
// redisStandaloneConfiguration.setHostName(host);
// redisStandaloneConfiguration.setPort(port);
// redisStandaloneConfiguration.setPassword(RedisPassword.of(password));
// return new JedisConnectionFactory(redisStandaloneConfiguration, jedisClientConfiguration);
// }
//
// @Bean
// public RedisTemplate<String, Object> redisTemplate() {
// RedisTemplate<String, Object> template = new RedisTemplate<>();
// template.setConnectionFactory(jedisConnectionFactory(jedisPoolConfig()));
//
// return template;
// }
//
// /**
// * cache
// */
// @Bean
// public RedisCacheManagerBuilderCustomizer redisCacheManagerBuilderCustomizer() {
// return (builder) -> RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(jedisConnectionFactory(jedisPoolConfig()))
// .withCacheConfiguration("tempCache",
// RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)))
// .withCacheConfiguration("longCache",
// RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofDays(7)));
// }
//
// @Bean("communityKeyGenerator")
// public KeyGenerator keyGenerator() {
// return new RedisConfig.CommunityKeyGenerator();
// }
//
// public static class CommunityKeyGenerator implements KeyGenerator {
// public Object generate(Object target, Method method, Object... params) {
// // todo prefix 加到common
// return "new_community_" + target.getClass().getSimpleName() + "_"
// + method.getName() + "_"
// + StringUtils.arrayToDelimitedString(params, "_");
// }
// }
//}
package
com
.
tanpu
.
community
.
config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.context.annotation.Bean
;
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
redis.clients.jedis.JedisPoolConfig
;
import
java.lang.reflect.Method
;
import
java.time.Duration
;
@Configuration
@EnableCaching
public
class
RedisConfig
{
@Value
(
"${spring.redis.host}"
)
private
String
host
;
@Value
(
"${spring.redis.port}"
)
private
int
port
;
@Value
(
"${spring.redis.password}"
)
private
String
password
;
@Value
(
"${spring.redis.timeout}"
)
private
int
timeout
;
@Value
(
"${spring.redis.max-active}"
)
private
int
maxActive
;
@Value
(
"${spring.redis.max-wait}"
)
private
long
maxWaitMillis
;
@Value
(
"${spring.redis.max-idle}"
)
private
int
maxIdle
;
@Bean
public
JedisPoolConfig
jedisPoolConfig
()
{
JedisPoolConfig
jedisPoolConfig
=
new
JedisPoolConfig
();
// maximum connection
jedisPoolConfig
.
setMaxTotal
(
maxActive
);
// Maximum wait time when no connection is available in the pool
jedisPoolConfig
.
setMaxWaitMillis
(
maxWaitMillis
);
// Maximum number of idle connections
jedisPoolConfig
.
setMinIdle
(
maxIdle
);
// Other properties can be added by yourself
return
jedisPoolConfig
;
}
@Bean
public
JedisConnectionFactory
jedisConnectionFactory
(
JedisPoolConfig
jedisPoolConfig
)
{
JedisClientConfiguration
jedisClientConfiguration
=
JedisClientConfiguration
.
builder
().
usePooling
()
.
poolConfig
(
jedisPoolConfig
).
and
().
readTimeout
(
Duration
.
ofMillis
(
timeout
)).
build
();
RedisStandaloneConfiguration
redisStandaloneConfiguration
=
new
RedisStandaloneConfiguration
();
redisStandaloneConfiguration
.
setHostName
(
host
);
redisStandaloneConfiguration
.
setPort
(
port
);
redisStandaloneConfiguration
.
setPassword
(
RedisPassword
.
of
(
password
));
return
new
JedisConnectionFactory
(
redisStandaloneConfiguration
,
jedisClientConfiguration
);
}
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
()
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
template
.
setConnectionFactory
(
jedisConnectionFactory
(
jedisPoolConfig
()));
return
template
;
}
/**
* cache
*/
@Bean
public
RedisCacheManagerBuilderCustomizer
redisCacheManagerBuilderCustomizer
()
{
return
(
builder
)
->
RedisCacheManager
.
RedisCacheManagerBuilder
.
fromConnectionFactory
(
jedisConnectionFactory
(
jedisPoolConfig
()))
.
withCacheConfiguration
(
"tempCache"
,
RedisCacheConfiguration
.
defaultCacheConfig
().
entryTtl
(
Duration
.
ofSeconds
(
10
)))
.
withCacheConfiguration
(
"longCache"
,
RedisCacheConfiguration
.
defaultCacheConfig
().
entryTtl
(
Duration
.
ofDays
(
7
)));
}
@Bean
(
"communityKeyGenerator"
)
public
KeyGenerator
keyGenerator
()
{
return
new
RedisConfig
.
CommunityKeyGenerator
();
}
public
static
class
CommunityKeyGenerator
implements
KeyGenerator
{
public
Object
generate
(
Object
target
,
Method
method
,
Object
...
params
)
{
// todo prefix 加到common
return
"new_community_"
+
target
.
getClass
().
getSimpleName
()
+
"_"
+
method
.
getName
()
+
"_"
+
StringUtils
.
arrayToDelimitedString
(
params
,
"_"
);
}
}
}
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.req.homepage.AddIdolReq
;
import
com.tanpu.community.manager.HomePageManager
;
import
com.tanpu.community.model.req.homepage.AddIdolReq
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@RestController
@Slf4j
@RequestMapping
(
value
=
"/api/homepage"
)
public
class
HomePageController
{
@Autowired
...
...
@@ -21,28 +20,49 @@ public class HomePageController {
@PostMapping
(
value
=
"/queryMyFans"
)
@ApiOperation
(
"查询自己的粉丝"
)
@ResponseBody
public
String
queryMyFans
()
{
public
CommonResp
queryMyFans
()
{
String
userId
=
"123"
;
List
<
FansRelEntity
>
fans
=
homePageManager
.
queryFansByIdolId
(
userId
);
System
.
out
.
println
(
fans
.
size
());
return
null
;
return
CommonResp
.
success
(
homePageManager
.
queryFansByIdolId
(
userId
));
}
@PostMapping
(
value
=
"/queryMyFans"
)
@ApiOperation
(
"查询他人的粉丝"
)
@ResponseBody
public
CommonResp
queryFans
(
@RequestParam
String
userId
)
{
return
CommonResp
.
success
(
homePageManager
.
queryFansByIdolId
(
userId
));
}
@PostMapping
(
value
=
"/queryMyFans"
)
@ApiOperation
(
"查询自己的关注"
)
@ResponseBody
public
CommonResp
queryMyIdols
()
{
String
userId
=
"123"
;
return
CommonResp
.
success
(
homePageManager
.
queryIdolsByFollowerId
(
userId
));
}
@PostMapping
(
value
=
"/queryUserFans"
)
@ApiOperation
(
"查询他人的关注"
)
@ResponseBody
public
CommonResp
queryIdols
(
@RequestParam
String
userId
)
{
return
CommonResp
.
success
(
homePageManager
.
queryIdolsByFollowerId
(
userId
));
}
@PostMapping
(
value
=
"/addIdol"
)
@ApiOperation
(
"关注他人"
)
@ResponseBody
public
String
addIdol
(
@RequestBody
AddIdolReq
req
)
{
public
CommonResp
addIdol
(
@RequestBody
AddIdolReq
req
)
{
String
userId
=
"123"
;
homePageManager
.
addIdol
(
req
.
idolId
,
userId
);
return
"11"
;
return
CommonResp
.
success
()
;
}
@PostMapping
(
value
=
"/query/likeTheme"
)
@ApiOperation
(
"我的点赞"
)
@ResponseBody
public
String
likeList
(){
public
CommonResp
likeList
(){
String
userId
=
"123"
;
return
"success"
;
return
CommonResp
.
success
()
;
}
}
community-service/src/main/java/com/tanpu/community/controller/MetricsController.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
com.tanpu.community.service.RedisService
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -14,8 +15,9 @@ public class MetricsController {
@ApiOperation
(
"浏览量埋点"
)
@RequestMapping
(
"/pv"
)
public
void
pageView
(
@RequestParam
String
themeId
){
public
CommonResp
pageView
(
@RequestParam
String
themeId
){
redisService
.
incr
(
RedisKeyConstant
.
THEME_VIEW_AMOUNT_
+
themeId
,
1L
);
return
CommonResp
.
success
();
}
...
...
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.community.api.beans.CommentReq
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.req.CreateCommentReq
;
import
com.tanpu.community.api.beans.req.CreateThemeReq
;
import
com.tanpu.community.api.beans.ForwardThemeDTO
;
import
com.tanpu.community.api.beans.
ThemeDTO
;
import
com.tanpu.community.api.beans.
qo.ThemeQo
;
import
com.tanpu.community.manager.ThemeManager
;
import
com.tanpu.community.service.FansRelService
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -27,25 +29,24 @@ public class ThemeController {
@ApiOperation
(
"新增主题"
)
@PostMapping
(
value
=
"/add"
)
@ResponseBody
public
String
insertTheme
(
@RequestBody
ThemeDTO
themeDTO
){
public
CommonResp
insertTheme
(
@RequestBody
CreateThemeReq
req
){
String
userId
=
"liujm"
;
themeDTO
.
setAuthorId
(
userId
);
// themeManager.insert(ThemeConvert.convertToEntity(themeDTO));
return
"success"
;
themeManager
.
createTheme
(
req
,
userId
);
return
CommonResp
.
success
();
}
@ApiOperation
(
"
获取推荐的圈文
"
)
@ApiOperation
(
"
圈子首页-推荐
"
)
@RequestMapping
(
value
=
"/recmend_list"
)
@ResponseBody
public
List
<
Theme
DTO
>
selectHotList
(){
public
List
<
Theme
Qo
>
selectHotList
(){
String
userId
=
"liujm"
;
return
themeManager
.
selectHotThemes
(
userId
);
}
@ApiOperation
(
"
获取关注的圈文
"
)
@ApiOperation
(
"
圈子首页-关注
"
)
@RequestMapping
(
value
=
"/interest_list"
)
@ResponseBody
public
List
<
Theme
DTO
>
selectInterestList
(){
public
List
<
Theme
Qo
>
selectInterestList
(){
String
userId
=
"liujm012"
;
return
themeManager
.
selectInterestThemes
(
userId
);
}
...
...
@@ -53,61 +54,61 @@ public class ThemeController {
@ApiOperation
(
"评论"
)
@RequestMapping
(
value
=
"/comment"
)
@ResponseBody
public
String
commetOnTheme
(
@RequestBody
CommentReq
req
){
public
CommonResp
commetOnTheme
(
@RequestBody
Create
CommentReq
req
){
String
userId
=
"liujm"
;
themeManager
.
comment
(
req
,
userId
);
return
"success"
;
return
CommonResp
.
success
()
;
}
@ApiOperation
(
"转发主题"
)
@RequestMapping
(
value
=
"/forward"
)
@ResponseBody
public
String
forwardTheme
(
ForwardThemeDTO
forwardThemeDTO
){
public
CommonResp
forwardTheme
(
ForwardThemeDTO
forwardThemeDTO
){
String
userId
=
"liujm"
;
themeManager
.
forward
(
forwardThemeDTO
,
userId
);
return
"success"
;
return
CommonResp
.
success
()
;
}
@ApiOperation
(
"点赞主题"
)
@GetMapping
(
value
=
"/like"
)
@ResponseBody
public
String
likeOnTheme
(
@RequestParam
String
themeId
){
public
CommonResp
likeOnTheme
(
@RequestParam
String
themeId
){
String
user
=
"liujm"
;
themeManager
.
like
(
themeId
,
user
);
return
"success"
;
return
CommonResp
.
success
()
;
}
@ApiOperation
(
"分享主题"
)
@GetMapping
(
value
=
"/share"
)
@ResponseBody
public
String
shareTheme
(
String
themeId
){
return
"success"
;
public
CommonResp
shareTheme
(
String
themeId
){
return
CommonResp
.
success
()
;
}
@ApiOperation
(
"收藏主题"
)
@RequestMapping
(
value
=
"/book"
)
@ResponseBody
public
String
bookTheme
(
String
themeId
){
public
CommonResp
bookTheme
(
String
themeId
){
String
user
=
"liujm"
;
// themeManager.book(themeId,user);
return
"success"
;
return
CommonResp
.
success
()
;
}
@ApiOperation
(
"举报主题"
)
@GetMapping
(
value
=
"/complaint"
)
@ResponseBody
public
String
complaintTheme
(
@RequestParam
String
themeId
){
public
CommonResp
complaintTheme
(
@RequestParam
String
themeId
){
return
"功能暂未开放"
;
return
CommonResp
.
failed
(
"功能暂未开放"
)
;
}
@ApiOperation
(
"屏蔽"
)
@RequestMapping
(
value
=
"/conceal"
)
@ResponseBody
public
String
concealTheme
(
String
themeId
){
public
CommonResp
concealTheme
(
String
themeId
){
String
user
=
"liujm"
;
// themeManager.blockContent(themeId,user);
return
"success"
;
return
CommonResp
.
success
()
;
}
}
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
52f1b37f
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.manager.TopicManager
;
import
com.tanpu.community.
model
.req.topic.TopicConcealReq
;
import
com.tanpu.community.
model
.req.topic.TopicModifyMountReq
;
import
com.tanpu.community.
model
.req.topic.TopicTopReq
;
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
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -24,75 +26,77 @@ public class TopicController {
@Autowired
private
TopicManager
topicManager
;
@Autowired
private
UserHolder
userHolder
;
@GetMapping
(
value
=
"/queryTopicInfoList"
)
@ApiOperation
(
"APP全部话题页面,可搜索"
)
@ResponseBody
public
List
<
TopicDTO
>
getTopicBriefInfoList
(){
public
CommonResp
<
List
<
TopicDTO
>
>
getTopicBriefInfoList
(){
List
<
TopicDTO
>
allTopic
=
topicManager
.
getAllTopicDetail
();
return
allTopic
;
return
CommonResp
.
success
(
allTopic
)
;
}
@GetMapping
(
value
=
"/admin/queryTopicDetailList"
)
@ApiOperation
(
"查询所有的话题详情"
)
@ResponseBody
public
List
<
TopicBriefInfoDTO
>
getAllTopicList
(){
public
CommonResp
<
List
<
TopicBriefInfoDTO
>
>
getAllTopicList
(){
List
<
TopicBriefInfoDTO
>
allTopic
=
topicManager
.
getAllTopicBriefInfo
();
return
allTopic
;
return
CommonResp
.
success
(
allTopic
)
;
}
@PostMapping
(
value
=
"/admin/insertTopic"
)
@ApiOperation
(
"新增话题"
)
@ResponseBody
public
String
addTopic
(
@RequestParam
String
topicTitle
){
//TODO:获取登录用户信息
String
userId
=
"liujm"
;
public
CommonResp
addTopic
(
@RequestParam
String
topicTitle
){
String
userId
=
userHolder
.
getUserId
();
topicManager
.
insertTopic
(
topicTitle
,
userId
);
return
"success"
;
return
CommonResp
.
success
()
;
}
@ApiOperation
(
"单个话题数据总览"
)
@PostMapping
(
"/admin/selectOne"
)
@ResponseBody
public
String
selectOne
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
public
CommonResp
selectOne
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"String"
);
}
TopicDTO
topicDTO
=
topicManager
.
getDetail
(
topicId
);
return
"success"
;
return
CommonResp
.
success
(
topicDTO
)
;
}
@PostMapping
(
value
=
"/admin/setTop"
)
@ApiOperation
(
"顶置/取消顶置话题"
)
@ResponseBody
public
String
setTopTopic
(
@RequestBody
TopicTopReq
req
)
throws
MissingServletRequestParameterException
{
public
CommonResp
setTopTopic
(
@RequestBody
TopicTopReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
setTopTopic
(
req
.
getTopicId
(),
req
.
isTop
());
return
"success"
;
return
CommonResp
.
success
()
;
}
@PostMapping
(
value
=
"/admin/setConceal"
)
@ApiOperation
(
"隐藏/显示话题"
)
@ResponseBody
public
String
setConceal
(
@RequestBody
TopicConcealReq
req
)
throws
MissingServletRequestParameterException
{
public
CommonResp
setConceal
(
@RequestBody
TopicConcealReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
setTopicConceal
(
req
.
getTopicId
(),
req
.
isConceal
());
return
"success"
;
return
CommonResp
.
success
()
;
}
@PostMapping
(
value
=
"/admin/modifyViewNum"
)
@ApiOperation
(
"话题浏览数调整"
)
@ApiOperation
(
"话题浏览数调整
(后台管理)
"
)
@ResponseBody
public
String
modifyViewNum
(
@RequestBody
TopicModifyMountReq
req
)
throws
MissingServletRequestParameterException
{
public
CommonResp
modifyViewNum
(
@RequestBody
TopicModifyMountReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
modifyViewAmount
(
req
.
getTopicId
(),
req
.
getModifyMount
());
return
"success"
;
return
CommonResp
.
success
()
;
}
@PostMapping
(
value
=
"/admin/dataAnalys"
)
@ApiOperation
(
"话题数据分析"
)
@ApiOperation
(
"话题数据分析
(后台管理)
"
)
@ResponseBody
public
TopicDataAnalysDTO
dataAnalys
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
public
CommonResp
<
TopicDataAnalysDTO
>
dataAnalys
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
TopicDataAnalysDTO
result
=
topicManager
.
queryDataAnalysis
(
topicId
);
return
result
;
return
CommonResp
.
success
(
result
)
;
}
...
...
community-service/src/main/java/com/tanpu/community/dao/CodeAutoGenerator.java
View file @
52f1b37f
...
...
@@ -22,7 +22,7 @@ public class CodeAutoGenerator {
String
mysqlUserName
=
"tamp_admin"
;
String
mysqlPassword
=
"@imeng123"
;
String
jdbcUrl
=
"jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community"
;
String
[]
tables
=
new
String
[]{
"
collection
"
};
String
[]
tables
=
new
String
[]{
"
home_page
"
};
// String[] tables = new String[]{"visit_summary", "black_list","collection","comment","fans_rel","file_record","home_page","theme","topic"};
String
basePackage
=
"com.tanpu.community"
;
String
mapperPackage
=
"dao.mapper.community"
;
...
...
community-service/src/main/java/com/tanpu/community/dao/entity/community/HomePageEntity.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
dao
.
entity
.
community
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* <p>
...
...
@@ -12,8 +16,11 @@ import io.swagger.annotations.ApiModelProperty;
* </p>
*
* @author xudong
* @since 2021-06-
10
* @since 2021-06-
29
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName
(
"home_page"
)
@ApiModel
(
value
=
"HomePageEntity对象"
,
description
=
"个人主页"
)
public
class
HomePageEntity
implements
Serializable
{
...
...
@@ -35,6 +42,12 @@ public class HomePageEntity implements Serializable {
@ApiModelProperty
(
value
=
"个人简介"
)
private
String
introduction
;
@ApiModelProperty
(
value
=
"性别"
)
private
Integer
sex
;
@ApiModelProperty
(
value
=
"地址"
)
private
String
location
;
private
String
createBy
;
private
LocalDateTime
createTime
;
...
...
@@ -86,6 +99,22 @@ public class HomePageEntity implements Serializable {
this
.
introduction
=
introduction
;
}
public
Integer
getSex
()
{
return
sex
;
}
public
void
setSex
(
Integer
sex
)
{
this
.
sex
=
sex
;
}
public
String
getLocation
()
{
return
location
;
}
public
void
setLocation
(
String
location
)
{
this
.
location
=
location
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
...
...
@@ -134,6 +163,8 @@ public class HomePageEntity implements Serializable {
", headImg="
+
headImg
+
", nickName="
+
nickName
+
", introduction="
+
introduction
+
", sex="
+
sex
+
", location="
+
location
+
", createBy="
+
createBy
+
", createTime="
+
createTime
+
", updateBy="
+
updateBy
+
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
manager
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.dao.mapper.community.FansRelMapper
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.service.FansRelService
;
import
com.tanpu.community.service.HomePageService
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
HomePageManager
{
...
...
@@ -16,16 +18,19 @@ public class HomePageManager {
@Autowired
private
FansRelService
fansRelService
;
public
List
<
FansRelEntity
>
queryFansByFollowerId
(
String
followerId
)
{
return
fansRelService
.
queryFansByFollowerId
(
followerId
)
;
@Resource
private
HomePageService
homePageService
;
// todo 组装粉丝的头像等信息
public
List
<
FollowQo
>
queryIdolsByFollowerId
(
String
followerId
)
{
List
<
String
>
idolIds
=
fansRelService
.
queryFansByFollowerId
(
followerId
);
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUserIds
(
idolIds
);
return
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
}
public
List
<
F
ansRelEntity
>
queryFansByIdolId
(
String
idolId
)
{
return
fansRelService
.
queryFansByIdolId
(
idolId
);
// todo 组装粉丝的头像等信息
public
List
<
F
ollowQo
>
queryFansByIdolId
(
String
idolId
)
{
List
<
String
>
fanIds
=
fansRelService
.
queryFansByIdolId
(
idolId
);
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUserIds
(
fanIds
);
return
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
}
public
void
addIdol
(
String
idolId
,
String
followerId
)
{
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.api.beans.CommentReq
;
import
com.tanpu.community.api.beans.req.CreateCommentReq
;
import
com.tanpu.community.api.beans.req.CreateThemeReq
;
import
com.tanpu.community.api.beans.ForwardThemeDTO
;
import
com.tanpu.community.api.beans.
ThemeDTO
;
import
com.tanpu.community.api.beans.
qo.ThemeQo
;
import
com.tanpu.community.api.constants.BlockTypeEnum
;
import
com.tanpu.community.api.constants.CollectionTypeEnum
;
import
com.tanpu.community.api.constants.CommentTypeEnum
;
...
...
@@ -12,6 +13,7 @@ import com.tanpu.community.dao.entity.user.OrderFlowEntity;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -20,7 +22,7 @@ import java.time.Duration;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
import
java.util.
Map
;
import
java.util.
Set
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -58,27 +60,40 @@ public class ThemeManager {
@Autowired
private
ThemeAttachmentService
themeAttachmentService
;
@Autowired
private
HomePageService
homePageService
;
public
void
createTheme
(
CreateThemeReq
req
,
String
userId
)
{
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
themeEntity
.
setAuthorId
(
userId
);
themeService
.
insertTheme
(
themeEntity
);
List
<
ThemeAttachmentEntity
>
themeAttachments
=
ConvertUtil
.
themeReqToAttachmentList
(
req
,
themeEntity
.
getId
());
themeAttachmentService
.
insertList
(
themeAttachments
);
}
// 返回推荐主题文章
public
List
<
Theme
DTO
>
selectHotThemes
(
String
userId
)
{
public
List
<
Theme
Qo
>
selectHotThemes
(
String
userId
)
{
// TODO:根据算法计算推荐主题
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectAll
();
List
<
Theme
DTO
>
themeDTOS
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
for
(
Theme
DTO
themeDTO
:
themeDTOS
)
{
fillDTOExtraInfo
(
theme
DT
O
,
userId
);
List
<
Theme
Qo
>
themeQos
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
for
(
Theme
Qo
themeQO
:
themeQos
)
{
fillDTOExtraInfo
(
theme
Q
O
,
userId
);
}
return
theme
DTOS
;
return
theme
Qos
;
}
// 返回关注主题
public
List
<
Theme
DTO
>
selectInterestThemes
(
String
userId
)
{
List
<
String
>
fansList
=
fansRelService
.
queryFansByFollowerId
(
userId
)
.
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
())
;
public
List
<
Theme
Qo
>
selectInterestThemes
(
String
userId
)
{
List
<
String
>
fansList
=
fansRelService
.
queryFansByFollowerId
(
userId
);
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectByFans
(
fansList
);
List
<
Theme
DTO
>
themeDTOS
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
for
(
Theme
DTO
themeDTO
:
themeDTOS
)
{
fillDTOExtraInfo
(
theme
DT
O
,
userId
);
List
<
Theme
Qo
>
themeQos
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
for
(
Theme
Qo
themeQO
:
themeQos
)
{
fillDTOExtraInfo
(
theme
Q
O
,
userId
);
}
return
theme
DTOS
;
return
theme
Qos
;
}
private
String
calUpToNowTime
(
LocalDateTime
start
)
{
...
...
@@ -105,7 +120,7 @@ public class ThemeManager {
}
// 评论(对主题)
public
void
comment
(
CommentReq
req
,
String
userId
)
{
public
void
comment
(
C
reateC
ommentReq
req
,
String
userId
)
{
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
targetId
(
req
.
getThemeId
())
.
authorId
(
userId
)
...
...
@@ -177,29 +192,29 @@ public class ThemeManager {
// }
// }
public
void
insert
(
ThemeEntity
themeEntity
)
{
themeService
.
insertTheme
(
themeEntity
);
}
//查询话题所需关联信息
private
void
fillDTOExtraInfo
(
Theme
DTO
themeDTO
,
String
userId
)
{
List
<
ThemeAttachmentEntity
>
attachments
=
themeAttachmentService
.
selectByThemeId
(
theme
DT
O
.
getId
());
private
void
fillDTOExtraInfo
(
Theme
Qo
themeQO
,
String
userId
)
{
List
<
ThemeAttachmentEntity
>
attachments
=
themeAttachmentService
.
selectByThemeId
(
theme
Q
O
.
getId
());
if
(
CollectionUtils
.
isEmpty
(
attachments
)){
return
;
}
List
<
Object
>
obs
=
attachments
.
stream
().
map
(
themeAttachmentEntity
->
transferAttachment
(
themeAttachmentEntity
,
userId
)).
collect
(
Collectors
.
toList
());
theme
DT
O
.
setAttachment
(
obs
);
theme
Q
O
.
setAttachment
(
obs
);
//是否关注
theme
DTO
.
setUpToNowTime
(
calUpToNowTime
(
themeDT
O
.
getCreateTime
()));
String
authorId
=
theme
DTO
.
getCreateBy
();
Map
<
String
,
FansRelEntity
>
fansMap
=
fansRelService
.
queryFansByFollowerId
(
userId
).
stream
().
collect
(
Collectors
.
toMap
(
FansRelEntity:
:
getIdolId
,
c
->
c
));
if
(
fans
Map
.
containsKey
(
authorId
))
{
theme
DT
O
.
setFollow
(
true
);
theme
QO
.
setUpToNowTime
(
calUpToNowTime
(
themeQ
O
.
getCreateTime
()));
String
authorId
=
theme
QO
.
getAuthorId
();
Set
<
String
>
fansSet
=
fansRelService
.
queryFansByFollowerId
(
userId
).
stream
().
collect
(
Collectors
.
toSet
(
));
if
(
fans
Set
.
contains
(
authorId
))
{
theme
Q
O
.
setFollow
(
true
);
}
else
{
theme
DT
O
.
setFollow
(
false
);
theme
Q
O
.
setFollow
(
false
);
}
//TODO 添加用户名、头像、认证、是否关注
HomePageEntity
userEntity
=
homePageService
.
selectByUser
(
userId
);
themeQO
.
setUserImg
(
userEntity
.
getHeadImg
());
themeQO
.
setNickName
(
userEntity
.
getNickName
());
}
public
Object
transferAttachment
(
ThemeAttachmentEntity
themeAttachment
,
String
userId
){
...
...
@@ -225,4 +240,5 @@ public class ThemeManager {
}
}
}
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
52f1b37f
...
...
@@ -35,18 +35,22 @@ public class TopicManager {
@Autowired
private
CommentService
commentService
;
//新增话题
public
void
insertTopic
(
String
topicTitle
,
String
userId
)
{
topicService
.
addTopic
(
topicTitle
,
userId
);
}
if
(
topicService
.
queryByTitile
(
topicTitle
)
==
null
){
topicService
.
addTopic
(
topicTitle
,
userId
);
}
return
;
}
//
后台管理-话题
列表
//
话题详情
列表
public
List
<
TopicDTO
>
getAllTopicDetail
()
{
return
ConvertUtil
.
topicEntitiesToDTOs
(
topicService
.
queryAll
());
}
//
APP-话题
列表
//
话题简介
列表
public
List
<
TopicBriefInfoDTO
>
getAllTopicBriefInfo
()
{
List
<
TopicEntity
>
allTopic
=
topicService
.
queryAll
();
List
<
TopicBriefInfoDTO
>
topicDTOS
=
ConvertUtil
.
topicEntitiesToBriefDTOs
(
allTopic
);
...
...
@@ -96,6 +100,10 @@ public class TopicManager {
}
public
void
modifyViewAmount
(
String
topicId
,
Long
modifyMount
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
if
(
topicEntity
==
null
)
{
throw
new
BizException
(
"找不到话题,id:"
+
topicId
);
}
topicService
.
modifyViewAmount
(
topicId
,
modifyMount
);
if
(
modifyMount
>
0
)
{
redisService
.
incr
(
RedisKeyConstant
.
TOPIC_TOTAL_VIEW_AMOUNT_
+
topicId
,
modifyMount
);
...
...
community-service/src/main/java/com/tanpu/community/service/FansRelService.java
View file @
52f1b37f
...
...
@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@EnableCaching
@Service
...
...
@@ -17,13 +18,16 @@ public class FansRelService {
@Resource
private
FansRelMapper
fansRelMapper
;
public
List
<
FansRelEntity
>
queryFansByFollowerId
(
String
followerId
)
{
return
fansRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FansRelEntity
>().
eq
(
FansRelEntity:
:
getFollowerId
,
followerId
));
public
List
<
String
>
queryFansByFollowerId
(
String
followerId
)
{
return
fansRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FansRelEntity
>()
.
eq
(
FansRelEntity:
:
getFollowerId
,
followerId
))
.
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
}
@Cacheable
(
value
=
"tempCache"
,
keyGenerator
=
"communityKeyGenerator"
)
public
List
<
FansRelEntity
>
queryFansByIdolId
(
String
idolId
)
{
return
fansRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FansRelEntity
>().
eq
(
FansRelEntity:
:
getIdolId
,
idolId
));
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
return
fansRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FansRelEntity
>().
eq
(
FansRelEntity:
:
getIdolId
,
idolId
))
.
stream
().
map
(
FansRelEntity:
:
getFollowerId
).
collect
(
Collectors
.
toList
());
}
public
void
addFans
(
String
idolId
,
String
followerId
)
{
...
...
community-service/src/main/java/com/tanpu/community/service/HomePageService.java
0 → 100644
View file @
52f1b37f
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.dao.mapper.community.HomePageMapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
HomePageService
{
@Resource
private
HomePageMapper
homePageMapper
;
public
HomePageEntity
selectByUser
(
String
userId
){
return
homePageMapper
.
selectOne
(
new
LambdaQueryWrapper
<
HomePageEntity
>()
.
in
(
HomePageEntity:
:
getId
,
userId
));
}
public
List
<
HomePageEntity
>
selectListByUserIds
(
List
<
String
>
userIds
){
return
homePageMapper
.
selectList
(
new
LambdaQueryWrapper
<
HomePageEntity
>()
.
in
(
HomePageEntity:
:
getId
,
userIds
));
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeAttachmentService.java
View file @
52f1b37f
...
...
@@ -18,4 +18,11 @@ public class ThemeAttachmentService {
return
themeAttachmentMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeAttachmentEntity
>()
.
eq
(
ThemeAttachmentEntity:
:
getThemeId
,
themeId
));
}
public
void
insertList
(
List
<
ThemeAttachmentEntity
>
themeAttachments
)
{
for
(
ThemeAttachmentEntity
themeAttachment
:
themeAttachments
)
{
themeAttachmentMapper
.
insert
(
themeAttachment
);
}
return
;
}
}
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
52f1b37f
...
...
@@ -80,4 +80,8 @@ public class TopicService {
.
eq
(
TopicEntity:
:
getViewAmountModify
,
oldAmount
));
return
;
}
public
TopicEntity
queryByTitile
(
String
topicTitle
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>().
eq
(
TopicEntity:
:
getTopicTitle
,
topicTitle
));
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
52f1b37f
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.community.api.beans.ThemeDTO
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.req.CreateThemeReq
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.TopicBriefInfoDTO
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.api.constants.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.dao.entity.community.ThemeAttachmentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.user.CurriculumResEntity
;
import
com.tanpu.community.dao.entity.user.FinProResEntity
;
import
com.tanpu.community.dao.entity.user.OrderFlowEntity
;
import
com.tanpu.community.dao.entity.zhibo.ZhiboThemeEntity
;
import
org.springframework.beans.BeanUtils
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
ConvertUtil
{
public
static
Theme
DTO
themeEntityToDTO
(
ThemeEntity
themeEntity
)
{
Theme
DTO
themeDTO
=
new
ThemeDTO
();
BeanUtils
.
copyProperties
(
themeEntity
,
theme
DT
O
);
return
theme
DT
O
;
public
static
Theme
Qo
themeEntityToDTO
(
ThemeEntity
themeEntity
)
{
Theme
Qo
themeQO
=
new
ThemeQo
();
BeanUtils
.
copyProperties
(
themeEntity
,
theme
Q
O
);
return
theme
Q
O
;
}
public
static
ThemeEntity
themeDTOToEntity
(
Theme
DTO
themeDTO
)
{
public
static
ThemeEntity
themeDTOToEntity
(
Theme
Qo
themeQO
)
{
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
theme
DTO
,
themeEntity
);
BeanUtils
.
copyProperties
(
theme
QO
,
themeEntity
);
return
themeEntity
;
}
public
static
List
<
Theme
DTO
>
themeEntitiesToDTOs
(
List
<
ThemeEntity
>
themeEntities
)
{
public
static
List
<
Theme
Qo
>
themeEntitiesToDTOs
(
List
<
ThemeEntity
>
themeEntities
)
{
return
themeEntities
.
stream
().
map
(
ConvertUtil:
:
themeEntityToDTO
).
collect
(
Collectors
.
toList
());
}
public
static
List
<
ThemeEntity
>
themeDTOSToEntitys
(
List
<
Theme
DTO
>
themeDTOS
)
{
return
theme
DTOS
.
stream
().
map
(
ConvertUtil:
:
themeDTOToEntity
).
collect
(
Collectors
.
toList
());
public
static
List
<
ThemeEntity
>
themeDTOSToEntitys
(
List
<
Theme
Qo
>
themeQos
)
{
return
theme
Qos
.
stream
().
map
(
ConvertUtil:
:
themeDTOToEntity
).
collect
(
Collectors
.
toList
());
}
public
static
TopicDTO
topicEntityToDTO
(
TopicEntity
topicEntity
){
public
static
TopicDTO
topicEntityToDTO
(
TopicEntity
topicEntity
)
{
TopicDTO
topicDTO
=
new
TopicDTO
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicDTO
);
BeanUtils
.
copyProperties
(
topicEntity
,
topicDTO
);
return
topicDTO
;
}
public
static
TopicBriefInfoDTO
topicToBriefInfoDTO
(
TopicEntity
topicEntity
){
public
static
TopicBriefInfoDTO
topicToBriefInfoDTO
(
TopicEntity
topicEntity
)
{
TopicBriefInfoDTO
topicBriefInfoDTO
=
new
TopicBriefInfoDTO
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicBriefInfoDTO
);
BeanUtils
.
copyProperties
(
topicEntity
,
topicBriefInfoDTO
);
return
topicBriefInfoDTO
;
}
public
static
List
<
TopicDTO
>
topicEntitiesToDTOs
(
List
<
TopicEntity
>
topicEntities
){
public
static
List
<
TopicDTO
>
topicEntitiesToDTOs
(
List
<
TopicEntity
>
topicEntities
)
{
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicEntityToDTO
).
collect
(
Collectors
.
toList
());
}
...
...
@@ -64,7 +65,7 @@ public class ConvertUtil {
public
static
DeleteTagEnum
deleteTagShift
(
DeleteTagEnum
deleteTagEnum
)
{
if
(
deleteTagEnum
.
getCode
().
equals
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
{
return
DeleteTagEnum
.
DELETED
;
}
else
{
}
else
{
return
DeleteTagEnum
.
NOT_DELETED
;
}
}
...
...
@@ -72,9 +73,34 @@ public class ConvertUtil {
public
static
Integer
deleteTagShift
(
Integer
deleteTag
)
{
if
(
deleteTag
.
equals
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
{
return
DeleteTagEnum
.
DELETED
.
getCode
();
}
else
{
}
else
{
return
DeleteTagEnum
.
NOT_DELETED
.
getCode
();
}
}
public
static
List
<
ThemeAttachmentEntity
>
themeReqToAttachmentList
(
CreateThemeReq
req
,
String
themeId
)
{
if
(
req
==
null
||
req
.
getAttachment
()
==
null
||
req
.
getAttachment
().
size
()
==
0
)
{
return
Collections
.
emptyList
();
}
List
<
ThemeAttachmentEntity
>
list
=
new
ArrayList
<>();
req
.
getAttachment
().
forEach
((
k
,
v
)
->
{
list
.
add
(
ThemeAttachmentEntity
.
builder
()
.
attachType
(
Integer
.
valueOf
(
k
))
.
attchId
(
v
)
.
themeId
(
themeId
)
.
build
());
});
return
list
;
}
public
static
FollowQo
homePageEntity2FollowQo
(
HomePageEntity
entity
)
{
if
(
entity
==
null
)
{
return
null
;
}
FollowQo
followQo
=
new
FollowQo
();
BeanUtils
.
copyProperties
(
entity
,
followQo
);
return
followQo
;
}
}
docs/create.sql
View file @
52f1b37f
...
...
@@ -4,6 +4,8 @@ CREATE TABLE `home_page` (
`head_img`
varchar
(
256
)
NOT
NULL
COMMENT
'头像url'
,
`nick_name`
varchar
(
32
)
NOT
NULL
COMMENT
'昵称'
,
`introduction`
varchar
(
256
)
NOT
NULL
COMMENT
'个人简介'
,
`sex`
int
(
3
)
COMMENT
'性别'
,
`location`
varchar
(
256
)
COMMENT
'地址'
,
`create_by`
varchar
(
64
)
DEFAULT
''
,
`create_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
`update_by`
varchar
(
64
)
DEFAULT
''
,
...
...
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