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
4a9778cb
Commit
4a9778cb
authored
Jul 22, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
举报主题、举报评论
parent
18750bc6
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
224 additions
and
33 deletions
+224
-33
ReportCommentReq.java
...npu/community/api/beans/req/comment/ReportCommentReq.java
+20
-0
ReportThemeReq.java
...m/tanpu/community/api/beans/req/theme/ReportThemeReq.java
+0
-2
ReportStatusEnum.java
.../java/com/tanpu/community/api/enums/ReportStatusEnum.java
+36
-0
ReportTypeEnum.java
...in/java/com/tanpu/community/api/enums/ReportTypeEnum.java
+40
-0
CommentController.java
...ava/com/tanpu/community/controller/CommentController.java
+5
-4
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+4
-3
ReportLogEntity.java
...tanpu/community/dao/entity/community/ReportLogEntity.java
+21
-4
ReportLogMapper.java
...tanpu/community/dao/mapper/community/ReportLogMapper.java
+1
-1
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+13
-3
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+10
-0
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+13
-2
ReportLogService.java
...in/java/com/tanpu/community/service/ReportLogService.java
+31
-0
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+29
-14
ReportLogEntityMapper.xml
...main/resources/mapper/community/ReportLogEntityMapper.xml
+1
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/comment/ReportCommentReq.java
0 → 100644
View file @
4a9778cb
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
comment
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
@ApiModel
(
value
=
"举报评论"
)
@Data
public
class
ReportCommentReq
{
@NotBlank
@ApiModelProperty
(
value
=
"评论Id"
)
private
String
commentId
;
@ApiModelProperty
(
value
=
"举报理由"
)
private
String
reason
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ReportThemeReq.java
View file @
4a9778cb
...
...
@@ -14,6 +14,4 @@ public class ReportThemeReq {
@ApiModelProperty
(
value
=
"举报理由"
)
private
String
reason
;
}
community-api/src/main/java/com/tanpu/community/api/enums/ReportStatusEnum.java
0 → 100644
View file @
4a9778cb
package
com
.
tanpu
.
community
.
api
.
enums
;
public
enum
ReportStatusEnum
{
NORMAL
(
0
,
"正常"
),
REPORTED
(
1
,
"被举报"
),
DONE
(
1
,
"已处理"
);
private
Integer
code
;
private
String
type
;
ReportStatusEnum
(
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/enums/ReportTypeEnum.java
0 → 100644
View file @
4a9778cb
package
com
.
tanpu
.
community
.
api
.
enums
;
import
org.apache.commons.collections4.SetUtils
;
import
java.util.HashSet
;
public
enum
ReportTypeEnum
{
THEME
(
1
,
"举报主题"
),
COMMENT
(
2
,
"举报评论"
),
USER
(
3
,
"举报用户"
);
public
static
final
HashSet
<
String
>
imageTypeSet
=
SetUtils
.
hashSet
(
"jpg"
,
"jpeg"
,
"png"
);
private
Integer
code
;
private
String
type
;
ReportTypeEnum
(
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/CommentController.java
View file @
4a9778cb
...
...
@@ -8,6 +8,7 @@ import com.tanpu.community.api.beans.qo.CommentQo;
import
com.tanpu.community.api.beans.req.comment.CreateCommentReq
;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.QueryCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.manager.CommentManager
;
import
com.tanpu.community.util.PageUtils
;
...
...
@@ -62,12 +63,12 @@ public class CommentController {
}
@ApiOperation
(
"举报评论"
)
@
Ge
tMapping
(
value
=
"/reportComment"
)
@
Pos
tMapping
(
value
=
"/reportComment"
)
@AuthLogin
@ResponseBody
public
CommonResp
<
Void
>
reportComment
(
@RequestParam
String
commentId
)
{
//todo
public
CommonResp
<
Void
>
reportComment
(
@Validated
@RequestBody
ReportCommentReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
return
CommonResp
.
failed
(
"功能暂未开放"
);
commentManager
.
report
(
req
,
userId
);
return
CommonResp
.
success
();
}
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
4a9778cb
...
...
@@ -104,9 +104,10 @@ public class ThemeController {
@ApiOperation
(
"举报主题"
)
@PostMapping
(
value
=
"/report"
)
@ResponseBody
public
CommonResp
complaintTheme
(
@RequestBody
ReportThemeReq
req
)
{
return
CommonResp
.
failed
(
"功能暂未开放"
);
public
CommonResp
<
Void
>
complaintTheme
(
@RequestBody
ReportThemeReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
themeManager
.
report
(
req
,
userId
);
return
CommonResp
.
success
();
}
@AuthLogin
...
...
community-service/src/main/java/com/tanpu/community/dao/entity/community/ReportLogEntity.java
View file @
4a9778cb
...
...
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
import
com.baomidou.mybatisplus.annotation.TableName
;
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
;
...
...
@@ -15,9 +18,12 @@ import java.time.LocalDateTime;
* </p>
*
* @author xudong
* @since 2021-07-2
1
* @since 2021-07-2
2
*/
@TableName
(
"report_log"
)
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
value
=
"ReportLogEntity对象"
,
description
=
"举报记录"
)
public
class
ReportLogEntity
implements
Serializable
{
...
...
@@ -25,7 +31,7 @@ public class ReportLogEntity implements Serializable {
@ApiModelProperty
(
value
=
"id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
Long
id
;
@ApiModelProperty
(
value
=
"举报发起人"
)
private
String
userId
;
...
...
@@ -39,6 +45,8 @@ public class ReportLogEntity implements Serializable {
@ApiModelProperty
(
value
=
"举报对象作者id"
)
private
String
targetUserId
;
private
String
reportReason
;
@ApiModelProperty
(
value
=
"上报时间"
)
private
LocalDateTime
reportTime
;
...
...
@@ -58,11 +66,11 @@ public class ReportLogEntity implements Serializable {
private
Integer
deleteTag
;
public
Integer
getId
()
{
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
...
...
@@ -98,6 +106,14 @@ public class ReportLogEntity implements Serializable {
this
.
targetUserId
=
targetUserId
;
}
public
String
getReportReason
()
{
return
reportReason
;
}
public
void
setReportReason
(
String
reportReason
)
{
this
.
reportReason
=
reportReason
;
}
public
LocalDateTime
getReportTime
()
{
return
reportTime
;
}
...
...
@@ -162,6 +178,7 @@ public class ReportLogEntity implements Serializable {
", reportType="
+
reportType
+
", targetId="
+
targetId
+
", targetUserId="
+
targetUserId
+
", reportReason="
+
reportReason
+
", reportTime="
+
reportTime
+
", dealResult="
+
dealResult
+
", dealUserId="
+
dealUserId
+
...
...
community-service/src/main/java/com/tanpu/community/dao/mapper/community/ReportLogMapper.java
View file @
4a9778cb
...
...
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
*
* @author xudong
* @since 2021-07-2
1
* @since 2021-07-2
2
*/
public
interface
ReportLogMapper
extends
BaseMapper
<
ReportLogEntity
>
{
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
4a9778cb
...
...
@@ -5,15 +5,17 @@ import com.tanpu.common.exception.BizException;
import
com.tanpu.community.api.beans.qo.CommentQo
;
import
com.tanpu.community.api.beans.req.comment.CreateCommentReq
;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.ReportTypeEnum
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.service.CollectionService
;
import
com.tanpu.community.service.CommentService
;
import
com.tanpu.community.service.
UserInfo
Service
;
import
com.tanpu.community.service.
ReportLog
Service
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -36,9 +38,8 @@ public class CommentManager {
@Autowired
private
CollectionService
collectionService
;
@Resource
private
UserInfoService
userInfo
Service
;
private
ReportLogService
reportLog
Service
;
// 评论(对主题)
public
void
comment
(
CreateCommentReq
req
,
String
userId
)
{
...
...
@@ -105,4 +106,13 @@ public class CommentManager {
}
}
//举报评论
public
void
report
(
ReportCommentReq
req
,
String
userId
)
{
//更改举报状态
commentService
.
updateReportStatus
(
req
.
getCommentId
());
//写入举报日志
CommentEntity
commentEntity
=
commentService
.
queryByCommentId
(
req
.
getCommentId
());
reportLogService
.
insert
(
ReportTypeEnum
.
COMMENT
,
userId
,
req
.
getCommentId
(),
commentEntity
.
getAuthorId
(),
req
.
getReason
());
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
4a9778cb
...
...
@@ -61,6 +61,9 @@ public class ThemeManager {
@Autowired
private
VisitSummaryService
visitSummaryService
;
@Autowired
private
ReportLogService
reportLogService
;
@Autowired
private
RankService
rankService
;
...
...
@@ -434,4 +437,11 @@ public class ThemeManager {
}
}
public
void
report
(
ReportThemeReq
req
,
String
userId
)
{
//更改举报状态
themeService
.
updateReportStatus
(
req
.
getThemeId
());
//写入举报日志
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
reportLogService
.
insert
(
ReportTypeEnum
.
THEME
,
userId
,
req
.
getThemeId
(),
themeEntity
.
getAuthorId
(),
req
.
getReason
());
}
}
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
4a9778cb
...
...
@@ -5,6 +5,7 @@ import com.tanpu.common.exception.BizException;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.ReportStatusEnum
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.mapper.community.CommentMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -34,8 +35,9 @@ public class CommentService {
}
public
List
<
CommentEntity
>
selectByUserId
(
String
userId
)
{
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getAuthorId
,
userId
));
public
CommentEntity
queryByCommentId
(
String
commmentId
)
{
return
commentMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getCommentId
,
commmentId
));
}
//统计主题集合的评论量
...
...
@@ -100,4 +102,13 @@ public class CommentService {
}
return
commentMapper
.
selectList
(
queryWrapper
);
}
public
void
updateReportStatus
(
String
commentId
)
{
CommentEntity
commentEntity
=
queryByCommentId
(
commentId
);
if
(
commentEntity
==
null
){
throw
new
BizException
(
"评论未找到,id:"
+
commentId
);
}
commentEntity
.
setReportStatus
(
ReportStatusEnum
.
REPORTED
.
getCode
());
commentMapper
.
updateById
(
commentEntity
);
}
}
community-service/src/main/java/com/tanpu/community/service/ReportLogService.java
0 → 100644
View file @
4a9778cb
package
com
.
tanpu
.
community
.
service
;
import
com.tanpu.community.api.enums.ReportTypeEnum
;
import
com.tanpu.community.dao.entity.community.ReportLogEntity
;
import
com.tanpu.community.dao.mapper.community.ReportLogMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
@Service
@Slf4j
public
class
ReportLogService
{
@Resource
private
ReportLogMapper
reportLogMapper
;
public
void
insert
(
ReportTypeEnum
type
,
String
userId
,
String
themeId
,
String
authorId
,
String
reason
){
ReportLogEntity
entity
=
ReportLogEntity
.
builder
().
userId
(
userId
)
.
reportType
(
type
.
getCode
())
.
targetId
(
themeId
)
.
targetUserId
(
authorId
)
.
reportReason
(
reason
)
.
reportTime
(
LocalDateTime
.
now
())
.
build
();
reportLogMapper
.
insert
(
entity
);
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
4a9778cb
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.ReportStatusEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -42,6 +43,7 @@ public class ThemeService {
/**
* 根据主题Id查询列表
*
* @return
*/
public
List
<
ThemeEntity
>
queryAll
()
{
...
...
@@ -83,7 +85,7 @@ public class ThemeService {
//根据ids返回主题详情,带分页
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
,
String
lastId
,
Integer
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
themeIds
)){
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
...
...
@@ -102,11 +104,12 @@ public class ThemeService {
/**
* 根据主题Id查询列表
*
* @param themeIds
* @return
*/
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
)
{
if
(
CollectionUtils
.
isEmpty
(
themeIds
)){
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
...
...
@@ -117,18 +120,18 @@ public class ThemeService {
}
/**
* 查询非传入作者的主题(可分页)
*
* @param lastId
* @param pageSize
* @param userId
* @return
*/
public
List
<
ThemeEntity
>
selectExcludeUser
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
ThemeEntity
>
selectExcludeUser
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
if
(!
StringUtils
.
isEmpty
(
userId
)){
queryWrapper
.
ne
(
ThemeEntity:
:
getAuthorId
,
userId
);
if
(!
StringUtils
.
isEmpty
(
userId
))
{
queryWrapper
.
ne
(
ThemeEntity:
:
getAuthorId
,
userId
);
}
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
...
...
@@ -136,7 +139,7 @@ public class ThemeService {
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
...
...
@@ -148,19 +151,20 @@ public class ThemeService {
/**
* 查询非传入作者的主题(可分页)
*
* @param lastId
* @param pageSize
* @param userId
* @return
*/
public
List
<
ThemeEntity
>
queryByThemeIdsExcludeUser
(
List
<
String
>
themeIds
,
String
userId
,
String
lastId
,
Integer
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
themeIds
)){
public
List
<
ThemeEntity
>
queryByThemeIdsExcludeUser
(
List
<
String
>
themeIds
,
String
userId
,
String
lastId
,
Integer
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getThemeId
,
themeIds
);
if
(!
StringUtils
.
isEmpty
(
userId
)){
queryWrapper
.
ne
(
ThemeEntity:
:
getAuthorId
,
userId
);
if
(!
StringUtils
.
isEmpty
(
userId
))
{
queryWrapper
.
ne
(
ThemeEntity:
:
getAuthorId
,
userId
);
}
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
...
...
@@ -168,7 +172,7 @@ public class ThemeService {
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
...
...
@@ -216,6 +220,7 @@ public class ThemeService {
/**
* 根据作者查询主题列表(可分页)
*
* @param userIds
* @param lastId
* @param pageSize
...
...
@@ -238,13 +243,14 @@ public class ThemeService {
/**
* 根据关键字搜索
*
* @param keyword
* @param lastId
* @param pageSize
* @return
*/
public
List
<
ThemeEntity
>
search
(
String
keyword
,
String
lastId
,
Integer
pageSize
)
{
if
(
StringUtils
.
isEmpty
(
keyword
)){
if
(
StringUtils
.
isEmpty
(
keyword
))
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
...
...
@@ -295,7 +301,8 @@ public class ThemeService {
/**
* 查询更新节点后的用户新建主题数
* @param userIds 用户ids
*
* @param userIds 用户ids
* @param lastViewTime 更新时间节点
* @return
*/
...
...
@@ -313,4 +320,12 @@ public class ThemeService {
}
public
void
updateReportStatus
(
String
themeId
)
{
ThemeEntity
themeEntity
=
queryByThemeId
(
themeId
);
if
(
themeEntity
==
null
)
{
throw
new
BizException
(
"主题未找到,id:"
+
themeId
);
}
themeEntity
.
setReportStatus
(
ReportStatusEnum
.
REPORTED
.
getCode
());
themeMapper
.
updateById
(
themeEntity
);
}
}
community-service/src/main/resources/mapper/community/ReportLogEntityMapper.xml
View file @
4a9778cb
...
...
@@ -9,6 +9,7 @@
<result
column=
"report_type"
property=
"reportType"
/>
<result
column=
"target_id"
property=
"targetId"
/>
<result
column=
"target_user_id"
property=
"targetUserId"
/>
<result
column=
"report_reason"
property=
"reportReason"
/>
<result
column=
"report_time"
property=
"reportTime"
/>
<result
column=
"deal_result"
property=
"dealResult"
/>
<result
column=
"deal_user_id"
property=
"dealUserId"
/>
...
...
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