Commit 212ba5db authored by 刘基明's avatar 刘基明

Merge branch 'v2.2.8' into 'master'

V2.2.8

See merge request !15
parents b8835e19 b8aaaf01
package com.tanpu.community.api;
import org.springframework.beans.factory.annotation.Value;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
/**
* monitor系统常量
......@@ -12,12 +14,6 @@ public final class CommunityConstant {
public static final String OSS_PREFIX_URL ="http://tamperfeodev.oss-cn-shanghai.aliyuncs.com/";
@Value("${aliyun.oss.bucketName}")
public String OSS_BUCKET_NAME;
@Value("${aliyun.oss.endpoint}")
public String OSS_END_POINT;
public static final String OSS_PREFIX_FOLDER ="community/";
//图片压缩比例:50%
......@@ -29,9 +25,17 @@ public final class CommunityConstant {
public static final Integer OSS_CHECK_FAIL_DEFAULT_HEIGHT = 1115;
public static final String THEME_PREFIX ="NEW_THEME_";
// 旧图片上传地址
public static final String OLD_FILE_UPLOAD_URL ="http://tp-fatools-svc/fatools/h5/rest/common/uploadSingleFile";
// 首页背景图配置
public static final Map<String,String> BACKGROUND_IMG_URL_MAP = ImmutableMap.of
// 西安家办
("309054222178349056","https://tamp-pro.oss-cn-shanghai.aliyuncs.com/corpCert/xi-an-homepage/green-yellow.png"
// 测试环境
,"295920641461243904","https://tamp-pro.oss-cn-shanghai.aliyuncs.com/corpCert/xi-an-homepage/green-yellow.png"
// 默认
,"default","https://tamp-pro.oss-cn-shanghai.aliyuncs.com/corpCert/xi-an-homepage/blue.png");
......
package com.tanpu.community.api.beans.qo;
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -28,6 +29,9 @@ public class AttachmentDetailVo {
private ShortVideoBaseInfoResp curriculum;
@ApiModelProperty("新版课程")
private CourseSimpleResp course;
@ApiModelProperty("线下活动")
private OfflineActivitySimpleResp activity;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 拼团配置
* @author: zejia zj wu
* @create: 2021-06-21 15:43
**/
@ApiModel(value = "拼团配置")
@Data
public class GroupBuyConfig implements Serializable {
/**
* 唯一主键
*/
@ApiModelProperty(value = "唯一主键")
private Integer id;
/**
* 拼团配置id
*/
@ApiModelProperty(value = "拼团配置id")
private String groupBuyConfigId;
/**
* 资源id
*/
@ApiModelProperty(value = "资源id")
private String resId;
/**
* 资源类型 300新版课程包
*/
@ApiModelProperty(value = "资源类型 300新版课程包")
private Integer resType;
/**
* 拼团价
*/
@ApiModelProperty(value = "拼团价")
private Integer groupBuyPrice;
/**
* 活动开始时间
*/
@ApiModelProperty(value = "活动开始时间")
private Long timeStart;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动结束时间")
private Long timeEnd;
/**
* 拼团时限 单位小时
*/
@ApiModelProperty(value = "拼团时限 单位小时")
private Long timeLimit;
/**
* 拼团规定人数
*/
@ApiModelProperty(value = "拼团规定人数")
private Integer peopleNumber;
/**
* 是否开启 在线拼团 0不开启 1开启
*/
@ApiModelProperty(value = "是否开启 在线拼团 0不开启 1开启")
private Integer isShow;
/**
* 拼团规则总述
*/
@ApiModelProperty(value = "拼团规则总述")
private String ruleMain;
/**
* 拼团规则详细
*/
@ApiModelProperty(value = "拼团规则详细")
private String ruleDetail;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Long createTime;
/**
* 修改时间
*/
@ApiModelProperty(value = "修改时间")
private Long updateTime;
/**
* 删除标识
*/
@ApiModelProperty(value = "删除标识")
private Integer deleteTag;
@ApiModelProperty(value = "拼团标识 1未参与 2拼团进行中 3拼团成功 4拼团失败")
private Integer groupBuyStatus;
private static final long serialVersionUID = 1L;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description 线下
* @Author wangyalei
* @Date 2021/9/5 下午9:37
**/
@ApiModel
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OfflineActivityDetailResp {
/**
* 活动Id
*/
@ApiModelProperty(value = "活动Id")
private String activityId;
/**
* 活动类型 1线下活动 2招募活动
*/
@ApiModelProperty(value = "活动类型 1线下活动 2招募活动")
private Integer activityType;
/**
* 活动标题
*/
@ApiModelProperty(value = "活动标题")
private String activityTitle;
/**
* 活动封面图
*/
@ApiModelProperty(value = "活动封面图")
private String activityCoverUrl;
/**
* 活动介绍长图
*/
@ApiModelProperty(value = "活动介绍长图")
private String activityDescriptionUrl;
/**
* 活动开始时间
*/
@ApiModelProperty(value = "活动开始时间")
private Long activityStartTime;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动结束时间")
private Long activityEndTime;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动状态 1未开始 2报名中 3报名结束")
private Integer activityState;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动状态文案 未开始 报名中 报名结束")
private String activityStateName;
/**
* 活动地点
*/
@ApiModelProperty(value = "活动地点")
private String activityLocation;
@ApiModelProperty(value = "主办方")
private OfflineActivitySponsorResp sponsor;
@ApiModelProperty("参与权限")
private ResExtResp resExtResp;
@ApiModelProperty("购买信息")
private Price price;
@ApiModel
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class OfflineActivitySponsorResp {
/**
* 主办方id
*/
@ApiModelProperty(value = "主办方id")
private String sponsorId;
/**
* 主办方名称
*/
@ApiModelProperty(value = "主办方名称")
private String sponsorName;
/**
* 主办方头像
*/
@ApiModelProperty(value = "主办方头像")
private String sponsorHeadImg;
/**
* 主办方简介
*/
@ApiModelProperty(value = "主办方简介")
private String sponsorDescription;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private String sponsorTelphone;
/**
* 微信号
*/
@ApiModelProperty(value = "微信号")
private String sponsorWechat;
/**
* 关联的机构id
*/
@ApiModelProperty(value = "关联的机构id")
private String corpId;
/**
* 举办活动的数量
*/
@ApiModelProperty(value = "举办活动的数量")
private Integer activityNum;
}
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Description 线下活动
* @Author wangyalei
* @Date 2021/9/5 下午9:24
**/
@ApiModel
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OfflineActivityListResp {
/**
* 活动Id
*/
@ApiModelProperty(value = "活动Id")
private String activityId;
/**
* 活动类型 1线下活动 2招募活动
*/
@ApiModelProperty(value = "活动类型 1线下活动 2招募活动")
private Integer activityType;
/**
* 活动标题
*/
@ApiModelProperty(value = "活动标题")
private String activityTitle;
/**
* 活动封面图
*/
@ApiModelProperty(value = "活动封面图")
private String activityCoverUrl;
/**
* 活动开始时间
*/
@ApiModelProperty(value = "活动开始时间")
private Date activityStartTime;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动结束时间")
private Date activityEndTime;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动状态 1未开始 2报名中 3报名结束")
private Integer activityState;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动状态文案 未开始 报名中 报名结束")
private Integer activityStateName;
/**
* 活动地点
*/
@ApiModelProperty(value = "活动地点")
private String activityLocation;
@ApiModelProperty(value = "主办方")
private OfflineActivityDetailResp.OfflineActivitySponsorResp sponsor;
@ApiModelProperty("参与权限")
private ResExtResp resExtResp;
@ApiModelProperty("购买信息")
private Price price;
@ApiModelProperty(value = "格式化开始-结束时间")
private String formatTime;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Description 线下活动
* @Author wangyalei
* @Date 2021/9/5 下午9:37
**/
@ApiModel
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OfflineActivitySimpleResp {
@ApiModelProperty(value = "活动Id")
private String activityId;
@ApiModelProperty(value = "活动类型 1线下活动 2招募活动")
private Integer activityType;
@ApiModelProperty(value = "活动标题")
private String activityTitle;
@ApiModelProperty(value = "活动封面图")
private String activityCoverUrl;
@ApiModelProperty(value = "活动开始时间")
private Date activityStartTime;
@ApiModelProperty(value = "活动结束时间")
private Date activityEndTime;
@ApiModelProperty(value = "报名开始时间")
private Date signUpStartTime;
@ApiModelProperty(value = "报名结束时间")
private Date signUpEndTime;
@ApiModelProperty(value = "起止时间")
private String formatTime;
@ApiModelProperty(value = "活动地点")
private String activityLocation;
@ApiModelProperty(value = "主办方名称")
private String sponsorName;
@ApiModelProperty(value = "报名状态 1未开始 2报名中 3报名结束")
private Integer signState;
@ApiModelProperty(value = "报名状态文案 未开始 报名中 报名结束")
private String signStateName;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @author: zhoupeng
* <p>
* =========================================
* =========================================
* ======== ========
* ======= ========== ======= =======
* ====== ===== == ==== ======
* ===== ===== == === =====
* ===== ===== == === =====
* ===== ===== == === =====
* ====== ========== == ======
* ======= =======
* =========================================
* =========================================
* <p>
* @email: zhoupeng_08@163.com
*/
@Data
@SuperBuilder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class Price {
@ApiModelProperty("资源id")
private String resId;
@ApiModelProperty("是不是白名单 0:不是 1:是白名单")
private Integer isWhite;
@ApiModelProperty("价格")
private String totalPrice;
@ApiModelProperty("积分")
private String totalScore;
@ApiModelProperty("付费模式 1:免费 2:积分 3:现金")
private Integer chargeMode;
@ApiModelProperty("划线价格")
private String discountPrice;
@ApiModelProperty("划线积分")
private String discountScore;
@ApiModelProperty("促销时间")
private Time3Type time3Type;
@ApiModelProperty("会员打折价")
private String memberDiscountPrice;
@ApiModelProperty("会员促销时间")
private Time3Type memberTime3Type;
@ApiModelProperty("报名信息 0:不需要 1:需要")
private Integer bmStatus;
@ApiModelProperty("报名信息 0:没有 1:已报名")
private Integer bmInfo;
@ApiModelProperty("审批状态 0:待审批 1:审批通过 2:审批失败")
private Integer spStatus;
@ApiModelProperty("action")
private String action;
@ApiModelProperty("报名信息")
private ResBmInfoResp resBmInfoResp;
/*@ApiModelProperty("会员身分")
private Integer memberLevel;
@ApiModelProperty("1:不上浮包含 2:上浮包含等级")
private Integer rose;*/
@ApiModelProperty("最终价格")
private String finalPrice;
@ApiModelProperty("最终积分")
private String finalScore;
@ApiModelProperty("最终身份")
private Integer finalLevel;
@ApiModelProperty("最终付费模式 1:免费 2:积分 3:现金")
private Integer finalChargeMode;
@ApiModelProperty("需不需要支付 2:不需要 1:需要")
private Integer isNeedBuy;
@ApiModelProperty("有没有支付 2:已购买 1:未购买")
private Integer isBuy;
@ApiModelProperty("是否正在参与拼团活动 0不参加 1参加")
private Integer isJoinGroupBuy = 0;
@ApiModelProperty("拼团活动配置信息")
private GroupBuyConfig groupBuyConfig;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.Date;
/**
* @author: zhoupeng
* <p>
* =========================================
* =========================================
* ======== ========
* ======= ========== ======= =======
* ====== ===== == ==== ======
* ===== ===== == === =====
* ===== ===== == === =====
* ===== ===== == === =====
* ====== ========== == ======
* ======= =======
* =========================================
* =========================================
* <p>
* @email: zhoupeng_08@163.com
*/
@Data
@ApiModel("报名信息")
public class ResBmInfoResp {
private String id;
private String resId;
private Integer resType;
private String operUser;
private String bmRemark;
private String wechat;
private String wechatQrCode;
private String title;
private String bmRemind;
private String bmNotice;
private String templateId;
private Date createTime;
private String createBy;
private Date updateTime;
private String updateBy;
private Integer deleteTag;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author: zhoupeng
* <p>
* =========================================
* =========================================
* ======== ========
* ======= ========== ======= =======
* ====== ===== == ==== ======
* ===== ===== == === =====
* ===== ===== == === =====
* ===== ===== == === =====
* ====== ========== == ======
* ======= =======
* =========================================
* =========================================
* <p>
* @email: zhoupeng_08@163.com
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ResExtResp {
private String id;
private String resId;
private Integer resType;
private Integer buy;
private Integer buyModel;
@ApiModelProperty("报名信息 0:不需要 1:需要")
private Integer bmStatus;
@ApiModelProperty("展示权限")
private Integer showAuth;
@ApiModelProperty("参与权限")
private Integer partakeAuth;
@ApiModelProperty("能不能参与 0:不能 1:可以")
private Integer partakeAuthStatus;
@ApiModelProperty("该去做什么 tamp理顾问卷 D2 tamp专家理顾问卷 D3 发生基金交易 (系统自动判断) T0 (提示文案: 该功能只对完成交易的探普理财师开放)")
private String partakeAuthSkip;
@ApiModelProperty("提示文案")
private String authMsg;
@ApiModelProperty("有没有做过合投 0:没有 1:有")
private Integer qfiiAuthStatus;
@ApiModelProperty("是否需要合格投资者认值 0:不需要 1:需要")
private Integer qfiiAuth;
@ApiModelProperty(value = "用户等级", example = "20")
private int levelGrade;
@ApiModelProperty(value = "用户等级对应的名称", example = "20")
private String levelLabel;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author: zhoupeng
* <p>
* =========================================
* =========================================
* ======== ========
* ======= ========== ======= =======
* ====== ===== == ==== ======
* ===== ===== == === =====
* ===== ===== == === =====
* ===== ===== == === =====
* ====== ========== == ======
* ======= =======
* =========================================
* =========================================
* <p>
* @email: zhoupeng_08@163.com
*/
@ApiModel("时间对象")
@Data
public class Time3Type {
@ApiModelProperty("开始时间")
private Long begin;
@ApiModelProperty("结束时间")
private Long end;
}
package com.tanpu.community.api.beans.vo.feign.fatools;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AdsPositionResp {
private String id;//唯一主键
private Integer apType;//类型
private String apImgurl;//图片地址
private String apLink;//链接地址
private String relId;//关联id
private Integer relType;//关联类型
}
......@@ -56,5 +56,4 @@ public class UserInfoNewChief {
@ApiModelProperty(value = "首席投顾数量")
private Long chiefCount;
}
\ No newline at end of file
......@@ -31,5 +31,11 @@ public class UserInfoOrg {
private String certPosition;
@ApiModelProperty("是否已关注 0未关注 1已关注")
private Integer isFollower = 0;
@ApiModelProperty("全新用户等级体系 详见 UserLevelEnum")
private Integer levelGrade;
@ApiModelProperty("当levelGrade=10有值 1投资萌新 2投资达人")
private Integer userInvestorType;
@ApiModelProperty("用户类型 1个人 2机构账号 3机构人员")
private Integer userType;
}
package com.tanpu.community.api.beans.vo.feign.fatools;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
......@@ -43,7 +41,10 @@ public class UserInfoResp {
private String recordNumber = "-";
@ApiModelProperty("团队成员")
private List<UserInfoOrg> userInfoOrgList;
@ApiModelProperty("主办活动")
private List<OfflineActivitySimpleResp> holdActivities;
@ApiModelProperty("团队招募")
private List<OfflineActivitySimpleResp> teamRecruitment;
//↓↓↓↓ 通用 ↓↓↓↓
@ApiModelProperty("用户id")
......@@ -89,9 +90,15 @@ public class UserInfoResp {
//↓↓↓↓↓首席投顾↓↓↓↓↓↓
@ApiModelProperty(value = "首席投顾")
private UserInfoNewChief userInfoNewChief;
@ApiModelProperty(value = "首席广告位")
private List<AdsPositionResp> adsPosition;
//↓↓↓↓↓机构用户信息↓↓↓↓↓↓
@ApiModelProperty(value = "机构用户信息")
private UserInfoNewOrg userInfoNewOrg;
//↓↓↓↓↓首部背景图↓↓↓↓↓↓
@ApiModelProperty(value = "主页背景图")
private String backgroundImgUrl;
}
\ No newline at end of file
......@@ -121,5 +121,12 @@ public class ThemeController {
return CommonResp.success();
}
@ApiOperation("文本查重初始化")
@GetMapping(value = "/initTextCheck")
@ResponseBody
public CommonResp<Void> initTextCheck() {
themeManager.initThemeTextCheck();
return CommonResp.success();
}
}
......@@ -19,11 +19,11 @@ public class CodeAutoGenerator {
String currentPath = System.getProperty("user.dir");
String codeBaseHome = "/community-service/src/main/java";
String author = "xudong";
String mysqlUserName = "tamp_admin";
String mysqlPassword = "@imeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community";
String mysqlUserName = "dev";
String mysqlPassword = "qimeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6lqwk9969zao53uro.mysql.rds.aliyuncs.com:3306/tamp_community";
// String[] tables = new String[]{"theme"};
String[] tables = new String[]{"file_record"};
String[] tables = new String[]{"theme_check_duplicate"};
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.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 主题文字查重表
* </p>
*
* @author xudong
* @since 2021-09-14
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("theme_check_duplicate")
@ApiModel(value="ThemeCheckDuplicateEntity对象", description="主题文字查重表")
public class ThemeCheckDuplicateEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "主题Id")
private String themeId;
private Integer themeType;
@ApiModelProperty(value = "分块")
private String partitionText;
@ApiModelProperty(value = "分块hash")
private Integer partitionHash;
@ApiModelProperty(value = "分块号")
private Integer partitionNum;
@ApiModelProperty(value = "分块总数")
private Integer totalParts;
@ApiModelProperty(value = "作者id")
private String userId;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Integer deleteTag;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getThemeId() {
return themeId;
}
public void setThemeId(String themeId) {
this.themeId = themeId;
}
public Integer getThemeType() {
return themeType;
}
public void setThemeType(Integer themeType) {
this.themeType = themeType;
}
public String getPartitionText() {
return partitionText;
}
public void setPartitionText(String partitionText) {
this.partitionText = partitionText;
}
public Integer getPartitionHash() {
return partitionHash;
}
public void setPartitionHash(Integer partitionHash) {
this.partitionHash = partitionHash;
}
public Integer getPartitionNum() {
return partitionNum;
}
public void setPartitionNum(Integer partitionNum) {
this.partitionNum = partitionNum;
}
public Integer getTotalParts() {
return totalParts;
}
public void setTotalParts(Integer totalParts) {
this.totalParts = totalParts;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
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 "ThemeCheckDuplicateEntity{" +
"id=" + id +
", themeId=" + themeId +
", themeType=" + themeType +
", partitionText=" + partitionText +
", partitionHash=" + partitionHash +
", partitionNum=" + partitionNum +
", totalParts=" + totalParts +
", userId=" + userId +
", createTime=" + createTime +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
"}";
}
}
package com.tanpu.community.dao.mapper.community;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
* <p>
* 主题文字查重表 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-09-08
*/
public interface ThemeCheckDuplicateMapper extends BaseMapper<ThemeCheckDuplicateEntity> {
@Update("update theme_check_duplicate set delete_tag=1 where theme_id =#{id}")
Long deleteByThemeId(@Param("id") String themeId);
@Select("select max(tmp.d) from (" +
"select theme_id ,count(*) as d " +
"from theme_check_duplicate ${ew.customSqlSegment}" +
") tmp")
Integer check(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper);
}
package com.tanpu.community.feign.activity;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class FeignBackClientForActivity implements FallbackFactory<FeignClientForActivity> {
@Override
public FeignClientForActivity create(Throwable throwable) {
return new FeignClientForActivity() {
@Override
public CommonResp<List<OfflineActivitySimpleResp>> simpleListByIds(List<String> activityIds) {
log.error("请求信息", throwable);
log.error("FeignClientForActivity.offlineActivityDetail-查询活动ids:{}", activityIds);
return CommonResp.error();
}
@Override
public CommonResp<List<OfflineActivitySimpleResp>> simpleListByOrgid(String orgId) {
log.error("请求信息", throwable);
log.error("FeignClientForActivity.offlineActivityDetail-查询活动orgId:{}", orgId);
return CommonResp.error();
}
};
}
}
package com.tanpu.community.feign.activity;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-jifen", contextId = "jifen", fallbackFactory = FeignBackClientForActivity.class, url = "http://tp-jifen-svc", path = "/jifen")
// @FeignClient(value = "service-jifen", contextId = "jifen", fallbackFactory = FeignBackClientForActivity.class, url = "http://127.0.0.1:8202/community")
public interface FeignClientForActivity {
@ApiOperation("线下活动列表-通过ids查询")
@GetMapping(value = "/offlineActivity/inter/listByIds")
CommonResp<List<OfflineActivitySimpleResp>> simpleListByIds(@ApiParam("活动ids") @RequestParam(value = "activityIds") List<String> activityIds);
@ApiOperation("线下活动列表-通过机构查询")
@GetMapping(value = "/offlineActivity/inter/listByOrgId")
CommonResp<List<OfflineActivitySimpleResp>> simpleListByOrgid(@ApiParam("机构id") @RequestParam(value = "orgId") String orgId);
}
......@@ -7,12 +7,14 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.BizStatus;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.DateUtils;
import com.tanpu.community.api.CommunityConstant;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.req.homepage.FollowRelReq;
import com.tanpu.community.api.beans.req.homepage.QueryFollowReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.page.Pageable;
import com.tanpu.community.api.beans.resp.Customer;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
......@@ -26,6 +28,7 @@ import com.tanpu.community.api.enums.ShowFollowStatusEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.mapper.community.FollowRelMapper;
import com.tanpu.community.feign.activity.FeignClientForActivity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.diagnose.FeignClientForDiagnose;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
......@@ -74,6 +77,8 @@ public class HomePageManager {
private FeignForPublicFund feignForPublicFund;
@Resource
private RedisCache redisCache;
@Resource
private FeignClientForActivity feignClientForActivity;
@Autowired
private NotificationService notificationService;
......@@ -169,6 +174,15 @@ public class HomePageManager {
});
userInfoNew.setUserInfoOrgList(userInfoOrgs);
}
// 家办活动
CommonResp<List<OfflineActivitySimpleResp>> activitySimpleResps = feignClientForActivity.simpleListByOrgid(userInfoNew.getUserInfoNewOrg().getCorpId());
if (usetInfoByOrgUserId.isSuccess() && CollectionUtils.isNotEmpty(usetInfoByOrgUserId.getData())) {
List<OfflineActivitySimpleResp> activities = activitySimpleResps.getData();
if (CollectionUtils.isNotEmpty(activities)){
userInfoNew.setHoldActivities(activities.stream().filter(o->o.getActivityType().equals(1)).collect(Collectors.toList()));
userInfoNew.setTeamRecruitment(activities.stream().filter(o->o.getActivityType().equals(2)).collect(Collectors.toList()));
}
}
} else {
//普通主页
......@@ -177,6 +191,14 @@ public class HomePageManager {
CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId);
if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData());
}
// 主页背景图
if (CommunityConstant.BACKGROUND_IMG_URL_MAP.containsKey(userInfoNew.getUserId())){
userInfoNew.setBackgroundImgUrl(CommunityConstant.BACKGROUND_IMG_URL_MAP.get(userInfoNew.getUserId()));
}else {
userInfoNew.setBackgroundImgUrl(CommunityConstant.BACKGROUND_IMG_URL_MAP.get("default"));
}
//刷新用户缓存
redisCache.put(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId), userInfoNew, 60);
......
......@@ -140,6 +140,9 @@ public class ThemeManager {
@Autowired
private NotificationService notificationService;
@Autowired
private ThemeTextCheckService themeTextCheckService;
@PostConstruct
public void init() throws IOException {
File f = new File(tmpDir);
......@@ -206,11 +209,16 @@ public class ThemeManager {
// 校验参数
checkAttachment(req.getContent());
// 文本查重,编辑不查
if (StringUtils.isBlank(req.getEditThemeId()) && themeTextCheckService.checkDuplicate(ConvertUtil.convertThemeText(JsonUtil.toJson(req.getContent())))) {
return CommonResp.error(ErrorCodeConstant.THEME_TEXT_DUPLICATE.getCode(), ErrorCodeConstant.THEME_TEXT_DUPLICATE.getMsg());
}
// 保存主题表
ThemeEntity themeEntity = new ThemeEntity();
BeanUtils.copyProperties(req, themeEntity);
themeEntity.setAuthorId(userId);
// 腾讯云敏感词校验
checkContent(req);
themeEntity.setContent(JsonUtil.toJson(req.getContent()));
......@@ -219,6 +227,7 @@ public class ThemeManager {
if (StringUtils.isBlank(req.getEditThemeId())) {
// 新建
themeService.insertTheme(themeEntity);
} else {
// 修改
themeService.update(themeEntity, req.getEditThemeId());
......@@ -233,12 +242,13 @@ public class ThemeManager {
}
themeAttachmentService.insertList(themeAttachments);
ESThemeQo esThemeQo = ConvertUtil.convert(themeEntity);
try {
esService.insertOrUpdateTheme(ConvertUtil.convert(themeEntity));
esService.insertOrUpdateTheme(esThemeQo);
} catch (Exception e) {
log.error("error in save theme to ES. themeId:{}, error:{}", themeEntity.getThemeId(), ExceptionUtils.getStackTrace(e));
}
themeTextCheckService.insert(esThemeQo.getTextContent(), themeEntity.getThemeId(), userId, themeEntity.getThemeType(), req.getEditThemeId());
redisCache.evict(StringUtils.joinWith("_", CACHE_THEME_ID, themeEntity.getThemeId()));
......@@ -247,8 +257,8 @@ public class ThemeManager {
if (1 == req.getSyncToNewComm()) {
CommonResp response = synchronizeToNewsFeed(req, themeEntity.getThemeId(), userId);
if (response.isNotSuccess()) {
if ("8001".equals(response.getCode())) {
// 内容受限,不滚发布
if ("8001".equals(response.getCode()) || ErrorCodeConstant.THEME_SYNCHRONIZE_FAILED.getCode().equals(response.getCode())) {
// 内容受限,不滚发布
return CommonResp.error(ErrorCodeConstant.THEME_SYNCHRONIZE_FAILED.getCode(), "发布成功,同步失败:" + response.getMsg(), themeResp);
} else {
// 其他回滚异常
......@@ -283,8 +293,12 @@ public class ThemeManager {
imgList.forEach(img -> {
feedList.add(convertImg(img, userId));
});
} else if (RelTypeEnum.OFFLINE_ACTIVITY.type.equals(themeContentReq.getType())) {
// throw new BizException("线下活动暂时无法同步到专栏");
return CommonResp.error(ErrorCodeConstant.THEME_SYNCHRONIZE_FAILED.getCode(), "线下活动无法同步");
} else {
//其他类型的附件
feedList.add(NewsFeedResReq.builder().relType(Integer.parseInt(themeContentReq.getType()))
.relId(themeContentReq.getValue())
.productType(themeContentReq.getProductType())
......@@ -747,7 +761,7 @@ public class ThemeManager {
// 逻辑删除主题,校验用户
public void delete(String themeId, String userId) {
themeService.deleteById(themeId, userId);
themeTextCheckService.deleteByThemeId(themeId);
this.evictThemeCache(themeId);
}
......@@ -936,4 +950,26 @@ public class ThemeManager {
redisCache.evict(StringUtils.joinWith("_", CACHE_THEME_ID, themeId));
}
/**
* 查重初始化
*/
@Transactional
public void initThemeTextCheck() {
List<ThemeEntity> themeEntities = themeService.queryLatestThemes(30);
List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities);
for (ThemeQo themeQo : themeQos) {
List<ThemeContentQo> content = themeQo.getContent();
for (ThemeContentQo themeContentQo : content) {
if (themeContentQo.getType().equals(RelTypeEnum.TEXT.type)) {
if (StringUtils.isNotBlank(themeContentQo.getValue()) && themeContentQo.getValue().length() > 50)
themeTextCheckService.insertInit(themeContentQo.getValue(), themeQo.getThemeId(),
themeQo.getAuthorId(), TimeUtils.getDateTimeOfTimestamp(themeQo.getCreateTime()), themeQo.getThemeType());
}
}
}
}
}
......@@ -12,6 +12,7 @@ import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
......@@ -35,7 +36,12 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -94,16 +100,18 @@ public class BatchFeignCallService {
Map<String, ZhiboListResp> zhiboMap = Maps.newHashMap();
// 设置产品信息
Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap();
// 设置活动信息
Map<String, OfflineActivitySimpleResp> activityMap = Maps.newHashMap();
// 图片信息
Map<String, FileRecordEntity> imgMap = Maps.newHashMap();
// 话题标题
Map<String, String> topicMap = Maps.newHashMap();
// 图片信息
Map<String, UserInfoResp> userMap = Maps.newHashMap();
// 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, userMap, themeQos);
//逐个装入
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, userMap, topicMap);
// 批量查询资源信息,将不同类型的id抽取,并通过ids查询并存放到id-对象Map中
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, activityMap, imgMap, topicMap, userMap, themeQos);
//逐个装入,将对象放入到Content中的detail对象中
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, activityMap, imgMap, userMap, topicMap);
}
......@@ -115,13 +123,14 @@ public class BatchFeignCallService {
* @param curriculumMap
* @param zhiboMap
* @param fundMap
* @param activityMap
*/
private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, CourseSimpleResp> courseMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgMap,
Map<String, OfflineActivitySimpleResp> activityMap, Map<String, FileRecordEntity> imgMap,
Map<String, String> topicMap,
Map<String, UserInfoResp> userMap,
List<ThemeQo> themeQos
......@@ -144,6 +153,8 @@ public class BatchFeignCallService {
HashSet<String> curriculumIds = Sets.newHashSet();
// 新课程id
HashSet<String> courseIds = Sets.newHashSet();
// 活动id
HashSet<String> activityIds = Sets.newHashSet();
// 图片id
HashSet<String> imageIds = Sets.newHashSet();
// 话题id
......@@ -181,12 +192,13 @@ public class BatchFeignCallService {
curriculumIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue());
}else if (c.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type)) {
c.getImgList().forEach(img->imageIds.add(img.getRelId()));
}
else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
} else if (c.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type)) {
c.getImgList().forEach(img -> imageIds.add(img.getRelId()));
} else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
courseIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.OFFLINE_ACTIVITY.type)) {
activityIds.add(c.getValue());
}
})
);
......@@ -214,9 +226,13 @@ public class BatchFeignCallService {
if (!CollectionUtils.isEmpty(zhiboIds)) {
// 直播列表
List<ZhiboListResp> list = feignService.getZhiboSimpleList(setToList(zhiboIds));
feignClientForZhibo.simpleList(setToList(zhiboIds));
zhiboMap.putAll(list.stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item, (oldValue, newValue) -> oldValue)));
}
if (!CollectionUtils.isEmpty(activityIds)) {
// 活动列表
List<OfflineActivitySimpleResp> list = feignService.getActivitySimpleList(setToList(activityIds));
activityMap.putAll(list.stream().collect(Collectors.toMap(OfflineActivitySimpleResp::getActivityId, item -> item, (oldValue, newValue) -> oldValue)));
}
if (!CollectionUtils.isEmpty(imageIds)) {
// 查询图片
List<FileRecordEntity> fileRecordEntities =
......@@ -358,7 +374,7 @@ public class BatchFeignCallService {
Map<String, CourseSimpleResp> courseMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgUrlMap,
Map<String, OfflineActivitySimpleResp> activityMap, Map<String, FileRecordEntity> imgUrlMap,
Map<String, UserInfoResp> userMap,
Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) {
......@@ -427,6 +443,11 @@ public class BatchFeignCallService {
themeContent.setDetail(AttachmentDetailVo.builder()
.product(product).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.OFFLINE_ACTIVITY.type)) {
if (activityMap.containsKey(themeContent.getValue())) {
themeContent.setDetail(AttachmentDetailVo.builder()
.activity(activityMap.get(themeContent.getValue())).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
//单图封装到imglist列表中
if (imgUrlMap.containsKey(themeContent.getValue())) {
......@@ -441,9 +462,9 @@ public class BatchFeignCallService {
.resizeUrl(imgEntity.getUrl() + CommunityConstant.OSS_RESIZE_RATIO)
.build();
// 图片审核屏蔽
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())){
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())) {
imagesDTO.setRemark(CommunityConstant.OSS_CHECK_FAIL_DEFAULT);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT+ CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT + CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setImgWidth(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_WIDTH);
imagesDTO.setImgHeight(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_HEIGHT);
}
......@@ -458,12 +479,12 @@ public class BatchFeignCallService {
if (imgUrlMap.containsKey(imagesDTO.getRelId())) {
FileRecordEntity imgEntity = imgUrlMap.get(imagesDTO.getRelId());
// 图片审核不通过,替换为默认图片 todo 配置移除
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())){
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())) {
imagesDTO.setRemark(CommunityConstant.OSS_CHECK_FAIL_DEFAULT);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT+ CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT + CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setImgWidth(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_WIDTH);
imagesDTO.setImgHeight(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_HEIGHT);
}else {
} else {
imagesDTO.setRemark(imgEntity.getUrl());
imagesDTO.setResizeUrl(imgEntity.getUrl() + CommunityConstant.OSS_RESIZE_RATIO);
String extInfo = imgEntity.getExtInfo();
......
......@@ -2,12 +2,14 @@ package com.tanpu.community.service;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.cache.LocalCache;
import com.tanpu.community.feign.activity.FeignClientForActivity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
......@@ -49,6 +51,10 @@ public class FeignService {
@Resource
private FeignClientForFatools feignClientForFatools;
@Resource
private FeignClientForActivity feignClientForActivity;
@Resource
private LocalCache localCache;
......@@ -82,8 +88,7 @@ public class FeignService {
} else {
return new ArrayList<>();
}
});
}
}); }
public List<ZhiboListResp> getZhiboSimpleList(List<String> zhiboIds) {
return batchExecute("getZhiboSimpleList_", zhiboIds, ZhiboListResp.class,
......@@ -97,6 +102,18 @@ public class FeignService {
});
}
public List<OfflineActivitySimpleResp> getActivitySimpleList(List<String> activityIds) {
return batchExecute("getActivitySimpleList_", activityIds, OfflineActivitySimpleResp.class,
OfflineActivitySimpleResp::getActivityId, ids -> {
CommonResp<List<OfflineActivitySimpleResp>> resp = feignClientForActivity.simpleListByIds(ids);
if (resp.isSuccess()) {
return resp.getData();
} else {
return new ArrayList<>();
}
});
}
public List<UserInfoResp> getUserList(List<String> userIds) {
return batchExecute("getUserList_", userIds, UserInfoResp.class,
UserInfoResp::getUserId, ids -> {
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.common.constant.BizStatus;
import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity;
import com.tanpu.community.dao.mapper.community.ThemeCheckDuplicateMapper;
import com.tanpu.community.util.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class ThemeTextCheckService {
@Resource
private ThemeCheckDuplicateMapper themeCheckDuplicateMapper;
private final String regex = "[,。!?;;:, ]";
// 插入
public void insert(String content, String themeId, String userId, Integer themeType, String editThemeId) {
if (StringUtils.isBlank(content) || content.length() < 50) {
return;
}
try {
if (StringUtils.isNotBlank(editThemeId)) {
themeCheckDuplicateMapper.deleteByThemeId(editThemeId);
}
content = content.replaceAll(regex, "。");
String[] split = content.split("。");
for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]);
insert(themeId, trim, getHash(trim), i + 1, split.length, userId, themeType);
}
} catch (Exception e) {
log.error("文本查重insert失败,themeId:" + themeId);
}
}
// 删除
public void deleteByThemeId(String themeId) {
themeCheckDuplicateMapper.deleteByThemeId(themeId);
}
private void insert(String themeId, String partition, Integer partitionHash, Integer num, Integer total, String userId, Integer themeType) {
ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder()
.themeId(themeId)
.partitionText(partition)
.partitionHash(partitionHash)
.partitionNum(num)
.totalParts(total)
.userId(userId)
.themeType(themeType)
.build();
themeCheckDuplicateMapper.insert(build);
}
public boolean checkDuplicate(String content) {
// 文字数小于50不查重
if (content.length() < 50) {
return false;
}
content = content.replaceAll(regex, "。");
String[] split = content.split("。");
List<Integer> list = new ArrayList<>();
for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]);
list.add(getHash(trim));
}
// 一年以内
LambdaQueryWrapper<ThemeCheckDuplicateEntity> w = new LambdaQueryWrapper<ThemeCheckDuplicateEntity>().in(ThemeCheckDuplicateEntity::getPartitionHash, list)
.eq(ThemeCheckDuplicateEntity::getDeleteTag, BizStatus.DeleteTag.tag_init)
.gt(ThemeCheckDuplicateEntity::getCreateTime, TimeUtils.getDaysBefore(360))
.groupBy(ThemeCheckDuplicateEntity::getThemeId);
Integer check = themeCheckDuplicateMapper.check(w);
// 重复率大于80%
if (check != null && check * 10 >= split.length * 8) {
return true;
}
return false;
}
public static Integer getHash(String str) {
return str.hashCode();
// try {
// // 生成一个MD5加密计算摘要
// MessageDigest md = MessageDigest.getInstance("MD5");
// // 计算md5函数
// md.update(str.getBytes());
// // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
// // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
// return new BigInteger(1, md.digest()).toString(16);
// } catch (Exception e) {
// throw new BizException("MD5加密出现错误");
// }
}
// 初始化
public void insertInit(String content, String themeId, String userId, LocalDateTime createTime, Integer themeType) {
themeCheckDuplicateMapper.deleteByThemeId(themeId);
content = content.replaceAll(regex, "。");
String[] split = content.split("。");
for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]);
ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder()
.themeId(themeId)
.partitionText(trim)
.partitionHash(getHash(split[i]))
.partitionNum(i + 1)
.totalParts(split.length)
.userId(userId)
.themeType(themeType)
.createTime(createTime)
.updateTime(createTime)
.build();
themeCheckDuplicateMapper.insert(build);
}
}
}
......@@ -71,6 +71,20 @@ public class ConvertUtil {
return themeEntities.stream().map(ConvertUtil::themeEntityToQo).collect(Collectors.toList());
}
// 抽取文本内容
public static String convertThemeText(String content) {
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(content, new TypeReference<List<ThemeContentQo>>() {
});
StringBuilder sb = new StringBuilder();
themeContentQos.stream().filter(q -> RelTypeEnum.TEXT.type.equals(q.getType())).forEach(q -> {
sb.append(q.getValue());
});
return sb.toString();
}
public static ESThemeQo convert(ThemeEntity entity) {
ESThemeQo qo = new ESThemeQo();
BeanUtils.copyProperties(entity, qo);
......@@ -184,7 +198,11 @@ public class ConvertUtil {
}
} else {
list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(content.getType()))
.attachId(content.getValue())
.themeId(themeId)
.build());
}
}
}
......
<?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.ThemeCheckDuplicateMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity">
<id column="id" property="id" />
<result column="theme_id" property="themeId" />
<result column="theme_type" property="themeType" />
<result column="partition_text" property="partitionText" />
<result column="partition_hash" property="partitionHash" />
<result column="partition_num" property="partitionNum" />
<result column="total_parts" property="totalParts" />
<result column="user_id" property="userId" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="delete_tag" property="deleteTag" />
</resultMap>
</mapper>
......@@ -16,4 +16,39 @@ CREATE TABLE `notification` (
`delete_tag` int(3) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_user_type_time` (`notified_user_id`,`update_time`,`message_type`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息通知记录'
\ No newline at end of file
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息通知记录';
CREATE TABLE `user_poster_attachement` (
`id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
`user_id` varchar(64) NOT NULL DEFAULT '' COMMENT '用户Id',
`type` varchar(16) NOT NULL DEFAULT '' COMMENT '附件类型',
`target_id` varchar(64) NOT NULL DEFAULT '' COMMENT '附件Id',
`sub_type` varchar(64) NOT NULL DEFAULT '' COMMENT '子类型,article-source,fund-type',
`course_packageId` varchar(64) NOT NULL DEFAULT '' COMMENT '课程包',
`product_is_recommend` int(4) NOT NULL DEFAULT '0' COMMENT '是否推荐',
`product_recommend` varchar(1000) NOT NULL DEFAULT '' COMMENT '推荐语',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`delete_tag` int(3) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_type_id` (`tpye`,`target_id`,`delete_tag`) USING BTREE,
KEY `idx_user_type_id` (`user_id`,`type`,`target_id`,`delete_tag`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作室海报附件表';
-- tamp_community.theme_check_duplicate definition
use tamp_community;
CREATE TABLE `theme_check_duplicate` (
`id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
`theme_id` varchar(64) NOT NULL DEFAULT '' COMMENT '主题Id',
`theme_type` int(3) DEFAULT '0',
`partition_text` varchar(64) NOT NULL DEFAULT '' COMMENT '分块',
`partition_hash` varchar(64) NOT NULL DEFAULT '' COMMENT '分块hash',
`partition_num` int(11) NOT NULL DEFAULT '0' COMMENT '分块号',
`total_parts` int(11) NOT NULL DEFAULT '0' COMMENT '分块总数',
`user_id` varchar(64) NOT NULL DEFAULT '' COMMENT '作者id',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`delete_tag` int(3) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_hash_theme_num` (`partition_hash`,`theme_id`,`partition_num`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题文字查重表';
\ No newline at end of file
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