Commit defdd604 authored by 吴泽佳's avatar 吴泽佳
parents 8a1ce175 68096abe
......@@ -17,6 +17,10 @@
<groupId>com.tanpu</groupId>
<artifactId>common</artifactId>
</dependency>
<dependency>
<groupId>com.tanpu</groupId>
<artifactId>tanpu-biz-common</artifactId>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
......
package com.tanpu.community.api.beans.qo;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class ESThemeQo {
......@@ -15,7 +12,7 @@ public class ESThemeQo {
@ApiModelProperty(value = "标题")
public String title;
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发 4:评论")
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发")
public Integer themeType;
@ApiModelProperty(value = "文本内容")
......
......@@ -49,15 +49,13 @@ public class ThemeAnalysDO {
@ApiModelProperty(value = "用户质量")
private Double userWeight = 0.0;
public Double calcScore() {
//质量=帖子质量+用户质量
public Double getRank() {
// 质量=帖子质量+用户质量
double w = (double) (viewCount * 0.1 + forwardCount * 3 + commentCount * 2 + likeCount * 1 + collectCount * 3) + userWeight;
double i = 1;//初试权重
double t = Double.valueOf(minuteTillNow) / 60;
double g = 0.1;//时间系数
double rank = (w + i) / Math.pow(t + 1, g);
return rank;
return (w + i) / Math.pow(t + 1, g);
}
}
......@@ -36,18 +36,23 @@ public class TopicRankQo {
private Integer viewCntAdjust;
@ApiModelProperty(value = "话题下的帖子权重")
private Integer themeWeight;
private Double themeWeight;
private Integer hoursTillNow;
/**
* TODO 热度计算算法
* 热度计算算法
*
* @return
*/
public Integer getRank() {
public Double getRank() {
double g = 0.3;//时间系数
//顶置话题
if (isTop > 0) {
return Integer.MAX_VALUE;
return Double.MAX_VALUE;
}
return this.disscussCount * 3 + viewCount + themeWeight;
Double socre = ((disscussCount * 3 + viewCount) / Math.pow(hoursTillNow + 1, g)) + themeWeight;
return socre;
}
}
package com.tanpu.community.api.constants;
public class ClientConstant {
private static final String PRODUCT_SERVICE_NAME ="service-product";
private static final String PRODUCT_WEB_BASE_PATH="product";
private static final String PRODUCT_SERVICE_URL = "${tanpu.qm-product.svc}";
private static final String COURSE_SERVICE_NAME ="service-course";
private static final String COURSE_WEB_BASE_PATH="course";
private static final String COURSE_SERVICE_URL = "${tanpu.qm-course.svc}";
private static final String TANPUROOM_SERVICE_NAME ="service-tanpuroom";
private static final String TANPUROOM_WEB_BASE_PATH="tanpuroom";
private static final String TANPUROOM_SERVICE_URL = "${tanpu.qm-tanpuroom.svc}";
private static final String ZHIBO_SERVICE_NAME ="service-zhibo";
private static final String ZHIBO_WEB_BASE_PATH="zhibo";
private static final String ZHIBO_SERVICE_URL = "${tanpu.qm-zhibo.svc}";
}
......@@ -40,6 +40,9 @@ public class RedisKeyConstant {
// 转发主题本身
public static final String CACHE_FORMER_THEME_ID = "CACHE_FORMER_THEME_ID_";
// 关注的人,上次浏览的最新主题last id
public static final String CACHE_IDOL_THEME_LAST_ID = "CACHE_IDOL_THEME_LAST_ID_";
public static final String THEME_VIEW_COUNT_="THEME_VIEW_COUNT_";
public static final String THEME_LIKE_COUNT_="THEME_LIKE_COUNT_";
public static final String THEME_BOOK_COUNT_="THEME_BOOK_COUNT_";
......
package com.tanpu.community.api.enums;
public enum CollectionTypeEnum {
LIKE_THEME(1,"点赞主题"),
COLLECT_THEME(2,"收藏主题"),
LIKE_COMMENT(3,"点赞评论");
private Integer code;
private String type;
CollectionTypeEnum(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;
public enum CommentTypeEnum {
public enum OssDirEnum {
Others("others/", "其他"),
Theme_Pic("pic/theme/","主题下的图片"),
;
THEME(1,"对主题的评论");
public String dir;
public String type;
private Integer code;
private String type;
CommentTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
public Integer getCode() {
return code;
public String getDir() {
return dir;
}
public void setCode(Integer code) {
this.code = code;
public void setDir(String dir) {
this.dir = dir;
}
public String getType() {
......@@ -27,4 +23,9 @@ public enum CommentTypeEnum {
public void setType(String type) {
this.type = type;
}
OssDirEnum(String dir, String type) {
this.dir = dir;
this.type = type;
}
}
package com.tanpu.community.api.enums;
public enum QueryRecordTypeEnum {
QUERY_PUBLISH(1,"发布"),
QUERY_COMMENT(2,"评论"),
QUERY_LIKE(3,"点赞"),
QUERY_COLLECT(4,"收藏");
private Integer code;
private String type;
QueryRecordTypeEnum(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;
}
}
......@@ -4,11 +4,9 @@ import org.apache.commons.collections4.SetUtils;
import java.util.HashSet;
public enum ReportTypeEnum {
public enum RankLogTypeEnum {
THEME(1,"举报主题"),
COMMENT(2,"举报评论"),
USER(3,"举报用户");
TOPIC(1,"话题排序"),THEME(2,"主题排序");
public static final HashSet<String> imageTypeSet = SetUtils.hashSet("jpg", "jpeg", "png");
......@@ -17,7 +15,7 @@ public enum ReportTypeEnum {
private String type;
ReportTypeEnum(Integer code, String type) {
RankLogTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
......
package com.tanpu.community.api.enums;
/**
* 资源类型
*/
public enum RelTypeEnum {
/**
* 专栏
*/
COLUMN(1, "栏目", 4),
/**
* 课程包
*/
PACKAGE(2, "课程包", 2),
/**
* 直播
*/
LIVE(3, "直播", 1),
/**
* 视频
*/
VIDEO(4, "视频", 2),
/**
* 音频
*/
AUDIO(5, "音频", 2),
/**
* 短视频
*/
SHORT_VIDEO(6, "小视频", 6),
/**
* 课件
*/
COURSE_WARE(7, "直播课件"),
FUND(88, "产品", 88),
PINGLUN(99, "评论", 99),
TAMP_CAMP(101, "训练营", 101),
TEXT(108, "圈子-文本",108),
SINGLE_IMG(109, "圈子-单图",109),
MULTIPLE_IMAGE(110, "圈子-多图",110),
RES_FILE(121, "资源文件", 121),
IMAGE_FILE(122,"图片文件",122),
ARTICLE(202, "文章", 202),
DAYREPORT(204, "早报", 204),
/**
* 新版课程
*/
NEW_COURSE_WARE(300, "新版课程 - 课程包", 300),
/**
* 新版课程
*/
NEW_COURSE_CHAPTER(301, "新版课程 - 章节", 301),
/**
* 新版课程
*/
NEW_COURSE_SECTION_AUDIO(303, "新版课程 - 小节 - 音频", 303),
/**
* 新版课程
*/
NEW_COURSE_SECTION_VIDEO(304, "新版课程 - 小节 - 视频", 304),
/**
* 新版课程附件
*/
NEW_COURSE_COURSE_ATTACHMENT(305, "新版课程 - 课件", 305),
/**
* 运营活动 对应 tamp_jifen.activity_config
*/
ACTIVITY_CONFIG(306, "活动", 306),
INVITE_ACTIVITY(307, "邀请活动", 307),
GROUP_BUY(310, "拼团活动", 307),
SYSTEM(999, "系统赠送", 999),
;
/**
* 前端用的类型
*/
public String type;
/**
* 名称
*/
public String name;
/**
* 服务端使用的类型
*/
public Integer serverType;
RelTypeEnum(Integer type, String name) {
this.type = type.toString();
this.name = name;
}
RelTypeEnum(Integer type, String name, Integer serverType) {
this.type = type.toString();
this.name = name;
this.serverType = serverType;
}
/**
* 获取名称
*
* @param type
* @return
*/
public static String getTypeName(Integer type) {
if (type == null) {
return "";
}
for (RelTypeEnum relTypeEnum : RelTypeEnum.values()) {
if (Integer.valueOf(relTypeEnum.type)== type) {
return relTypeEnum.name;
}
}
return "";
}
}
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;
//1:产品 2:直播 3:短视频 4:课程
public enum ThemeAttachmentEnum {
PRODUCT(1,"产品"),
ZHIBO(2,"直播"),
SHORTVIDEO(3,"短视频"),
COURSE(4,"课程");
private Integer code;
private String type;
ThemeAttachmentEnum(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;
public enum TopicStatusEnum {
HOTTEST(1,"最热"),
NEWEST(2,"最新");;
private Integer code;
private String type;
TopicStatusEnum(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 com.tanpu.common.api.CommonResp;
import javax.validation.constraints.NotNull;
/**
* @program: wealthgrow-new
* @description: 用户权限等级
* @author: zejia zj wu
* @create: 2021-07-22 10:59
**/
public enum UserLevelEnum {
USER_TOURIST(0, "游客", "游客"),
USER_REGISTERED(1, "注册会员", "注册会员"),
/**
* 如果当前登录用户是投资人且要求权限大于投资人 返回 actionCode T1
* 弹框提示
* 该功能只对{levelGrade}开放哦
* 如需更改认证信息,可前往“我的”进行重新认证
* 点击「知道了」关闭弹框
*/
USER_INVESTOR(10, "投资人", "普通会员", "D2"),
/**
* tamp理顾问卷 D2
*/
USER_FINANCIAL_PRACTITIONER(20, "探普理顾", "投资顾问", "D2"),
/**
* tamp专家理顾问卷 D3
*/
USER_FINANCIAL_ADVISOR(30, "探普专家理顾", "专家投顾", "D3"),
/**
* 发生基金交易 (系统自动判断) T0 (提示文案: 该功能只对完成交易的探普理财师开放)
*/
USER_SENIOR_FINANCIAL_ADVISER(40, "交易理财师", "专家投顾", "T0"),
/**
* 探普签约理财师
*/
USER_CHIEF_FINANCIAL_ADVISER(50, "首席投顾", "首席投顾", "T0"),
/**
* 白名单用户
*/
USER_WHITE_LIST(999, "白名单用户", "特定用户", "T0"),
;
private int code;
private String name;
private String label;
private String actionCode;
UserLevelEnum(int code, String name, String label) {
this.code = code;
this.name = name;
this.label = label;
}
UserLevelEnum(int code, String name, String label, String functionCode) {
this.code = code;
this.name = name;
this.label = label;
this.actionCode = functionCode;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
public String getLabel() {
return label;
}
public String getActionCode() {
return actionCode;
}
}
package com.tanpu.community.api.enums;
public enum UserTypeEnum {
USER_GENERAL(1,"普通个人"),
USER_ORG(2,"机构账号"),
USER_ORG_PERSONNEL(3,"机构人员");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
UserTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
package com.tanpu.community.api.enums;
public enum VisitTypeEnum {
TOPIC_PAGE_VIEW(1,"进入话题页"),
THEME_PAGE_VIEW(2,"进入主题正文"),
FOLLOW_THEME_VIEW(3,"查看关注主题");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
VisitTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
......@@ -18,6 +18,11 @@
<artifactId>community-api</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.tanpu</groupId>-->
<!-- <artifactId>tanpu-biz-common</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
......
......@@ -2,9 +2,12 @@ package com.tanpu.community.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.AuthLogin;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.enums.OssDirEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.manager.FileManager;
import lombok.extern.slf4j.Slf4j;
......@@ -13,6 +16,7 @@ import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
......@@ -23,17 +27,24 @@ public class FileController {
@Autowired
private FileManager fileManager;
@Autowired
private RedisCache redisCache;
@Autowired
private CaffeineCacheManager localCache;
@Resource
private UserHolder userHolder;
@PostMapping("/uploadFile")
@ResponseBody
@AuthLogin
public CommonResp<FileUploadResp> uploadToRemote(@RequestParam(value = "file") MultipartFile file) {
return CommonResp.success(fileManager.uploadFile(file));
String userId = userHolder.getUserId();
return CommonResp.success(fileManager.uploadFile(file, OssDirEnum.Others, userId));
}
@PostMapping("/uploadThemePic")
@ResponseBody
@AuthLogin
public CommonResp<FileUploadResp> uploadThemePic(@RequestParam(value = "file") MultipartFile file) {
String userId = userHolder.getUserId();
return CommonResp.success(fileManager.uploadFile(file, OssDirEnum.Theme_Pic, userId));
}
@GetMapping("/test")
......
......@@ -50,7 +50,7 @@ public class ThemeController {
@ApiOperation("主题正文")
@GetMapping(value = "/detail")
@ResponseBody
public CommonResp<ThemeQo> getThemeMainText(@RequestParam String themeId) {
public CommonResp<ThemeQo> getDetail(@RequestParam(value = "themeId") String themeId) {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.getThemeDetail(themeId, userId));
}
......
......@@ -23,7 +23,7 @@ public class CodeAutoGenerator {
String mysqlPassword = "@imeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community";
// String[] tables = new String[]{"theme"};
String[] tables = new String[]{"comment","follow_rel","theme","visit_log"};
String[] tables = new String[]{"visit_log"};
String basePackage = "com.tanpu.community";
String mapperPackage = "dao.mapper.community";
String entityPackage = "dao.entity.community";
......
package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 话题排序日志记录’
* </p>
*
* @author xudong
* @since 2021-07-30
*/
@TableName("rank_log")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value="RankLogEntity对象", description="话题排序日志记录’")
public class RankLogEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "1:话题 2:主题")
private Integer type;
@ApiModelProperty(value = "总排序数量")
private Integer totalCount;
@ApiModelProperty(value = "页码")
private Integer pageNumber;
@ApiModelProperty(value = "页面大小")
private Integer pageSize;
@ApiModelProperty(value = "排序内容")
private String content;
@ApiModelProperty(value = "花费间隔,单位毫秒")
private Long rankCost;
@ApiModelProperty(value = "排序时间")
private LocalDateTime rankTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Integer deleteTag;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public Integer getPageNumber() {
return pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Long getRankCost() {
return rankCost;
}
public void setRankCost(Long rankCost) {
this.rankCost = rankCost;
}
public LocalDateTime getRankTime() {
return rankTime;
}
public void setRankTime(LocalDateTime rankTime) {
this.rankTime = rankTime;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
public Integer getDeleteTag() {
return deleteTag;
}
public void setDeleteTag(Integer deleteTag) {
this.deleteTag = deleteTag;
}
@Override
public String toString() {
return "RankLogEntity{" +
"id=" + id +
", type=" + type +
", totalCount=" + totalCount +
", pageNumber=" + pageNumber +
", pageSize=" + pageSize +
", content=" + content +
", rankCost=" + rankCost +
", rankTime=" + rankTime +
", createTime=" + createTime +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
"}";
}
}
......@@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
* </p>
*
* @author xudong
* @since 2021-07-28
* @since 2021-08-02
*/
@TableName("visit_log")
@Builder
......@@ -42,7 +42,7 @@ public class VisitLogEntity implements Serializable {
private String refId;
@ApiModelProperty(value = "关联目标类型 1:进入话题页 2:进入主题正文 3、用户查看首页-关注")
private Integer refType;
private String refType;
@ApiModelProperty(value = "浏览时间 单位秒")
private Integer duration;
......@@ -94,11 +94,11 @@ public class VisitLogEntity implements Serializable {
this.refId = refId;
}
public Integer getRefType() {
public String getRefType() {
return refType;
}
public void setRefType(Integer refType) {
public void setRefType(String refType) {
this.refType = refType;
}
......
package com.tanpu.community.dao.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* <p>
*
* </p>
*
* @author xudong
* @since 2021-06-16
*/
@TableName("user_rist_rz")
@ApiModel(value="UserRistRzEntity对象", description="")
public class UserRistRzEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "唯一主键")
private String id;
@ApiModelProperty(value = "用户手机号认证")
private String urrRzPhone;
@ApiModelProperty(value = "用户手机号认证时间")
private LocalDateTime urrRzPhoneDate;
@ApiModelProperty(value = "认证用户姓名")
private String urrRzName;
@ApiModelProperty(value = "身份信息认证-证件类型")
private String urrRzCertType;
@ApiModelProperty(value = "身份信息认证-证件号")
private String urrRzCertNo;
@ApiModelProperty(value = "身份信息认证时间")
private LocalDateTime urrRzCertDate;
@ApiModelProperty(value = "合格投资者认证关联用户记录")
private String investorCertifiedId;
@ApiModelProperty(value = "合格投资者认证状态")
private Integer investorCertifiedStatus;
@ApiModelProperty(value = "合格投资者认证时间")
private LocalDateTime investorCertifiedTime;
@ApiModelProperty(value = "风险测评认证关联用户记录")
private String investorRiskrzId;
@ApiModelProperty(value = "风险测评认证状态")
private Integer investorRiskrzStatus;
@ApiModelProperty(value = "风险测评认证时间")
private LocalDateTime investorRiskrzTime;
@ApiModelProperty(value = "测评到期时间")
private LocalDateTime expireTime;
@ApiModelProperty(value = "机构ID")
private String orgId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createtime;
@ApiModelProperty(value = "创建人")
private String createby;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updatetime;
@ApiModelProperty(value = "修改人")
private String updateby;
@ApiModelProperty(value = "删除标识")
private Integer deletetag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUrrRzPhone() {
return urrRzPhone;
}
public void setUrrRzPhone(String urrRzPhone) {
this.urrRzPhone = urrRzPhone;
}
public LocalDateTime getUrrRzPhoneDate() {
return urrRzPhoneDate;
}
public void setUrrRzPhoneDate(LocalDateTime urrRzPhoneDate) {
this.urrRzPhoneDate = urrRzPhoneDate;
}
public String getUrrRzName() {
return urrRzName;
}
public void setUrrRzName(String urrRzName) {
this.urrRzName = urrRzName;
}
public String getUrrRzCertType() {
return urrRzCertType;
}
public void setUrrRzCertType(String urrRzCertType) {
this.urrRzCertType = urrRzCertType;
}
public String getUrrRzCertNo() {
return urrRzCertNo;
}
public void setUrrRzCertNo(String urrRzCertNo) {
this.urrRzCertNo = urrRzCertNo;
}
public LocalDateTime getUrrRzCertDate() {
return urrRzCertDate;
}
public void setUrrRzCertDate(LocalDateTime urrRzCertDate) {
this.urrRzCertDate = urrRzCertDate;
}
public String getInvestorCertifiedId() {
return investorCertifiedId;
}
public void setInvestorCertifiedId(String investorCertifiedId) {
this.investorCertifiedId = investorCertifiedId;
}
public Integer getInvestorCertifiedStatus() {
return investorCertifiedStatus;
}
public void setInvestorCertifiedStatus(Integer investorCertifiedStatus) {
this.investorCertifiedStatus = investorCertifiedStatus;
}
public LocalDateTime getInvestorCertifiedTime() {
return investorCertifiedTime;
}
public void setInvestorCertifiedTime(LocalDateTime investorCertifiedTime) {
this.investorCertifiedTime = investorCertifiedTime;
}
public String getInvestorRiskrzId() {
return investorRiskrzId;
}
public void setInvestorRiskrzId(String investorRiskrzId) {
this.investorRiskrzId = investorRiskrzId;
}
public Integer getInvestorRiskrzStatus() {
return investorRiskrzStatus;
}
public void setInvestorRiskrzStatus(Integer investorRiskrzStatus) {
this.investorRiskrzStatus = investorRiskrzStatus;
}
public LocalDateTime getInvestorRiskrzTime() {
return investorRiskrzTime;
}
public void setInvestorRiskrzTime(LocalDateTime investorRiskrzTime) {
this.investorRiskrzTime = investorRiskrzTime;
}
public LocalDateTime getExpireTime() {
return expireTime;
}
public void setExpireTime(LocalDateTime expireTime) {
this.expireTime = expireTime;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public LocalDateTime getCreatetime() {
return createtime;
}
public void setCreatetime(LocalDateTime createtime) {
this.createtime = createtime;
}
public String getCreateby() {
return createby;
}
public void setCreateby(String createby) {
this.createby = createby;
}
public LocalDateTime getUpdatetime() {
return updatetime;
}
public void setUpdatetime(LocalDateTime updatetime) {
this.updatetime = updatetime;
}
public String getUpdateby() {
return updateby;
}
public void setUpdateby(String updateby) {
this.updateby = updateby;
}
public Integer getDeletetag() {
return deletetag;
}
public void setDeletetag(Integer deletetag) {
this.deletetag = deletetag;
}
@Override
public String toString() {
return "UserRistRzEntity{" +
"id=" + id +
", urrRzPhone=" + urrRzPhone +
", urrRzPhoneDate=" + urrRzPhoneDate +
", urrRzName=" + urrRzName +
", urrRzCertType=" + urrRzCertType +
", urrRzCertNo=" + urrRzCertNo +
", urrRzCertDate=" + urrRzCertDate +
", investorCertifiedId=" + investorCertifiedId +
", investorCertifiedStatus=" + investorCertifiedStatus +
", investorCertifiedTime=" + investorCertifiedTime +
", investorRiskrzId=" + investorRiskrzId +
", investorRiskrzStatus=" + investorRiskrzStatus +
", investorRiskrzTime=" + investorRiskrzTime +
", expireTime=" + expireTime +
", orgId=" + orgId +
", createtime=" + createtime +
", createby=" + createby +
", updatetime=" + updatetime +
", updateby=" + updateby +
", deletetag=" + deletetag +
"}";
}
}
package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.RankLogEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 话题排序日志记录’ Mapper 接口
* </p>
*
* @author xudong
* @since 2021-07-30
*/
public interface RankLogMapper extends BaseMapper<RankLogEntity> {
}
......@@ -20,7 +20,6 @@ import java.util.List;
*/
public interface ThemeMapper extends BaseMapper<ThemeEntity> {
@Select("select former_theme_id as id, count(1) as times from theme ${ew.customSqlSegment}")
@Select("select former_theme_id as id, count(1) as times from theme ${ew.customSqlSegment}")
List<TimesCountEntity> selectCountByThemeIds(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper);
}
......@@ -16,6 +16,6 @@ import java.util.List;
* @since 2021-07-22
*/
public interface TopicMapper extends BaseMapper<TopicEntity> {
@Select("select * from topic where id>#{startId} and delete_tag=0 order by id asc limit #{size}")
@Select("select * from topic where id>#{startId} and delete_tag=0 and is_conceal=0 order by id asc limit #{size}")
List<TopicEntity> selectGtIdPageable(@Param("startId") Long startId, @Param("size") Integer size);
}
......@@ -21,18 +21,15 @@ import java.util.List;
* @since 2021-07-28
*/
public interface VisitLogMapper extends BaseMapper<VisitLogEntity> {
@Select("select * from visit_log where ident=#{ident}")
VisitLogEntity selectByIdent(@Param("ident") String ident);
@Select("select * from visit_log where ident=#{ident} and ref_id=#{refId}")
VisitLogEntity selectByIdentAndRefId(@Param("ident") String ident, @Param("refId") String refId);
@Update("update visit_log set duration=duration+#{duration} where ident=#{ident}")
void updateDurByIdent(@Param("duration") Integer dur, @Param("ident") String ident);
@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);
@Select("select ref_id as id, count(1) as times from visit_log ${ew.customSqlSegment}")
List<TimesCountEntity> selectCountByThemeIds(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper);
@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> selectRefIdByVisitorIdAndCreateBetween(@Param("visitorId") String visitorId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
}
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xudong
* @since 2021-07-14
*/
public interface UserInfoMapper extends BaseMapper<UserInfoEntity> {
}
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.UserRistRzEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-16
*/
public interface UserRistRzMapper extends BaseMapper<UserRistRzEntity> {
}
package com.tanpu.community.manager;
import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import com.tanpu.biz.common.enums.community.CommentTypeEnum;
import com.tanpu.biz.common.enums.community.ReportTypeEnum;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.qo.CommentQo;
......@@ -7,10 +10,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.comment.LikeCommentReq;
import com.tanpu.community.api.beans.req.comment.ReportCommentReq;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.api.enums.ReportTypeEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
......@@ -21,6 +21,7 @@ import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Comparator;
......@@ -117,6 +118,7 @@ public class CommentManager {
}
//举报评论
@Transactional
public void report(ReportCommentReq req, String userId) {
//更改举报状态
commentService.updateReportStatus(req.getCommentId());
......
......@@ -3,14 +3,15 @@ package com.tanpu.community.manager;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.enums.OssDirEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.service.OSSFileService;
import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
......@@ -25,7 +26,7 @@ public class FileManager {
@Autowired
private OSSFileService ossFileService;
public FileUploadResp uploadFile(MultipartFile file) {
public FileUploadResp uploadFile(MultipartFile file, OssDirEnum dirEnum, String userId) {
if (file == null) {
throw new BizException(ErrorCodeConstant.FILE_UPLOAD_FAIL);
}
......@@ -42,7 +43,16 @@ public class FileManager {
if (data.length == 0 || StringUtils.isEmpty(originalName)) {
throw new BizException("上传文件为空");
}
FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName);
String dirPrefix = "";
if (dirEnum != null) {
dirPrefix = dirPrefix + dirEnum.dir;
}
if (StringUtils.isNotBlank(userId)) {
dirPrefix = dirPrefix + userId + "/";
}
FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName, dirPrefix);
return ConvertUtil.fileRecordEntity2Resp(fileRecordEntity);
}
......@@ -51,9 +61,4 @@ public class FileManager {
.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;
}
}
package com.tanpu.community.manager;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.biz.common.enums.user.UserLevelEnum;
import com.tanpu.biz.common.enums.user.UserTypeEnum;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.BizStatus;
import com.tanpu.common.exception.BizException;
......@@ -173,7 +175,7 @@ public class HomePageManager {
public Page<FollowQo> queryFollow(QueryFollowReq req, String userId) {
//TODO 数据库分页
List<String> userIds = QueryFollowTypeEnum.QUERY_FANS.getCode().equals(req.getQueryType()) ?
followRelService.queryFansByIdolId(req.getUserId()) : followRelService.queryFansByFollowerId(req.getUserId());
followRelService.queryFansByIdolId(req.getUserId()) : followRelService.queryIdolsByFollowerId(req.getUserId());
List<FollowQo> followQos = new ArrayList<>();
if (!CollectionUtils.isEmpty(userIds)) {
List<UserInfoResp> userInfoNews = feignClientForFatools.queryUserListNew(userIds);
......@@ -187,7 +189,7 @@ public class HomePageManager {
//判断返回列表中的用户是否被当前用户关注
public List<FollowQo> judgeFollowed(List<FollowQo> followQos, String followerId) {
Set<String> idolSet = new HashSet<>(followRelService.queryFansByFollowerId(followerId));
Set<String> idolSet = new HashSet<>(followRelService.queryIdolsByFollowerId(followerId));
return followQos.stream().map(o -> {
if (idolSet.contains(o.getUserId())) {
o.setFollowed(true);
......
......@@ -4,7 +4,6 @@ import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.service.RankService;
import com.tanpu.community.service.TopicService;
import com.tanpu.community.service.VisitLogService;
......@@ -15,6 +14,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import static com.tanpu.biz.common.enums.clue.PageEnum.COMM_VISIT_TOPIC_DETAIL;
@Service
public class TopicManager {
......@@ -42,9 +43,10 @@ public class TopicManager {
}
// 话题详情页
public TopicRankQo getDetail(String topicId) {
//TODO 临时埋点,接入新埋点后删除
visitLogService.addPageView(userHolder.getUserId(), topicId, VisitTypeEnum.TOPIC_PAGE_VIEW);
visitLogService.addPageView(userHolder.getUserId(), topicId, COMM_VISIT_TOPIC_DETAIL);
return rankService.getTopicDetail(topicId);
}
......
package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON;
import com.tanpu.biz.common.enums.clue.PageEnum;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.dao.entity.community.VisitLogEntity;
import com.tanpu.community.service.VisitLogService;
......@@ -11,6 +12,9 @@ import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Slf4j
@Service
public class VisitSummaryManager {
......@@ -26,8 +30,10 @@ public class VisitSummaryManager {
@KafkaListener(topics = kafakTopic)
public void updateVisitSummary(String message) {
// {"durMillsInc":10000,"ident":"AD7B8CE8-2DA4-4FB4-907F-C551B926BA5C","localDate":"2021-08-02","pageId":"p13503","refId":"88737580570230824","visitorId":"275321532031467520"}
log.info("receive kafka msg: {}", message);
KafkaDurationUptMsg msg = JSON.parseObject(message, KafkaDurationUptMsg.class);
// ident在每次进入新页面 & 回退 的时候都会随机生成一个,所以用ident做唯一key即可。
VisitLogEntity vs = ConvertUtil.convertFromKafka(msg);
visitLogService.insertOrUpdateDur(vs);
......
......@@ -2,6 +2,8 @@ package com.tanpu.community.service;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.user.UserLevelEnum;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.enums.fund.ProductTypeEnum;
import com.tanpu.common.util.JsonUtil;
......@@ -15,8 +17,6 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.UserLevelEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.feign.course.FeignClientForCourse;
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity;
import com.tanpu.community.dao.entity.community.TimesCountEntity;
......@@ -12,10 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -28,7 +25,11 @@ public class CollectionService {
@Transactional
public void saveOrUpdate(String themeId, String userId, CollectionTypeEnum type) {
// 判断记录是否存在,无论是否删除
CollectionEntity queryCollection = getTargetCollection(themeId, userId, type);
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getTargetId, themeId);
CollectionEntity queryCollection = collectionMapper.selectOne(queryWrapper);
if (queryCollection != null) {
queryCollection.setDeleteTag(DeleteTagEnum.NOT_DELETED.getCode());
queryCollection.setCollectionTime(LocalDateTime.now());
......@@ -47,7 +48,7 @@ public class CollectionService {
//根据用户、主题、类型查询未删除对象
public CollectionEntity getNotDeleteTargetCollection(String targetId, String userId, CollectionTypeEnum type) {
public CollectionEntity getTarget(String targetId, String userId, CollectionTypeEnum type) {
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
......@@ -56,15 +57,21 @@ public class CollectionService {
return collectionMapper.selectOne(queryWrapper);
}
//根据用户、主题、类型查询记录,包括已删除对象
public CollectionEntity getTargetCollection(String themeId, String userId, CollectionTypeEnum type) {
//根据用户、主题、类型查询未删除对象
public Set<String> getTargets(List<String> targetIds, String userId, CollectionTypeEnum type) {
if (CollectionUtils.isEmpty(targetIds)){
return new HashSet<>();
}
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getTargetId, themeId);
return collectionMapper.selectOne(queryWrapper);
.in(CollectionEntity::getTargetId, targetIds)
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return collectionMapper.selectList(queryWrapper).stream().map(CollectionEntity::getTargetId)
.collect(Collectors.toSet());
}
// 根据用户id和行为type获取target_id列表
public Set<String> getSetByUser(String userId, CollectionTypeEnum type) {
return collectionMapper.selectList(new LambdaQueryWrapper<CollectionEntity>()
......@@ -95,7 +102,7 @@ public class CollectionService {
// 统计多个对象(主题、评论)的数量(点赞、收藏)
public Map<String, Integer> getCountMapByType(List<String> targetIds, CollectionTypeEnum type) {
if (CollectionUtils.isEmpty(targetIds)){
if (CollectionUtils.isEmpty(targetIds)) {
return new HashMap<>();
}
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>().eq(CollectionEntity::getCollectionType, 1)
......@@ -116,7 +123,7 @@ public class CollectionService {
//逻辑删除,修改delete_tag
@Transactional
public void delete(String themeId, String userId, CollectionTypeEnum type) {
CollectionEntity queryCollection = getNotDeleteTargetCollection(themeId, userId, type);
CollectionEntity queryCollection = getTarget(themeId, userId, type);
if (queryCollection != null) {
queryCollection.setDeleteTag(DeleteTagEnum.DELETED.getCode());
queryCollection.setUncollectionTime(LocalDateTime.now());
......
......@@ -2,11 +2,11 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.biz.common.enums.community.CommentTypeEnum;
import com.tanpu.biz.common.enums.community.ReportStatusEnum;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ReportStatusEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.community.TimesCountEntity;
......@@ -40,6 +40,9 @@ public class CommentService {
@Transactional
public void insertComment(CommentEntity commentEntity) {
commentEntity.setCommentId(uuidGenHelper.getUuidStr());
if (commentEntity.getContent().length()>500){
throw new IllegalArgumentException("评论内容超过500字");
}
commentMapper.insert(commentEntity);
//失效缓存
evictThemeCache(commentEntity.getThemeId());
......
......@@ -21,7 +21,7 @@ public class FollowRelService {
@Resource
private FollowRelMapper followRelMapper;
public List<String> queryFansByFollowerId(String followerId) {
public List<String> queryIdolsByFollowerId(String followerId) {
return followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFansId, followerId)
.eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()))
......
......@@ -58,27 +58,19 @@ public class OSSFileService {
@Transactional
public FileRecordEntity uploadFile(byte[] data, String fileName) {
public FileRecordEntity uploadFile(byte[] data, String fileName, String dirPrefix) {
String fileSuffix = fileName.substring(fileName.lastIndexOf('.') + 1);
return uploadFile(data, fileName, fileSuffix, null, OssRelType.None);
return uploadFile(data, fileName, fileSuffix, dirPrefix);
}
@Transactional
public FileRecordEntity uploadFile(byte[] data, String fileName, String relId, OssRelType relType) {
String fileSuffix = fileName.substring(fileName.lastIndexOf('.') + 1);
return uploadFile(data, fileName, fileSuffix, relId, relType);
}
@Transactional
public FileRecordEntity uploadFile(byte[] data, String fileName, String fileSuffix,
String relId, OssRelType relType) {
// todo uniqueLong
public FileRecordEntity uploadFile(byte[] data, String fileName, String fileSuffix, String dirPrefix) {
String[] arr = StringUtils.split(fileName, ".");
String suffix = arr[arr.length - 1];
if (FileTypeEnum.imageTypeSet.contains(suffix)) {
//上传
String id = uuidGenHelper.getUuidStr();
String key = CommunityConstant.OSS_PREFIX_FOLDER+id + "." + suffix;
String key = CommunityConstant.OSS_PREFIX_FOLDER + dirPrefix + id + "." + suffix;
ossHelper.writeFile(bucketName, key, data, fileSuffix);
//落库
......@@ -93,7 +85,6 @@ public class OSSFileService {
HashMap<String, Integer> attr = getStringIntegerHashMap(data);
record.setExtInfo(JsonUtil.toJson(attr));
fileRecordMapper.insert(record);
return record;
......
package com.tanpu.community.service;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.ThemeAnalysDO;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.enums.RankLogTypeEnum;
import com.tanpu.community.dao.entity.community.RankLogEntity;
import com.tanpu.community.dao.mapper.community.RankLogMapper;
import com.tanpu.community.util.BizUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class RankLogService {
@Resource
private RankLogMapper rankLogMapper;
private Integer pageSize = 50;
//话题排序日志
public void logTopicRank(List<TopicRankQo> rankList, LocalDateTime logTime, Long cost) {
if (CollectionUtils.isEmpty(rankList)) {
return;
}
//分页插入
for (int i = 0; i * pageSize < rankList.size(); i++) {
int pageStart = i * pageSize;
List<TopicRankQo> sublist = BizUtils.subList(rankList, pageStart, pageSize);
RankLogEntity entity = RankLogEntity.builder().rankTime(logTime)
.type(RankLogTypeEnum.TOPIC.getCode())
.totalCount(rankList.size())
.rankCost(cost)
.content(JsonUtil.toJson(sublist))
.pageNumber(i + 1)
.pageSize(sublist.size())
.build();
rankLogMapper.insert(entity);
}
}
//主题排序日志
public void logThemeRank(List<ThemeAnalysDO> themeList, LocalDateTime logTime, Long cost) {
if (CollectionUtils.isEmpty(themeList)) {
return;
}
//分页插入
for (int i = 0; i * pageSize < themeList.size(); i++) {
int pageStart = i * pageSize;
List<ThemeAnalysDO> sublist = BizUtils.subList(themeList, pageStart, pageSize);
RankLogEntity entity = RankLogEntity.builder().rankTime(logTime)
.type(RankLogTypeEnum.THEME.getCode())
.totalCount(themeList.size())
.rankCost(cost)
.content(JsonUtil.toJson(sublist))
.pageNumber(i + 1)
.pageSize(sublist.size())
.build();
rankLogMapper.insert(entity);
}
}
}
package com.tanpu.community.service;
import com.tanpu.biz.common.enums.clue.PageEnum;
import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import com.tanpu.biz.common.enums.community.TopicStatusEnum;
import com.tanpu.community.api.beans.qo.ThemeAnalysDO;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.util.BizUtils;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
......@@ -43,7 +47,7 @@ public class RankService {
private RedisCache redisCache;
@Resource
private FeignClientForFatools feignClientForFatools;
private RankLogService rankLogService;
//最热
private List<ThemeAnalysDO> hotestThemes = new ArrayList<>();
......@@ -56,6 +60,8 @@ public class RankService {
* 计算主题热度排行
*/
public void rankThemes() {
LocalDateTime start = LocalDateTime.now();
//7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(7);
if (CollectionUtils.isEmpty(themeEntities)) {
......@@ -68,7 +74,7 @@ public class RankService {
Map<String, Integer> bookCountMap = collectionService.getCountMapByType(themeIds, CollectionTypeEnum.COLLECT_THEME);
Map<String, Integer> commentCountMap = commentService.getCountMapByThemeIds(themeIds);
Map<String, Integer> forwardCountMap = themeService.getForwardCountMap(themeIds);
Map<String, Integer> visitCountMap = visitLogService.getCountMapByTargetIds(themeIds, VisitTypeEnum.THEME_PAGE_VIEW);
Map<String, Integer> visitCountMap = visitLogService.getCountMapByTargetIds(themeIds, PageEnum.COMM_VISIT_THEME.getId());
for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId();
......@@ -90,11 +96,13 @@ public class RankService {
}
}
//打分
Map<ThemeAnalysDO, Double> map = themeAnalysDOS.stream().collect(Collectors.toMap(o -> o, ThemeAnalysDO::calcScore));
Map<ThemeAnalysDO, Double> map = themeAnalysDOS.stream().collect(Collectors.toMap(o -> o, ThemeAnalysDO::getRank));
//排序
hotestThemes = map.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.map(e -> e.getKey()).collect(Collectors.toList());
//落库
rankLogService.logThemeRank(hotestThemes, start, TimeUtils.calMillisTillNow(start));
}
......@@ -104,22 +112,26 @@ public class RankService {
* @return
*/
public void rankTopics() {
LocalDateTime start = LocalDateTime.now();
List<TopicEntity> topicEntities = topicService.queryAll();
if (CollectionUtils.isEmpty(topicEntities)) {
return;
}
List<TopicRankQo> topicRankQos = ConvertUtil.topicEntityToHotQos(topicEntities);
List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList());
Map<String, Integer> countMapByTargetIds = visitLogService.getCountMapByTargetIds(topicIds, VisitTypeEnum.TOPIC_PAGE_VIEW);
Map<String, Integer> topicViewMap = visitLogService.getCountMapByTargetIds(topicIds, PageEnum.COMM_VISIT_TOPIC_DETAIL.getId());
for (TopicRankQo topic : topicRankQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
if (CollectionUtils.isEmpty(themeIds)) {
topic.setViewCount(countMapByTargetIds.getOrDefault(topic.getTopicId(), 0));
topic.setViewCount(topicViewMap.getOrDefault(topic.getTopicId(), 0));
topic.setDisscussCount(0);
topic.setThemeWeight(0.0);
topic.setFormatViewCount(BizUtils.formatCountNumber(topic.getViewCount()));
topic.setFormatDisscussCount(BizUtils.formatCountNumber(topic.getDisscussCount()));
continue;
}
// 浏览量
Integer topicPV = countMapByTargetIds.getOrDefault(topic.getTopicId(), 0);
Integer topicPV = topicViewMap.getOrDefault(topic.getTopicId(), 0);
Integer themePV = visitLogService.queryThemeVisit(themeIds);
topic.setViewCount(topicPV + themePV + topic.getViewCntAdjust());
//讨论数=发布主题贴数+回复总数
......@@ -127,14 +139,14 @@ public class RankService {
topic.setDisscussCount(themeIds.size() + commentCount);
//帖子权重,求和
double themeSum = getHotestThemes().stream().filter(o -> topic.getTopicId().equals(o.getTopicId()))
.mapToDouble(ThemeAnalysDO::calcScore)
.mapToDouble(ThemeAnalysDO::getRank)
.sum();
topic.setThemeWeight((int) themeSum);
topic.setThemeWeight(themeSum);
//格式化浏览量、讨论量
topic.setFormatViewCount(BizUtils.formatCountNumber(topic.getViewCount()));
topic.setFormatDisscussCount(BizUtils.formatCountNumber(topic.getDisscussCount()));
}
Map<TopicRankQo, Integer> map = topicRankQos.stream().collect(Collectors.toMap(o -> o, TopicRankQo::getRank));
Map<TopicRankQo, Double> map = topicRankQos.stream().collect(Collectors.toMap(o -> o, TopicRankQo::getRank));
List<TopicRankQo> rankList = map.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.map(Map.Entry::getKey)
......@@ -142,6 +154,9 @@ public class RankService {
rankList.get(0).setType(TopicStatusEnum.HOTTEST.getCode());
this.rankTopicList = rankList;
this.rankTopicListTop4 = rankList.stream().limit(4).collect(Collectors.toList());
//落库
rankLogService.logTopicRank(rankList, start, TimeUtils.calMillisTillNow(start));
return;
}
......
......@@ -7,8 +7,6 @@ import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.util.BizUtils;
import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -41,8 +39,6 @@ public class RecommendService {
@Autowired
private ThemeService themeService;
@Autowired
private VisitLogService visitLogService;
// 最新
private List<ThemeAnalysDO> recentThemeList = new ArrayList<>();
......@@ -135,7 +131,7 @@ public class RecommendService {
String id;
while (hotTimes > 0 && hotThemeIds.size() > hotIdx) {
id = hotThemeIds.get(hotIdx);
if (!set.contains(id)){
if (!set.contains(id)) {
result.add(id);
set.add(id);
}
......@@ -145,7 +141,7 @@ public class RecommendService {
}
while (newTimes > 0 && newThemeIds.size() > newIdx) {
id = newThemeIds.get(newIdx);
if (!set.contains(id)){
if (!set.contains(id)) {
result.add(id);
set.add(id);
}
......@@ -155,7 +151,7 @@ public class RecommendService {
}
while (recTimes > 0 && recThemeIds.size() > recIdx) {
id = recThemeIds.get(recIdx);
if (!set.contains(id)){
if (!set.contains(id)) {
result.add(id);
set.add(id);
}
......@@ -180,13 +176,14 @@ public class RecommendService {
if (hotStart >= hotIds.size() && newestStart >= newestIds.size() && recmdStart >= recmdIds.size()) {
break;
}
retList.addAll(BizUtils.subList(hotIds, hotStart, hotStart + 6));
retList.addAll(BizUtils.subList(newestIds, newestStart, newestStart + 3));
retList.addAll(BizUtils.subList(recmdIds, recmdStart, recmdStart + 1));
round++;
}
return retList;
return retList;
}
......
package com.tanpu.community.service;
import com.tanpu.community.api.enums.ReportTypeEnum;
import com.tanpu.biz.common.enums.community.ReportTypeEnum;
import com.tanpu.community.dao.entity.community.ReportLogEntity;
import com.tanpu.community.dao.mapper.community.ReportLogMapper;
import lombok.extern.slf4j.Slf4j;
......@@ -16,7 +16,7 @@ public class ReportLogService {
@Resource
private ReportLogMapper reportLogMapper;
public void insert(ReportTypeEnum type,String userId, String themeId, String authorId, String reason){
public void insert(ReportTypeEnum type, String userId, String themeId, String authorId, String reason){
ReportLogEntity entity = ReportLogEntity.builder().userId(userId)
.reportType(type.getCode())
.targetId(themeId)
......
......@@ -2,11 +2,11 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.biz.common.enums.community.ReportStatusEnum;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.redis.RedisHelper;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ReportStatusEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TimesCountEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper;
......@@ -19,10 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -75,13 +72,6 @@ public class ThemeService {
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
}
public List<ThemeEntity> queryThemesByUserId(String userId) {
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getAuthorId, userId)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(ThemeEntity::getId));
}
//根据用户id查询主题list
public List<ThemeEntity> queryThemesByUserId(String userId, String lastId, Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
......@@ -218,7 +208,7 @@ public class ThemeService {
return themeMapper.selectList(queryWrapper);
}
//根据话题查询所有的主题Id
//根据话题查询所有的主题Id,包括已删除的主题
public List<String> queryThemeIdsByTopic(String topidId) {
if (StringUtils.isEmpty(topidId)) {
return Collections.emptyList();
......@@ -256,13 +246,25 @@ public class ThemeService {
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED));
}
public Integer getForwardCountByUser(String themeId, String userId) {
public boolean judgeForwardByUser(String themeId, String userId) {
return themeMapper.selectCount(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getFormerThemeId, themeId)
.eq(ThemeEntity::getAuthorId, userId)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED));
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED))>0;
}
public Set<String> getForwardUsers(List<String> themeIds) {
if (CollectionUtils.isEmpty(themeIds)){
return new HashSet<>();
}
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getFormerThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED))
.stream().map(ThemeEntity::getAuthorId).collect(Collectors.toSet());
}
@Transactional
public void deleteById(String themeId,String userId) {
ThemeEntity themeEntity = themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
......@@ -281,16 +283,14 @@ public class ThemeService {
* @param lastViewTime 更新时间节点
* @return
*/
public Integer queryCountFromLastTime(List<String> userIds, LocalDateTime lastViewTime) {
public Integer queryCountFromLastId(List<String> userIds, Long lastId) {
if (CollectionUtils.isEmpty(userIds)) {
return 0;
}
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getAuthorId, userIds)
.gt(ThemeEntity::getId, lastId)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
if (lastViewTime != null) {
queryWrapper.gt(ThemeEntity::getCreateTime, lastViewTime);
}
return themeMapper.selectCount(queryWrapper);
}
......
......@@ -3,7 +3,6 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.StatusEnum;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.mapper.community.TopicMapper;
......@@ -11,7 +10,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
......@@ -44,24 +42,8 @@ public class TopicService {
return retList;
}
public List<TopicEntity> queryByKeyword(String keyword) {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
.like(TopicEntity::getTopicTitle, keyword)
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(TopicEntity::getCreateTime));
}
@Transactional
public void addTopic(String topicTitle, String userId) {
TopicEntity entity = TopicEntity.builder()
.topicId(uuidGenHelper.getUuidStr())
.topicTitle(topicTitle)
.isTop(StatusEnum.FALSE.getCode())
.isConceal(StatusEnum.FALSE.getCode())
.build();
topicMapper.insert(entity);
}
public void updateTopicToTop(String topicId) {
......
package com.tanpu.community.service;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.dao.mapper.user.UserInfoMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class UserInfoService {
@Resource
private UserInfoMapper userInfoMapper;
public UserInfoEntity queryUserById(String userId) {
return userInfoMapper.selectById(userId);
}
public List<UserInfoEntity> queryUserByIds(List<String> ids) {
return userInfoMapper.selectBatchIds(ids);
}
}
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.user.UserRistRzEntity;
import com.tanpu.community.dao.mapper.user.UserRistRzMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Slf4j
@Service
public class UserService {
@Resource
private UserRistRzMapper userRistRzMapper;
// 查询是否合格投资者
public Boolean isQualifiedInvestor(String userId) {
UserRistRzEntity ristRz = userRistRzMapper.selectOne(new LambdaQueryWrapper<UserRistRzEntity>().eq(UserRistRzEntity::getCreateby, userId));
// todo 1代表合格
return (ristRz != null && ristRz.getInvestorCertifiedStatus() == 1);
}
}
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.biz.common.enums.clue.PageEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.VisitTypeEnum;
import com.tanpu.community.dao.entity.community.TimesCountEntity;
import com.tanpu.community.dao.entity.community.VisitLogEntity;
import com.tanpu.community.dao.mapper.community.VisitLogMapper;
......@@ -14,13 +14,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.tanpu.biz.common.enums.clue.PageEnum.COMM_VISIT_TOPIC_DETAIL;
@Slf4j
@Service
public class VisitLogService {
......@@ -32,7 +33,7 @@ public class VisitLogService {
public List<String> queryUserRecentVisited(String userId) {
Date endDate = new Date();
Date startDate = DateUtils.addDays(endDate, -7);
List<String> visited = visitLogMapper.selectRefIdByUserIdAndCreateBetween(userId, startDate, endDate);
List<String> visited = visitLogMapper.selectRefIdByVisitorIdAndCreateBetween(userId, startDate, endDate);
return visited;
}
......@@ -57,7 +58,7 @@ public class VisitLogService {
@Transactional
public void insertOrUpdateDur(VisitLogEntity vs) {
if (visitLogMapper.selectByIdent(vs.getIdent()) == null) {
if (visitLogMapper.selectByIdentAndRefId(vs.getIdent(), vs.getRefId()) == null) {
visitLogMapper.insert(vs);
} else {
visitLogMapper.updateDurByIdent(vs.getDuration(), vs.getIdent());
......@@ -66,11 +67,11 @@ public class VisitLogService {
@Transactional
//TODO 临时埋点,接入新埋点后删除
public void addPageView(String userId, String targetId, VisitTypeEnum type) {
public void addPageView(String userId, String targetId, PageEnum type) {
visitLogMapper.insert(VisitLogEntity.builder()
.visitorId(userId)
.refId(targetId)
.refType(type.getCode())
.refType(type.getId())
.duration(0)
.build());
}
......@@ -79,14 +80,14 @@ public class VisitLogService {
public Integer queryTopicDetailVisit(String topicId) {
return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitLogEntity::getRefId, topicId)
.eq(VisitLogEntity::getRefType, VisitTypeEnum.TOPIC_PAGE_VIEW.getCode()));
.eq(VisitLogEntity::getRefType, COMM_VISIT_TOPIC_DETAIL.getId()));
}
// 查询主题 浏览量
public Integer queryThemeVisit(String theme) {
return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitLogEntity::getRefId, theme)
.eq(VisitLogEntity::getRefType, VisitTypeEnum.THEME_PAGE_VIEW.getCode()));
.eq(VisitLogEntity::getRefType, PageEnum.COMM_VISIT_THEME.getId()));
}
// 查询主题 浏览量
......@@ -96,30 +97,30 @@ public class VisitLogService {
}
return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
.in(VisitLogEntity::getRefId, themes)
.eq(VisitLogEntity::getRefType, VisitTypeEnum.THEME_PAGE_VIEW.getCode()));
.eq(VisitLogEntity::getRefType, PageEnum.COMM_VISIT_THEME.getId()));
}
public LocalDateTime queryLatestViewFollow(String userId) {
List<VisitLogEntity> visitSummaryEntities = visitLogMapper.selectList(new LambdaQueryWrapper<VisitLogEntity>()
.eq(VisitLogEntity::getVisitorId, userId)
.eq(VisitLogEntity::getRefType, VisitTypeEnum.FOLLOW_THEME_VIEW.getCode())
.orderByDesc(VisitLogEntity::getCreateTime));
if (CollectionUtils.isEmpty(visitSummaryEntities)) {
return null;
} else {
return visitSummaryEntities.get(0).getCreateTime();
}
}
// public LocalDateTime queryLatestViewFollow(String userId) {
// List<VisitLogEntity> visitSummaryEntities = visitLogMapper.selectList(new LambdaQueryWrapper<VisitLogEntity>()
// .eq(VisitLogEntity::getVisitorId, userId)
// .eq(VisitLogEntity::getRefType, VisitTypeEnum.FOLLOW_THEME_VIEW.getCode())
// .orderByDesc(VisitLogEntity::getCreateTime));
// if (CollectionUtils.isEmpty(visitSummaryEntities)) {
// return null;
// } else {
// return visitSummaryEntities.get(0).getCreateTime();
// }
// }
//统计行为集合的浏览量
public Map<String, Integer> getCountMapByTargetIds(List<String> refIds, VisitTypeEnum type) {
public Map<String, Integer> getCountMapByTargetIds(List<String> refIds, String refType) {
if (CollectionUtils.isEmpty(refIds)){
return new HashMap<>();
}
LambdaQueryWrapper<VisitLogEntity> wrapper = (new LambdaQueryWrapper<VisitLogEntity>()
.in(VisitLogEntity::getRefId,refIds))
.eq(VisitLogEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED)
.eq(VisitLogEntity::getRefType,type.getCode())
.eq(VisitLogEntity::getRefType, refType)
.groupBy(VisitLogEntity::getRefId);
return visitLogMapper.selectCountByThemeIds(wrapper).stream()
.collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes));
......
......@@ -16,6 +16,7 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchPhraseQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
......@@ -132,33 +133,43 @@ public class ESHelper {
helper.client = highClient;
System.out.println("insert");
Map<String, Object> map = new HashMap<>();
map.put("name", "太阳44444444444444");
map.put("context", "这里有一个小太阳444444444");
// helper.insert("test_index", "", "2", map);
SearchSourceBuilder search = new SearchSourceBuilder();
BoolQueryBuilder boolQb = QueryBuilders.boolQuery();
MatchQueryBuilder matchQb = QueryBuilders.matchQuery("textContent", "小星星");
boolQb.must(matchQb);
String[] ks = new String[]{"左侧", "五粮液"};
for (String k : ks) {
MatchPhraseQueryBuilder contentQb = QueryBuilders.matchPhraseQuery("textContent", k);
MatchPhraseQueryBuilder titleQb = QueryBuilders.matchPhraseQuery("title", k);
boolQb.should(contentQb);
boolQb.should(titleQb);
}
// String[] includes = new String[]{"id"};
// String[] excludes = new String[]{};
search.query(boolQb).from(0).size(50);
SearchHit[] hits = helper.selectLike(search);
System.out.println(hits.length);
for (SearchHit hit : hits) {
System.out.println(hit.toString());
System.out.println(hit.getFields());
}
System.out.println("done");
try {
SearchRequest req = new SearchRequest("new-community");
req.source(search);
SearchResponse resp = helper.client.search(req, RequestOptions.DEFAULT);
SearchHit[] hits = resp.getHits().getHits();
System.out.println(hits.length);
for (SearchHit hit : hits) {
System.out.println(hit.toString());
System.out.println(hit.getFields());
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("done");
}
......
......@@ -42,14 +42,13 @@ public class ESService {
helper.insert(String.valueOf(qo.themeType), qo.themeId, JSON.toJSONString(qo));
}
public List<ESThemeQo> queryThemeIdByContentAndTitle(String keyword, int from, int size) {
public List<ESThemeQo> queryThemeIdByContentAndTitle(String[] keywords, int from, int size) {
SearchSourceBuilder search = new SearchSourceBuilder();
BoolQueryBuilder boolQb = QueryBuilders.boolQuery();
// 如果关键词带空格,则拆分
String[] ks = StringUtils.split(keyword, ' ');
for (String k : ks) {
for (String k : keywords) {
MatchPhraseQueryBuilder contentQb = QueryBuilders.matchPhraseQuery("textContent", k);
MatchPhraseQueryBuilder titleQb = QueryBuilders.matchPhraseQuery("title", k);
boolQb.should(contentQb);
......
package com.tanpu.community.util;
import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.enums.RelTypeEnum;
import org.apache.commons.codec.binary.Base64;
import java.util.ArrayList;
import java.util.List;
......@@ -17,19 +18,21 @@ public class BizUtils {
return list.subList(start, realEnd);
}
public static String getThemeContent(String keyword, ThemeQo theme) {
public static String getThemeContent(String[] keywords, ThemeQo theme) {
for (ThemeContentQo paragraph : theme.content) {
if (paragraph.getType().equals(RelTypeEnum.TEXT.type)) {
int idx = paragraph.getValue().indexOf(keyword);
if (idx == -1) {
continue;
} else if (idx < 30) {
// 如果关键词在段落偏头部的部分,则全部返回给前端,前端自由展示
return paragraph.getValue();
} else {
// 否则,保留关键词 向前20个字符
return "..." + paragraph.getValue().substring(idx - 20);
for (String keyword : keywords) {
int idx = paragraph.getValue().indexOf(keyword);
if (idx == -1) {
continue;
} else if (idx < 30) {
// 如果关键词在段落偏头部的部分,则全部返回给前端,前端自由展示
return paragraph.getValue();
} else {
// 否则,保留关键词 向前20个字符
return "..." + paragraph.getValue().substring(idx - 20);
}
}
}
}
......@@ -46,8 +49,14 @@ public class BizUtils {
}
public static void main(String[] args) {
System.out.println(formatCountNumber(110400));
System.out.println(formatCountNumber(111100));
System.out.println(formatCountNumber(1000));
String sk = "59V9ke9txaIFzWxHFKTb1eoOOpmKpJ";
String policy = "{\"expiration\":\"2021-07-30T12:00:00.000Z\",\"conditions\":[[\"content-length-range\",0,1024*1024*1024]]}";
System.out.println(policy);
String encodePolicy = new String(Base64.encodeBase64(policy.getBytes()));
String sign = com.aliyun.oss.common.auth.ServiceSignature.create().computeSignature(sk, encodePolicy);
System.out.println(encodePolicy);
System.out.println(sign);
}
}
package com.tanpu.community.util;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.community.TopicStatusEnum;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
......@@ -10,8 +12,6 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
......@@ -66,10 +66,7 @@ public class ConvertUtil {
// 抽取文本内容
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(entity.getContent(), new TypeReference<List<ThemeContentQo>>() {});
StringBuilder sb = new StringBuilder();
themeContentQos.stream().filter(q -> {
// todo enum
return q.getType().equals("108");
}).forEach(q -> {
themeContentQos.stream().filter(q -> RelTypeEnum.TEXT.type.equals(q.getType())).forEach(q -> {
sb.append(q.getValue());
});
qo.textContent = sb.toString();
......@@ -94,6 +91,7 @@ public class ConvertUtil {
if(TimeUtils.calMinuteTillNow(topicEntity.getCreateTime())<120){
topicRankQo.setType(TopicStatusEnum.NEWEST.getCode());
}
topicRankQo.setHoursTillNow((int) TimeUtils.calHoursTillNow(topicEntity.getCreateTime()));
return topicRankQo;
}
......@@ -116,7 +114,6 @@ public class ConvertUtil {
return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList());
}
/**
* VISIT_SUMMARY
*/
......@@ -124,11 +121,10 @@ public class ConvertUtil {
VisitLogEntity vs = new VisitLogEntity();
vs.setAuthorId(msg.pidUserId);
vs.setDeleteTag(DeleteTagEnum.NOT_DELETED.ordinal());
vs.setDuration(1);
vs.setDuration((int) msg.durMillsInc / 1000);
vs.setIdent(msg.ident);
vs.setRefId(msg.refId);
// todo
vs.setRefType(-1);
vs.setRefType(msg.pageId);
vs.setVisitorId(msg.visitorId);
return vs;
}
......
......@@ -79,7 +79,7 @@ public class TencentcloudUtils {
* @param text
* @return
*/
public static CommonResp textModeration(String text) {
public static boolean textModeration(String text) {
TextModerationRequest req = new TextModerationRequest();
req.setContent(Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8)));
TextModerationResponse res = null;
......@@ -87,16 +87,15 @@ public class TencentcloudUtils {
res = getTmsClient().TextModeration(req);
// suggestion Block 不通过
if (res.getSuggestion().equals("Block")) {
// TODO: 2021/7/20
return CommonResp.error();
// return CommonResp.error(CommonResp.CONTENT_ILLEGAL, getTextLabel(res.getLabel(), res.getKeywords()));
return false;
}
} catch (TencentCloudSDKException e) {
log.error("调用腾文本内容安全异常");
e.printStackTrace();
return CommonResp.failed("文本检查异常");
//调用失败时,不影响用户发布主题
return true;
}
return CommonResp.success();
return true;
}
/**
......
......@@ -37,12 +37,30 @@ public class TimeUtils {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
}
//计算迄今时间
//计算迄今分钟
public static long calMinuteTillNow(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
return between.toMinutes();
}
//计算迄今毫秒数
public static long calMillisTillNow(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
return between.toMillis();
}
//计算迄今天数
public static long calDaysTillNow(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
return between.toDays();
}
//计算迄今天数
public static long calHoursTillNow(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
return between.toHours();
}
//计算n天前的时间
public static LocalDateTime getDaysBefore(Integer number) {
......
......@@ -93,5 +93,5 @@ recommend:
new: 2
python: 1
python:
enable: true
enable: false
url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ No newline at end of file
<?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">
<mapper namespace="com.tanpu.community.dao.mapper.community.RankLogMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.RankLogEntity">
<id column="id" property="id" />
<result column="type" property="type" />
<result column="total_count" property="totalCount" />
<result column="page_number" property="pageNumber" />
<result column="page_size" property="pageSize" />
<result column="content" property="content" />
<result column="rank_cost" property="rankCost" />
<result column="rank_time" property="rankTime" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="delete_tag" property="deleteTag" />
</resultMap>
</mapper>
<?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">
<mapper namespace="com.tanpu.community.dao.mapper.user.UserInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.user.UserInfoEntity">
<id column="id" property="id" />
<result column="user_type" property="userType" />
<result column="ui_openid" property="uiOpenid" />
<result column="ui_unionId" property="uiUnionid" />
<result column="ui_telphone" property="uiTelphone" />
<result column="ui_pwd" property="uiPwd" />
<result column="ui_nickname" property="uiNickname" />
<result column="ui_headimg" property="uiHeadimg" />
<result column="ui_username" property="uiUsername" />
<result column="ui_sex" property="uiSex" />
<result column="ui_birthday" property="uiBirthday" />
<result column="ui_introduction" property="uiIntroduction" />
<result column="ui_type_mp" property="uiTypeMp" />
<result column="ui_headimg_mp" property="uiHeadimgMp" />
<result column="ui_username_mp" property="uiUsernameMp" />
<result column="ui_telphone_mp" property="uiTelphoneMp" />
<result column="ui_mobilephone_mp" property="uiMobilephoneMp" />
<result column="ui_company_mp" property="uiCompanyMp" />
<result column="ui_company_address_mp" property="uiCompanyAddressMp" />
<result column="ui_position_mp" property="uiPositionMp" />
<result column="ui_industry_mp" property="uiIndustryMp" />
<result column="ui_email_mp" property="uiEmailMp" />
<result column="ui_introduction_mp" property="uiIntroductionMp" />
<result column="ui_wechat_qrcode" property="uiWechatQrcode" />
<result column="ui_wechat_xcx_qrcode" property="uiWechatXcxQrcode" />
<result column="ui_type" property="uiType" />
<result column="ui_shenfen" property="uiShenfen" />
<result column="ui_rzstatus" property="uiRzstatus" />
<result column="org_id" property="orgId" />
<result column="team_id" property="teamId" />
<result column="join_time" property="joinTime" />
<result column="staff_no" property="staffNo" />
<result column="investor_certified_status" property="investorCertifiedStatus" />
<result column="investor_certified_time" property="investorCertifiedTime" />
<result column="to_partner" property="toPartner" />
<result column="ui_grade" property="uiGrade" />
<result column="content_review" property="contentReview" />
<result column="ui_honor" property="uiHonor" />
<result column="ui_hb_userid" property="uiHbUserid" />
<result column="staff_region" property="staffRegion" />
<result column="branch_name" property="branchName" />
<result column="sub_branch_name" property="subBranchName" />
<result column="branch_network_name" property="branchNetworkName" />
<result column="ui_grade_name" property="uiGradeName" />
<result column="ui_target_grade_name" property="uiTargetGradeName" />
<result column="ui_source" property="uiSource" />
<result column="createtime" property="createtime" />
<result column="createby" property="createby" />
<result column="updatetime" property="updatetime" />
<result column="updateby" property="updateby" />
<result column="deletetag" property="deletetag" />
<result column="front_roles" property="frontRoles" />
<result column="ui_check_status" property="uiCheckStatus" />
<result column="city" property="city" />
<result column="province" property="province" />
<result column="country" property="country" />
<result column="ui_inviter" property="uiInviter" />
<result column="ui_inviter_phone" property="uiInviterPhone" />
<result column="ui_age" property="uiAge" />
<result column="ui_region" property="uiRegion" />
<result column="ui_wecaht" property="uiWecaht" />
<result column="ui_inviter_time" property="uiInviterTime" />
<result column="unionid" property="unionid" />
<result column="level" property="level" />
<result column="level_grade" property="levelGrade" />
<result column="age" property="age" />
<result column="district" property="district" />
<result column="address" property="address" />
<result column="education" property="education" />
<result column="wechat" property="wechat" />
<result column="high_worth_customer_num" property="highWorthCustomerNum" />
<result column="customer_asset" property="customerAsset" />
<result column="financial_planner" property="financialPlanner" />
<result column="vip_end_time" property="vipEndTime" />
<result column="ui_register_time" property="uiRegisterTime" />
<result column="ui_auth" property="uiAuth" />
<result column="ui_channel" property="uiChannel" />
<result column="review_time" property="reviewTime" />
<result column="ui_apple_userid" property="uiAppleUserid" />
<result column="ifa_no" property="ifaNo" />
<result column="realname" property="realname" />
</resultMap>
</mapper>
<?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">
<mapper namespace="com.tanpu.community.dao.mapper.user.UserRistRzMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.user.UserRistRzEntity">
<id column="id" property="id" />
<result column="urr_rz_phone" property="urrRzPhone" />
<result column="urr_rz_phone_date" property="urrRzPhoneDate" />
<result column="urr_rz_name" property="urrRzName" />
<result column="urr_rz_cert_type" property="urrRzCertType" />
<result column="urr_rz_cert_no" property="urrRzCertNo" />
<result column="urr_rz_cert_date" property="urrRzCertDate" />
<result column="investor_certified_id" property="investorCertifiedId" />
<result column="investor_certified_status" property="investorCertifiedStatus" />
<result column="investor_certified_time" property="investorCertifiedTime" />
<result column="investor_riskrz_id" property="investorRiskrzId" />
<result column="investor_riskrz_status" property="investorRiskrzStatus" />
<result column="investor_riskrz_time" property="investorRiskrzTime" />
<result column="expire_time" property="expireTime" />
<result column="org_id" property="orgId" />
<result column="createtime" property="createtime" />
<result column="createby" property="createby" />
<result column="updatetime" property="updatetime" />
<result column="updateby" property="updateby" />
<result column="deletetag" property="deletetag" />
</resultMap>
</mapper>
This diff is collapsed.
......@@ -69,6 +69,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.tanpu</groupId>
<artifactId>tanpu-biz-common</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.tanpu</groupId>
<artifactId>common</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