Commit 4879eb18 authored by 张辰's avatar 张辰

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

# Conflicts:
#	community-service/src/main/java/com/tanpu/community/controller/SearchController.java
parents 5a6e3f13 e37a3f77
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;
}
......@@ -49,6 +49,8 @@ public class ThemeNotifyQo {
public String topicTitle;
@ApiModelProperty(value = "评论/转发内容")
private String content;
@ApiModelProperty(value = "评论Id")
private String commentId;
@ApiModelProperty(value = "转发类型-主题id")
private String forwardThemeId;
......
......@@ -24,4 +24,7 @@ public class CreateCommentReq {
@ApiModelProperty(value = "评论内容")
private String comment;
@ApiModelProperty(value = "同步转发,1 同步 ,0 不同步(默认)")
private int syncForward = 0;
}
package com.tanpu.community.api.beans.req.notification;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -14,7 +13,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class NotifyQueryReq {
@ApiModelProperty(value = "1:转发 2:点赞 3:评论 4:关注 0:全部")
@ApiModelProperty(value = "1:转发 2:点赞(主题点赞+评论点赞) 3:评论 4:关注 0:全部")
private Integer type;
@ApiModelProperty(value = "最后一条通知")
......
......@@ -21,8 +21,11 @@ public class ForwardThemeReq {
private List<ThemeContentReq> content;
@ApiModelProperty(value = "话题Id")
private String topicId="";
private String topicId = "";
@ApiModelProperty(value = "修改,则传入正在编辑的ThemeId")
private String editThemeId="";
private String editThemeId = "";
@ApiModelProperty(value = "同步评论,1 同步 ,0 不同步(默认)")
private int syncComment = 0;
}
......@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.req.theme;
import com.tanpu.community.api.beans.vo.ImagesDTO;
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.List;
@Data
@ApiModel(value = "主题内容")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ThemeContentReq {
@ApiModelProperty(value = "RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论))")
......
......@@ -10,6 +10,8 @@ import javax.validation.constraints.NotNull;
@Data
public class ThemeListReq {
@ApiModelProperty(value = "用户Id")
private String userId;
@NotNull(message = "主题类型不能为空")
@ApiModelProperty(value = "类型,1:推荐 2:关注 3:话题-热门 4:话题-最新")
......
package com.tanpu.community.api.beans.resp;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@ApiModel(value = "主题搜索")
public class ThemeAndUserSearchResp {
public List<ThemeQo> themes;
public List<FollowQo> users;
public ThemeAndUserSearchResp() {
this.themes = new ArrayList<>();
this.users = new ArrayList<>();
}
}
package com.tanpu.community.api.beans.resp;
import com.tanpu.community.api.beans.qo.FollowQo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@ApiModel(value = "主题搜索")
public class UserSearchResp {
public List<FollowQo> users;
public UserSearchResp() {
this.users = new ArrayList<>();
}
}
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;
}
......@@ -47,4 +47,6 @@ public class CourseSimpleResp {
@ApiModelProperty("1:音频 2:视频")
private Integer type;
@ApiModelProperty("状态 0:待上架 1:上架 2:下架")
private Integer status;
}
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
package com.tanpu.community.api.constants;
public class BizConstant {
public static class SyncCommentType{
public static final int SYNC_COMMENT=1;
public static final int NOT_SYNC_COMMENT=0;
}
public static class SyncForwardType{
public static final int SYNC_FORWARD=1;
public static final int NOT_SYNC_FORWARD=0;
}
}
......@@ -2,6 +2,14 @@ package com.tanpu.community.api.constants;
public class RedisKeyConstant {
public static final String ENV = "env";
// token app 小程序用
public static final String TAMP_TOKEN = "tampToken";
// H5 cookie
public static final String SESSION_COOKIE_NAME = "qimsession";
// redis token 前缀
public static final String REDIS_PREFIX_TOKEN = "s:sid:";
//点赞量
public static final String THEME_LIKE_COUNT ="THEME_LIKE_COUNT_";
//收藏量
......
......@@ -8,7 +8,8 @@ package com.tanpu.community.api.enums;
**/
public enum FundCompanyTypeEnum {
PUBLIC(0,"公募"),
PRIVATE(1,"私募");
PRIVATE(1,"私募"),
WHITELIST(2,"白名单");
private Integer code;
private String type;
......
......@@ -12,6 +12,7 @@ public enum NotificationTypeEnum {
LIKE(2,"点赞"),
COMMENT(3,"评论"),
FOLLOW(4,"关注"),
COMMENT_LIKE(5,"点赞评论"),
ALL(0,"全部");
private Integer code;
......
......@@ -33,7 +33,7 @@ public class ApolloRefresherConfig implements ApplicationContextAware {
this.applicationContext = applicationContext;
}
@ApolloConfigChangeListener(value = {"application.yml"})
@ApolloConfigChangeListener(value = {"common","application.yml"})
public void onChange(ConfigChangeEvent changeEvent) {
refreshProperties(changeEvent);
}
......
......@@ -11,6 +11,7 @@ import com.tanpu.community.api.beans.req.comment.QueryCommentReq;
import com.tanpu.community.api.beans.req.comment.ReportCommentReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.manager.CommentManager;
import com.tanpu.community.util.HttpServletHelper;
import com.tanpu.community.util.PageUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -31,6 +32,8 @@ public class CommentController {
@Resource
private UserHolder userHolder;
@Resource
private HttpServletHelper httpServletHelper;
@ApiOperation("发表评论")
@AuthLogin
......@@ -42,12 +45,11 @@ public class CommentController {
}
@ApiOperation("评论列表")
@AuthLogin
@PostMapping(value = "/queryComment")
@ResponseBody
public CommonResp<Page<CommentQo>> queryComment(@Validated @RequestBody QueryCommentReq req) {
String userId = userHolder.getUserId();
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId);
String selfUserId = httpServletHelper.getCurrentUserId();
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), selfUserId);
return CommonResp.success(PageUtils.page(req.getPage(), result));
}
......
......@@ -15,14 +15,20 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.manager.HomePageManager;
import com.tanpu.community.manager.ThemeManager;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import com.tanpu.community.util.HttpServletHelper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
......@@ -40,14 +46,16 @@ public class HomePageController {
@Resource
private UserHolder userHolder;
@Resource
private HttpServletHelper httpServletHelper;
// 用户信息查询 (供圈子服务调用)
@ApiOperation(value = "个人中心 查询")
@GetMapping(value = "/queryUserInfoNew")
@AuthLogin
public CommonResp<UserInfoResp> queryUsersListNew(@RequestParam(value = "userId", required = false) String userId) {
String userIdMyself = userHolder.getUserId();
return CommonResp.success(homePageManager.queryUsersInfo(userIdMyself, userId));
public CommonResp<UserInfoResp> queryUsersListNew(@RequestParam(value = "userId") String userId) {
String selfUserId = httpServletHelper.getCurrentUserId();
return CommonResp.success(homePageManager.queryUsersInfo(selfUserId, userId));
}
// 理财师客户列表查询 (供圈子服务调用)
......@@ -69,10 +77,13 @@ public class HomePageController {
@PostMapping(value = "/followList")
@ApiOperation("查询关注/粉丝列表")
@ResponseBody
@AuthLogin
public CommonResp<Page<FollowQo>> queryFollowList(@RequestBody QueryFollowReq req) {
String userId = userHolder.getUserId();
return CommonResp.success(homePageManager.queryFollow(req, userId));
String selfUserId = userHolder.getUserId();
// 为空查询当前用户自己的粉丝/关注列表
if (StringUtils.isEmpty(req.getUserId()) && StringUtils.isNotEmpty(selfUserId)) {
req.setUserId(selfUserId);
}
return CommonResp.success(homePageManager.queryFollow(req, selfUserId));
}
@PostMapping(value = "/addIdol")
......@@ -88,10 +99,9 @@ public class HomePageController {
@PostMapping(value = "/themeList")
@ApiOperation("用户的帖子列表")
@ResponseBody
@AuthLogin
public CommonResp<List<ThemeQo>> likeList(@Validated @RequestBody QueryRecordThemeReq req) {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.queryThemesByUser(req, userId));
String selfUserId = httpServletHelper.getCurrentUserId();
return CommonResp.success(themeManager.queryThemesByUser(req, selfUserId));
}
}
......@@ -2,17 +2,22 @@ package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.common.auth.UserInfoHelper;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.qo.TopicDetailQo;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.req.search.ThemeFullSearchReq;
import com.tanpu.community.api.beans.resp.ThemeAndUserSearchResp;
import com.tanpu.community.api.beans.resp.ThemeFullSearchResp;
import com.tanpu.community.api.beans.resp.UserSearchResp;
import com.tanpu.community.manager.HomePageManager;
import com.tanpu.community.manager.ThemeManager;
import com.tanpu.community.util.PagePdfGenUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
......@@ -28,6 +33,9 @@ public class SearchController {
@Autowired
private ThemeManager themeManager;
@Autowired
private HomePageManager homePageManager;
// 内容全文搜索
@ApiOperation("全文搜索主题")
@PostMapping(value = "/themeFullText")
......@@ -37,6 +45,26 @@ public class SearchController {
return CommonResp.success(resp);
}
// 用户+内容全文搜索
@ApiOperation("综合搜索")
@PostMapping(value = "/muLtipuleSearch")
@ResponseBody
public CommonResp<ThemeAndUserSearchResp> themeFullTextAndUserSearch(@RequestBody ThemeFullSearchReq req) {
ThemeFullSearchResp themeFullSearch = themeManager.themeFullSearch(req.keyword, req.page.pageNumber, req.page.pageSize, req.ident, userHolder.getUserId());
List<FollowQo> users = homePageManager.userNameSerach(req.keyword, 1, 3, req.ident, userHolder.getUserId());
return CommonResp.success(ThemeAndUserSearchResp.builder().themes(themeFullSearch.getThemes()).users(users).build());
}
// 用户搜索
@ApiOperation("用户姓名模糊查询")
@PostMapping(value = "/userNameFuzzy")
@ResponseBody
public CommonResp<UserSearchResp> userNameSerach(@RequestBody ThemeFullSearchReq req) {
List<FollowQo> users = homePageManager.userNameSerach(req.keyword, req.page.pageNumber, req.page.pageSize, req.ident, userHolder.getUserId());
return CommonResp.success(UserSearchResp.builder().users(users).build());
}
@GetMapping("/testGenPdf")
public CommonResp testGenPdf(@RequestParam("url") String url) {
PagePdfGenUtils.genPdf(url);
......
......@@ -8,9 +8,14 @@ import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.api.beans.resp.ThemeListResp;
import com.tanpu.community.feign.community.FeignClientForCommunity;
import com.tanpu.community.manager.ThemeManager;
import com.tanpu.community.service.TraceTestService;
import com.tanpu.community.util.HttpServletHelper;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -26,6 +31,11 @@ public class ThemeController {
private ThemeManager themeManager;
@Resource
private UserHolder userHolder;
@Resource
private HttpServletHelper httpServletHelper;
@Autowired
private TraceTestService traceTestService;
@AuthLogin
@ApiOperation("发表主题")
......@@ -36,22 +46,27 @@ public class ThemeController {
return themeManager.publishTheme(req, userId);
}
@AuthLogin
@ApiOperation("主题列表-推荐/关注/热门/最新")
@PostMapping(value = "/list")
@ResponseBody
public CommonResp<ThemeListResp> selectInterestList(@Validated @RequestBody ThemeListReq req) {
String userId = userHolder.getUserId();
ThemeListResp result = themeManager.queryList(req, userId);
String selfUserId = httpServletHelper.getCurrentUserId();
if (StringUtils.isEmpty(req.getUserId())) {
req.setUserId(selfUserId);
}
ThemeListResp result = themeManager.queryList(req, req.getUserId());
return CommonResp.success(result);
}
@AuthLogin
@ApiOperation("主题正文")
@GetMapping(value = "/detail")
@ResponseBody
public CommonResp<ThemeQo> getDetail(@RequestParam(value = "themeId") String themeId) {
String userId = userHolder.getUserId();
public CommonResp<ThemeQo> getDetail(@RequestParam(value = "themeId") String themeId,
@RequestParam(value = "userId", required = false) String userId) {
String selfUserId = httpServletHelper.getCurrentUserId();
if (StringUtils.isEmpty(userId)) {
userId = selfUserId;
}
return themeManager.getThemeDetail(themeId, userId);
}
......@@ -121,5 +136,18 @@ public class ThemeController {
return CommonResp.success();
}
@ApiOperation("文本查重初始化")
@GetMapping(value = "/initTextCheck")
@ResponseBody
public CommonResp<Void> initTextCheck() {
themeManager.initThemeTextCheck();
return CommonResp.success();
}
@PostMapping(value = "/testTrace")
@ResponseBody
public CommonResp<Void> testTrace() {
traceTestService.testTraceId();
return CommonResp.success();
}
}
......@@ -35,7 +35,6 @@ public class TopicController {
return CommonResp.success(topicManager.getAllTopicBriefInfo(req));
}
@AuthLogin
@GetMapping(value = "/detailPage")
@ApiOperation("话题详情页顶部")
@ResponseBody
......
......@@ -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", url = "${tanpu.jifen.svc:}", path = "/jifen")
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);
}
......@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
@Slf4j
@Component
......@@ -20,6 +21,12 @@ public class FeignBackClientForCommunity implements FallbackFactory<FeignClientF
return null;
}
@Override
public CommonResp testTraceId(@RequestParam("no") String no) {
log.error("请求信息", throwable);
log.error("FeignBackClientForCommunity.testTraceId-测试traceId:{}", no);
return null;
}
};
}
}
......@@ -4,9 +4,11 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(value = "service-community", contextId = "community", fallbackFactory = FeignBackClientForCommunity.class, url = "http://tp-tamp-community-svc", path = "/community")
@FeignClient(value = "service-community", url = "${tanpu.community.svc:}", path = "/community")
// @FeignClient(value = "service-community", contextId = "community", fallbackFactory = FeignBackClientForCommunity.class, url = "http://127.0.0.1:8202/community")
public interface FeignClientForCommunity {
......@@ -15,4 +17,9 @@ public interface FeignClientForCommunity {
@PostMapping("/newsFeed/save4NewComm")
CommonResp saveNewsFeed4NewComm(NewsFeedSave4NewCommReq req);
/**
* 测试用 traceId
*/
@GetMapping("/newsFeed/testTraceId")
CommonResp testTraceId(@RequestParam("no") String no);
}
......@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://tp-course-svc", path = "/course")
@FeignClient(value = "service-course", contextId = "course", url = "${tanpu.course.svc:}", path = "/course")
//@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://172.20.1.249:8060/course")
public interface FeignClientForCourse {
......
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, url = "http://tp-diagnose-svc", path = "/diagnose")
@FeignClient(value = "service-diagnose", url = "${tanpu.diagnose.svc:}", path = "/diagnose")
//@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, path = "http://172.20.1.249:8201/diagnose")
public interface FeignClientForDiagnose {
......
......@@ -2,27 +2,24 @@ package com.tanpu.community.feign.fatools;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.page.Pageable;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
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;
import com.tanpu.community.api.beans.vo.feign.user.FileQueryResp;
import com.tanpu.community.api.beans.vo.feign.user.UserInfoVo;
import com.tanpu.community.config.FeignConfiguration;
import com.tanpu.community.feign.diagnose.FeignBackClientForDiagnose;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
@FeignClient(value = "fatools", contextId = "fatools", fallbackFactory = FeignbackForFatools.class, url = "http://tp-fatools-svc", path = "/fatools")
@FeignClient(value = "fatools",url = "${tanpu.fatools.svc:}", path = "/fatools")
//@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public interface FeignClientForFatools {
......@@ -44,7 +41,7 @@ public interface FeignClientForFatools {
// 用户信息查询 (供圈子服务调用)
@ApiOperation(value = "查询用户信息")
@GetMapping(value = "/queryUserInfoNew")
@GetMapping(value = "/queryUserInfoNew", produces = {MediaType.APPLICATION_JSON_VALUE})
CommonResp<UserInfoResp> queryUserInfoNew(@RequestParam("userId") String userId);
@ApiOperation(value = "批量查询查询基本信息")
......@@ -59,4 +56,9 @@ public interface FeignClientForFatools {
@GetMapping(value = "/queryChiefFinancialAdviserList")
CommonResp<Page<UserInfoNewChief>> queryChiefFinancialAdviserList(@RequestParam("pageNumber") Integer pageNumber,@RequestParam("pageSize") Integer pageSize);
@ApiOperation(value = "根据昵称模糊查询目标用户")
@GetMapping(value = "/queryByUserNameMp")
List<UserInfoResp> queryByUserNameMp(@RequestParam("keyword") String keyword,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("pageNumber") Integer pageNumber);
}
......@@ -71,6 +71,12 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
log.info("FeignbackForFatools.queryChiefFinancialAdviserList", throwable);
return CommonResp.error();
}
@Override
public List<UserInfoResp> queryByUserNameMp(String keyword, Integer pageSize, Integer pageNumber) {
log.info("FeignbackForFatools.queryByUserNameMp", throwable);
return null;
}
};
}
......
package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
......@@ -27,6 +28,20 @@ public class FeignBackClientForProducts implements FallbackFactory<FeignClientFo
log.error("FeignClientForProducts.getProductInfoByIds-查询产品ids:{}", ids);
return null;
}
@Override
public CommonResp<FundCompanySimpleVO> getFundCompanyInfoSimple(String id) {
log.error("请求信息", throwable);
log.error("FeignClientForProducts.getFundCompanyInfoSimple-查询产品ids:{}", id);
return null;
}
@Override
public CommonResp<FundCompanySimpleVO> getCompanyFundCount(String id) {
log.error("请求信息", throwable);
log.error("FeignClientForProducts.getCompanyFundCount-查询产品ids:{}", id);
return null;
}
};
}
}
package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.feign.fatools.FeignbackForFatools;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://tp-product-svc", path = "/product")
@FeignClient(value = "service-product", url = "${tanpu.product.svc:}", path = "/product")
//@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://172.20.0.68:8194/product")
public interface FeignClientForProducts {
......@@ -23,4 +23,12 @@ public interface FeignClientForProducts {
@ApiOperation("根据id查询列表")
@GetMapping("/getProductInfoByIds")
CommonResp<List<ProductInfoVO>> getProductInfoByIds(@ApiParam("产品id") @RequestParam("fundIds") List<String> fundIds);
@ApiOperation("基金公司-简单信息")
@GetMapping("/fund/companyInfoSimple")
CommonResp<FundCompanySimpleVO> getFundCompanyInfoSimple(@ApiParam("基金公司id") @RequestParam("id") String id);
@ApiOperation("私募类型基金公司-持有产品数")
@GetMapping("/fund/companyFundCount")
CommonResp<FundCompanySimpleVO> getCompanyFundCount(@ApiParam("基金公司id") @RequestParam("id") String id);
}
......@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-fund", url = "http://127.0.0.1:8194/fund")
@FeignClient(value = "service-fund", contextId = "fund", fallbackFactory = FeignbackForFund.class, url = "http://tp-fund-svc", path = "/fund")
@FeignClient(value = "service-fund", url = "${tanpu.fund.svc:http://tp-fund-svc}", path = "/fund")
//@FeignClient(value = "service-fund", path = "/fund")
public interface FeignForFund {
......
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-fundpublic", contextId = "fundpublic", fallbackFactory = FeignbackForPublicFund.class, url = "http://tp-fundpublic-svc", path = "/fundpublic")
@FeignClient(value = "service-fundpublic", contextId = "fundpublic", url = "${tanpu.fundpublic.svc:}", path = "/fundpublic")
//@FeignClient(value = "service-fundpublic",path = "/fundpublic")
public interface FeignForPublicFund {
......
......@@ -4,9 +4,7 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.course.CurriCulumInfoDetailDto;
import com.tanpu.community.api.beans.vo.feign.course.CurriculumDetailVo;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.feign.product.FeignbackForPublicFund;
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.PostMapping;
......@@ -15,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://tp-tanpuroom-svc", path = "/tanpuroom")
@FeignClient(value = "service-tanpuroom", url = "${tanpu.tanpuroom.svc:}", path = "/tanpuroom")
//@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://172.20.0.183:8086/tanpuroom")
public interface FeignClientForTanpuroom {
......
......@@ -3,7 +3,6 @@ package com.tanpu.community.feign.zhibo;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboDetailVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.feign.tanpuroom.FeignBackClientForTanpuroom;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -14,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
//@FeignClient(value = "service-zhibo", url = "${tanpu.feo-zhibo.svc:}", fallbackFactory = FeignbackForZhibo.class, path = "/zhibo")
@FeignClient(value = "service-zhibo", contextId = "zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://tp-zhibo-svc", path = "/zhibo")
@FeignClient(value = "service-zhibo", url = "${tanpu.zhibo.svc:}", path = "/zhibo")
//@FeignClient(value = "service-zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://172.20.0.169:8183/zhibo")
public interface FeignClientForZhibo {
......
package com.tanpu.community.manager;
import com.google.common.collect.Sets;
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.constant.ErrorCodeConstant;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.qo.CommentQo;
import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.comment.LikeCommentReq;
import com.tanpu.community.api.beans.req.comment.ReportCommentReq;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.constants.BizConstant;
import com.tanpu.community.api.enums.NotificationTypeEnum;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.cache.RedisCache;
......@@ -67,7 +70,7 @@ public class CommentManager {
if (StringUtils.isEmpty(req.getComment())) {
throw new IllegalArgumentException("评论内容不能为空");
}
if (req.getComment().length()>500){
if (req.getComment().length() > 500) {
throw new IllegalArgumentException("评论内容不能超过500字");
}
......@@ -86,11 +89,25 @@ public class CommentManager {
commentService.insertComment(commentEntity);
CommentQo commentQo = ConvertUtil.commentEntity2Qo(commentEntity);
buildUserInfo(commentQo);
// 消息通知
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
notificationService.insert(userId,themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT,commentEntity.getCommentId(),req.getComment());
notificationService.putNotifyCache(themeEntity.getAuthorId(),userId,NotificationTypeEnum.COMMENT);
if (themeEntity == null) {
throw new BizException(ErrorCodeConstant.UNREACHABLE);
}
notificationService.insert(userId, themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT, commentEntity.getCommentId(), req.getComment());
notificationService.putNotifyCache(themeEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT);
// 评论同步转发并消息通知
if (req.getSyncForward() == BizConstant.SyncForwardType.SYNC_FORWARD) {
String themeId = themeService.commentSyncForward(req, userId);
// 消息通知
ThemeEntity commentTheme = themeService.queryByThemeId(req.getThemeId());
notificationService.insertForward(userId, commentTheme.getAuthorId(), commentTheme.getThemeId(), "", req.getComment(), themeId);
notificationService.putNotifyCache(commentTheme.getAuthorId(), userId, NotificationTypeEnum.FORWARD);
}
return commentQo;
}
......@@ -100,7 +117,12 @@ public class CommentManager {
List<CommentEntity> commentEntities = commentService.selectByThemeId(themeId);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
Set<String> likeCommentList = collectionService.getSetByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
Set<String> likeCommentList;
if (StringUtils.isNotEmpty(userId)) {
likeCommentList = collectionService.getSetByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
} else {
likeCommentList = Sets.newHashSetWithExpectedSize(0);
}
for (CommentQo commentQo : commentQos) {
// 封装用户信息
......@@ -122,7 +144,7 @@ public class CommentManager {
private void buildUserInfo(CommentQo commentQo) {
String authorId = commentQo.getAuthorId();
UserInfoResp userInfo = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId),
60, () ->this.getUserInfo(authorId) , UserInfoResp.class);
60, () -> this.getUserInfo(authorId), UserInfoResp.class);
if (userInfo != null) {
commentQo.setUserImg(userInfo.getHeadImageUrl());
commentQo.setNickName(userInfo.getNickName());
......@@ -136,7 +158,7 @@ public class CommentManager {
commentQo.setLikeCount(0);
}
private UserInfoResp getUserInfo(String authorId){
private UserInfoResp getUserInfo(String authorId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
......@@ -147,7 +169,12 @@ public class CommentManager {
//点赞评论/取消点赞
public void likeComment(LikeCommentReq req, String userId) {
if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) {
collectionService.saveOrUpdate(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
boolean b = collectionService.saveOrUpdate(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
if (b) {
CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId());
notificationService.insertLikeComment(userId, commentEntity.getAuthorId(), req.getCommentId());
notificationService.putNotifyCache(commentEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT_LIKE);
}
} else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
collectionService.delete(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
......@@ -168,11 +195,13 @@ public class CommentManager {
//删除评论
public void delete(String commentId, String userId) {
commentService.delete(commentId,userId);
if (StringUtils.isBlank(commentId)){
throw new BizException("commentId不能为空");
}
commentService.delete(commentId, userId);
CommentEntity commentEntity = commentService.queryByIdIncludeDelete(commentId);
ThemeEntity themeEntity = themeService.queryByThemeId(commentEntity.getThemeId());
notificationService.deleteCommentNotify(themeEntity.getAuthorId(),userId,commentId,commentEntity.getCreateTime());
notificationService.deleteCommentNotify(themeEntity.getAuthorId(), userId, commentId, commentEntity.getCreateTime());
}
......
......@@ -79,7 +79,7 @@ public class NotificationManager {
List<ThemeNotifyQo> themeNotifyQos = ConvertUtil.notificationEntitiy2ThemeQos(query);
UserInfoResp currentUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId),
60, () -> this.getUserInfo(userId), UserInfoResp.class);
Set<String> followUserIds= followRelService.queryIdolsByFansId(userId).stream().collect(Collectors.toSet());
Set<String> followUserIds = followRelService.queryIdolsByFansId(userId).stream().collect(Collectors.toSet());
for (ThemeNotifyQo themeNotifyQo : themeNotifyQos) {
// 用户信息
......@@ -93,18 +93,28 @@ public class NotificationManager {
themeNotifyQo.setUserInvestorType(userInfo.getUserInvestorType());
themeNotifyQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
themeNotifyQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
// 封装引用对象
if (StringUtils.isNotEmpty(themeNotifyQo.getFormerThemeId())) {
if (NotificationTypeEnum.COMMENT.getCode().equals(themeNotifyQo.getMessageType())){
// 评论类型将commentId替换为themeId
CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getFormerThemeId());
// 评论根据commentEntity找到ThemeId
if (NotificationTypeEnum.COMMENT.getCode().equals(themeNotifyQo.getMessageType()) ||
NotificationTypeEnum.COMMENT_LIKE.getCode().equals(themeNotifyQo.getMessageType())) {
// 评论类型将commentId替换为themeId
CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getCommentId());
if (commentEntity != null) {
themeNotifyQo.setFormerThemeId(commentEntity.getThemeId());
if (NotificationTypeEnum.COMMENT_LIKE.getCode().equals(themeNotifyQo.getMessageType())) {
themeNotifyQo.setContent(commentEntity.getContent());
}
}
ThemeEntity former = themeService.queryByThemeId(themeNotifyQo.getFormerThemeId());
}
// 封装引用对象
if (StringUtils.isNotEmpty(themeNotifyQo.getFormerThemeId())) {
ThemeEntity former = themeService.queryByThemeId(themeNotifyQo.getFormerThemeId());
if (former != null) {
themeNotifyQo.setFormerUserName(currentUser.getNickName());
if (StringUtils.isNotBlank(former.getTopicId())){
if (StringUtils.isNotBlank(former.getTopicId())) {
// 内部话题
themeNotifyQo.setFormerTopicId(former.getTopicId());
themeNotifyQo.setFormerTopicTitle(topicService.queryTitleById(former.getTopicId()));
......@@ -113,11 +123,10 @@ public class NotificationManager {
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(former.getContent(), new TypeReference<List<ThemeContentQo>>() {
});
themeNotifyQo.setFormerContent(themeContentQos.get(0).getValue());
}
if (ThemeTypeEnum.LONG_TEXT.getCode().equals(former.getThemeType())) {
} else if (ThemeTypeEnum.LONG_TEXT.getCode().equals(former.getThemeType())) {
themeNotifyQo.setFormerContent(former.getTitle());
}
}else {
} else {
// 引用主题已被删除
themeNotifyQo.setFormerThemeId(null);
}
......@@ -127,7 +136,7 @@ public class NotificationManager {
themeNotifyQo.setTopicTitle(topicService.queryTitleById(themeNotifyQo.getTopicId()));
}
// 点赞聚合
if (themeNotifyQo.getLikeUserCount()!=null && themeNotifyQo.getLikeUserCount()>1) {
if (themeNotifyQo.getLikeUserCount() != null && themeNotifyQo.getLikeUserCount() > 1) {
List<UserBriefInfoQO> likeUsers = themeNotifyQo.getLikeUsers();
for (UserBriefInfoQO likeUser : likeUsers) {
UserInfoResp luser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, likeUser.getUserId()),
......@@ -143,7 +152,7 @@ public class NotificationManager {
redisCache.evict(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + userId);
// 更新查询时间,用于删除评论
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_QUERY_TIME + userId,
JsonUtil.toJson(LocalDateTime.now()),60 * 60 * 24 * 30);
JsonUtil.toJson(LocalDateTime.now()), 60 * 60 * 24 * 30);
return themeNotifyQos;
}
......@@ -166,7 +175,7 @@ public class NotificationManager {
notificationService.insert(followRelEntity.getFansId(), followRelEntity.getIdolId(), NotificationTypeEnum.FOLLOW
, followRelEntity.getFansId(), "", followRelEntity.getUpdateTime());
notificationService.putNotifyCacheFollow(followRelEntity.getIdolId(), followRelEntity.getFansId(),followRelEntity.getUpdateTime());
notificationService.putNotifyCacheFollow(followRelEntity.getIdolId(), followRelEntity.getFansId(), followRelEntity.getUpdateTime());
}
// 转发
List<ThemeEntity> themeEntities = themeService.queryAllForward();
......@@ -184,7 +193,7 @@ public class NotificationManager {
.topicId(themeEntity.getTopicId()).build();
notificationService.insert(themeEntity.getAuthorId(), former.getAuthorId(), NotificationTypeEnum.FORWARD
, themeEntity.getFormerThemeId(), JsonUtil.toJson(content), themeEntity.getUpdateTime());
notificationService.putNotifyCache(former.getAuthorId(), themeEntity.getAuthorId(), NotificationTypeEnum.FORWARD,themeEntity.getUpdateTime());
notificationService.putNotifyCache(former.getAuthorId(), themeEntity.getAuthorId(), NotificationTypeEnum.FORWARD, themeEntity.getUpdateTime());
}
// 评论
List<CommentEntity> commentEntities = commentService.queryAll();
......@@ -227,7 +236,6 @@ public class NotificationManager {
}
private UserInfoResp getUserInfo(String authorId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) {
......
......@@ -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();
......
......@@ -27,14 +27,15 @@ public class CollectionService {
private CollectionMapper collectionMapper;
// 若不存在则新增,若存在则修改deleteTag
@Transactional
public boolean saveOrUpdate(String themeId, String userId, CollectionTypeEnum type) {
public boolean saveOrUpdate(String targetId, String userId, CollectionTypeEnum type) {
// 判断记录是否存在,无论是否删除
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getTargetId, themeId);
.eq(CollectionEntity::getTargetId, targetId);
CollectionEntity queryCollection = collectionMapper.selectOne(queryWrapper);
if (queryCollection != null) {
queryCollection.setDeleteTag(DeleteTagEnum.NOT_DELETED.getCode());
......@@ -45,11 +46,12 @@ public class CollectionService {
CollectionEntity entity = CollectionEntity.builder()
.collectionType(type.getCode())
.userId(userId)
.targetId(themeId)
.targetId(targetId)
.collectionTime(LocalDateTime.now())
.build();
collectionMapper.insert(entity);
return true;
}
}
......
......@@ -6,6 +6,7 @@ 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.beans.req.theme.ForwardThemeReq;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.CommentEntity;
......@@ -44,7 +45,6 @@ public class CommentService {
//失效缓存
evictThemeCache(commentEntity.getThemeId());
}
......@@ -163,4 +163,19 @@ public class CommentService {
public CommentEntity queryByCommentId(String commentId) {
return commentMapper.selectOne(new LambdaQueryWrapper<CommentEntity>().eq(CommentEntity::getCommentId,commentId));
}
public String forwardSyncComment(ForwardThemeReq req, String userId) {
CommentEntity commentEntity = CommentEntity.builder()
.themeId(req.getFormerThemeId())
.authorId(userId)
.content(req.getContent().get(0).getValue())
.commentType(CommentTypeEnum.THEME.getCode())
.build();
this.insertComment(commentEntity);
return commentEntity.getCommentId();
}
}
......@@ -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 -> {
......
......@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
@Service
......@@ -84,7 +85,7 @@ public class NotificationService {
}
@Transactional
public void insertLike(String operatorId, String notifierId, String targetId) {
NotificationEntity entity = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>()
.eq(NotificationEntity::getMessageType, NotificationTypeEnum.LIKE.getCode())
......@@ -112,6 +113,34 @@ public class NotificationService {
}
@Transactional
public void insertLikeComment(String operatorId, String notifierId, String targetId) {
NotificationEntity entity = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>()
.eq(NotificationEntity::getMessageType, NotificationTypeEnum.COMMENT_LIKE.getCode())
.eq(NotificationEntity::getTargetId, targetId)
.eq(NotificationEntity::getNotifiedUserId, notifierId));
if (entity != null) {
NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class);
notificationLikeDO.addItem(operatorId);
entity.setContent(JsonUtil.toJson(notificationLikeDO));
entity.setUpdateTime(LocalDateTime.now());
notificationMapper.updateById(entity);
} else {
NotificationLikeDO notificationLikeDO = new NotificationLikeDO();
notificationLikeDO.addItem(operatorId);
NotificationEntity build = NotificationEntity.builder().operatorId(operatorId)
.notificationId(uuidGenHelper.getUuidStr())
.messageType(NotificationTypeEnum.COMMENT_LIKE.getCode())
.notifiedUserId(notifierId)
.content(JsonUtil.toJson(notificationLikeDO))
.targetId(targetId)
.operatorId(operatorId)
.build();
insert(build);
}
}
@Transactional
public void insert(NotificationEntity entity) {
notificationMapper.insert(entity);
......@@ -136,8 +165,12 @@ public class NotificationService {
.eq(NotificationEntity::getNotificationId, lastId));
queryWrapper.lt(NotificationEntity::getUpdateTime, lastOne.getCreateTime());
}
if (!NotificationTypeEnum.ALL.getCode().equals(type)) {
if (!NotificationTypeEnum.ALL.getCode().equals(type) && !NotificationTypeEnum.LIKE.getCode().equals(type)) {
queryWrapper.eq(NotificationEntity::getMessageType, type);
} else if (NotificationTypeEnum.LIKE.getCode().equals(type)) {
// 类型2点赞返回评论点赞和主题点赞
queryWrapper.in(NotificationEntity::getMessageType,
Arrays.asList(NotificationTypeEnum.LIKE.getCode(), NotificationTypeEnum.COMMENT_LIKE.getCode()));
}
return notificationMapper.selectList(queryWrapper);
}
......@@ -182,28 +215,31 @@ public class NotificationService {
public void putNotifyCache(String notifyUserId, String operatorId, NotificationTypeEnum type) {
UserInfoResp userInfo = getUserInfo(operatorId);
redisCache.incr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + type.getType() + "了你的内容", 60 * 60 * 24 * 30);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId, TimeUtils.format(LocalDateTime.now()), 60 * 60 * 24 * 30);
}
// 消息通知队列缓存
public void putNotifyCacheFollow(String notifyUserId, String operatorId) {
UserInfoResp userInfo = getUserInfo(operatorId);
redisCache.incr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "关注了你", 60 * 60 * 24 * 30);
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_TIME + notifyUserId, TimeUtils.format(LocalDateTime.now()), 60 * 60 * 24 * 30);
if (NotificationTypeEnum.COMMENT_LIKE.equals(type)) {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "点赞了你的评论", 60 * 60 * 24 * 30);
} else if (NotificationTypeEnum.FOLLOW.equals(type)) {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + "关注了你", 60 * 60 * 24 * 30);
} else {
redisCache.set(RedisKeyConstant.MESSAGE_NOTIFY_LAST_MSG + notifyUserId, userInfo.getNickName() + type.getType() + "了你的内容", 60 * 60 * 24 * 30);
}
}
// 删除评论及缓存
// 删除评论通知及缓存,并更新
public void deleteCommentNotify(String notifyUserId, String operatorId, String commentId, LocalDateTime commentTime) {
// 物理删除
NotificationEntity commentNotify = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>().eq(NotificationEntity::getTargetId, commentId));
NotificationEntity commentNotify = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>()
.eq(NotificationEntity::getTargetId, commentId)
.eq(NotificationEntity::getOperatorId, operatorId)
.eq(NotificationEntity::getNotifiedUserId, notifyUserId)
.eq(NotificationEntity::getMessageType, NotificationTypeEnum.COMMENT.getCode()));
NotificationEntity last = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>().eq(NotificationEntity::getNotifiedUserId, notifyUserId)
.orderByDesc(NotificationEntity::getUpdateTime)
.last("limit 1"));
if (commentNotify==null || last==null){
return;
}
notificationMapper.deleteById(commentNotify.getId());
// 如果删除的评论是最後一條通知,则需要从库中再找一条最新的
if (last.getNotificationId().equals(commentNotify.getNotificationId())) {
......@@ -231,7 +267,7 @@ public class NotificationService {
// 处理更新数量
String lastTime = redisCache.get(RedisKeyConstant.MESSAGE_NOTIFY_QUERY_TIME + notifyUserId);
LocalDateTime lastQueryTime =StringUtils.isNotBlank(lastTime)?JsonUtil.toBean(lastTime,LocalDateTime.class):LocalDateTime.now();
LocalDateTime lastQueryTime = StringUtils.isNotBlank(lastTime) ? JsonUtil.toBean(lastTime, LocalDateTime.class) : LocalDateTime.now();
// 如果删除的评论时时间在红点提示时间内,则缓存数-1
if (StringUtils.isBlank(lastTime) || TimeUtils.lessThan(lastQueryTime, commentTime)) {
redisCache.decr(RedisKeyConstant.MESSAGE_NOTIFY_COUNT + notifyUserId);
......
......@@ -96,7 +96,7 @@ public class RankService {
LocalDateTime start = LocalDateTime.now();
//7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(7);
List<ThemeEntity> themeEntities = themeService.queryRecentdays(30);
if (CollectionUtils.isEmpty(themeEntities)) {
return;
}
......
package com.tanpu.community.service;
import com.google.common.collect.Lists;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.ThemeAnalysDO;
import com.tanpu.community.api.beans.resp.PythonResponse;
......@@ -8,6 +9,7 @@ import com.tanpu.community.util.BizUtils;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.TimeUtils;
import lombok.extern.slf4j.Slf4j;
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;
......@@ -72,11 +74,16 @@ public class RecommendService {
newThemeIds = BizUtils.subList(newThemeIds, 0, pageSize);
//推荐话题
List<String> recThemeIds = getPythonRecommendList(userId).stream()
.filter(id -> {
return !excludeIds.contains(id);
}).collect(Collectors.toList());
recThemeIds = BizUtils.subList(recThemeIds, pageStart, pageSize);
List<String> recThemeIds;
if (StringUtils.isNotEmpty(userId)) {
recThemeIds = getPythonRecommendList(userId).stream()
.filter(id -> {
return !excludeIds.contains(id);
}).collect(Collectors.toList());
recThemeIds = BizUtils.subList(recThemeIds, pageStart, pageSize);
} else {
recThemeIds = Lists.newArrayListWithCapacity(0);
}
// merge
return mergeRecommend(hotThemeIds, newThemeIds, recThemeIds);
......
......@@ -2,10 +2,14 @@ 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.RelTypeEnum;
import com.tanpu.biz.common.enums.community.ReportStatusEnum;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.redis.RedisHelper;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity;
......@@ -19,6 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
......@@ -275,4 +280,19 @@ public class ThemeService {
.eq(ThemeEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())
.orderByAsc(ThemeEntity::getCreateTime));
}
public String commentSyncForward(CreateCommentReq req, String userId) {
// 评论构造theme content
List<ThemeContentReq> themeContentReqs = Arrays.asList(ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build());
ThemeContentReq.builder().type(RelTypeEnum.TEXT.type).value(req.getComment()).build();
ThemeEntity themeEntity = ThemeEntity.builder()
.content(JsonUtil.toJson(themeContentReqs))
.topicId("")
.formerThemeId(req.getThemeId())
.authorId(userId)
.themeType(ThemeTypeEnum.FORWARD.getCode())
.build();
this.insertTheme(themeEntity);
return themeEntity.getThemeId();
}
}
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 {
public static final int SENTENCE_MIN_LENGTH = 5;
@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]);
if (trim.length() > SENTENCE_MIN_LENGTH) {
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]);
if (trim.length() > SENTENCE_MIN_LENGTH) {
list.add(getHash(trim));
}
}
if (list.size() <= 2) {
return false;
}
// 一年以内
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 >= list.size() * 0.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]);
if (trim.length() > SENTENCE_MIN_LENGTH) {
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);
}
}
}
}
package com.tanpu.community.service;
import com.tanpu.community.feign.community.FeignClientForCommunity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.instrument.async.LazyTraceAsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.concurrent.atomic.AtomicInteger;
@Service
@Slf4j
public class TraceTestService {
@Autowired
private BeanFactory beanFactory;
@Autowired
private FeignClientForCommunity feignClientForCommunity;
private LazyTraceAsyncTaskExecutor executor;
private AtomicInteger count;
@PostConstruct
private void init() {
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
pool.setMaxPoolSize(3);
pool.setCorePoolSize(1);
pool.setKeepAliveSeconds(3600);
pool.initialize();
executor = new LazyTraceAsyncTaskExecutor(beanFactory, pool);
count = new AtomicInteger(0);
}
public void testTraceId() {
Integer c = count.incrementAndGet();
log.info("parent count is " + c);
for (int i = 1; i <= 3; i++) {
int subCount = i;
executor.submit(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
log.info("child count is " + c + "-" + subCount);
feignClientForCommunity.testTraceId("" + c + "-" + subCount);
} catch (Exception e) {
}
}
});
}
}
}
......@@ -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());
}
}
}
......@@ -250,6 +268,12 @@ public class ConvertUtil {
) {
themeNotifyQo.setFormerThemeId(entity.getTargetId());
}
// 评、点赞评论 评论Id
if (entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode()) ||
entity.getMessageType().equals(NotificationTypeEnum.COMMENT.getCode())
) {
themeNotifyQo.setCommentId(entity.getTargetId());
}
// 转发有话题信息
if (entity.getMessageType().equals(NotificationTypeEnum.FORWARD.getCode())) {
themeNotifyQo.setFormerThemeId(entity.getTargetId());
......@@ -266,7 +290,8 @@ public class ConvertUtil {
}
}
// 点赞需要聚合头像和人数
if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode())) {
if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode()) ||
entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode())) {
if (!StringUtils.isEmpty(entity.getContent())) {
try {
......@@ -280,8 +305,6 @@ public class ConvertUtil {
}
}
}
return themeNotifyQo;
}
......
package com.tanpu.community.util;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.common.redis.RedisHelper;
import com.tanpu.community.api.constants.RedisKeyConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpCookie;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Optional;
/**
* @Description TODO
* @Author wangyalei
* @Date 2021/9/23 下午8:31
**/
@Slf4j
@Service
public class HttpServletHelper {
@Resource
private RedisHelper redisHelper;
@Resource
private UserHolder userHolder;
public String getCurrentUserId() {
// String userId = null;
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
// String clientEnv = request.getHeader(RedisKeyConstant.ENV);
// if (isAndroid(clientEnv) || isIOS(clientEnv) || isPc(clientEnv) || isMiniProgram(clientEnv)) {
// // android,ios,pc,小程序用token
// String token = request.getHeader(RedisKeyConstant.TAMP_TOKEN);
// // redis获取的value,都带有 "",这里去掉
// userId = StringUtils.remove(redisHelper.get(RedisKeyConstant.REDIS_PREFIX_TOKEN + token), "\"");
// } else {
// // 用cookie
// Cookie[] cookies = request.getCookies();
// if (cookies != null) {
// Optional<Cookie> first = Arrays.stream(request.getCookies())
// .filter(cookie -> StringUtils.equalsIgnoreCase(RedisKeyConstant.SESSION_COOKIE_NAME, cookie.getName()))
// .findFirst();
// if (first.isPresent()) {
// userId = first.get().getValue();
// }
// }
// }
String userId = userHolder.getUserId();
log.debug("当前登录用户Id: {}", userId);
return userId;
}
public static boolean isAndroid(String clientEnv) {
return "android".equalsIgnoreCase(clientEnv);
}
public static boolean isIOS(String clientEnv) {
return "ios".equalsIgnoreCase(clientEnv);
}
public static boolean isPc(String clientEnv) {
return "pc".equalsIgnoreCase(clientEnv);
}
public static boolean isMiniProgram(String clientEnv) {
return "xcx".equalsIgnoreCase(clientEnv);
}
}
......@@ -79,23 +79,23 @@ public class TencentcloudUtils {
* @param text
* @return
*/
public static boolean textModeration(String text) {
public static String textModeration(String text) {
TextModerationRequest req = new TextModerationRequest();
req.setContent(Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8)));
TextModerationResponse res = null;
try {
res = getTmsClient().TextModeration(req);
// suggestion Block 不通过
if (res.getSuggestion().equals("Block")) {
return false;
if (res.getSuggestion().equals("Block") && res.getKeywords().length > 0) {
return ":"+res.getKeywords()[0];
}
} catch (TencentCloudSDKException e) {
log.error("调用腾文本内容安全异常");
e.printStackTrace();
//调用失败时,不影响用户发布主题
return true;
return "";
}
return true;
return "";
}
/**
......
apollo.bootstrap.enabled: true
apollo.bootstrap.enabled: false
#app.id: tanpu-community
#apollo:
......@@ -15,15 +15,7 @@ server:
spring.datasource:
community:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: tamp_admin
password: '@imeng123'
maxActive: 2
minIdle: 2
initialSize: 2
user:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: tamp_admin
password: '@imeng123'
maxActive: 2
......@@ -96,4 +88,29 @@ recommend:
python: 1
python:
enable: false
url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ No newline at end of file
url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
tmpfile:
dir: /data/tmp
tanpu:
fatools:
svc: 127.0.0.1:8189
product:
svc: https://testtamper.tanpuyun.com
jifen:
svc: https://testtamper.tanpuyun.com
fund:
svc: https://testtamper.tanpuyun.com
course:
svc: https://testtamper.tanpuyun.com
community:
svc: https://testtamper.tanpuyun.com
order:
svc: https://testtamper.tanpuyun.com
tanpuroom:
svc: https://testtamper.tanpuyun.com
zhibo:
svc: https://testtamper.tanpuyun.com
diagnose:
svc: https://testtamper.tanpuyun.com
\ 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.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
......@@ -165,6 +165,12 @@
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>io.github.fanyong920</groupId>
<artifactId>jvppeteer</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
......
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