Commit 4a9778cb authored by 刘基明's avatar 刘基明

举报主题、举报评论

parent 18750bc6
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;
}
......@@ -14,6 +14,4 @@ public class ReportThemeReq {
@ApiModelProperty(value = "举报理由")
private String reason;
}
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;
}
}
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;
}
}
......@@ -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("举报评论")
@GetMapping(value = "/reportComment")
@PostMapping(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();
}
}
......@@ -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
......
......@@ -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-21
* @since 2021-07-22
*/
@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 +
......
......@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
*
* @author xudong
* @since 2021-07-21
* @since 2021-07-22
*/
public interface ReportLogMapper extends BaseMapper<ReportLogEntity> {
......
......@@ -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.UserInfoService;
import com.tanpu.community.service.ReportLogService;
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 userInfoService;
private ReportLogService reportLogService;
// 评论(对主题)
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());
}
}
......@@ -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());
}
}
......@@ -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);
}
}
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);
}
}
......@@ -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,6 +301,7 @@ public class ThemeService {
/**
* 查询更新节点后的用户新建主题数
*
* @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);
}
}
......@@ -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" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment