Commit 1c8fbd84 authored by 吴泽佳's avatar 吴泽佳
parents b49984c1 3fdd9bb1
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 { ...@@ -14,6 +14,4 @@ public class ReportThemeReq {
@ApiModelProperty(value = "举报理由") @ApiModelProperty(value = "举报理由")
private String reason; private String reason;
} }
...@@ -6,6 +6,13 @@ import java.time.LocalDate; ...@@ -6,6 +6,13 @@ import java.time.LocalDate;
@Data @Data
public class KafkaDurationUptMsg { public class KafkaDurationUptMsg {
private String ident; public String ident;
private Long durMillsInc; public long durMillsInc;
public String pidUuid;
public String pidUserId;
public String visitorId;
public String faId;
public String pageId;
public String refId;
public LocalDate localDate;
} }
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;
}
}
package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.req.topic.TopicConcealReq;
import com.tanpu.community.api.beans.req.topic.TopicTopReq;
import com.tanpu.community.manager.TopicManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;
@RestController
@Slf4j
@RequestMapping(value = "/api/admin/topic")
public class AdminController {
@Autowired
private TopicManager topicManager;
@Autowired
private UserHolder userHolder;
@GetMapping(value="/add")
@ApiOperation("新增话题")
@ResponseBody
public CommonResp<Void> addTopic(@RequestParam String topicTitle){
String userId = userHolder.getUserId();
topicManager.insertTopic(topicTitle,userId);
return CommonResp.success();
}
//
// @ApiOperation("单个话题详细数据")
// @GetMapping("/detailData")
// @ResponseBody
// public CommonResp<TopicDO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException {
// if (StringUtils.isEmpty(topicId)){
// throw new MissingServletRequestParameterException("topicId","String");
// }
// TopicDO topicDO =topicManager.getDetail(topicId);
// return CommonResp.success(topicDO);
// }
@PostMapping(value = "/setTop")
@ApiOperation("顶置/取消顶置话题")
@ResponseBody
public CommonResp<Void> setTopTopic(@RequestBody TopicTopReq req) throws MissingServletRequestParameterException {
topicManager.setTopTopic(req.getTopicId(),req.isTop());
return CommonResp.success();
}
@PostMapping(value = "/setConceal")
@ApiOperation("隐藏/显示话题")
@ResponseBody
public CommonResp<Void> setConceal(@RequestBody TopicConcealReq req) throws MissingServletRequestParameterException {
topicManager.setTopicConceal(req.getTopicId(),req.isConceal());
return CommonResp.success();
}
//
// @PostMapping(value = "/modifyViewNum")
// @ApiOperation("话题浏览数调整(后台管理)")
// @ResponseBody
// public CommonResp<Void> modifyViewNum(@RequestBody TopicModifyMountReq req) throws MissingServletRequestParameterException {
// topicManager.modifyViewCount(req.getTopicId(),req.getModifyMount());
// return CommonResp.success();
// }
//
// @GetMapping(value = "/dataAnalyse")
// @ApiOperation("话题数据分析")
// @ResponseBody
// public CommonResp<TopicDataAnalysDTO> dataAnalyse(@RequestParam String topicId) throws MissingServletRequestParameterException {
// TopicDataAnalysDTO result =topicManager.queryDataAnalysis(topicId);
// return CommonResp.success(result);
// }
}
...@@ -8,6 +8,7 @@ import com.tanpu.community.api.beans.qo.CommentQo; ...@@ -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.CreateCommentReq;
import com.tanpu.community.api.beans.req.comment.LikeCommentReq; 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.QueryCommentReq;
import com.tanpu.community.api.beans.req.comment.ReportCommentReq;
import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.manager.CommentManager; import com.tanpu.community.manager.CommentManager;
import com.tanpu.community.util.PageUtils; import com.tanpu.community.util.PageUtils;
...@@ -62,12 +63,12 @@ public class CommentController { ...@@ -62,12 +63,12 @@ public class CommentController {
} }
@ApiOperation("举报评论") @ApiOperation("举报评论")
@GetMapping(value = "/reportComment") @PostMapping(value = "/reportComment")
@AuthLogin @AuthLogin
@ResponseBody @ResponseBody
public CommonResp<Void> reportComment(@RequestParam String commentId) { public CommonResp<Void> reportComment(@Validated @RequestBody ReportCommentReq req) {
//todo
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
return CommonResp.failed("功能暂未开放"); commentManager.report(req,userId);
return CommonResp.success();
} }
} }
...@@ -104,9 +104,10 @@ public class ThemeController { ...@@ -104,9 +104,10 @@ public class ThemeController {
@ApiOperation("举报主题") @ApiOperation("举报主题")
@PostMapping(value = "/report") @PostMapping(value = "/report")
@ResponseBody @ResponseBody
public CommonResp complaintTheme(@RequestBody ReportThemeReq req) { public CommonResp<Void> complaintTheme(@RequestBody ReportThemeReq req) {
String userId = userHolder.getUserId();
return CommonResp.failed("功能暂未开放"); themeManager.report(req, userId);
return CommonResp.success();
} }
@AuthLogin @AuthLogin
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 黑名单 * 黑名单
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
@TableName("black_list") @TableName("black_list")
@ApiModel(value="BlackListEntity对象", description="黑名单")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="BlackListEntity对象", description="黑名单")
public class BlackListEntity implements Serializable { public class BlackListEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "屏蔽发起人") @ApiModelProperty(value = "屏蔽发起人")
private String blocker; private String blocker;
...@@ -51,11 +50,11 @@ public class BlackListEntity implements Serializable { ...@@ -51,11 +50,11 @@ public class BlackListEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 收藏/点赞 * 收藏/点赞
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
@TableName("collection") @TableName("collection")
@ApiModel(value="CollectionEntity对象", description="收藏/点赞")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="CollectionEntity对象", description="收藏/点赞")
public class CollectionEntity implements Serializable { public class CollectionEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -30,7 +29,7 @@ public class CollectionEntity implements Serializable { ...@@ -30,7 +29,7 @@ public class CollectionEntity implements Serializable {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private String id; private String id;
@ApiModelProperty(value = "类型 1:点赞,2:收藏") @ApiModelProperty(value = "类型 1:点赞主题,2:收藏主题 3、点赞评论")
private Integer collectionType; private Integer collectionType;
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 评论 * 评论
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-21 * @since 2021-07-22
*/ */
@TableName("comment") @TableName("comment")
@ApiModel(value="CommentEntity对象", description="评论")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="CommentEntity对象", description="评论")
public class CommentEntity implements Serializable { public class CommentEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "评论主键Id") @ApiModelProperty(value = "评论主键Id")
private String commentId; private String commentId;
...@@ -67,11 +66,11 @@ public class CommentEntity implements Serializable { ...@@ -67,11 +66,11 @@ public class CommentEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 粉丝关系 * 粉丝关系
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-12 * @since 2021-07-22
*/ */
@TableName("follow_rel") @TableName("follow_rel")
@ApiModel(value="FollowRelEntity对象", description="粉丝关系")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="FollowRelEntity对象", description="粉丝关系")
public class FollowRelEntity implements Serializable { public class FollowRelEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "被关注的人id") @ApiModelProperty(value = "被关注的人id")
private String followUserId; private String followUserId;
...@@ -52,11 +51,11 @@ public class FollowRelEntity implements Serializable { ...@@ -52,11 +51,11 @@ public class FollowRelEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 个人主页 * 个人主页
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
@TableName("home_page") @TableName("home_page")
@ApiModel(value="HomePageEntity对象", description="个人主页")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="HomePageEntity对象", description="个人主页")
public class HomePageEntity implements Serializable { public class HomePageEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private String userId; private String userId;
...@@ -58,11 +57,11 @@ public class HomePageEntity implements Serializable { ...@@ -58,11 +57,11 @@ public class HomePageEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
......
...@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId; ...@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -15,9 +18,12 @@ import java.time.LocalDateTime; ...@@ -15,9 +18,12 @@ import java.time.LocalDateTime;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-21 * @since 2021-07-22
*/ */
@TableName("report_log") @TableName("report_log")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value="ReportLogEntity对象", description="举报记录") @ApiModel(value="ReportLogEntity对象", description="举报记录")
public class ReportLogEntity implements Serializable { public class ReportLogEntity implements Serializable {
...@@ -25,7 +31,7 @@ public class ReportLogEntity implements Serializable { ...@@ -25,7 +31,7 @@ public class ReportLogEntity implements Serializable {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "举报发起人") @ApiModelProperty(value = "举报发起人")
private String userId; private String userId;
...@@ -39,6 +45,8 @@ public class ReportLogEntity implements Serializable { ...@@ -39,6 +45,8 @@ public class ReportLogEntity implements Serializable {
@ApiModelProperty(value = "举报对象作者id") @ApiModelProperty(value = "举报对象作者id")
private String targetUserId; private String targetUserId;
private String reportReason;
@ApiModelProperty(value = "上报时间") @ApiModelProperty(value = "上报时间")
private LocalDateTime reportTime; private LocalDateTime reportTime;
...@@ -58,11 +66,11 @@ public class ReportLogEntity implements Serializable { ...@@ -58,11 +66,11 @@ public class ReportLogEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
...@@ -98,6 +106,14 @@ public class ReportLogEntity implements Serializable { ...@@ -98,6 +106,14 @@ public class ReportLogEntity implements Serializable {
this.targetUserId = targetUserId; this.targetUserId = targetUserId;
} }
public String getReportReason() {
return reportReason;
}
public void setReportReason(String reportReason) {
this.reportReason = reportReason;
}
public LocalDateTime getReportTime() { public LocalDateTime getReportTime() {
return reportTime; return reportTime;
} }
...@@ -162,6 +178,7 @@ public class ReportLogEntity implements Serializable { ...@@ -162,6 +178,7 @@ public class ReportLogEntity implements Serializable {
", reportType=" + reportType + ", reportType=" + reportType +
", targetId=" + targetId + ", targetId=" + targetId +
", targetUserId=" + targetUserId + ", targetUserId=" + targetUserId +
", reportReason=" + reportReason +
", reportTime=" + reportTime + ", reportTime=" + reportTime +
", dealResult=" + dealResult + ", dealResult=" + dealResult +
", dealUserId=" + dealUserId + ", dealUserId=" + dealUserId +
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 主题内容 * 主题内容
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-21 * @since 2021-07-22
*/ */
@TableName("theme") @TableName("theme")
@ApiModel(value="ThemeEntity对象", description="主题内容")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="ThemeEntity对象", description="主题内容")
public class ThemeEntity implements Serializable { public class ThemeEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "主题主键Id") @ApiModelProperty(value = "主题主键Id")
private String themeId; private String themeId;
...@@ -68,11 +67,11 @@ public class ThemeEntity implements Serializable { ...@@ -68,11 +67,11 @@ public class ThemeEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 话题 * 话题
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
@TableName("topic") @TableName("topic")
@ApiModel(value="TopicEntity对象", description="话题")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(value="TopicEntity对象", description="话题")
public class TopicEntity implements Serializable { public class TopicEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
@ApiModelProperty(value = "uuid") @ApiModelProperty(value = "话题主键Id")
private String topicId; private String topicId;
@ApiModelProperty(value = "话题名称") @ApiModelProperty(value = "话题名称")
...@@ -45,7 +44,7 @@ public class TopicEntity implements Serializable { ...@@ -45,7 +44,7 @@ public class TopicEntity implements Serializable {
@ApiModelProperty(value = "是否隐藏") @ApiModelProperty(value = "是否隐藏")
private Integer isConceal; private Integer isConceal;
@ApiModelProperty(value = "浏览量调整") @ApiModelProperty(value = "浏览量调整基数")
private Long viewCntAdjust; private Long viewCntAdjust;
private LocalDateTime createTime; private LocalDateTime createTime;
...@@ -55,11 +54,11 @@ public class TopicEntity implements Serializable { ...@@ -55,11 +54,11 @@ public class TopicEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
...@@ -95,12 +94,12 @@ public class TopicEntity implements Serializable { ...@@ -95,12 +94,12 @@ public class TopicEntity implements Serializable {
this.isConceal = isConceal; this.isConceal = isConceal;
} }
public Long getviewCntAdjust() { public Long getViewCntAdjust() {
return viewCntAdjust; return viewCntAdjust;
} }
public void setViewAmountModify(Long viewAmountModify) { public void setViewCntAdjust(Long viewCntAdjust) {
this.viewCntAdjust = viewAmountModify; this.viewCntAdjust = viewCntAdjust;
} }
public LocalDateTime getCreateTime() { public LocalDateTime getCreateTime() {
...@@ -135,7 +134,7 @@ public class TopicEntity implements Serializable { ...@@ -135,7 +134,7 @@ public class TopicEntity implements Serializable {
", topicTitle=" + topicTitle + ", topicTitle=" + topicTitle +
", isTop=" + isTop + ", isTop=" + isTop +
", isConceal=" + isConceal + ", isConceal=" + isConceal +
", viewAmountModify=" + viewCntAdjust + ", viewCntAdjust=" + viewCntAdjust +
", createTime=" + createTime + ", createTime=" + createTime +
", updateTime=" + updateTime + ", updateTime=" + updateTime +
", deleteTag=" + deleteTag + ", deleteTag=" + deleteTag +
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 浏览记录 * 浏览记录
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-19 * @since 2021-07-22
*/ */
@TableName("visit_summary") @TableName("visit_summary")
@ApiModel(value="VisitSummaryEntity对象", description="浏览记录")
@Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder
@ApiModel(value="VisitSummaryEntity对象", description="浏览记录")
public class VisitSummaryEntity implements Serializable { public class VisitSummaryEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private String id; private Long id;
@ApiModelProperty(value = "session_id") @ApiModelProperty(value = "session_id")
private String ident; private String ident;
...@@ -55,11 +54,11 @@ public class VisitSummaryEntity implements Serializable { ...@@ -55,11 +54,11 @@ public class VisitSummaryEntity implements Serializable {
private Integer deleteTag; private Integer deleteTag;
public String getId() { public Long getId() {
return id; return id;
} }
public void setId(String id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
public interface BlackListMapper extends BaseMapper<BlackListEntity> { public interface BlackListMapper extends BaseMapper<BlackListEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
public interface CollectionMapper extends BaseMapper<CollectionEntity> { public interface CollectionMapper extends BaseMapper<CollectionEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-21 * @since 2021-07-22
*/ */
public interface CommentMapper extends BaseMapper<CommentEntity> { public interface CommentMapper extends BaseMapper<CommentEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
public interface FollowRelMapper extends BaseMapper<FollowRelEntity> { public interface FollowRelMapper extends BaseMapper<FollowRelEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
public interface HomePageMapper extends BaseMapper<HomePageEntity> { public interface HomePageMapper extends BaseMapper<HomePageEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-21 * @since 2021-07-22
*/ */
public interface ReportLogMapper extends BaseMapper<ReportLogEntity> { public interface ReportLogMapper extends BaseMapper<ReportLogEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-21 * @since 2021-07-22
*/ */
public interface ThemeMapper extends BaseMapper<ThemeEntity> { public interface ThemeMapper extends BaseMapper<ThemeEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-07 * @since 2021-07-22
*/ */
public interface TopicMapper extends BaseMapper<TopicEntity> { public interface TopicMapper extends BaseMapper<TopicEntity> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-19 * @since 2021-07-22
*/ */
public interface VisitSummaryMapper extends BaseMapper<VisitSummaryEntity> { public interface VisitSummaryMapper extends BaseMapper<VisitSummaryEntity> {
......
...@@ -5,15 +5,17 @@ import com.tanpu.common.exception.BizException; ...@@ -5,15 +5,17 @@ import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.qo.CommentQo; 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.CreateCommentReq;
import com.tanpu.community.api.beans.req.comment.LikeCommentReq; 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.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.enums.CollectionTypeEnum; import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.CommentTypeEnum; import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.OperationTypeEnum; 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.dao.entity.community.CommentEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools; import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.service.CollectionService; import com.tanpu.community.service.CollectionService;
import com.tanpu.community.service.CommentService; 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 com.tanpu.community.util.ConvertUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -36,9 +38,8 @@ public class CommentManager { ...@@ -36,9 +38,8 @@ public class CommentManager {
@Autowired @Autowired
private CollectionService collectionService; private CollectionService collectionService;
@Resource @Resource
private UserInfoService userInfoService; private ReportLogService reportLogService;
// 评论(对主题) // 评论(对主题)
public void comment(CreateCommentReq req, String userId) { public void comment(CreateCommentReq req, String userId) {
...@@ -105,4 +106,13 @@ public class CommentManager { ...@@ -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());
}
} }
...@@ -9,8 +9,6 @@ import org.springframework.context.annotation.Configuration; ...@@ -9,8 +9,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Slf4j @Slf4j
@Service @Service
@Configuration @Configuration
...@@ -36,11 +34,10 @@ public class ConJobManager { ...@@ -36,11 +34,10 @@ public class ConJobManager {
} }
/** /**
* 定时统计主题排行 * 定时统计主题、话题排行
*/ */
@Scheduled(cron = "0 */2 * * * ?") @Scheduled(cron = "0 */2 * * * ?")
public void themeRank() { public void themeRank() {
System.out.println(LocalDateTime.now());
rankService.rankThemes(); rankService.rankThemes();
rankService.rankTopics(); rankService.rankTopics();
} }
......
package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class KafkaManager {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private VisitSummaryService visitSummaryService;
// public void sendMessage(String message) {
// System.out.println("#### send " + message);
// this.kafkaTemplate.send("users", message);
// }
// todo topic
@KafkaListener(topics = "newCommunityVisitor")
public void consumeVisitorHis(String message) {
System.out.println("#### receive " + message);
}
// todo topic
@KafkaListener(topics = "newCommunityVisitor")
public void consumeDurationUpdate(String message) {
KafkaDurationUptMsg msg = JSON.parseObject(message, KafkaDurationUptMsg.class);
visitSummaryService.updateDurByIdent(msg.getIdent(), msg.getDurMillsInc().intValue());
}
}
...@@ -61,6 +61,9 @@ public class ThemeManager { ...@@ -61,6 +61,9 @@ public class ThemeManager {
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitSummaryService visitSummaryService;
@Autowired
private ReportLogService reportLogService;
@Autowired @Autowired
private RankService rankService; private RankService rankService;
...@@ -178,6 +181,19 @@ public class ThemeManager { ...@@ -178,6 +181,19 @@ public class ThemeManager {
} }
/**
* 举报主题
* @param req
* @param userId
*/
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());
}
// 返回用户发布、回复、收藏的主题列表 // 返回用户发布、回复、收藏的主题列表
public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) { public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) {
...@@ -187,46 +203,8 @@ public class ThemeManager { ...@@ -187,46 +203,8 @@ public class ThemeManager {
themeEntities = themeService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize()); themeEntities = themeService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
break; break;
case 2://回复 case 2://回复
List<ThemeQo> commentThemeList = new ArrayList<>();
//评论列表 List<ThemeQo> commentThemeList = getCommentThemeQos(req, userId);
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return commentThemeList; return commentThemeList;
case 3://点赞 case 3://点赞
Set<String> likeThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.LIKE_THEME); Set<String> likeThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.LIKE_THEME);
...@@ -241,6 +219,51 @@ public class ThemeManager { ...@@ -241,6 +219,51 @@ public class ThemeManager {
return themeQos; return themeQos;
} }
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities;
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return null;
}
//查询正文 //查询正文
public ThemeQo getDetail(String themeId, String userId) { public ThemeQo getDetail(String themeId, String userId) {
...@@ -434,4 +457,5 @@ public class ThemeManager { ...@@ -434,4 +457,5 @@ public class ThemeManager {
} }
} }
} }
...@@ -66,51 +66,12 @@ public class TopicManager { ...@@ -66,51 +66,12 @@ public class TopicManager {
} }
public void setTopTopic(String topicId, boolean setTop) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null) {
throw new BizException("找不到话题,id:" + topicId);
}
if (setTop) {
topicService.updateTopicToTop(topicId);
} else {
topicService.updateTopicNotTop(topicId);
}
}
public void setTopicConceal(String topicId, boolean setConceal) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null) {
throw new BizException("找不到话题,id:" + topicId);
}
if (setConceal) {
topicService.updateTopicToConceal(topicId);
} else {
topicService.updateTopicNotConceal(topicId);
}
}
public void modifyViewCount(String topicId, Long modifyMount) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null) {
throw new BizException("找不到话题,id:" + topicId);
}
topicService.modifyViewCount(topicId, modifyMount);
if (modifyMount > 0) {
redisService.incr(RedisKeyConstant.TOPIC_TOTAL_VIEW_COUNT_ + topicId, modifyMount);
} else {
redisService.decr(RedisKeyConstant.TOPIC_TOTAL_VIEW_COUNT_ + topicId, -modifyMount);
}
}
public void refreshRedisCache() { public void refreshRedisCache() {
List<TopicEntity> topicEntities = topicService.queryAll(); List<TopicEntity> topicEntities = topicService.queryAll();
for (TopicEntity topic : topicEntities) { for (TopicEntity topic : topicEntities) {
String topicId = topic.getTopicId(); String topicId = topic.getTopicId();
Long viewCountModify = topic.getviewCntAdjust(); Long viewCountModify = topic.getViewCntAdjust();
List<String> themeIds = themeService.queryThemeIdsByTopic(topicId); List<String> themeIds = themeService.queryThemeIdsByTopic(topicId);
Integer likeCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.LIKE_THEME); Integer likeCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.LIKE_THEME);
Integer bookCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.COLLECT_THEME); Integer bookCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.COLLECT_THEME);
...@@ -136,7 +97,7 @@ public class TopicManager { ...@@ -136,7 +97,7 @@ public class TopicManager {
} }
//后台管理:返回数据分析 //返回数据分析
public TopicDataAnalysDTO queryDataAnalysis(String topicId) { public TopicDataAnalysDTO queryDataAnalysis(String topicId) {
TopicDataAnalysDTO topicDataAnalysDTO = new TopicDataAnalysDTO(); TopicDataAnalysDTO topicDataAnalysDTO = new TopicDataAnalysDTO();
TopicEntity topicEntity = topicService.queryById(topicId); TopicEntity topicEntity = topicService.queryById(topicId);
......
package com.tanpu.community.manager; package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON;
import com.tanpu.common.auth.UserHolder; import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.enums.VisitTypeEnum; import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity;
import com.tanpu.community.service.VisitSummaryService; import com.tanpu.community.service.VisitSummaryService;
import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@Slf4j
@Service @Service
public class VisitSummaryManager { public class VisitSummaryManager {
@Resource private static final String kafakTopic = "tp_new_community_queue_ubr_dur_upd";
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private VisitSummaryService visitSummaryService; private VisitSummaryService visitSummaryService;
@Autowired @Autowired
private UserHolder userHolder; private UserHolder userHolder;
@KafkaListener(topics = kafakTopic)
public void updateVisitSummary(String message) {
KafkaDurationUptMsg msg = JSON.parseObject(message, KafkaDurationUptMsg.class);
// ident在每次进入新页面 & 回退 的时候都会随机生成一个,所以用ident做唯一key即可。
VisitSummaryEntity vs = ConvertUtil.convertFromKafka(msg);
}
public void addTopicPageView(String topicId) { public void addTopicPageView(String topicId) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
visitSummaryService.addPageView(userId, topicId, VisitTypeEnum.TOPIC_PAGE_VIEW); visitSummaryService.addPageView(userId, topicId, VisitTypeEnum.TOPIC_PAGE_VIEW);
...@@ -31,5 +58,4 @@ public class VisitSummaryManager { ...@@ -31,5 +58,4 @@ public class VisitSummaryManager {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
visitSummaryService.addPageView(userId, userId, VisitTypeEnum.FOLLOW_THEME_VIEW); visitSummaryService.addPageView(userId, userId, VisitTypeEnum.FOLLOW_THEME_VIEW);
} }
} }
...@@ -5,6 +5,7 @@ import com.tanpu.common.exception.BizException; ...@@ -5,6 +5,7 @@ import com.tanpu.common.exception.BizException;
import com.tanpu.common.uuid.UuidGenHelper; import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.CommentTypeEnum; import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum; 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.entity.community.CommentEntity;
import com.tanpu.community.dao.mapper.community.CommentMapper; import com.tanpu.community.dao.mapper.community.CommentMapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -34,8 +35,9 @@ public class CommentService { ...@@ -34,8 +35,9 @@ public class CommentService {
} }
public List<CommentEntity> selectByUserId(String userId) { public CommentEntity queryByCommentId(String commmentId) {
return commentMapper.selectList(new LambdaQueryWrapper<CommentEntity>().eq(CommentEntity::getAuthorId, userId)); return commentMapper.selectOne(new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getCommentId, commmentId));
} }
//统计主题集合的评论量 //统计主题集合的评论量
...@@ -100,4 +102,13 @@ public class CommentService { ...@@ -100,4 +102,13 @@ public class CommentService {
} }
return commentMapper.selectList(queryWrapper); 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; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.common.exception.BizException; import com.tanpu.common.exception.BizException;
import com.tanpu.common.uuid.UuidGenHelper; import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum; 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.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper; import com.tanpu.community.dao.mapper.community.ThemeMapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -42,6 +43,7 @@ public class ThemeService { ...@@ -42,6 +43,7 @@ public class ThemeService {
/** /**
* 根据主题Id查询列表 * 根据主题Id查询列表
*
* @return * @return
*/ */
public List<ThemeEntity> queryAll() { public List<ThemeEntity> queryAll() {
...@@ -83,7 +85,7 @@ public class ThemeService { ...@@ -83,7 +85,7 @@ public class ThemeService {
//根据ids返回主题详情,带分页 //根据ids返回主题详情,带分页
public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize) { public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize) {
if (CollectionUtils.isEmpty(themeIds)){ if (CollectionUtils.isEmpty(themeIds)) {
return Collections.emptyList(); return Collections.emptyList();
} }
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
...@@ -102,11 +104,12 @@ public class ThemeService { ...@@ -102,11 +104,12 @@ public class ThemeService {
/** /**
* 根据主题Id查询列表 * 根据主题Id查询列表
*
* @param themeIds * @param themeIds
* @return * @return
*/ */
public List<ThemeEntity> queryByThemeIds(List<String> themeIds) { public List<ThemeEntity> queryByThemeIds(List<String> themeIds) {
if (CollectionUtils.isEmpty(themeIds)){ if (CollectionUtils.isEmpty(themeIds)) {
return Collections.emptyList(); return Collections.emptyList();
} }
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
...@@ -117,18 +120,18 @@ public class ThemeService { ...@@ -117,18 +120,18 @@ public class ThemeService {
} }
/** /**
* 查询非传入作者的主题(可分页) * 查询非传入作者的主题(可分页)
*
* @param lastId * @param lastId
* @param pageSize * @param pageSize
* @param userId * @param userId
* @return * @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<>(); LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<>();
if (!StringUtils.isEmpty(userId)){ if (!StringUtils.isEmpty(userId)) {
queryWrapper.ne(ThemeEntity::getAuthorId,userId); queryWrapper.ne(ThemeEntity::getAuthorId, userId);
} }
if (StringUtils.isNotEmpty(lastId)) { if (StringUtils.isNotEmpty(lastId)) {
...@@ -136,7 +139,7 @@ public class ThemeService { ...@@ -136,7 +139,7 @@ public class ThemeService {
if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId); if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime()); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
} }
if (pageSize!=null){ if (pageSize != null) {
queryWrapper.last("limit " + pageSize); queryWrapper.last("limit " + pageSize);
} }
...@@ -148,19 +151,20 @@ public class ThemeService { ...@@ -148,19 +151,20 @@ public class ThemeService {
/** /**
* 查询非传入作者的主题(可分页) * 查询非传入作者的主题(可分页)
*
* @param lastId * @param lastId
* @param pageSize * @param pageSize
* @param userId * @param userId
* @return * @return
*/ */
public List<ThemeEntity> queryByThemeIdsExcludeUser(List<String> themeIds,String userId,String lastId, Integer pageSize) { public List<ThemeEntity> queryByThemeIdsExcludeUser(List<String> themeIds, String userId, String lastId, Integer pageSize) {
if (CollectionUtils.isEmpty(themeIds)){ if (CollectionUtils.isEmpty(themeIds)) {
return Collections.emptyList(); return Collections.emptyList();
} }
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds); .in(ThemeEntity::getThemeId, themeIds);
if (!StringUtils.isEmpty(userId)){ if (!StringUtils.isEmpty(userId)) {
queryWrapper.ne(ThemeEntity::getAuthorId,userId); queryWrapper.ne(ThemeEntity::getAuthorId, userId);
} }
if (StringUtils.isNotEmpty(lastId)) { if (StringUtils.isNotEmpty(lastId)) {
...@@ -168,7 +172,7 @@ public class ThemeService { ...@@ -168,7 +172,7 @@ public class ThemeService {
if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId); if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime()); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
} }
if (pageSize!=null){ if (pageSize != null) {
queryWrapper.last("limit " + pageSize); queryWrapper.last("limit " + pageSize);
} }
...@@ -216,6 +220,7 @@ public class ThemeService { ...@@ -216,6 +220,7 @@ public class ThemeService {
/** /**
* 根据作者查询主题列表(可分页) * 根据作者查询主题列表(可分页)
*
* @param userIds * @param userIds
* @param lastId * @param lastId
* @param pageSize * @param pageSize
...@@ -238,13 +243,14 @@ public class ThemeService { ...@@ -238,13 +243,14 @@ public class ThemeService {
/** /**
* 根据关键字搜索 * 根据关键字搜索
*
* @param keyword * @param keyword
* @param lastId * @param lastId
* @param pageSize * @param pageSize
* @return * @return
*/ */
public List<ThemeEntity> search(String keyword, String lastId, Integer pageSize) { public List<ThemeEntity> search(String keyword, String lastId, Integer pageSize) {
if (StringUtils.isEmpty(keyword)){ if (StringUtils.isEmpty(keyword)) {
return Collections.emptyList(); return Collections.emptyList();
} }
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
...@@ -295,7 +301,8 @@ public class ThemeService { ...@@ -295,7 +301,8 @@ public class ThemeService {
/** /**
* 查询更新节点后的用户新建主题数 * 查询更新节点后的用户新建主题数
* @param userIds 用户ids *
* @param userIds 用户ids
* @param lastViewTime 更新时间节点 * @param lastViewTime 更新时间节点
* @return * @return
*/ */
...@@ -313,4 +320,12 @@ public class ThemeService { ...@@ -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);
}
} }
...@@ -93,15 +93,6 @@ public class TopicService { ...@@ -93,15 +93,6 @@ public class TopicService {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId, topicIds)); return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId, topicIds));
} }
public void modifyViewCount(String topicId, long Count) {
TopicEntity topicEntity = queryById(topicId);
Long oldCount = topicEntity.getviewCntAdjust();
topicEntity.setViewAmountModify(topicEntity.getviewCntAdjust() + Count);
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getviewCntAdjust, oldCount));
return;
}
public TopicEntity queryByTitile(String topicTitle) { public TopicEntity queryByTitile(String topicTitle) {
return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicTitle, topicTitle)); return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicTitle, topicTitle));
} }
......
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference; ...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.resp.FileUploadResp; import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.beans.vo.ImagesDTO; import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.beans.vo.TopicDTO; import com.tanpu.community.api.beans.vo.TopicDTO;
import com.tanpu.community.api.beans.qo.*; import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq; import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
...@@ -14,6 +15,7 @@ import com.tanpu.community.api.enums.RelTypeEnum; ...@@ -14,6 +15,7 @@ import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum; import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*; import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity; import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -27,6 +29,9 @@ import java.util.stream.Collectors; ...@@ -27,6 +29,9 @@ import java.util.stream.Collectors;
public class ConvertUtil { public class ConvertUtil {
/**
* THEME
*/
public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) { public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
if (themeEntity == null) { if (themeEntity == null) {
return null; return null;
...@@ -88,6 +93,9 @@ public class ConvertUtil { ...@@ -88,6 +93,9 @@ public class ConvertUtil {
} }
/**
* TOPIC
*/
public static TopicDTO topicEntityToDTO(TopicEntity topicEntity) { public static TopicDTO topicEntityToDTO(TopicEntity topicEntity) {
TopicDTO topicDTO = new TopicDTO(); TopicDTO topicDTO = new TopicDTO();
BeanUtils.copyProperties(topicEntity, topicDTO); BeanUtils.copyProperties(topicEntity, topicDTO);
...@@ -163,6 +171,22 @@ public class ConvertUtil { ...@@ -163,6 +171,22 @@ public class ConvertUtil {
} }
} }
/**
* VISIT_SUMMARY
*/
public static VisitSummaryEntity convertFromKafka(KafkaDurationUptMsg msg) {
VisitSummaryEntity vs = new VisitSummaryEntity();
vs.setAuthorId(msg.pidUserId);
vs.setDeleteTag(DeleteTagEnum.NOT_DELETED.ordinal());
vs.setDuration(1);
vs.setIdent(msg.ident);
vs.setRefId(msg.refId);
// todo
vs.setRefType(-1);
vs.setVisitorId(msg.visitorId);
return vs;
}
/** /**
* 解析 List<ThemeContentReq>为Attachment列表 * 解析 List<ThemeContentReq>为Attachment列表
* *
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<result column="report_type" property="reportType" /> <result column="report_type" property="reportType" />
<result column="target_id" property="targetId" /> <result column="target_id" property="targetId" />
<result column="target_user_id" property="targetUserId" /> <result column="target_user_id" property="targetUserId" />
<result column="report_reason" property="reportReason" />
<result column="report_time" property="reportTime" /> <result column="report_time" property="reportTime" />
<result column="deal_result" property="dealResult" /> <result column="deal_result" property="dealResult" />
<result column="deal_user_id" property="dealUserId" /> <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