Commit 2e5f22ef authored by 吴泽佳's avatar 吴泽佳

Merge branch 'dev' of http://47.100.44.39:10001/tp-backend/tanpu-community into dev

# Conflicts:
#	community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
#	community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
#	community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
#	community-service/src/main/java/com/tanpu/community/service/RankService.java
#	community-service/src/main/resources/application-dev.yml
parents d1ba9594 8f4feb3e
...@@ -26,6 +26,9 @@ public class TopicRankQo { ...@@ -26,6 +26,9 @@ public class TopicRankQo {
@ApiModelProperty(value = "是否置顶") @ApiModelProperty(value = "是否置顶")
private Integer isTop; private Integer isTop;
@ApiModelProperty(value = "浏览量调整基数")
private Integer viewCntAdjust;
/** /**
* TODO 热度计算算法 * TODO 热度计算算法
* @return * @return
...@@ -35,6 +38,6 @@ public class TopicRankQo { ...@@ -35,6 +38,6 @@ public class TopicRankQo {
if (isTop>0){ if (isTop>0){
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }
return this.viewCount+this.disscussCount*3; return this.viewCount+this.disscussCount*3+viewCount;
} }
} }
...@@ -10,8 +10,6 @@ import java.util.List; ...@@ -10,8 +10,6 @@ import java.util.List;
@Data @Data
public class CreateThemeReq { public class CreateThemeReq {
private static final long serialVersionUID = 1L;
@NotNull(message = "类型不能为空") @NotNull(message = "类型不能为空")
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题") @ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题")
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
@ApiModel(value = "主题内容") @ApiModel(value = "主题内容")
public class ThemeContentReq { public class ThemeContentReq {
@ApiModelProperty(value = "RelTypeEnum类型,8:文本,88:产品 3:直播 6:短视频 2:课程,9:图片 10:多图(讨论)") @ApiModelProperty(value = "RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论))")
private String type; private String type;
@ApiModelProperty(value = "文本的值是内容,附件的值为id") @ApiModelProperty(value = "文本的值是内容,附件的值为id")
......
package com.tanpu.community.api.beans.vo.feign.pay;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "支付详情")
public class PayDetailVO {
private String id;
private String title;
private String cover;
private String info;
private Integer score;
private Long price;
/**
* 划线价
*/
private Long crossedPrice;
private Integer availableScore;
private Integer balance;
/**
* 1:免费 2:积分 3现金
*/
private Integer chargeMode;
/**
* 类型:1:栏目 3:直播 4:视频 5 音频 7:直播课件
*/
private Integer relType;
}
...@@ -65,6 +65,16 @@ ...@@ -65,6 +65,16 @@
<artifactId>spring-cloud-starter-zipkin</artifactId> <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<!-- mybatis-plus自动生成所需包--> <!-- mybatis-plus自动生成所需包-->
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
......
...@@ -3,10 +3,13 @@ package com.tanpu.community.config; ...@@ -3,10 +3,13 @@ package com.tanpu.community.config;
import com.tanpu.community.cache.RedisCache; import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.util.SpringUtils; import com.tanpu.community.util.SpringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Arrays;
@Configuration @Configuration
public class CacheConfig { public class CacheConfig {
...@@ -16,6 +19,14 @@ public class CacheConfig { ...@@ -16,6 +19,14 @@ public class CacheConfig {
@Bean @Bean
public RedisCache redisCache() { public RedisCache redisCache() {
return new RedisCache.Builder().cacheName("community2").build(); return new RedisCache.Builder().cacheName("redis").build();
}
@Bean
public CacheManager cacheManager() {
CaffeineCacheManager cacheManager = new CaffeineCacheManager();
cacheManager.setCacheNames(Arrays.asList("local"));
cacheManager.setCacheSpecification("maximumSize=10,expireAfterWrite=10s");
return cacheManager;
} }
} }
...@@ -71,4 +71,14 @@ public class CommentController { ...@@ -71,4 +71,14 @@ public class CommentController {
commentManager.report(req,userId); commentManager.report(req,userId);
return CommonResp.success(); return CommonResp.success();
} }
@ApiOperation("删除评论")
@GetMapping(value = "/deleteComment")
@AuthLogin
@ResponseBody
public CommonResp<Void> reportComment(@RequestParam(value = "commentId") String commentId) {
String userId = userHolder.getUserId();
commentManager.delete(commentId,userId);
return CommonResp.success();
}
} }
...@@ -21,4 +21,16 @@ public class FileController { ...@@ -21,4 +21,16 @@ public class FileController {
public CommonResp<FileUploadResp> uploadToRemote(@RequestParam(value = "file") MultipartFile file) { public CommonResp<FileUploadResp> uploadToRemote(@RequestParam(value = "file") MultipartFile file) {
return CommonResp.success(fileManager.uploadFile(file)); return CommonResp.success(fileManager.uploadFile(file));
} }
@GetMapping("/test")
public String test() {
for (int i = 0; i < 30; i++) {
System.out.println(fileManager.getId("" + i / 2));
}
for (int i = 30; i > 0; i--) {
System.out.println(fileManager.getId("" + i / 2));
}
return "";
}
} }
...@@ -8,7 +8,6 @@ import com.tanpu.community.api.beans.qo.ThemeQo; ...@@ -8,7 +8,6 @@ import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.theme.*; import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp; import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.api.beans.resp.ThemeListResp; import com.tanpu.community.api.beans.resp.ThemeListResp;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.manager.ThemeManager; import com.tanpu.community.manager.ThemeManager;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -17,7 +16,6 @@ import org.springframework.validation.annotation.Validated; ...@@ -17,7 +16,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
@RestController @RestController
@Slf4j @Slf4j
...@@ -28,8 +26,6 @@ public class ThemeController { ...@@ -28,8 +26,6 @@ public class ThemeController {
private ThemeManager themeManager; private ThemeManager themeManager;
@Resource @Resource
private UserHolder userHolder; private UserHolder userHolder;
@Autowired
private RedisCache redisCache;
@AuthLogin @AuthLogin
@ApiOperation("发表主题") @ApiOperation("发表主题")
...@@ -79,12 +75,12 @@ public class ThemeController { ...@@ -79,12 +75,12 @@ public class ThemeController {
} }
@AuthLogin @AuthLogin
@ApiOperation("用户删除自有主题") @ApiOperation("用户删除主题")
@GetMapping(value = "/delete") @GetMapping(value = "/delete")
@ResponseBody @ResponseBody
public CommonResp<Void> delete(@RequestParam(value = "themeId") String themeId) { public CommonResp<Void> delete(@RequestParam(value = "themeId") String themeId) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
themeManager.delete(themeId); themeManager.delete(themeId, userId);
return CommonResp.success(); return CommonResp.success();
} }
......
...@@ -19,11 +19,11 @@ public class CodeAutoGenerator { ...@@ -19,11 +19,11 @@ public class CodeAutoGenerator {
String currentPath = System.getProperty("user.dir"); String currentPath = System.getProperty("user.dir");
String codeBaseHome = "/community-service/src/main/java"; String codeBaseHome = "/community-service/src/main/java";
String author = "xudong"; String author = "xudong";
String mysqlUserName = "dev"; String mysqlUserName = "tamp_admin";
String mysqlPassword = "qimeng123"; String mysqlPassword = "@imeng123";
String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_community"; String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community";
String[] tables = new String[]{"comment"}; // String[] tables = new String[]{"theme"};
// String[] tables = new String[]{"follow_rel", "black_list","collection","comment","follow_rel","file_record","home_page","theme","topic","theme_attachment"}; String[] tables = new String[]{"comment","follow_rel","theme","visit_log"};
String basePackage = "com.tanpu.community"; String basePackage = "com.tanpu.community";
String mapperPackage = "dao.mapper.community"; String mapperPackage = "dao.mapper.community";
String entityPackage = "dao.entity.community"; String entityPackage = "dao.entity.community";
......
...@@ -3,7 +3,6 @@ package com.tanpu.community.dao.entity.community; ...@@ -3,7 +3,6 @@ package com.tanpu.community.dao.entity.community;
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 com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
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;
...@@ -19,7 +18,7 @@ import java.time.LocalDateTime; ...@@ -19,7 +18,7 @@ import java.time.LocalDateTime;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-22 * @since 2021-07-28
*/ */
@TableName("comment") @TableName("comment")
@ApiModel(value="CommentEntity对象", description="评论") @ApiModel(value="CommentEntity对象", description="评论")
...@@ -55,16 +54,14 @@ public class CommentEntity implements Serializable { ...@@ -55,16 +54,14 @@ public class CommentEntity implements Serializable {
@ApiModelProperty(value = "回复评论id") @ApiModelProperty(value = "回复评论id")
private String replyId; private String replyId;
@ApiModelProperty(value = "是否通过 0:初始值 1:已通过(管理后台使用)") @ApiModelProperty(value = "审核状态 0:初始值 1:已通过(管理后台使用)")
private Integer isPass; private Integer reviewStatus;
@ApiModelProperty(value = "举报状态 0:未被举报 1:被举报 2:已处理") @ApiModelProperty(value = "举报状态 0:未被举报 1:被举报 2:已处理")
private Integer reportStatus; private Integer reportStatus;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime createTime; private LocalDateTime createTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime updateTime; private LocalDateTime updateTime;
private Integer deleteTag; private Integer deleteTag;
...@@ -134,12 +131,12 @@ public class CommentEntity implements Serializable { ...@@ -134,12 +131,12 @@ public class CommentEntity implements Serializable {
this.replyId = replyId; this.replyId = replyId;
} }
public Integer getIsPass() { public Integer getReviewStatus() {
return isPass; return reviewStatus;
} }
public void setIsPass(Integer isPass) { public void setReviewStatus(Integer reviewStatus) {
this.isPass = isPass; this.reviewStatus = reviewStatus;
} }
public Integer getReportStatus() { public Integer getReportStatus() {
...@@ -185,7 +182,7 @@ public class CommentEntity implements Serializable { ...@@ -185,7 +182,7 @@ public class CommentEntity implements Serializable {
", themeId=" + themeId + ", themeId=" + themeId +
", parentId=" + parentId + ", parentId=" + parentId +
", replyId=" + replyId + ", replyId=" + replyId +
", isPass=" + isPass + ", reviewStatus=" + reviewStatus +
", reportStatus=" + reportStatus + ", reportStatus=" + reportStatus +
", createTime=" + createTime + ", createTime=" + createTime +
", updateTime=" + updateTime + ", updateTime=" + updateTime +
......
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 java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableName;
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-22 * @since 2021-07-28
*/ */
@TableName("follow_rel") @TableName("follow_rel")
@ApiModel(value="FollowRelEntity对象", description="粉丝关系") @ApiModel(value="FollowRelEntity对象", description="粉丝关系")
...@@ -33,10 +34,10 @@ public class FollowRelEntity implements Serializable { ...@@ -33,10 +34,10 @@ public class FollowRelEntity implements Serializable {
private Long id; private Long id;
@ApiModelProperty(value = "被关注的人id") @ApiModelProperty(value = "被关注的人id")
private String followUserId; private String idolId;
@ApiModelProperty(value = "粉丝id") @ApiModelProperty(value = "粉丝id")
private String followerId; private String fansId;
@ApiModelProperty(value = "关注时间") @ApiModelProperty(value = "关注时间")
private LocalDateTime followTime; private LocalDateTime followTime;
...@@ -59,20 +60,20 @@ public class FollowRelEntity implements Serializable { ...@@ -59,20 +60,20 @@ public class FollowRelEntity implements Serializable {
this.id = id; this.id = id;
} }
public String getFollowUserId() { public String getIdolId() {
return followUserId; return idolId;
} }
public void setFollowUserId(String followUserId) { public void setIdolId(String idolId) {
this.followUserId = followUserId; this.idolId = idolId;
} }
public String getFollowerId() { public String getFansId() {
return followerId; return fansId;
} }
public void setFollowerId(String followerId) { public void setFansId(String fansId) {
this.followerId = followerId; this.fansId = fansId;
} }
public LocalDateTime getFollowTime() { public LocalDateTime getFollowTime() {
...@@ -119,8 +120,8 @@ public class FollowRelEntity implements Serializable { ...@@ -119,8 +120,8 @@ public class FollowRelEntity implements Serializable {
public String toString() { public String toString() {
return "FollowRelEntity{" + return "FollowRelEntity{" +
"id=" + id + "id=" + id +
", followUserId=" + followUserId + ", idolId=" + idolId +
", followerId=" + followerId + ", fansId=" + fansId +
", followTime=" + followTime + ", followTime=" + followTime +
", unfollowTime=" + unfollowTime + ", unfollowTime=" + unfollowTime +
", createTime=" + createTime + ", createTime=" + createTime +
......
...@@ -18,7 +18,7 @@ import java.time.LocalDateTime; ...@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-23 * @since 2021-07-28
*/ */
@TableName("theme") @TableName("theme")
@Builder @Builder
...@@ -42,12 +42,9 @@ public class ThemeEntity implements Serializable { ...@@ -42,12 +42,9 @@ public class ThemeEntity implements Serializable {
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发") @ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发")
private Integer themeType; private Integer themeType;
@ApiModelProperty(value = "文本内容(json),type:附件类型(8:文本,88:产品 3:直播 6:短视频 300:课程,9:图片 10:多图),productType:基金类型(0 公募,1 私募,2 白名单,3 私有)") @ApiModelProperty(value = "文本内容(json),type:附件类型(108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论)),productType:基金类型(0 公募,1 私募,2 白名单,3 私有)")
private String content; private String content;
@ApiModelProperty(value = "讨论中的文本")
private String discussContent;
@ApiModelProperty(value = "作者id") @ApiModelProperty(value = "作者id")
private String authorId; private String authorId;
...@@ -57,8 +54,8 @@ public class ThemeEntity implements Serializable { ...@@ -57,8 +54,8 @@ public class ThemeEntity implements Serializable {
@ApiModelProperty(value = "所属的话题") @ApiModelProperty(value = "所属的话题")
private String topicId; private String topicId;
@ApiModelProperty(value = "是否通过 0:初始值 1:已通过(管理后台使用)") @ApiModelProperty(value = "审核状态 0:未审核 1:审核通过(管理后台使用)")
private Integer isPass; private Integer reviewStatus;
@ApiModelProperty(value = "举报状态 0:未被举报 1:被举报 2:已处理") @ApiModelProperty(value = "举报状态 0:未被举报 1:被举报 2:已处理")
private Integer reportStatus; private Integer reportStatus;
...@@ -111,14 +108,6 @@ public class ThemeEntity implements Serializable { ...@@ -111,14 +108,6 @@ public class ThemeEntity implements Serializable {
this.content = content; this.content = content;
} }
public String getDiscussContent() {
return discussContent;
}
public void setDiscussContent(String discussContent) {
this.discussContent = discussContent;
}
public String getAuthorId() { public String getAuthorId() {
return authorId; return authorId;
} }
...@@ -143,12 +132,12 @@ public class ThemeEntity implements Serializable { ...@@ -143,12 +132,12 @@ public class ThemeEntity implements Serializable {
this.topicId = topicId; this.topicId = topicId;
} }
public Integer getIsPass() { public Integer getReviewStatus() {
return isPass; return reviewStatus;
} }
public void setIsPass(Integer isPass) { public void setReviewStatus(Integer reviewStatus) {
this.isPass = isPass; this.reviewStatus = reviewStatus;
} }
public Integer getReportStatus() { public Integer getReportStatus() {
...@@ -191,11 +180,10 @@ public class ThemeEntity implements Serializable { ...@@ -191,11 +180,10 @@ public class ThemeEntity implements Serializable {
", title=" + title + ", title=" + title +
", themeType=" + themeType + ", themeType=" + themeType +
", content=" + content + ", content=" + content +
", discussContent=" + discussContent +
", authorId=" + authorId + ", authorId=" + authorId +
", formerThemeId=" + formerThemeId + ", formerThemeId=" + formerThemeId +
", topicId=" + topicId + ", topicId=" + topicId +
", isPass=" + isPass + ", reviewStatus=" + reviewStatus +
", reportStatus=" + reportStatus + ", reportStatus=" + reportStatus +
", createTime=" + createTime + ", createTime=" + createTime +
", updateTime=" + updateTime + ", updateTime=" + updateTime +
......
...@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; ...@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-22 * @since 2021-07-29
*/ */
@TableName("topic") @TableName("topic")
@ApiModel(value="TopicEntity对象", description="话题") @ApiModel(value="TopicEntity对象", description="话题")
...@@ -45,7 +45,7 @@ public class TopicEntity implements Serializable { ...@@ -45,7 +45,7 @@ public class TopicEntity implements Serializable {
private Integer isConceal; private Integer isConceal;
@ApiModelProperty(value = "浏览量调整基数") @ApiModelProperty(value = "浏览量调整基数")
private Long viewCntAdjust; private Integer viewCntAdjust;
private LocalDateTime createTime; private LocalDateTime createTime;
...@@ -94,11 +94,11 @@ public class TopicEntity implements Serializable { ...@@ -94,11 +94,11 @@ public class TopicEntity implements Serializable {
this.isConceal = isConceal; this.isConceal = isConceal;
} }
public Long getViewCntAdjust() { public Integer getViewCntAdjust() {
return viewCntAdjust; return viewCntAdjust;
} }
public void setViewCntAdjust(Long viewCntAdjust) { public void setViewCntAdjust(Integer viewCntAdjust) {
this.viewCntAdjust = viewCntAdjust; this.viewCntAdjust = viewCntAdjust;
} }
......
...@@ -15,14 +15,14 @@ import lombok.NoArgsConstructor; ...@@ -15,14 +15,14 @@ import lombok.NoArgsConstructor;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-22 * @since 2021-07-28
*/ */
@TableName("visit_summary") @TableName("visit_log")
@ApiModel(value="VisitSummaryEntity对象", description="浏览记录")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class VisitSummaryEntity implements Serializable { @ApiModel(value="VisitLogEntity对象", description="浏览记录")
public class VisitLogEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -136,7 +136,7 @@ public class VisitSummaryEntity implements Serializable { ...@@ -136,7 +136,7 @@ public class VisitSummaryEntity implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "VisitSummaryEntity{" + return "VisitLogEntity{" +
"id=" + id + "id=" + id +
", ident=" + ident + ", ident=" + ident +
", visitorId=" + visitorId + ", visitorId=" + visitorId +
......
...@@ -3,13 +3,12 @@ package com.tanpu.community.dao.mapper.community; ...@@ -3,13 +3,12 @@ package com.tanpu.community.dao.mapper.community;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.tanpu.community.dao.entity.community.TimesCountEntity; import com.tanpu.community.dao.entity.community.TimesCountEntity;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity; import com.tanpu.community.dao.entity.community.VisitLogEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -19,21 +18,21 @@ import java.util.List; ...@@ -19,21 +18,21 @@ import java.util.List;
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-07-22 * @since 2021-07-28
*/ */
public interface VisitSummaryMapper extends BaseMapper<VisitSummaryEntity> { public interface VisitLogMapper extends BaseMapper<VisitLogEntity> {
@Select("select * from visit_summary where ident=#{ident}") @Select("select * from visit_log where ident=#{ident}")
VisitSummaryEntity selectByIdent(@Param("ident") String ident); VisitLogEntity selectByIdent(@Param("ident") String ident);
@Update("update visit_summary set duration=duration+#{duration} where ident=#{ident}") @Update("update visit_log set duration=duration+#{duration} where ident=#{ident}")
void updateDurByIdent(@Param("duration") Integer dur, @Param("ident") String ident); void updateDurByIdent(@Param("duration") Integer dur, @Param("ident") String ident);
@Select("select ref_id from visit_summary where visitor_id=#{visitorId} and ref_id in (#{refIds})") @Select("select ref_id from visit_log where visitor_id=#{visitorId} and ref_id in (#{refIds})")
List<String> selectRefIdByUserId(@Param("visitorId") String visitorId, @Param("refIds") String refIds); List<String> selectRefIdByUserId(@Param("visitorId") String visitorId, @Param("refIds") String refIds);
@Select("select ref_id as id, count(1) as times from visit_summary ${ew.customSqlSegment}") @Select("select ref_id as id, count(1) as times from visit_log ${ew.customSqlSegment}")
List<TimesCountEntity> selectCountByThemeIds(@Param(Constants.WRAPPER)LambdaQueryWrapper wrapper); List<TimesCountEntity> selectCountByThemeIds(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper);
@Select("select ref_id from visit_summary where visitor_id=#{visitorId} and date(create_time) between #{startDate} and #{endDate}") @Select("select ref_id from visit_log where visitor_id=#{visitorId} and date(create_time) between #{startDate} and #{endDate}")
List<String> selectRefIdByUserIdAndCreateBetween(@Param("visitorId") String visitorId, @Param("startDate") Date startDate, @Param("endDate") Date endDate); List<String> selectRefIdByUserIdAndCreateBetween(@Param("visitorId") String visitorId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
} }
...@@ -75,7 +75,7 @@ public class CommentManager { ...@@ -75,7 +75,7 @@ public class CommentManager {
//查询用户信息 //查询用户信息
String authorId = commentQo.getAuthorId(); String authorId = commentQo.getAuthorId();
UserInfoResp userInfo = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId), UserInfoResp userInfo = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId),
60 * 10, () ->this.getUserInfo(authorId) , UserInfoResp.class); 60, () ->this.getUserInfo(authorId) , UserInfoResp.class);
if (userInfo != null) { if (userInfo != null) {
commentQo.setUserImg(userInfo.getHeadImageUrl()); commentQo.setUserImg(userInfo.getHeadImageUrl());
commentQo.setNickName(userInfo.getNickName()); commentQo.setNickName(userInfo.getNickName());
...@@ -124,4 +124,10 @@ public class CommentManager { ...@@ -124,4 +124,10 @@ public class CommentManager {
CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId()); CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId());
reportLogService.insert(ReportTypeEnum.COMMENT, userId, req.getCommentId(), commentEntity.getAuthorId(), req.getReason()); reportLogService.insert(ReportTypeEnum.COMMENT, userId, req.getCommentId(), commentEntity.getAuthorId(), req.getReason());
} }
//删除评论
public void delete(String commentId, String userId) {
commentService.delete(commentId,userId);
}
} }
...@@ -2,7 +2,7 @@ package com.tanpu.community.manager; ...@@ -2,7 +2,7 @@ package com.tanpu.community.manager;
import com.tanpu.community.service.RankService; import com.tanpu.community.service.RankService;
import com.tanpu.community.service.RedisService; import com.tanpu.community.service.RedisService;
import com.tanpu.community.service.VisitSummaryService; import com.tanpu.community.service.VisitLogService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -15,7 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
public class ConJobManager { public class ConJobManager {
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitLogService visitLogService;
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
...@@ -29,7 +29,7 @@ public class ConJobManager { ...@@ -29,7 +29,7 @@ public class ConJobManager {
@Scheduled(cron = "*/10 * * * * ?") @Scheduled(cron = "*/10 * * * * ?")
public void topicVisitorStats() { public void topicVisitorStats() {
String topicId = "123"; String topicId = "123";
Integer detailVisitTimes = visitSummaryService.queryTopicDetailVisit(topicId); Integer detailVisitTimes = visitLogService.queryTopicDetailVisit(topicId);
redisService.set("topicVisitorStats", detailVisitTimes); redisService.set("topicVisitorStats", detailVisitTimes);
} }
......
...@@ -8,6 +8,7 @@ import com.tanpu.community.service.OSSFileService; ...@@ -8,6 +8,7 @@ import com.tanpu.community.service.OSSFileService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -49,4 +50,10 @@ public class FileManager { ...@@ -49,4 +50,10 @@ public class FileManager {
return ossFileService.queryByIds(fileIds).stream() return ossFileService.queryByIds(fileIds).stream()
.collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl)); .collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl));
} }
@Cacheable(value = "local", key = "#id")
public String getId(String id) {
System.out.println("cache " + id);
return "haha " + id;
}
} }
...@@ -126,10 +126,10 @@ public class HomePageManager { ...@@ -126,10 +126,10 @@ public class HomePageManager {
// 设置关注列表 // 设置关注列表
List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList()); List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList());
List<FollowRelEntity> followRelEntities = followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>() List<FollowRelEntity> followRelEntities = followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowerId, userId) .eq(FollowRelEntity::getIdolId, userId)
.in(FollowRelEntity::getFollowUserId, collect) .in(FollowRelEntity::getFansId, collect)
.eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init)); .eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init));
Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getFollowUserId, Function.identity())); Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getIdolId, Function.identity()));
userInfoOrgs.forEach(userInfoOrg -> { userInfoOrgs.forEach(userInfoOrg -> {
if (collect1.containsKey(userInfoOrg.getUserId())) if (collect1.containsKey(userInfoOrg.getUserId()))
userInfoOrg.setIsFollower(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注 userInfoOrg.setIsFollower(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注
...@@ -154,9 +154,9 @@ public class HomePageManager { ...@@ -154,9 +154,9 @@ public class HomePageManager {
} }
private void getFansNUmAndFollowNum(UserInfoResp userInfoNew) { private void getFansNUmAndFollowNum(UserInfoResp userInfoNew) {
Integer fansNumber = followRelMapper.selectCount(new LambdaQueryWrapper<FollowRelEntity>().eq(FollowRelEntity::getFollowUserId, userInfoNew.getUserId()) Integer fansNumber = followRelMapper.selectCount(new LambdaQueryWrapper<FollowRelEntity>().eq(FollowRelEntity::getIdolId, userInfoNew.getUserId())
.eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init)); .eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init));
Integer followNumber = followRelMapper.selectCount(new LambdaQueryWrapper<FollowRelEntity>().eq(FollowRelEntity::getFollowerId, userInfoNew.getUserId()) Integer followNumber = followRelMapper.selectCount(new LambdaQueryWrapper<FollowRelEntity>().eq(FollowRelEntity::getFansId, userInfoNew.getUserId())
.eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init)); .eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init));
userInfoNew.setFollowNumber(followNumber); userInfoNew.setFollowNumber(followNumber);
userInfoNew.setFansNumber(fansNumber); userInfoNew.setFansNumber(fansNumber);
......
...@@ -69,7 +69,7 @@ public class ThemeManager { ...@@ -69,7 +69,7 @@ public class ThemeManager {
private BatchFeignCallService batchFeignCallService; private BatchFeignCallService batchFeignCallService;
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitLogService visitLogService;
@Autowired @Autowired
private ReportLogService reportLogService; private ReportLogService reportLogService;
...@@ -104,14 +104,17 @@ public class ThemeManager { ...@@ -104,14 +104,17 @@ public class ThemeManager {
return !excludeIds.contains(tId); return !excludeIds.contains(tId);
}).limit(pageSize).collect(Collectors.toList()); }).limit(pageSize).collect(Collectors.toList());
List<ThemeQo> themes = ConvertUtil.themeEntitiesToDTOs(themeService.queryByThemeIds(filterEsIds));
resp.themes = convertEntityToQo(themeService.queryByThemeIds(filterEsIds), userId); resp.themes = convertEntityToQo(themeService.queryByThemeIds(filterEsIds), userId);
resp.themes.sort(new Comparator<ThemeQo>() {
@Override
public int compare(ThemeQo o1, ThemeQo o2) {
return o2.createTime.compareTo(o1.createTime);
}
});
// 截取关键词出现的那一部分段落 // 截取关键词出现的那一部分段落
for (ThemeQo theme : resp.themes) { for (ThemeQo theme : resp.themes) {
theme.briefContent4FullSearch = BizUtils.getThemeContent(keyword, theme); theme.briefContent4FullSearch = BizUtils.getThemeContent(keyword, theme);
} }
resp.excludeIds.addAll(filterEsIds); resp.excludeIds.addAll(filterEsIds);
return resp; return resp;
...@@ -124,35 +127,29 @@ public class ThemeManager { ...@@ -124,35 +127,29 @@ public class ThemeManager {
@Transactional @Transactional
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) { public CreateThemeResp publishTheme(CreateThemeReq req, String userId) {
//保存主题表 // 保存主题表
ThemeEntity themeEntity = new ThemeEntity(); ThemeEntity themeEntity = new ThemeEntity();
BeanUtils.copyProperties(req, themeEntity); BeanUtils.copyProperties(req, themeEntity);
themeEntity.setAuthorId(userId); themeEntity.setAuthorId(userId);
themeEntity.setContent(JsonUtil.toJson(req.getContent())); themeEntity.setContent(JsonUtil.toJson(req.getContent()));
//讨论类型,将讨论中的文本放入到discussContent中
if (ThemeTypeEnum.DISCUSSION.getCode().equals(themeEntity.getThemeType())) {
String content = req.getContent().get(0).getValue();
if (content.length()>256){
content= content.substring(0,255);
}
themeEntity.setDiscussContent(content);
}
//腾讯云敏感词校验
// 腾讯云敏感词校验,
// TODO 图片校验
checkContent(themeEntity.getContent()); checkContent(themeEntity.getContent());
if (StringUtils.isEmpty(req.getEditThemeId())) { if (StringUtils.isEmpty(req.getEditThemeId())) {
//新建 // 新建
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
} else { } else {
//修改 // 修改
themeService.update(themeEntity, req.getEditThemeId()); themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId()); themeEntity.setThemeId(req.getEditThemeId());
} }
//保存附件表 // 保存附件表
List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId()); List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId());
if (StringUtils.isNotEmpty(req.getEditThemeId())) { if (StringUtils.isNotEmpty(req.getEditThemeId())) {
//修改需要刪除 // 修改需要刪除
themeAttachmentService.deleteByThemeId(req.getEditThemeId()); themeAttachmentService.deleteByThemeId(req.getEditThemeId());
} }
themeAttachmentService.insertList(themeAttachments); themeAttachmentService.insertList(themeAttachments);
...@@ -180,13 +177,12 @@ public class ThemeManager { ...@@ -180,13 +177,12 @@ public class ThemeManager {
.build(); .build();
if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId().equals(req.getFormerThemeId())) { if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId().equals(req.getFormerThemeId())) {
//新建 // 新建
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
} else { } else {
//修改 // 修改
themeService.update(themeEntity, req.getEditThemeId()); themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId()); themeEntity.setThemeId(req.getEditThemeId());
} }
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build(); return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
} }
...@@ -206,7 +202,7 @@ public class ThemeManager { ...@@ -206,7 +202,7 @@ public class ThemeManager {
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
//推荐 //推荐
// 需要筛掉用户访问过详情的 & 最近出现在列表页过的. // 需要筛掉用户访问过详情的 & 最近出现在列表页过的.
List<String> visitedIds = visitSummaryService.queryUserRecentVisited(userId); List<String> visitedIds = visitLogService.queryUserRecentVisited(userId);
List<String> excludes = ListUtils.union(req.excludeIds, visitedIds); List<String> excludes = ListUtils.union(req.excludeIds, visitedIds);
List<String> recmdIds = recommendService.getRecommendThemes(pageStart, querySize, userId, excludes); List<String> recmdIds = recommendService.getRecommendThemes(pageStart, querySize, userId, excludes);
...@@ -217,7 +213,7 @@ public class ThemeManager { ...@@ -217,7 +213,7 @@ public class ThemeManager {
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
// TODO 临时埋点,接入新埋点后删除 // TODO 临时埋点,接入新埋点后删除
if (CollectionUtils.isEmpty(req.getExcludeIds())) { if (CollectionUtils.isEmpty(req.getExcludeIds())) {
visitSummaryService.addPageView(userId, userId, VisitTypeEnum.FOLLOW_THEME_VIEW); visitLogService.addPageView(userId, userId, VisitTypeEnum.FOLLOW_THEME_VIEW);
} }
// 根据关注列表查询,按时间倒序 // 根据关注列表查询,按时间倒序
List<String> fansList = followRelService.queryFansByFollowerId(userId); List<String> fansList = followRelService.queryFansByFollowerId(userId);
...@@ -252,31 +248,31 @@ public class ThemeManager { ...@@ -252,31 +248,31 @@ public class ThemeManager {
return resp; return resp;
} }
//主题Entity转QO,组装所有信息 // 主题Entity转QO,组装所有信息
private List<ThemeQo> convertEntityToQo(List<ThemeEntity> themeEntities, String userId) { private List<ThemeQo> convertEntityToQo(List<ThemeEntity> themeEntities, String userId) {
//Entity转Qo //Entity转Qo
List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities); List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities);
//批量查询附件detail // 批量查询附件detail
batchFeignCallService.getAttachDetailByBatch(themeQos); batchFeignCallService.getAttachDetailByBatch(themeQos);
//其他信息 //其他信息
for (ThemeQo themeQO : themeQos) { for (ThemeQo themeQO : themeQos) {
//通用信息 // 通用信息
buildThemeQoExtraInfo(themeQO); buildThemeQoExtraInfo(themeQO);
//和用户相关信息 // 和用户相关信息
buildThemeExtraInfoByUser(userId, themeQO); buildThemeExtraInfoByUser(userId, themeQO);
} }
return themeQos; return themeQos;
} }
//转发对象、点赞、收藏、转发数 // 转发对象、点赞、收藏、转发数
private void buildThemeQoExtraInfo(ThemeQo themeQo) { private void buildThemeQoExtraInfo(ThemeQo themeQo) {
String themeId = themeQo.getThemeId(); String themeId = themeQo.getThemeId();
//封装转发对象 // 封装转发对象
FormerThemeQo former = redisCache.getObject(StringUtils.joinWith("_", CACHE_FORMER_THEME_ID, themeId), 60, FormerThemeQo former = redisCache.getObject(StringUtils.joinWith("_", CACHE_FORMER_THEME_ID, themeId), 60,
() -> this.getFormerTheme(themeQo.getFormerThemeId()), FormerThemeQo.class); () -> this.getFormerTheme(themeQo.getFormerThemeId()), FormerThemeQo.class);
themeQo.setFormerTheme(former); themeQo.setFormerTheme(former);
//点赞,收藏,转发 // 点赞,收藏,转发
Integer likeCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME); Integer likeCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME);
Integer commentCount = commentService.getCommentCountByThemeId(themeId); Integer commentCount = commentService.getCommentCountByThemeId(themeId);
Integer forwardCount = themeService.getForwardCountById(themeId); Integer forwardCount = themeService.getForwardCountById(themeId);
...@@ -285,18 +281,19 @@ public class ThemeManager { ...@@ -285,18 +281,19 @@ public class ThemeManager {
themeQo.setForwardCount(forwardCount); themeQo.setForwardCount(forwardCount);
} }
//组装和当前用户相关信息 // 组装和当前用户相关信息
private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) { private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) {
//todo 批量查询 IN
String themeId = themeQo.getThemeId(); String themeId = themeQo.getThemeId();
//是否关注作者 // 是否关注作者
themeQo.setFollow(followRelService.checkFollow(themeQo.getAuthorId(), userId)); themeQo.setFollow(followRelService.checkFollow(themeQo.getAuthorId(), userId));
//是否点赞 // 是否点赞
CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME); CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME);
themeQo.setHasLiked(likeEntity != null); themeQo.setHasLiked(likeEntity != null);
//是否转发 // 是否转发
Integer forwardCountByUser = themeService.getForwardCountByUser(themeId, userId); Integer forwardCountByUser = themeService.getForwardCountByUser(themeId, userId);
themeQo.setHasForward(forwardCountByUser > 0); themeQo.setHasForward(forwardCountByUser > 0);
//是否收藏 // 是否收藏
CollectionEntity collectionEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.COLLECT_THEME); CollectionEntity collectionEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.COLLECT_THEME);
themeQo.setHasCollect(collectionEntity != null); themeQo.setHasCollect(collectionEntity != null);
} }
...@@ -329,19 +326,19 @@ public class ThemeManager { ...@@ -329,19 +326,19 @@ public class ThemeManager {
} }
//查询正文 // 查询正文
public ThemeQo getThemeDetail(String themeId, String userId) { public ThemeQo getThemeDetail(String themeId, String userId) {
//TODO 临时埋点,接入新埋点后删除 //TODO 临时埋点,接入新埋点后删除
visitSummaryService.addPageView(userId, themeId, VisitTypeEnum.THEME_PAGE_VIEW); visitLogService.addPageView(userId, themeId, VisitTypeEnum.THEME_PAGE_VIEW);
//查询详情 // 查询详情
ThemeQo themeQo = redisCache.getObject(StringUtils.joinWith("_", CACHE_THEME_ID, themeId), 60, ThemeQo themeQo = redisCache.getObject(StringUtils.joinWith("_", CACHE_THEME_ID, themeId), 60,
() -> this.getDetailCommon(themeId), ThemeQo.class); () -> this.getDetailCommon(themeId), ThemeQo.class);
//添加用户相关信息 // 添加用户相关信息
buildThemeExtraInfoByUser(userId, themeQo); buildThemeExtraInfoByUser(userId, themeQo);
return themeQo; return themeQo;
} }
//正文通用信息,与用户无关,可使用缓存 // 正文通用信息,与用户无关,可使用缓存
private ThemeQo getDetailCommon(String themeId) { private ThemeQo getDetailCommon(String themeId) {
ThemeEntity themeEntity = themeService.queryByThemeId(themeId); ThemeEntity themeEntity = themeService.queryByThemeId(themeId);
if (themeEntity == null) { if (themeEntity == null) {
...@@ -389,7 +386,7 @@ public class ThemeManager { ...@@ -389,7 +386,7 @@ public class ThemeManager {
//关注用户是否有更新 //关注用户是否有更新
public Integer getFollowUpdateCount(String userId) { public Integer getFollowUpdateCount(String userId) {
LocalDateTime lastViewTime = visitSummaryService.queryLatestViewFollow(userId); LocalDateTime lastViewTime = visitLogService.queryLatestViewFollow(userId);
List<String> fansList = followRelService.queryFansByFollowerId(userId); List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime); return themeService.queryCountFromLastTime(fansList, lastViewTime);
} }
...@@ -418,9 +415,9 @@ public class ThemeManager { ...@@ -418,9 +415,9 @@ public class ThemeManager {
} }
//逻辑删除主题 // 逻辑删除主题,校验用户
public void delete(String themeId) { public void delete(String themeId,String userId) {
themeService.deleteById(themeId); themeService.deleteById(themeId,userId);
} }
...@@ -477,23 +474,23 @@ public class ThemeManager { ...@@ -477,23 +474,23 @@ public class ThemeManager {
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) { private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>(); List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities; List<ThemeEntity> themeEntities;
//评论列表 // 评论列表
List<CommentEntity> commentEntities = commentService.queryCommentsByUserId(req.getUserId(), req.getLastId(), req.getPageSize()); List<CommentEntity> commentEntities = commentService.queryCommentsByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息 // 当前用户信息
UserInfoResp userInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, req.getUserId()), UserInfoResp userInfo = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, req.getUserId()),
60 * 10, () -> this.getUserInfo(req.getUserId()), UserInfoResp.class); 60, () -> this.getUserInfo(req.getUserId()), UserInfoResp.class);
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet()); Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) { if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList; return commentThemeList;
} }
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds)); themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId); List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件 // 组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos); batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表 // 主题列表
Map<String, ThemeQo> themeMap = themeQos.stream() Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o)); .collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象 // 主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) { for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId(); String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里 //评论内容包装到ThemeContentQo里
......
...@@ -7,7 +7,7 @@ import com.tanpu.community.api.beans.req.topic.TopicSearchReq; ...@@ -7,7 +7,7 @@ import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.api.enums.VisitTypeEnum; import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.service.RankService; import com.tanpu.community.service.RankService;
import com.tanpu.community.service.TopicService; import com.tanpu.community.service.TopicService;
import com.tanpu.community.service.VisitSummaryService; import com.tanpu.community.service.VisitLogService;
import com.tanpu.community.util.PageUtils; import com.tanpu.community.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,11 +18,9 @@ import java.util.List; ...@@ -18,11 +18,9 @@ import java.util.List;
@Service @Service
public class TopicManager { public class TopicManager {
@Autowired
private TopicService topicService;
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitLogService visitLogService;
@Autowired @Autowired
private RankService rankService; private RankService rankService;
...@@ -46,7 +44,7 @@ public class TopicManager { ...@@ -46,7 +44,7 @@ public class TopicManager {
// 话题详情页 // 话题详情页
public TopicRankQo getDetail(String topicId) { public TopicRankQo getDetail(String topicId) {
//TODO 临时埋点,接入新埋点后删除 //TODO 临时埋点,接入新埋点后删除
visitSummaryService.addPageView(userHolder.getUserId(), topicId, VisitTypeEnum.TOPIC_PAGE_VIEW); visitLogService.addPageView(userHolder.getUserId(), topicId, VisitTypeEnum.TOPIC_PAGE_VIEW);
return rankService.getTopicDetail(topicId); return rankService.getTopicDetail(topicId);
} }
......
...@@ -2,8 +2,8 @@ package com.tanpu.community.manager; ...@@ -2,8 +2,8 @@ package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg; import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity; import com.tanpu.community.dao.entity.community.VisitLogEntity;
import com.tanpu.community.service.VisitSummaryService; import com.tanpu.community.service.VisitLogService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -21,7 +21,7 @@ public class VisitSummaryManager { ...@@ -21,7 +21,7 @@ public class VisitSummaryManager {
private KafkaTemplate<String, String> kafkaTemplate; private KafkaTemplate<String, String> kafkaTemplate;
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitLogService visitLogService;
@KafkaListener(topics = kafakTopic) @KafkaListener(topics = kafakTopic)
...@@ -29,7 +29,7 @@ public class VisitSummaryManager { ...@@ -29,7 +29,7 @@ public class VisitSummaryManager {
log.info("receive kafka msg: {}", message); log.info("receive kafka msg: {}", message);
KafkaDurationUptMsg msg = JSON.parseObject(message, KafkaDurationUptMsg.class); KafkaDurationUptMsg msg = JSON.parseObject(message, KafkaDurationUptMsg.class);
// ident在每次进入新页面 & 回退 的时候都会随机生成一个,所以用ident做唯一key即可。 // ident在每次进入新页面 & 回退 的时候都会随机生成一个,所以用ident做唯一key即可。
VisitSummaryEntity vs = ConvertUtil.convertFromKafka(msg); VisitLogEntity vs = ConvertUtil.convertFromKafka(msg);
visitSummaryService.insertOrUpdateDur(vs); visitLogService.insertOrUpdateDur(vs);
} }
} }
...@@ -79,7 +79,8 @@ public class CollectionService { ...@@ -79,7 +79,8 @@ public class CollectionService {
return collectionMapper.selectList(new LambdaQueryWrapper<CollectionEntity>() return collectionMapper.selectList(new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getUserId, userId) .eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getCollectionType, type.getCode()) .eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())) .eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(CollectionEntity::getCollectionTime))
.stream().map(CollectionEntity::getTargetId).collect(Collectors.toList()); .stream().map(CollectionEntity::getTargetId).collect(Collectors.toList());
} }
......
...@@ -124,4 +124,18 @@ public class CommentService { ...@@ -124,4 +124,18 @@ public class CommentService {
commentMapper.updateById(commentEntity); commentMapper.updateById(commentEntity);
redisCache.evict(StringUtils.joinWith("_", CAHCE_COMMENT_ID, commentId)); redisCache.evict(StringUtils.joinWith("_", CAHCE_COMMENT_ID, commentId));
} }
//删除评论
@Transactional
public void delete(String commentId, String userId) {
CommentEntity commentEntity = this.queryByCommentId(commentId);
if (commentEntity==null || !commentEntity.getAuthorId().equals(userId)){
throw new BizException("删除评论与用户不匹配,commentId:"+commentId+",userId:"+userId);
}
commentEntity.setDeleteTag(DeleteTagEnum.DELETED.getCode());
commentMapper.updateById(commentEntity);
//删除主题的评论列表缓存
redisCache.evict(StringUtils.joinWith("_", CAHCE_COMMENT_ID, commentEntity.getThemeId()));
}
} }
...@@ -23,19 +23,19 @@ public class FollowRelService { ...@@ -23,19 +23,19 @@ public class FollowRelService {
public List<String> queryFansByFollowerId(String followerId) { public List<String> queryFansByFollowerId(String followerId) {
return followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>() return followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowerId, followerId) .eq(FollowRelEntity::getFansId, followerId)
.eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())) .eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()))
.stream().map(FollowRelEntity::getFollowUserId) .stream().map(FollowRelEntity::getIdolId)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator") // @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public List<String> queryFansByIdolId(String idolId) { public List<String> queryFansByIdolId(String idolId) {
LambdaQueryWrapper<FollowRelEntity> queryWrapper = new LambdaQueryWrapper<FollowRelEntity>() LambdaQueryWrapper<FollowRelEntity> queryWrapper = new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowUserId, idolId) .eq(FollowRelEntity::getIdolId, idolId)
.eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()); .eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return followRelMapper.selectList(queryWrapper) return followRelMapper.selectList(queryWrapper)
.stream().map(FollowRelEntity::getFollowerId).collect(Collectors.toList()); .stream().map(FollowRelEntity::getFansId).collect(Collectors.toList());
} }
@Transactional @Transactional
...@@ -43,8 +43,8 @@ public class FollowRelService { ...@@ -43,8 +43,8 @@ public class FollowRelService {
FollowRelEntity searchResult = queryRecord(idolId, followerId); FollowRelEntity searchResult = queryRecord(idolId, followerId);
if (searchResult==null){ if (searchResult==null){
FollowRelEntity entity = FollowRelEntity.builder() FollowRelEntity entity = FollowRelEntity.builder()
.followUserId(idolId) .idolId(idolId)
.followerId(followerId) .fansId(followerId)
.followTime(LocalDateTime.now()) .followTime(LocalDateTime.now())
.build(); .build();
...@@ -75,14 +75,14 @@ public class FollowRelService { ...@@ -75,14 +75,14 @@ public class FollowRelService {
public FollowRelEntity queryRecord(String idolId, String followerId){ public FollowRelEntity queryRecord(String idolId, String followerId){
return followRelMapper.selectOne(new LambdaQueryWrapper<FollowRelEntity>() return followRelMapper.selectOne(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowUserId,idolId) .eq(FollowRelEntity::getIdolId,idolId)
.eq(FollowRelEntity::getFollowerId,followerId)); .eq(FollowRelEntity::getFansId,followerId));
} }
public boolean checkFollow(String idolId,String followerId){ public boolean checkFollow(String idolId,String followerId){
return followRelMapper.selectCount(new LambdaQueryWrapper<FollowRelEntity>() return followRelMapper.selectCount(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowUserId,idolId) .eq(FollowRelEntity::getIdolId,idolId)
.eq(FollowRelEntity::getFollowerId,followerId) .eq(FollowRelEntity::getFansId,followerId)
.eq(FollowRelEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())) .eq(FollowRelEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode()))
>0; >0;
} }
......
...@@ -33,7 +33,7 @@ public class RankService { ...@@ -33,7 +33,7 @@ public class RankService {
@Autowired @Autowired
private TopicService topicService; private TopicService topicService;
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitLogService visitLogService;
@Autowired @Autowired
private FeignService feignService; private FeignService feignService;
...@@ -57,7 +57,7 @@ public class RankService { ...@@ -57,7 +57,7 @@ public class RankService {
public void rankThemes() { public void rankThemes() {
//7天内所有主题进行热度值排序 //7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(7); List<ThemeEntity> themeEntities = themeService.queryRecentdays(7);
if (CollectionUtils.isEmpty(themeEntities)){ if (CollectionUtils.isEmpty(themeEntities)) {
return; return;
} }
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities); List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
...@@ -67,19 +67,19 @@ public class RankService { ...@@ -67,19 +67,19 @@ public class RankService {
Map<String, Integer> bookCountMap = collectionService.getCountMapByType(themeIds, CollectionTypeEnum.COLLECT_THEME); Map<String, Integer> bookCountMap = collectionService.getCountMapByType(themeIds, CollectionTypeEnum.COLLECT_THEME);
Map<String, Integer> commentCountMap = commentService.getCountMapByThemeIds(themeIds); Map<String, Integer> commentCountMap = commentService.getCountMapByThemeIds(themeIds);
Map<String, Integer> forwardCountMap = themeService.getForwardCountMap(themeIds); Map<String, Integer> forwardCountMap = themeService.getForwardCountMap(themeIds);
Map<String, Integer> visitCountMap = visitSummaryService.getCountMapByTargetIds(themeIds, VisitTypeEnum.THEME_PAGE_VIEW); Map<String, Integer> visitCountMap = visitLogService.getCountMapByTargetIds(themeIds, VisitTypeEnum.THEME_PAGE_VIEW);
for (ThemeAnalysDO theme : themeAnalysDOS) { for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId(); String themeId = theme.getThemeId();
theme.setCommentCount(commentCountMap.getOrDefault(themeId,0)); theme.setCommentCount(commentCountMap.getOrDefault(themeId, 0));
theme.setLikeCount(likeCountMap.getOrDefault(themeId, 0)); theme.setLikeCount(likeCountMap.getOrDefault(themeId, 0));
theme.setForwardCount(forwardCountMap.getOrDefault(themeId,0)); theme.setForwardCount(forwardCountMap.getOrDefault(themeId, 0));
theme.setCollectCount(bookCountMap.getOrDefault(themeId,0)); theme.setCollectCount(bookCountMap.getOrDefault(themeId, 0));
theme.setViewCount(visitCountMap.getOrDefault(themeId,0)); theme.setViewCount(visitCountMap.getOrDefault(themeId, 0));
//查询用户质量 //查询用户质量
String authorId = theme.getAuthorId(); String authorId = theme.getAuthorId();
UserInfoResp authorInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, authorId), UserInfoResp authorInfo = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId),
60 * 10, () -> feignService.getUserInfoById(authorId), UserInfoResp.class); 60, () -> feignService.getUserInfoById(authorId), UserInfoResp.class);
if (authorInfo == null || authorInfo.getLevelGrade() == null) { if (authorInfo == null || authorInfo.getLevelGrade() == null) {
theme.setUserWeight(0.0); theme.setUserWeight(0.0);
} else { } else {
...@@ -109,17 +109,17 @@ public class RankService { ...@@ -109,17 +109,17 @@ public class RankService {
} }
List<TopicRankQo> topicRankQos = ConvertUtil.topicEntityToHotQos(topicEntities); List<TopicRankQo> topicRankQos = ConvertUtil.topicEntityToHotQos(topicEntities);
List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList()); List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList());
Map<String, Integer> countMapByTargetIds = visitSummaryService.getCountMapByTargetIds(topicIds, VisitTypeEnum.TOPIC_PAGE_VIEW); Map<String, Integer> countMapByTargetIds = visitLogService.getCountMapByTargetIds(topicIds, VisitTypeEnum.TOPIC_PAGE_VIEW);
for (TopicRankQo topic : topicRankQos) { for (TopicRankQo topic : topicRankQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId()); List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
if (CollectionUtils.isEmpty(themeIds)) { if (CollectionUtils.isEmpty(themeIds)) {
topic.setViewCount(countMapByTargetIds.getOrDefault(topic.getTopicId(),0)); topic.setViewCount(countMapByTargetIds.getOrDefault(topic.getTopicId(), 0));
topic.setDisscussCount(0); topic.setDisscussCount(0);
continue; continue;
} }
// 浏览量 // 浏览量
Integer topicPV = countMapByTargetIds.getOrDefault(topic.getTopicId(),0); Integer topicPV = countMapByTargetIds.getOrDefault(topic.getTopicId(), 0);
Integer themePV = visitSummaryService.queryThemeVisit(themeIds); Integer themePV = visitLogService.queryThemeVisit(themeIds);
topic.setViewCount(topicPV + themePV); topic.setViewCount(topicPV + themePV);
//讨论数=发布主题贴数+回复总数 //讨论数=发布主题贴数+回复总数
Integer commentCount = commentService.getTotalCountByThemeIds(themeIds); Integer commentCount = commentService.getTotalCountByThemeIds(themeIds);
......
...@@ -42,7 +42,7 @@ public class RecommendService { ...@@ -42,7 +42,7 @@ public class RecommendService {
private ThemeService themeService; private ThemeService themeService;
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitLogService visitLogService;
// 最新 // 最新
private List<ThemeAnalysDO> recentThemeList = new ArrayList<>(); private List<ThemeAnalysDO> recentThemeList = new ArrayList<>();
......
...@@ -263,11 +263,11 @@ public class ThemeService { ...@@ -263,11 +263,11 @@ public class ThemeService {
} }
@Transactional @Transactional
public void deleteById(String themeId) { public void deleteById(String themeId,String userId) {
ThemeEntity themeEntity = themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>() ThemeEntity themeEntity = themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getThemeId, themeId)); .eq(ThemeEntity::getThemeId, themeId));
if (themeEntity == null) { if (themeEntity == null || !themeEntity.getAuthorId().equals(userId)) {
throw new BizException("主题未找到,id:" + themeId); throw new BizException("主题与用户不匹配,id:" + themeId+",userId"+userId);
} }
themeEntity.setDeleteTag(DeleteTagEnum.DELETED.getCode()); themeEntity.setDeleteTag(DeleteTagEnum.DELETED.getCode());
themeMapper.updateById(themeEntity); themeMapper.updateById(themeEntity);
......
...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.VisitTypeEnum; import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.dao.entity.community.TimesCountEntity; import com.tanpu.community.dao.entity.community.TimesCountEntity;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity; import com.tanpu.community.dao.entity.community.VisitLogEntity;
import com.tanpu.community.dao.mapper.community.VisitSummaryMapper; import com.tanpu.community.dao.mapper.community.VisitLogMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
...@@ -23,16 +23,16 @@ import java.util.stream.Collectors; ...@@ -23,16 +23,16 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
public class VisitSummaryService { public class VisitLogService {
@Resource @Resource
private VisitSummaryMapper visitSummaryMapper; private VisitLogMapper visitLogMapper;
// 获取用户7天内访问过的 // 获取用户7天内访问过的
public List<String> queryUserRecentVisited(String userId) { public List<String> queryUserRecentVisited(String userId) {
Date endDate = new Date(); Date endDate = new Date();
Date startDate = DateUtils.addDays(endDate, -7); Date startDate = DateUtils.addDays(endDate, -7);
List<String> visited = visitSummaryMapper.selectRefIdByUserIdAndCreateBetween(userId, startDate, endDate); List<String> visited = visitLogMapper.selectRefIdByUserIdAndCreateBetween(userId, startDate, endDate);
return visited; return visited;
} }
...@@ -41,33 +41,33 @@ public class VisitSummaryService { ...@@ -41,33 +41,33 @@ public class VisitSummaryService {
if (refIds.isEmpty()) { if (refIds.isEmpty()) {
return refIds; return refIds;
} }
List<String> visited = visitSummaryMapper.selectList(new LambdaQueryWrapper<VisitSummaryEntity>() List<String> visited = visitLogMapper.selectList(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitSummaryEntity::getVisitorId, userId) .eq(VisitLogEntity::getVisitorId, userId)
.in(VisitSummaryEntity::getRefId, refIds)) .in(VisitLogEntity::getRefId, refIds))
.stream().map(VisitSummaryEntity::getRefId).distinct().collect(Collectors.toList()); .stream().map(VisitLogEntity::getRefId).distinct().collect(Collectors.toList());
return ListUtils.subtract(refIds, visited); return ListUtils.subtract(refIds, visited);
} }
public List<String> queryUserVisited(String userId) { public List<String> queryUserVisited(String userId) {
List<String> visited = visitSummaryMapper.selectList(new LambdaQueryWrapper<VisitSummaryEntity>() List<String> visited = visitLogMapper.selectList(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitSummaryEntity::getVisitorId, userId)) .eq(VisitLogEntity::getVisitorId, userId))
.stream().map(VisitSummaryEntity::getRefId).distinct().collect(Collectors.toList()); .stream().map(VisitLogEntity::getRefId).distinct().collect(Collectors.toList());
return visited; return visited;
} }
@Transactional @Transactional
public void insertOrUpdateDur(VisitSummaryEntity vs) { public void insertOrUpdateDur(VisitLogEntity vs) {
if (visitSummaryMapper.selectByIdent(vs.getIdent()) == null) { if (visitLogMapper.selectByIdent(vs.getIdent()) == null) {
visitSummaryMapper.insert(vs); visitLogMapper.insert(vs);
} else { } else {
visitSummaryMapper.updateDurByIdent(vs.getDuration(), vs.getIdent()); visitLogMapper.updateDurByIdent(vs.getDuration(), vs.getIdent());
} }
} }
@Transactional @Transactional
//TODO 临时埋点,接入新埋点后删除 //TODO 临时埋点,接入新埋点后删除
public void addPageView(String userId, String targetId, VisitTypeEnum type) { public void addPageView(String userId, String targetId, VisitTypeEnum type) {
visitSummaryMapper.insert(VisitSummaryEntity.builder() visitLogMapper.insert(VisitLogEntity.builder()
.visitorId(userId) .visitorId(userId)
.refId(targetId) .refId(targetId)
.refType(type.getCode()) .refType(type.getCode())
...@@ -77,16 +77,16 @@ public class VisitSummaryService { ...@@ -77,16 +77,16 @@ public class VisitSummaryService {
// 查询话题 详细页面 浏览量 // 查询话题 详细页面 浏览量
public Integer queryTopicDetailVisit(String topicId) { public Integer queryTopicDetailVisit(String topicId) {
return visitSummaryMapper.selectCount(new LambdaQueryWrapper<VisitSummaryEntity>() return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitSummaryEntity::getRefId, topicId) .eq(VisitLogEntity::getRefId, topicId)
.eq(VisitSummaryEntity::getRefType, VisitTypeEnum.TOPIC_PAGE_VIEW.getCode())); .eq(VisitLogEntity::getRefType, VisitTypeEnum.TOPIC_PAGE_VIEW.getCode()));
} }
// 查询主题 浏览量 // 查询主题 浏览量
public Integer queryThemeVisit(String theme) { public Integer queryThemeVisit(String theme) {
return visitSummaryMapper.selectCount(new LambdaQueryWrapper<VisitSummaryEntity>() return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitSummaryEntity::getRefId, theme) .eq(VisitLogEntity::getRefId, theme)
.eq(VisitSummaryEntity::getRefType, VisitTypeEnum.THEME_PAGE_VIEW.getCode())); .eq(VisitLogEntity::getRefType, VisitTypeEnum.THEME_PAGE_VIEW.getCode()));
} }
// 查询主题 浏览量 // 查询主题 浏览量
...@@ -94,16 +94,16 @@ public class VisitSummaryService { ...@@ -94,16 +94,16 @@ public class VisitSummaryService {
if (CollectionUtils.isEmpty(themes)){ if (CollectionUtils.isEmpty(themes)){
return 0; return 0;
} }
return visitSummaryMapper.selectCount(new LambdaQueryWrapper<VisitSummaryEntity>() return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
.in(VisitSummaryEntity::getRefId, themes) .in(VisitLogEntity::getRefId, themes)
.eq(VisitSummaryEntity::getRefType, VisitTypeEnum.THEME_PAGE_VIEW.getCode())); .eq(VisitLogEntity::getRefType, VisitTypeEnum.THEME_PAGE_VIEW.getCode()));
} }
public LocalDateTime queryLatestViewFollow(String userId) { public LocalDateTime queryLatestViewFollow(String userId) {
List<VisitSummaryEntity> visitSummaryEntities = visitSummaryMapper.selectList(new LambdaQueryWrapper<VisitSummaryEntity>() List<VisitLogEntity> visitSummaryEntities = visitLogMapper.selectList(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitSummaryEntity::getVisitorId, userId) .eq(VisitLogEntity::getVisitorId, userId)
.eq(VisitSummaryEntity::getRefType, VisitTypeEnum.FOLLOW_THEME_VIEW.getCode()) .eq(VisitLogEntity::getRefType, VisitTypeEnum.FOLLOW_THEME_VIEW.getCode())
.orderByDesc(VisitSummaryEntity::getCreateTime)); .orderByDesc(VisitLogEntity::getCreateTime));
if (CollectionUtils.isEmpty(visitSummaryEntities)) { if (CollectionUtils.isEmpty(visitSummaryEntities)) {
return null; return null;
} else { } else {
...@@ -116,12 +116,12 @@ public class VisitSummaryService { ...@@ -116,12 +116,12 @@ public class VisitSummaryService {
if (CollectionUtils.isEmpty(refIds)){ if (CollectionUtils.isEmpty(refIds)){
return new HashMap<>(); return new HashMap<>();
} }
LambdaQueryWrapper<VisitSummaryEntity> wrapper = (new LambdaQueryWrapper<VisitSummaryEntity>() LambdaQueryWrapper<VisitLogEntity> wrapper = (new LambdaQueryWrapper<VisitLogEntity>()
.in(VisitSummaryEntity::getRefId,refIds)) .in(VisitLogEntity::getRefId,refIds))
.eq(VisitSummaryEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED) .eq(VisitLogEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED)
.eq(VisitSummaryEntity::getRefType,type.getCode()) .eq(VisitLogEntity::getRefType,type.getCode())
.groupBy(VisitSummaryEntity::getRefId); .groupBy(VisitLogEntity::getRefId);
return visitSummaryMapper.selectCountByThemeIds(wrapper).stream() return visitLogMapper.selectCountByThemeIds(wrapper).stream()
.collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes)); .collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes));
} }
} }
...@@ -31,7 +31,7 @@ public class BizUtils { ...@@ -31,7 +31,7 @@ public class BizUtils {
return paragraph.getValue(); return paragraph.getValue();
} else { } else {
// 否则,保留关键词 向前20个字符 // 否则,保留关键词 向前20个字符
return paragraph.getValue().substring(idx - 20); return "..." + paragraph.getValue().substring(idx - 20);
} }
} }
} }
......
...@@ -120,8 +120,8 @@ public class ConvertUtil { ...@@ -120,8 +120,8 @@ public class ConvertUtil {
/** /**
* VISIT_SUMMARY * VISIT_SUMMARY
*/ */
public static VisitSummaryEntity convertFromKafka(KafkaDurationUptMsg msg) { public static VisitLogEntity convertFromKafka(KafkaDurationUptMsg msg) {
VisitSummaryEntity vs = new VisitSummaryEntity(); VisitLogEntity vs = new VisitLogEntity();
vs.setAuthorId(msg.pidUserId); vs.setAuthorId(msg.pidUserId);
vs.setDeleteTag(DeleteTagEnum.NOT_DELETED.ordinal()); vs.setDeleteTag(DeleteTagEnum.NOT_DELETED.ordinal());
vs.setDuration(1); vs.setDuration(1);
......
apollo.bootstrap.enabled: true apollo.bootstrap.enabled: false
#app.id: tanpu-community #app.id: tanpu-community
#apollo: #apollo:
...@@ -11,21 +11,19 @@ server: ...@@ -11,21 +11,19 @@ server:
port: 8080 port: 8080
servlet: servlet:
context-path: /community context-path: /community
spring.datasource: spring.datasource:
community: community:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: dev username: tamp_admin
password: qimeng123 password: '@imeng123'
maxActive: 2 maxActive: 2
minIdle: 2 minIdle: 2
initialSize: 2 initialSize: 2
user: user:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: dev password: '@imeng123'
password: qimeng123
maxActive: 2 maxActive: 2
minIdle: 2 minIdle: 2
initialSize: 2 initialSize: 2
...@@ -95,5 +93,5 @@ recommend: ...@@ -95,5 +93,5 @@ recommend:
new: 2 new: 2
python: 1 python: 1
python: python:
enable: false enable: true
url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511 url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ No newline at end of file
...@@ -8,7 +8,7 @@ apollo.bootstrap.enabled: true ...@@ -8,7 +8,7 @@ apollo.bootstrap.enabled: true
# namespaces: application.yml # namespaces: application.yml
server: server:
port: 8060 port: 8080
servlet: servlet:
context-path: /community context-path: /community
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<result column="theme_id" property="themeId" /> <result column="theme_id" property="themeId" />
<result column="parent_id" property="parentId" /> <result column="parent_id" property="parentId" />
<result column="reply_id" property="replyId" /> <result column="reply_id" property="replyId" />
<result column="is_pass" property="isPass" /> <result column="review_status" property="reviewStatus" />
<result column="report_status" property="reportStatus" /> <result column="report_status" property="reportStatus" />
<result column="create_time" property="createTime" /> <result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" /> <result column="update_time" property="updateTime" />
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.FollowRelEntity"> <resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.FollowRelEntity">
<id column="id" property="id" /> <id column="id" property="id" />
<result column="follow_user_id" property="followUserId" /> <result column="idol_id" property="idolId" />
<result column="follower_id" property="followerId" /> <result column="fans_id" property="fansId" />
<result column="follow_time" property="followTime" /> <result column="follow_time" property="followTime" />
<result column="unfollow_time" property="unfollowTime" /> <result column="unfollow_time" property="unfollowTime" />
<result column="create_time" property="createTime" /> <result column="create_time" property="createTime" />
......
...@@ -9,11 +9,10 @@ ...@@ -9,11 +9,10 @@
<result column="title" property="title" /> <result column="title" property="title" />
<result column="theme_type" property="themeType" /> <result column="theme_type" property="themeType" />
<result column="content" property="content" /> <result column="content" property="content" />
<result column="discuss_content" property="discussContent" />
<result column="author_id" property="authorId" /> <result column="author_id" property="authorId" />
<result column="former_theme_id" property="formerThemeId" /> <result column="former_theme_id" property="formerThemeId" />
<result column="topic_id" property="topicId" /> <result column="topic_id" property="topicId" />
<result column="is_pass" property="isPass" /> <result column="review_status" property="reviewStatus" />
<result column="report_status" property="reportStatus" /> <result column="report_status" property="reportStatus" />
<result column="create_time" property="createTime" /> <result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" /> <result column="update_time" property="updateTime" />
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tanpu.community.dao.mapper.community.VisitSummaryMapper"> <mapper namespace="com.tanpu.community.dao.mapper.community.VisitLogMapper">
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.VisitSummaryEntity"> <resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.VisitLogEntity">
<id column="id" property="id" /> <id column="id" property="id" />
<result column="ident" property="ident" /> <result column="ident" property="ident" />
<result column="visitor_id" property="visitorId" /> <result column="visitor_id" property="visitorId" />
......
...@@ -128,6 +128,18 @@ ...@@ -128,6 +128,18 @@
<version>2.4.5</version> <version>2.4.5</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.7.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
......
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