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
c915b558
Commit
c915b558
authored
Jun 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
点赞收藏相关
parent
cee42399
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
144 additions
and
23 deletions
+144
-23
BlockTypeEnum.java
...java/com/tanpu/community/api/constants/BlockTypeEnum.java
+29
-0
pom.xml
community-service/pom.xml
+7
-0
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+8
-1
MetricsController.java
...ava/com/tanpu/community/controller/MetricsController.java
+22
-0
BlackListMapper.java
...tanpu/community/dao/mapper/community/BlackListMapper.java
+16
-0
ThemeMapper.java
...com/tanpu/community/dao/mapper/community/ThemeMapper.java
+0
-1
TopicMapper.java
...com/tanpu/community/dao/mapper/community/TopicMapper.java
+0
-2
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+24
-15
BlackListService.java
...in/java/com/tanpu/community/service/BlackListService.java
+13
-1
RedisService.java
...c/main/java/com/tanpu/community/service/RedisService.java
+23
-1
create.sql
docs/create.sql
+1
-1
pom.xml
pom.xml
+1
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/constants/BlockTypeEnum.java
0 → 100644
View file @
c915b558
package
com
.
tanpu
.
community
.
api
.
constants
;
public
enum
BlockTypeEnum
{
USER
(
1
,
"屏蔽用户"
),
CONTENT
(
2
,
"屏蔽内容"
);
private
Integer
code
;
private
String
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
;
}
BlockTypeEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
}
community-service/pom.xml
View file @
c915b558
...
...
@@ -43,6 +43,13 @@
<artifactId>
spring-cloud-starter-zipkin
</artifactId>
</dependency>
<!-- mybatis-plus自动生成所需包-->
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity-engine-core
</artifactId>
<version>
2.3
</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>-->
...
...
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
c915b558
package
com
.
tanpu
.
community
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.manager.HomePageManager
;
import
com.tanpu.community.model.req.homepage.AddIdolReq
;
...
...
@@ -38,4 +37,12 @@ public class HomePageController {
return
"11"
;
}
@PostMapping
(
value
=
"/query/likeTheme"
)
@ApiOperation
(
"我的点赞"
)
@ResponseBody
public
String
likeList
(){
String
userId
=
"123"
;
return
"success"
;
}
}
community-service/src/main/java/com/tanpu/community/controller/MetricsController.java
0 → 100644
View file @
c915b558
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.community.service.RedisService
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@RequestMapping
(
value
=
"/metric"
)
public
class
MetricsController
{
@Autowired
private
RedisService
redisService
;
@ApiOperation
(
"浏览量埋点"
)
@RequestMapping
(
"/pv"
)
public
void
pageView
(
@RequestParam
String
themeId
){
redisService
.
incr
(
"pv"
+
themeId
,
1L
);
}
}
community-service/src/main/java/com/tanpu/community/dao/mapper/community/BlackListMapper.java
View file @
c915b558
package
com
.
tanpu
.
community
.
dao
.
mapper
.
community
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* 黑名单 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-16
*/
public
interface
BlackListMapper
extends
BaseMapper
<
BlackListEntity
>
{
}
community-service/src/main/java/com/tanpu/community/dao/mapper/community/ThemeMapper.java
View file @
c915b558
...
...
@@ -2,7 +2,6 @@ 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 @
c915b558
...
...
@@ -2,7 +2,6 @@ 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>
...
...
@@ -12,7 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
* @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 @
c915b558
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.api.constants.BlockTypeEnum
;
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
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -34,15 +27,18 @@ public class ThemeManager {
@Autowired
private
FansRelService
fansRelService
;
@Autowired
private
BlackListService
blackListService
;
//返回推荐主题文章
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
;
}
...
...
@@ -87,12 +83,25 @@ public class ThemeManager {
collectionEntity
.
setCreateTime
(
LocalDateTime
.
now
());
collectionService
.
insertCollection
(
collectionEntity
);
}
//投诉
//投诉
(主题)
public
void
complaint
(
String
themeId
,
String
user
)
{
}
//屏蔽
public
void
conceal
(
String
themeId
,
String
user
)
{
//屏蔽(用户)
public
void
blockUser
(
String
themeId
,
String
userId
)
{
BlackListEntity
blackListEntity
=
new
BlackListEntity
();
blackListEntity
.
setBlockedId
(
themeService
.
selectTheme
(
themeId
).
getAuthorId
());
blackListEntity
.
setBlocker
(
userId
);
blackListEntity
.
setBlockedType
(
BlockTypeEnum
.
USER
.
getCode
());
blackListService
.
insertBlackList
(
blackListEntity
);
}
//屏蔽(内容)
public
void
blockContent
(
String
themeId
,
String
userId
)
{
BlackListEntity
blackListEntity
=
new
BlackListEntity
();
blackListEntity
.
setBlockedId
(
themeId
);
blackListEntity
.
setBlocker
(
userId
);
blackListEntity
.
setBlockedType
(
BlockTypeEnum
.
CONTENT
.
getCode
());
blackListService
.
insertBlackList
(
blackListEntity
);
}
}
community-service/src/main/java/com/tanpu/community/service/BlackListService.java
View file @
c915b558
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.mapper.community.BlackListMapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
BlackListService
{
@Resource
private
BlackListMapper
blackListMapper
;
public
void
insertBlackList
(
BlackListEntity
blackListEntity
){
blackListMapper
.
insert
(
blackListEntity
);
}
public
void
deleteBlackList
(
String
blocker
,
String
blockId
,
String
blockType
){
blackListMapper
.
delete
(
new
LambdaQueryWrapper
<
BlackListEntity
>().
eq
(
BlackListEntity:
:
getBlocker
,
blocker
).
eq
(
BlackListEntity:
:
getBlockedId
,
blockId
).
eq
(
BlackListEntity:
:
getBlockedType
,
blockType
));
return
;
}
}
community-service/src/main/java/com/tanpu/community/service/RedisService.java
View file @
c915b558
package
com
.
tanpu
.
community
.
service
;
import
com.tanpu.common.exception.BizException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
...
...
@@ -45,4 +45,26 @@ public class RedisService {
Object
v
=
redisTemplate
.
opsForValue
().
get
(
key
);
return
v
==
null
?
null
:
(
Integer
)
v
;
}
/**
* incr
*/
public
long
incr
(
String
key
,
Long
delta
){
if
(
delta
<
0
){
throw
new
BizException
(
"递增银子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
/**
* incr
*/
public
long
decr
(
String
key
,
Long
delta
){
if
(
delta
<
0
){
throw
new
BizException
(
"递减银子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
decrement
(
key
,
delta
);
}
}
docs/create.sql
View file @
c915b558
...
...
@@ -111,7 +111,7 @@ CREATE TABLE `file_record` (
CREATE
TABLE
`black_list`
(
`id`
varchar
(
64
)
PRIMARY
KEY
COMMENT
'id'
,
`blocker`
varchar
(
64
)
NOT
NULL
COMMENT
'屏蔽发起人'
,
`blocked_type`
int
(
4
)
NOT
NULL
COMMENT
'屏蔽类型'
,
`blocked_type`
int
(
4
)
NOT
NULL
COMMENT
'屏蔽类型
,1:用户,2:内容
'
,
`blocked_id`
varchar
(
64
)
NOT
NULL
COMMENT
'被屏蔽的'
,
`create_by`
varchar
(
64
)
DEFAULT
''
,
`create_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
...
...
pom.xml
View file @
c915b558
...
...
@@ -36,7 +36,7 @@
<dependency>
<groupId>
com.tanpu
</groupId>
<artifactId>
common
</artifactId>
<version>
1.0.
3
-RELEASE
</version>
<version>
1.0.
4
-RELEASE
</version>
</dependency>
<dependency>
...
...
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