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
a257696c
Commit
a257696c
authored
Jun 23, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
topic表添加字段
parent
03101543
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
185 additions
and
91 deletions
+185
-91
DeleteTagEnum.java
...java/com/tanpu/community/api/constants/DeleteTagEnum.java
+34
-0
RedisKeyConstant.java
...a/com/tanpu/community/api/constants/RedisKeyConstant.java
+8
-8
TopicStatusEnum.java
...va/com/tanpu/community/api/constants/TopicStatusEnum.java
+2
-0
CollectionEntity.java
...anpu/community/dao/entity/community/CollectionEntity.java
+9
-2
CommentEntity.java
...m/tanpu/community/dao/entity/community/CommentEntity.java
+9
-2
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+22
-24
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+8
-8
BlackListService.java
...in/java/com/tanpu/community/service/BlackListService.java
+5
-4
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+54
-27
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+4
-6
RedisService.java
...c/main/java/com/tanpu/community/service/RedisService.java
+8
-8
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+5
-2
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+17
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/constants/DeleteTagEnum.java
0 → 100644
View file @
a257696c
package
com
.
tanpu
.
community
.
api
.
constants
;
public
enum
DeleteTagEnum
{
NOT_DELETED
(
0
,
"未删除"
),
DELETED
(
1
,
"已删除"
);
private
Integer
code
;
private
String
type
;
DeleteTagEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
community-api/src/main/java/com/tanpu/community/api/constants/RedisKeyConstant.java
View file @
a257696c
...
...
@@ -4,28 +4,28 @@ public class RedisKeyConstant {
//话题页浏览量
public
static
final
String
TOPIC_VIEW_AMOUNT_
=
"TOPIC_PAGE_VIEW_AMOUNT_"
;
//话题总浏览量
//话题总浏览量
=总浏览量+带这个话题的帖子量
public
static
final
String
TOPIC_TOTAL_VIEW_AMOUNT_
=
"TOPIC_TOTAL_VIEW_AMOUNT_"
;
//点赞量
public
static
final
String
TOPIC_LIKE_AMOUNT_
=
"TOPIC_LIKE_AMOUNT_"
;
//收藏量
public
static
final
String
TOPIC_BOOK_AMOUNT_
=
"TOPIC_BOOK_AMOUNT_"
;
//评论数
public
static
final
String
TOPIC_COMMENT_AMOUNT_
=
"TOPIC_COMMENT_AMOUNT_"
;
//用户数
public
static
final
String
TOPIC_USER_AMOUNT_
=
"TOPIC_USER_AMOUNT_"
;
//讨论量
//讨论量
=发布主题贴数+回复总数
public
static
final
String
TOPIC_DISCUSS_AMOUNT_
=
"TOPIC_DISCUSS_AMOUNT_"
;
//发帖数
public
static
final
String
TOPIC_THEME_AMOUNT_
=
"TOPIC_THEME_AMOUNT_"
;
//回帖数
public
static
final
String
TOPIC_COM
ENT_AMOUNT_
=
"TOPIC_CO
MENT_AMOUNT_"
;
//总用户数
public
static
final
String
TOPIC_COM
MENT_AMOUNT_
=
"TOPIC_COM
MENT_AMOUNT_"
;
//总用户数
=访问话题页+发帖+回帖(去重)
public
static
final
String
TOPIC_TOTAOL_USER_AMOUNT_
=
"TOPIC_TOTAOL_USER_AMOUNT_"
;
//访问话题人数
public
static
final
String
TOPIC_USER_VIEW_AMOUNT_
=
"TOPIC_USER_VIEW_AMOUNT_"
;
//发帖人数
public
static
final
String
TOPIC_
POSTER_AMOUNT_
=
"TOPIC_POSTER
_AMOUNT_"
;
public
static
final
String
TOPIC_
USER_POST_AMOUNT_
=
"TOPIC_USER_POST
_AMOUNT_"
;
//回帖人数
public
static
final
String
TOPIC_
REPLIER_AMOUNT_
=
"TOPIC_REPLIER
_AMOUNT_"
;
public
static
final
String
TOPIC_
USER_COMMET_AMOUNT_
=
"TOPIC_USER_COMMET
_AMOUNT_"
;
public
static
final
String
THEME_VIEW_AMOUNT_
=
"THEME_VIEW_AMOUNT_"
;
public
static
final
String
THEME_LIKE_AMOUNT_
=
"THEME_LIKE_AMOUNT_"
;
...
...
community-api/src/main/java/com/tanpu/community/api/constants/TopicStatusEnum.java
View file @
a257696c
...
...
@@ -27,4 +27,6 @@ public enum TopicStatusEnum {
this
.
code
=
code
;
this
.
status
=
status
;
}
}
community-service/src/main/java/com/tanpu/community/dao/entity/community/CollectionEntity.java
View file @
a257696c
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>
...
...
@@ -14,6 +18,9 @@ import io.swagger.annotations.ApiModelProperty;
* @author xudong
* @since 2021-06-10
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName
(
"collection"
)
@ApiModel
(
value
=
"CollectionEntity对象"
,
description
=
"收藏/点赞"
)
public
class
CollectionEntity
implements
Serializable
{
...
...
community-service/src/main/java/com/tanpu/community/dao/entity/community/CommentEntity.java
View file @
a257696c
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>
...
...
@@ -14,6 +18,9 @@ import io.swagger.annotations.ApiModelProperty;
* @author xudong
* @since 2021-06-10
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName
(
"comment"
)
@ApiModel
(
value
=
"CommentEntity对象"
,
description
=
"评论"
)
public
class
CommentEntity
implements
Serializable
{
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
a257696c
...
...
@@ -40,9 +40,9 @@ public class ThemeManager {
@Autowired
private
RedisService
redisService
;
//返回推荐主题文章
public
List
<
ThemeDTO
>
selectHotThemes
(){
//TODO:根据算法计算推荐主题
//
返回推荐主题文章
public
List
<
ThemeDTO
>
selectHotThemes
()
{
//
TODO:根据算法计算推荐主题
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectAll
();
List
<
ThemeDTO
>
themeDTOS
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
for
(
ThemeDTO
themeDTO
:
themeDTOS
)
{
...
...
@@ -53,8 +53,8 @@ public class ThemeManager {
return
themeDTOS
;
}
//返回关注主题
public
List
<
ThemeDTO
>
selectInterestThemes
(
String
userId
){
//
返回关注主题
public
List
<
ThemeDTO
>
selectInterestThemes
(
String
userId
)
{
List
<
String
>
fansList
=
fansRelService
.
queryFansByFollowerId
(
userId
).
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectByFans
(
fansList
);
List
<
ThemeDTO
>
themeDTOS
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
...
...
@@ -69,21 +69,21 @@ public class ThemeManager {
private
String
calUpToNowTime
(
LocalDateTime
start
)
{
Duration
between
=
Duration
.
between
(
LocalDateTime
.
now
(),
start
);
long
duration
=
between
.
toMinutes
();
if
(
duration
<
1
)
{
if
(
duration
<
1
)
{
return
"刚刚"
;
}
else
if
(
duration
<
60
)
{
return
duration
+
"分钟前"
;
}
else
if
(
duration
<
60
*
24
)
{
return
duration
/
60
+
"小时前"
;
}
else
if
(
start
.
getYear
()==
LocalDateTime
.
now
().
getYear
())
{
}
else
if
(
duration
<
60
)
{
return
duration
+
"分钟前"
;
}
else
if
(
duration
<
60
*
24
)
{
return
duration
/
60
+
"小时前"
;
}
else
if
(
start
.
getYear
()
==
LocalDateTime
.
now
().
getYear
())
{
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"MM-dd HH:mm:ss"
));
}
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
}
//点赞
//
点赞
public
void
like
(
String
themeId
,
String
userId
)
{
collectionService
.
add
Collection
(
themeId
,
userId
,
CollectionTypeEnum
.
LIKE
);
collectionService
.
add
IfNotExist
(
themeId
,
userId
,
CollectionTypeEnum
.
LIKE
);
}
public
void
unlike
(
String
themeId
,
String
userId
)
{
...
...
@@ -91,11 +91,13 @@ public class ThemeManager {
// 评论(对主题)
public
void
commentToTheme
(
String
themeId
,
String
userId
,
String
comment
)
{
CommentEntity
commentEntity
=
new
CommentEntity
();
commentEntity
.
setTargetId
(
themeId
);
commentEntity
.
setAuthorId
(
userId
);
commentEntity
.
setCommentType
(
CommentTypeEnum
.
THEME
.
getCode
());
commentEntity
.
setContent
(
comment
);
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
targetId
(
themeId
)
.
authorId
(
userId
)
.
content
(
comment
)
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
build
();
commentService
.
insertComment
(
commentEntity
);
}
...
...
@@ -104,14 +106,10 @@ public class ThemeManager {
//TODO
}
//分享
public
void
share
(
String
themeId
,
String
user
)
{
//TODO
}
//收藏
public
void
favorite
(
String
themeId
,
String
userId
)
{
collectionService
.
add
Collection
(
themeId
,
userId
,
CollectionTypeEnum
.
BOOK
);
collectionService
.
add
IfNotExist
(
themeId
,
userId
,
CollectionTypeEnum
.
BOOK
);
}
public
void
unFavorite
(
String
themeId
,
String
userId
)
{
...
...
@@ -137,7 +135,7 @@ public class ThemeManager {
public
void
blockTheme
(
String
themeId
,
String
userId
)
{
blackListService
.
addBlock
(
themeId
,
userId
,
BlockTypeEnum
.
THEME
);
BlackListEntity
selectOne
=
blackListService
.
selectOne
(
userId
,
BlockTypeEnum
.
USER
.
getCode
(),
themeService
.
selectTheme
(
themeId
).
getAuthorId
());
if
(
selectOne
==
null
)
{
if
(
selectOne
==
null
)
{
blackListService
.
addBlock
(
themeService
.
selectTheme
(
themeId
).
getAuthorId
(),
userId
,
BlockTypeEnum
.
USER
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
a257696c
...
...
@@ -47,12 +47,12 @@ public class TopicManager {
public
List
<
TopicDTO
>
getAllTopicDetail
()
{
return
ConvertUtil
.
topicEntitiesToDTOs
(
topicService
.
query
TopicList
());
return
ConvertUtil
.
topicEntitiesToDTOs
(
topicService
.
query
All
());
}
public
List
<
TopicBriefInfoDTO
>
getAllTopicBriefInfo
()
{
List
<
TopicEntity
>
allTopic
=
topicService
.
query
TopicList
();
List
<
TopicEntity
>
allTopic
=
topicService
.
query
All
();
List
<
TopicBriefInfoDTO
>
topicDTOS
=
ConvertUtil
.
topicEntitiesToBriefDTOs
(
allTopic
);
//讨论数=发布主题贴数+回复总数
for
(
TopicBriefInfoDTO
topicDTO
:
topicDTOS
)
{
...
...
@@ -109,8 +109,10 @@ public class TopicManager {
public
void
refreshRedisCache
(){
List
<
String
>
topicIds
=
topicService
.
queryTopicList
().
stream
().
map
(
TopicEntity:
:
getId
).
collect
(
Collectors
.
toList
());
for
(
String
topicId
:
topicIds
)
{
List
<
TopicEntity
>
topicEntities
=
topicService
.
queryAll
();
for
(
TopicEntity
topic
:
topicEntities
)
{
String
topicId
=
topic
.
getId
();
Long
viewAmountModify
=
topic
.
getViewAmountModify
();
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectByTopic
(
topicId
);
List
<
String
>
themeIds
=
themeEntities
.
stream
().
map
(
ThemeEntity:
:
getId
).
collect
(
Collectors
.
toList
());
Long
likeAmountByThemeIds
=
collectionService
.
getLikeAmountByThemeIds
(
themeIds
);
...
...
@@ -119,16 +121,14 @@ public class TopicManager {
redisService
.
set
(
RedisKeyConstant
.
TOPIC_LIKE_AMOUNT_
+
topicId
,
likeAmountByThemeIds
);
redisService
.
set
(
RedisKeyConstant
.
TOPIC_BOOK_AMOUNT_
+
topicId
,
bookAmountByThemeIds
);
redisService
.
set
(
RedisKeyConstant
.
TOPIC_COMMENT_AMOUNT_
+
topicId
,
commentAmountByThemeIds
);
redisService
.
set
(
RedisKeyConstant
.
TOPIC_DISCUSS_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_TOTAL_VIEW_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_THEME_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_COMENT_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_TOTAOL_USER_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_DISCUSS_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_
POSTER_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_
REPLIER_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_
USER_POST_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
redisService
.
set
(
RedisKeyConstant
.
TOPIC_
USER_COMMET_AMOUNT_
+
topicId
,
commentAmountByThemeIds
+
themeIds
.
size
());
}
...
...
community-service/src/main/java/com/tanpu/community/service/BlackListService.java
View file @
a257696c
...
...
@@ -18,13 +18,14 @@ public class BlackListService {
blackListEntity
.
setBlockedId
(
blockId
);
blackListEntity
.
setBlocker
(
userId
);
blackListEntity
.
setBlockedType
(
type
.
getCode
());
blackListMapper
.
insert
(
blackListEntity
);
}
public
BlackListEntity
selectOne
(
String
blocker
,
Integer
blockType
,
String
blockId
)
{
return
blackListMapper
.
selectOne
(
new
LambdaQueryWrapper
<
BlackListEntity
>().
eq
(
BlackListEntity:
:
getBlocker
,
blocker
).
eq
(
BlackListEntity:
:
getBlockedId
,
blockId
).
eq
(
BlackListEntity:
:
getBlockedType
,
blockType
));
public
BlackListEntity
selectOne
(
String
blocker
,
Integer
blockType
,
String
blockId
)
{
return
blackListMapper
.
selectOne
(
new
LambdaQueryWrapper
<
BlackListEntity
>()
.
eq
(
BlackListEntity:
:
getBlocker
,
blocker
)
.
eq
(
BlackListEntity:
:
getBlockedId
,
blockId
)
.
eq
(
BlackListEntity:
:
getBlockedType
,
blockType
));
}
public
void
removeBlackList
(
String
blocker
,
String
blockId
,
BlockTypeEnum
blockType
)
{
...
...
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
a257696c
...
...
@@ -2,8 +2,10 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.api.constants.CollectionTypeEnum
;
import
com.tanpu.community.api.constants.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.CollectionEntity
;
import
com.tanpu.community.dao.mapper.community.CollectionMapper
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
...
...
@@ -14,58 +16,83 @@ public class CollectionService {
@Resource
private
CollectionMapper
collectionMapper
;
public
void
addCollection
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
){
// todo 判断是否存在
CollectionEntity
collectionEntity
=
new
CollectionEntity
();
collectionEntity
.
setCollectionType
(
type
.
getCode
());
collectionEntity
.
setAuthorId
(
userId
);
collectionEntity
.
setTargetId
(
themeId
);
collectionEntity
.
setCreateBy
(
userId
);
collectionMapper
.
insert
(
collectionEntity
);
// 若不存在则新增,若存在则修改deleteTag
public
void
addIfNotExist
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
)
{
// 判断是否存在
CollectionEntity
queryCollection
=
getTargetCollection
(
themeId
,
userId
,
type
);
if
(
queryCollection
!=
null
)
{
Integer
oldDeleteTag
=
queryCollection
.
getDeleteTag
();
queryCollection
.
setDeleteTag
(
ConvertUtil
.
deleteTagShift
(
oldDeleteTag
));
collectionMapper
.
updateById
(
queryCollection
);
}
else
{
CollectionEntity
entity
=
CollectionEntity
.
builder
()
.
collectionType
(
type
.
getCode
())
.
authorId
(
userId
)
.
targetId
(
themeId
)
.
createBy
(
userId
)
.
build
();
collectionMapper
.
insert
(
entity
);
}
}
//根据用户id获取点赞列表
public
List
<
CollectionEntity
>
getLikeListByUser
(
String
userId
){
//根据用户、主题、类型查询
public
CollectionEntity
getTargetCollection
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
)
{
return
collectionMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
)
.
eq
(
CollectionEntity:
:
getAuthorId
,
userId
)
.
eq
(
CollectionEntity:
:
getTargetId
,
themeId
));
}
// 根据用户id获取点赞列表
public
List
<
CollectionEntity
>
getLikeListByUser
(
String
userId
)
{
return
collectionMapper
.
selectList
(
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE
.
getCode
()));
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
//根据用户id获取收藏列表
public
List
<
CollectionEntity
>
getBookListByUser
(
String
userId
){
// 根据用户id获取收藏列表
public
List
<
CollectionEntity
>
getBookListByUser
(
String
userId
)
{
return
collectionMapper
.
selectList
(
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
BOOK
.
getCode
()));
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
BOOK
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
//
统计
主题的点赞量
public
Long
getLikeAmountByThemeId
(
String
themeId
){
//
统计单个
主题的点赞量
public
Long
getLikeAmountByThemeId
(
String
themeId
)
{
return
(
long
)
collectionMapper
.
selectList
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getTargetId
,
themeId
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE
.
getCode
())))
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())))
.
size
();
}
//
统计主题集合
的点赞量
public
Long
getLikeAmountByThemeIds
(
List
<
String
>
themeIds
){
//
统计多个主题
的点赞量
public
Long
getLikeAmountByThemeIds
(
List
<
String
>
themeIds
)
{
return
(
long
)
collectionMapper
.
selectList
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
in
(
CollectionEntity:
:
getTargetId
,
themeIds
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE
.
getCode
())))
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE
.
getCode
()))
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
.
size
();
}
//统计主题的收藏量
public
Long
getBookAmountByThemeId
(
String
themeId
){
//统计
单个
主题的收藏量
public
Long
getBookAmountByThemeId
(
String
themeId
)
{
return
(
long
)
collectionMapper
.
selectList
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getTargetId
,
themeId
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
BOOK
.
getCode
())))
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
BOOK
.
getCode
()))
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
.
size
();
}
//统
计主题集合
的收藏量
public
Long
getBookAmountByThemeIds
(
List
<
String
>
themeIds
){
//统
多个主题
的收藏量
public
Long
getBookAmountByThemeIds
(
List
<
String
>
themeIds
)
{
return
(
long
)
collectionMapper
.
selectList
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
in
(
CollectionEntity:
:
getTargetId
,
themeIds
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
BOOK
.
getCode
())))
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
BOOK
.
getCode
()))
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
.
size
();
}
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
a257696c
...
...
@@ -14,19 +14,17 @@ public class CommentService {
@Resource
private
CommentMapper
commentMapper
;
public
void
insertComment
(
CommentEntity
commentEntity
){
public
void
insertComment
(
CommentEntity
commentEntity
)
{
commentMapper
.
insert
(
commentEntity
);
}
public
List
<
CommentEntity
>
selectByUserId
(
String
userId
){
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getAuthorId
,
userId
));
public
List
<
CommentEntity
>
selectByUserId
(
String
userId
)
{
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getAuthorId
,
userId
));
}
//统计主题集合的评论量
public
Long
getCommentAmountByThemeIds
(
List
<
String
>
themeIds
){
public
Long
getCommentAmountByThemeIds
(
List
<
String
>
themeIds
)
{
return
(
long
)
commentMapper
.
selectList
((
new
LambdaQueryWrapper
<
CommentEntity
>()
.
in
(
CommentEntity:
:
getTargetId
,
themeIds
)))
.
size
();
...
...
community-service/src/main/java/com/tanpu/community/service/RedisService.java
View file @
a257696c
...
...
@@ -54,22 +54,22 @@ public class RedisService {
/**
* incr
*/
public
long
incr
(
String
key
,
Long
delta
)
{
if
(
delta
<
0
)
{
throw
new
BizException
(
"递增
银
子必须大于0"
);
public
long
incr
(
String
key
,
Long
delta
)
{
if
(
delta
<
0
)
{
throw
new
BizException
(
"递增
因
子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
return
redisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
/**
* incr
*/
public
long
decr
(
String
key
,
Long
delta
)
{
if
(
delta
<
0
)
{
throw
new
BizException
(
"递减
银
子必须大于0"
);
public
long
decr
(
String
key
,
Long
delta
)
{
if
(
delta
<
0
)
{
throw
new
BizException
(
"递减
因
子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
decrement
(
key
,
delta
);
return
redisTemplate
.
opsForValue
().
decrement
(
key
,
delta
);
}
}
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
a257696c
...
...
@@ -20,7 +20,7 @@ public class TopicService {
private
TopicMapper
topicMapper
;
public
List
<
TopicEntity
>
query
TopicList
(){
public
List
<
TopicEntity
>
query
All
(){
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getDeleteTag
,
TopicStatusEnum
.
FALSE
.
getCode
()));
}
...
...
@@ -64,7 +64,10 @@ public class TopicService {
public
void
modifyViewAmount
(
String
topicId
,
long
amount
){
TopicEntity
topicEntity
=
topicMapper
.
selectById
(
topicId
);
Long
oldAmount
=
topicEntity
.
getViewAmountModify
();
topicEntity
.
setViewAmountModify
(
topicEntity
.
getViewAmountModify
()
+
amount
);
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getViewAmountModify
,
oldAmount
));
return
;
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
a257696c
...
...
@@ -3,6 +3,7 @@ package com.tanpu.community.util;
import
com.tanpu.community.api.beans.ThemeDTO
;
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.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -54,4 +55,20 @@ public class ConvertUtil {
public
static
List
<
TopicBriefInfoDTO
>
topicEntitiesToBriefDTOs
(
List
<
TopicEntity
>
topicEntities
)
{
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicToBriefInfoDTO
).
collect
(
Collectors
.
toList
());
}
public
static
DeleteTagEnum
deleteTagShift
(
DeleteTagEnum
deleteTagEnum
)
{
if
(
deleteTagEnum
.
getCode
().
equals
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
{
return
DeleteTagEnum
.
DELETED
;
}
else
{
return
DeleteTagEnum
.
NOT_DELETED
;
}
}
public
static
Integer
deleteTagShift
(
Integer
deleteTag
)
{
if
(
deleteTag
.
equals
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
{
return
DeleteTagEnum
.
DELETED
.
getCode
();
}
else
{
return
DeleteTagEnum
.
NOT_DELETED
.
getCode
();
}
}
}
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