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
cee42399
Commit
cee42399
authored
Jun 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
正文相关
parent
35360880
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
323 additions
and
8 deletions
+323
-8
CollectionTypeEnum.java
...com/tanpu/community/api/constants/CollectionTypeEnum.java
+30
-0
CommentTypeEnum.java
...va/com/tanpu/community/api/constants/CommentTypeEnum.java
+32
-0
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+71
-4
ThemeMapper.java
...com/tanpu/community/dao/mapper/community/ThemeMapper.java
+1
-0
TopicMapper.java
...com/tanpu/community/dao/mapper/community/TopicMapper.java
+2
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+88
-1
BlackListService.java
...in/java/com/tanpu/community/service/BlackListService.java
+12
-0
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+33
-0
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+27
-0
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+25
-1
create.sql
docs/create.sql
+2
-2
No files found.
community-api/src/main/java/com/tanpu/community/api/constants/CollectionTypeEnum.java
0 → 100644
View file @
cee42399
package
com
.
tanpu
.
community
.
api
.
constants
;
public
enum
CollectionTypeEnum
{
LIKE
(
1
,
"点赞"
),
BOOK
(
2
,
"收藏"
);
private
Integer
code
;
private
String
type
;
CollectionTypeEnum
(
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/CommentTypeEnum.java
0 → 100644
View file @
cee42399
package
com
.
tanpu
.
community
.
api
.
constants
;
public
enum
CommentTypeEnum
{
TEXT
(
1
,
"纯文字"
);
private
Integer
code
;
private
String
type
;
CommentTypeEnum
(
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-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
cee42399
...
...
@@ -2,13 +2,14 @@ package com.tanpu.community.controller;
import
com.tanpu.community.api.beans.ThemeDTO
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.manager.ThemeManager
;
import
com.tanpu.community.service.FansRelService
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -20,18 +21,84 @@ public class ThemeController {
@Autowired
private
ThemeManager
themeManager
;
@Autowired
private
FansRelService
fansRelService
;
@ApiOperation
(
"新增主题"
)
@RequestMapping
(
value
=
"/add"
)
@ResponseBody
public
void
insertTheme
(
@RequestBody
ThemeDTO
themeDTO
){
}
public
List
<
ThemeEntity
>
selectList
(){
@ApiOperation
(
"系统推荐主题列表"
)
@RequestMapping
(
value
=
"/add"
)
@ResponseBody
public
List
<
ThemeEntity
>
selectHotList
(){
return
null
;
}
@ApiOperation
(
"用户关注主题列表"
)
@RequestMapping
(
value
=
"/add"
)
@ResponseBody
public
List
<
ThemeEntity
>
selectInterestList
(){
String
userId
=
"liujm012"
;
return
null
;
}
@ApiOperation
(
"评论"
)
@RequestMapping
(
value
=
"/comment"
)
@ResponseBody
public
String
commetOnTheme
(
String
themeId
,
String
commet
){
String
user
=
"liujm"
;
themeManager
.
comment
(
themeId
,
user
,
commet
);
return
"success"
;
}
@ApiOperation
(
"转发主题"
)
@RequestMapping
(
value
=
"/forward"
)
@ResponseBody
public
String
forwardTheme
(
String
themeId
){
return
"success"
;
}
@ApiOperation
(
"点赞主题"
)
@RequestMapping
(
value
=
"/like"
)
@ResponseBody
public
String
likeOnTheme
(
String
themeId
){
String
user
=
"liujm"
;
themeManager
.
like
(
themeId
,
user
);
return
"success"
;
}
@ApiOperation
(
"分享主题"
)
@RequestMapping
(
value
=
"/share"
)
@ResponseBody
public
String
shareTheme
(
String
themeId
){
return
"success"
;
}
@ApiOperation
(
"收藏主题"
)
@RequestMapping
(
value
=
"/book"
)
@ResponseBody
public
String
bookTheme
(
String
themeId
){
String
user
=
"liujm"
;
themeManager
.
book
(
themeId
,
user
);
return
"success"
;
}
@ApiOperation
(
"举报主题"
)
@RequestMapping
(
value
=
"/complaint"
)
@ResponseBody
public
String
complaintTheme
(
String
themeId
){
return
"success"
;
}
@ApiOperation
(
"屏蔽"
)
@RequestMapping
(
value
=
"/conceal"
)
@ResponseBody
public
String
concealTheme
(
String
themeId
){
return
"success"
;
}
}
community-service/src/main/java/com/tanpu/community/dao/mapper/community/ThemeMapper.java
View file @
cee42399
...
...
@@ -2,6 +2,7 @@ package com.tanpu.community.dao.mapper.community;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* <p>
...
...
community-service/src/main/java/com/tanpu/community/dao/mapper/community/TopicMapper.java
View file @
cee42399
...
...
@@ -2,6 +2,7 @@ package com.tanpu.community.dao.mapper.community;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* <p>
...
...
@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author xudong
* @since 2021-06-10
*/
@Mapper
public
interface
TopicMapper
extends
BaseMapper
<
TopicEntity
>
{
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
cee42399
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.api.constants.CollectionTypeEnum
;
import
com.tanpu.community.api.constants.CommentTypeEnum
;
import
com.tanpu.community.dao.entity.community.CollectionEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.service.CollectionService
;
import
com.tanpu.community.service.CommentService
;
import
com.tanpu.community.service.FansRelService
;
import
com.tanpu.community.service.ThemeService
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.tomcat.jni.Local
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
ThemeManager
{
@
Autowired
@
Resource
private
ThemeService
themeService
;
@Autowired
private
CollectionService
collectionService
;
@Autowired
private
CommentService
commentService
;
@Autowired
private
FansRelService
fansRelService
;
public
List
<
ThemeEntity
>
selectHotThemes
(){
//TOTO:根据算法计算推荐主题
return
null
;
}
public
List
<
ThemeEntity
>
selectInterestThemes
(
String
userId
){
List
<
String
>
fansRelEntities
=
fansRelService
.
queryFansByFollowerId
(
userId
).
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
return
null
;
}
//点赞
public
void
like
(
String
themeId
,
String
userId
)
{
CollectionEntity
collectionEntity
=
new
CollectionEntity
();
collectionEntity
.
setCollectionType
(
CollectionTypeEnum
.
LIKE
.
getCode
());
collectionEntity
.
setAuthorId
(
userId
);
collectionEntity
.
setTargetId
(
themeId
);
collectionEntity
.
setCreateBy
(
userId
);
collectionEntity
.
setCreateTime
(
LocalDateTime
.
now
());
collectionService
.
insertCollection
(
collectionEntity
);
}
//评论
public
void
comment
(
String
themeId
,
String
userId
,
String
comment
)
{
CommentEntity
commentEntity
=
new
CommentEntity
();
commentEntity
.
setTargetId
(
themeId
);
commentEntity
.
setAuthorId
(
userId
);
commentEntity
.
setCommentType
(
CommentTypeEnum
.
TEXT
.
getCode
());
commentEntity
.
setContent
(
comment
);
commentService
.
insertComment
(
commentEntity
);
}
//转发
public
void
forward
(
String
themeId
,
String
user
)
{
}
//分享
public
void
share
(
String
themeId
,
String
user
)
{
}
//收藏
public
void
book
(
String
themeId
,
String
userId
)
{
CollectionEntity
collectionEntity
=
new
CollectionEntity
();
collectionEntity
.
setCollectionType
(
CollectionTypeEnum
.
BOOK
.
getCode
());
collectionEntity
.
setAuthorId
(
userId
);
collectionEntity
.
setTargetId
(
themeId
);
collectionEntity
.
setCreateBy
(
userId
);
collectionEntity
.
setCreateTime
(
LocalDateTime
.
now
());
collectionService
.
insertCollection
(
collectionEntity
);
}
//投诉
public
void
complaint
(
String
themeId
,
String
user
)
{
}
//屏蔽
public
void
conceal
(
String
themeId
,
String
user
)
{
}
}
community-service/src/main/java/com/tanpu/community/service/BlackListService.java
0 → 100644
View file @
cee42399
package
com
.
tanpu
.
community
.
service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
BlackListService
{
}
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
0 → 100644
View file @
cee42399
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.tanpu.community.dao.entity.community.CollectionEntity
;
import
com.tanpu.community.dao.mapper.community.CollectionMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
CollectionService
{
@Resource
private
CollectionMapper
collectionMapper
;
public
void
insertCollection
(
CollectionEntity
collectionEntity
){
collectionMapper
.
insert
(
collectionEntity
);
}
//根据用户id获取点赞列表
public
List
<
CollectionEntity
>
getLikeListByUser
(
String
userId
){
return
collectionMapper
.
selectList
(
new
LambdaQueryWrapper
<
CollectionEntity
>().
eq
(
CollectionEntity:
:
getCollectionType
,
1
));
}
//根据用户id获取收藏列表
public
List
<
CollectionEntity
>
getBookListByUser
(
String
userId
){
return
collectionMapper
.
selectList
(
new
LambdaQueryWrapper
<
CollectionEntity
>().
eq
(
CollectionEntity:
:
getCollectionType
,
2
));
}
}
community-service/src/main/java/com/tanpu/community/service/CommentService.java
0 → 100644
View file @
cee42399
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.mapper.community.CommentMapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
CommentService
{
@Resource
private
CommentMapper
commentMapper
;
public
void
insertComment
(
CommentEntity
commentEntity
){
commentMapper
.
insert
(
commentEntity
);
}
public
List
<
CommentEntity
>
selectByUserId
(
String
userId
){
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getAuthorId
,
userId
));
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
cee42399
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
ThemeService
{
@
Autowired
@
Resource
private
ThemeMapper
themeMapper
;
public
void
insertTheme
(
ThemeEntity
themeEntity
){
themeMapper
.
insert
(
themeEntity
);
}
//根据id返回主题详情
public
ThemeEntity
selectTheme
(
String
themeId
){
return
themeMapper
.
selectById
(
themeId
);
}
//根据话题查询主题
public
List
<
ThemeEntity
>
selectByTopic
(
String
topidId
){
QueryWrapper
<
ThemeEntity
>
themeEntityQueryWrapper
=
new
QueryWrapper
<>();
themeEntityQueryWrapper
.
eq
(
"topic_id"
,
topidId
);
return
themeMapper
.
selectList
(
themeEntityQueryWrapper
);
}
}
docs/create.sql
View file @
cee42399
...
...
@@ -50,7 +50,7 @@ CREATE TABLE `theme` (
CREATE
TABLE
`comment`
(
`id`
varchar
(
64
)
PRIMARY
KEY
COMMENT
'id'
,
`comment_type`
int
(
4
)
NOT
NULL
COMMENT
'类型'
,
`comment_type`
int
(
4
)
NOT
NULL
COMMENT
'类型
,目前仅支持1:文字,上限500字
'
,
`content`
text
COMMENT
'文本内容'
,
`author_id`
varchar
(
64
)
NOT
NULL
COMMENT
'作者id'
,
`target_id`
varchar
(
64
)
NOT
NULL
COMMENT
'评论的目标id'
,
...
...
@@ -67,7 +67,7 @@ CREATE TABLE `comment` (
CREATE
TABLE
`collection`
(
`id`
varchar
(
64
)
PRIMARY
KEY
COMMENT
'id'
,
`collection_type`
int
(
4
)
NOT
NULL
COMMENT
'类型'
,
`collection_type`
int
(
4
)
NOT
NULL
COMMENT
'类型
,1:点赞,2:收藏
'
,
`author_id`
varchar
(
64
)
NOT
NULL
COMMENT
'作者id'
,
`target_id`
varchar
(
64
)
NOT
NULL
COMMENT
'评论的目标id'
,
`create_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