Commit 1f84303a authored by 吴泽佳's avatar 吴泽佳
parents 8d9f4c33 547cb7e9
......@@ -18,23 +18,23 @@ public class ESThemeQo {
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发 4:评论")
public Integer themeType;
@ApiModelProperty(value = "内容")
public String content;
@ApiModelProperty(value = "话题名称")
public String topicTitle;
@ApiModelProperty(value = "昵称")
public String nickName;
@ApiModelProperty(value = "作者认证")
public String authLabel;
@ApiModelProperty(value = "转发的主题")
public FormerThemeQo formerTheme;
@ApiModelProperty(value = "评论Id(我的评论列表使用)")
public String commentId;
@ApiModelProperty(value = "文本内容")
public String textContent;
// @ApiModelProperty(value = "话题名称")
// public String topicTitle;
//
// @ApiModelProperty(value = "昵称")
// public String nickName;
//
// @ApiModelProperty(value = "作者认证")
// public String authLabel;
//
// @ApiModelProperty(value = "转发的主题")
// public FormerThemeQo formerTheme;
//
// @ApiModelProperty(value = "评论Id(我的评论列表使用)")
// public String commentId;
public Long createTime;
......
......@@ -23,7 +23,6 @@ public class ThemeContentQo {
@ApiModelProperty(value = "文本的值是内容,附件的值为id")
private String value;
@ApiModelProperty(value = "产品类型,0 公募,1 私募,2 白名单,3 私有")
private Integer productType;
......
......@@ -57,8 +57,16 @@ public class ThemeQo implements Serializable {
@ApiModelProperty(value = "当前用户是否关注该作者")
public boolean follow;
@ApiModelProperty(value = "作者认证")
private Integer authLabel;
@ApiModelProperty("认证标签用-用户等级体系 0 游客 1注册用户 10投资人 20 探普理顾 30 探普专家理顾 40 交易理财师 50 首席投顾")
private Integer levelGrade;
@ApiModelProperty("认证标签用-当levelGrade=10有值 1投资萌新 2投资达人")
private String userInvestorType;
@ApiModelProperty("认证标签用-用户类型 1普通账号 2机构账号 3机构人员")
private Integer userType;
@ApiModelProperty("认证标签用-所属机构id")
private String belongUserOrgId;
@ApiModelProperty("认证标签用-所属机构名")
private String belongUserOrgName;
@ApiModelProperty(value = "认证机构")
private String authOrg;
......
......@@ -15,9 +15,9 @@ public class Pageable {
public static final Integer DEFAULT_PAGE_NUMBER = 0;
private Integer pageNumber = DEFAULT_PAGE_NUMBER;
public Integer pageNumber = DEFAULT_PAGE_NUMBER;
private Integer pageSize = DEFAULT_PAGE_SIZE;
public Integer pageSize = DEFAULT_PAGE_SIZE;
public Pageable() {
}
......
......@@ -3,7 +3,11 @@ package com.tanpu.community.api.beans.req.search;
import com.tanpu.community.api.beans.req.page.Pageable;
import lombok.Data;
import java.util.List;
@Data
public class ThemeFullSearchReq extends Pageable {
public class ThemeFullSearchReq {
public Pageable page;
public String keyword;
public List<String> excludeIds;
}
package com.tanpu.community.api.beans.resp;
import com.tanpu.community.api.beans.qo.ThemeQo;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class ThemeFullSearchResp {
public List<String> excludeIds;
public List<ThemeQo> themes;
public ThemeFullSearchResp() {
this.excludeIds = new ArrayList<>();
this.themes = new ArrayList<>();
}
}
......@@ -167,6 +167,13 @@
<scope>test</scope>
</dependency>
<!--腾讯云内容校验-->
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>4.0.11</version>
</dependency>
</dependencies>
<build>
......
......@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableCaching
@EnableScheduling
@EnableFeignClients
@EnableConfigurationProperties({ESConfig.class})
public class CommunityApplication {
public static void main(String[] args) {
......
package com.tanpu.community.config;
import lombok.Data;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
......@@ -16,16 +17,14 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Configuration
@Data
@Component
@ConfigurationProperties(prefix = "es")
public class ESConfig {
@Value("${es.userName}")
private String userName;
@Value("${es.userPasswd}")
private String userPasswd;
@Value("${es.host}")
private String host;
@Value("${es.port}")
private Integer port;
@Bean
......
......@@ -6,6 +6,7 @@ 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.req.search.ThemeFullSearchReq;
import com.tanpu.community.api.beans.resp.ThemeFullSearchResp;
import com.tanpu.community.manager.ThemeManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -27,9 +28,12 @@ public class SearchController {
private ThemeManager themeManager;
// 内容全文搜索
public CommonResp<List<ThemeQo>> themeSearch(ThemeFullSearchReq req) {
List<ThemeQo> list = themeManager.themeFullSearch(req.keyword, req.getPageNumber(), req.getPageSize(), userHolder.getUserId());
return CommonResp.success(list);
@ApiOperation("全文搜索主题")
@PostMapping(value = "/themeFullText")
@ResponseBody
public CommonResp<ThemeFullSearchResp> themeFullText(@RequestBody ThemeFullSearchReq req) {
ThemeFullSearchResp resp = themeManager.themeFullSearch(req.keyword, req.page.pageNumber, req.page.pageSize, req.excludeIds, userHolder.getUserId());
return CommonResp.success(resp);
}
}
package com.tanpu.community.dao.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* <p>
* 定价表
* </p>
*
* @author xudong
* @since 2021-06-24
*/
@TableName("curriculum_price")
@ApiModel(value="CurriculumPriceEntity对象", description="定价表")
public class CurriculumPriceEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
@ApiModelProperty(value = "关联id")
private String relId;
@ApiModelProperty(value = "付费模式 1:免费 2:积分 3:现金")
private Integer chargeMode;
@ApiModelProperty(value = "价格")
private Long price;
@ApiModelProperty(value = "划线价")
private Long crossedPrice;
@ApiModelProperty(value = "是否促销 0:否 1 :是 ")
private Integer promo;
@ApiModelProperty(value = "促销价格")
private Long promoPrice;
@ApiModelProperty(value = "促销开始日期")
private LocalDateTime promoStartTime;
@ApiModelProperty(value = "促销结束日期")
private LocalDateTime promoEndTime;
@ApiModelProperty(value = "使用积分 0:不使用 1:使用 (保留字段)")
private Integer useScore;
@ApiModelProperty(value = "积分")
private Integer score;
@ApiModelProperty(value = "是否有角色价 0:没有 1:有")
private Integer isRolePrice;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
@ApiModelProperty(value = "删除")
private Integer deleteTag;
@ApiModelProperty(value = "更新人")
private String updateBy;
@ApiModelProperty(value = "机构id")
private String orgId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRelId() {
return relId;
}
public void setRelId(String relId) {
this.relId = relId;
}
public Integer getChargeMode() {
return chargeMode;
}
public void setChargeMode(Integer chargeMode) {
this.chargeMode = chargeMode;
}
public Long getPrice() {
return price;
}
public void setPrice(Long price) {
this.price = price;
}
public Long getCrossedPrice() {
return crossedPrice;
}
public void setCrossedPrice(Long crossedPrice) {
this.crossedPrice = crossedPrice;
}
public Integer getPromo() {
return promo;
}
public void setPromo(Integer promo) {
this.promo = promo;
}
public Long getPromoPrice() {
return promoPrice;
}
public void setPromoPrice(Long promoPrice) {
this.promoPrice = promoPrice;
}
public LocalDateTime getPromoStartTime() {
return promoStartTime;
}
public void setPromoStartTime(LocalDateTime promoStartTime) {
this.promoStartTime = promoStartTime;
}
public LocalDateTime getPromoEndTime() {
return promoEndTime;
}
public void setPromoEndTime(LocalDateTime promoEndTime) {
this.promoEndTime = promoEndTime;
}
public Integer getUseScore() {
return useScore;
}
public void setUseScore(Integer useScore) {
this.useScore = useScore;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public Integer getIsRolePrice() {
return isRolePrice;
}
public void setIsRolePrice(Integer isRolePrice) {
this.isRolePrice = isRolePrice;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
public Integer getDeleteTag() {
return deleteTag;
}
public void setDeleteTag(Integer deleteTag) {
this.deleteTag = deleteTag;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
@Override
public String toString() {
return "CurriculumPriceEntity{" +
"id=" + id +
", relId=" + relId +
", chargeMode=" + chargeMode +
", price=" + price +
", crossedPrice=" + crossedPrice +
", promo=" + promo +
", promoPrice=" + promoPrice +
", promoStartTime=" + promoStartTime +
", promoEndTime=" + promoEndTime +
", useScore=" + useScore +
", score=" + score +
", isRolePrice=" + isRolePrice +
", createTime=" + createTime +
", createBy=" + createBy +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
", updateBy=" + updateBy +
", orgId=" + orgId +
"}";
}
}
package com.tanpu.community.dao.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* <p>
* 课程资源
* </p>
*
* @author xudong
* @since 2021-06-23
*/
@TableName("curriculum_res")
@ApiModel(value="CurriculumResEntity对象", description="课程资源")
public class CurriculumResEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private String id;
@ApiModelProperty(value = "课程名称")
private String title;
@ApiModelProperty(value = "课程音视频")
private String audio;
@ApiModelProperty(value = "音/视频类型 1:音频 2:视频 3:小视频")
private Integer audioType;
@ApiModelProperty(value = "讲师id")
private String teacherId;
@ApiModelProperty(value = "讲师姓名")
private String teacherName;
@ApiModelProperty(value = "文稿内容")
private String content;
@ApiModelProperty(value = "时长")
private Integer duration;
@ApiModelProperty(value = "文件大小KB")
private Integer fileSize;
@ApiModelProperty(value = "组织id")
private String orgId;
@ApiModelProperty(value = "房间密码")
private String roomPwd;
@ApiModelProperty(value = "白名单 1:白名单 2:黑名单")
private Integer whiteList;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "阅读数")
private Integer readNum;
@ApiModelProperty(value = "阅读基础数")
private Integer readBaseNum;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
@ApiModelProperty(value = "删除标识")
private Integer deleteTag;
@ApiModelProperty(value = "状态")
private Integer status;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "简介")
private String info;
@ApiModelProperty(value = "封面")
private String cover;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAudio() {
return audio;
}
public void setAudio(String audio) {
this.audio = audio;
}
public Integer getAudioType() {
return audioType;
}
public void setAudioType(Integer audioType) {
this.audioType = audioType;
}
public String getTeacherId() {
return teacherId;
}
public void setTeacherId(String teacherId) {
this.teacherId = teacherId;
}
public String getTeacherName() {
return teacherName;
}
public void setTeacherName(String teacherName) {
this.teacherName = teacherName;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public Integer getFileSize() {
return fileSize;
}
public void setFileSize(Integer fileSize) {
this.fileSize = fileSize;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public String getRoomPwd() {
return roomPwd;
}
public void setRoomPwd(String roomPwd) {
this.roomPwd = roomPwd;
}
public Integer getWhiteList() {
return whiteList;
}
public void setWhiteList(Integer whiteList) {
this.whiteList = whiteList;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Integer getReadNum() {
return readNum;
}
public void setReadNum(Integer readNum) {
this.readNum = readNum;
}
public Integer getReadBaseNum() {
return readBaseNum;
}
public void setReadBaseNum(Integer readBaseNum) {
this.readBaseNum = readBaseNum;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
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;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
@Override
public String toString() {
return "CurriculumResEntity{" +
"id=" + id +
", title=" + title +
", audio=" + audio +
", audioType=" + audioType +
", teacherId=" + teacherId +
", teacherName=" + teacherName +
", content=" + content +
", duration=" + duration +
", fileSize=" + fileSize +
", orgId=" + orgId +
", roomPwd=" + roomPwd +
", whiteList=" + whiteList +
", createBy=" + createBy +
", readNum=" + readNum +
", readBaseNum=" + readBaseNum +
", createTime=" + createTime +
", updateBy=" + updateBy +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
", status=" + status +
", sort=" + sort +
", info=" + info +
", cover=" + cover +
"}";
}
}
package com.tanpu.community.dao.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* <p>
*
* </p>
*
* @author xudong
* @since 2021-06-24
*/
@TableName("order_flow")
@ApiModel(value="OrderFlowEntity对象", description="")
public class OrderFlowEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "唯一主键")
private String id;
@ApiModelProperty(value = "订单号")
private String abOrdernum;
@ApiModelProperty(value = "产品价格")
private Long abPrice;
@ApiModelProperty(value = "积分")
private Long abScore;
@ApiModelProperty(value = "积分抵扣")
private Long abScoreDeduct;
@ApiModelProperty(value = "账户余额抵扣")
private Long abAccountDeduct;
@ApiModelProperty(value = "支付通道付款金额")
private Long abPayment;
@ApiModelProperty(value = "支付方式 1:免费 2:积分 3现金")
private String abPayMode;
@ApiModelProperty(value = "订单总额")
private Long abTotalMoney;
@ApiModelProperty(value = "产品类型")
private String abType;
@ApiModelProperty(value = "产品ID")
private String abProid;
@ApiModelProperty(value = "产品规格ID")
private String abProSiid;
@ApiModelProperty(value = "产品规格类型")
private String abSiType;
@ApiModelProperty(value = "产品规格规格名称")
private String abSiName;
@ApiModelProperty(value = "产品规格规格编码")
private String abSiCode;
@ApiModelProperty(value = "产品规格定价模式")
private String abSiPattern;
@ApiModelProperty(value = "状态 WAIT:待支付 SUCCESS:支付成功 FAIL:支付失败 CANCEL:取消交易")
private String abStatus;
@ApiModelProperty(value = "权益分配状态")
private String abRightsStatus;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createtime;
@ApiModelProperty(value = "创建人")
private String createby;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updatetime;
@ApiModelProperty(value = "修改人")
private String updateby;
@ApiModelProperty(value = "删除标识")
private String deletetag;
@ApiModelProperty(value = "微信unionid")
private String unionid;
@ApiModelProperty(value = "交易流水号")
private String transactionSerialNo;
@ApiModelProperty(value = "付款时间")
private LocalDateTime payTime;
@ApiModelProperty(value = "完成时间")
private LocalDateTime completeTime;
@ApiModelProperty(value = "机构id")
private String orgId;
@ApiModelProperty(value = "注册手机号")
private String registerPhone;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAbOrdernum() {
return abOrdernum;
}
public void setAbOrdernum(String abOrdernum) {
this.abOrdernum = abOrdernum;
}
public Long getAbPrice() {
return abPrice;
}
public void setAbPrice(Long abPrice) {
this.abPrice = abPrice;
}
public Long getAbScore() {
return abScore;
}
public void setAbScore(Long abScore) {
this.abScore = abScore;
}
public Long getAbScoreDeduct() {
return abScoreDeduct;
}
public void setAbScoreDeduct(Long abScoreDeduct) {
this.abScoreDeduct = abScoreDeduct;
}
public Long getAbAccountDeduct() {
return abAccountDeduct;
}
public void setAbAccountDeduct(Long abAccountDeduct) {
this.abAccountDeduct = abAccountDeduct;
}
public Long getAbPayment() {
return abPayment;
}
public void setAbPayment(Long abPayment) {
this.abPayment = abPayment;
}
public String getAbPayMode() {
return abPayMode;
}
public void setAbPayMode(String abPayMode) {
this.abPayMode = abPayMode;
}
public Long getAbTotalMoney() {
return abTotalMoney;
}
public void setAbTotalMoney(Long abTotalMoney) {
this.abTotalMoney = abTotalMoney;
}
public String getAbType() {
return abType;
}
public void setAbType(String abType) {
this.abType = abType;
}
public String getAbProid() {
return abProid;
}
public void setAbProid(String abProid) {
this.abProid = abProid;
}
public String getAbProSiid() {
return abProSiid;
}
public void setAbProSiid(String abProSiid) {
this.abProSiid = abProSiid;
}
public String getAbSiType() {
return abSiType;
}
public void setAbSiType(String abSiType) {
this.abSiType = abSiType;
}
public String getAbSiName() {
return abSiName;
}
public void setAbSiName(String abSiName) {
this.abSiName = abSiName;
}
public String getAbSiCode() {
return abSiCode;
}
public void setAbSiCode(String abSiCode) {
this.abSiCode = abSiCode;
}
public String getAbSiPattern() {
return abSiPattern;
}
public void setAbSiPattern(String abSiPattern) {
this.abSiPattern = abSiPattern;
}
public String getAbStatus() {
return abStatus;
}
public void setAbStatus(String abStatus) {
this.abStatus = abStatus;
}
public String getAbRightsStatus() {
return abRightsStatus;
}
public void setAbRightsStatus(String abRightsStatus) {
this.abRightsStatus = abRightsStatus;
}
public LocalDateTime getCreatetime() {
return createtime;
}
public void setCreatetime(LocalDateTime createtime) {
this.createtime = createtime;
}
public String getCreateby() {
return createby;
}
public void setCreateby(String createby) {
this.createby = createby;
}
public LocalDateTime getUpdatetime() {
return updatetime;
}
public void setUpdatetime(LocalDateTime updatetime) {
this.updatetime = updatetime;
}
public String getUpdateby() {
return updateby;
}
public void setUpdateby(String updateby) {
this.updateby = updateby;
}
public String getDeletetag() {
return deletetag;
}
public void setDeletetag(String deletetag) {
this.deletetag = deletetag;
}
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getTransactionSerialNo() {
return transactionSerialNo;
}
public void setTransactionSerialNo(String transactionSerialNo) {
this.transactionSerialNo = transactionSerialNo;
}
public LocalDateTime getPayTime() {
return payTime;
}
public void setPayTime(LocalDateTime payTime) {
this.payTime = payTime;
}
public LocalDateTime getCompleteTime() {
return completeTime;
}
public void setCompleteTime(LocalDateTime completeTime) {
this.completeTime = completeTime;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public String getRegisterPhone() {
return registerPhone;
}
public void setRegisterPhone(String registerPhone) {
this.registerPhone = registerPhone;
}
@Override
public String toString() {
return "OrderFlowEntity{" +
"id=" + id +
", abOrdernum=" + abOrdernum +
", abPrice=" + abPrice +
", abScore=" + abScore +
", abScoreDeduct=" + abScoreDeduct +
", abAccountDeduct=" + abAccountDeduct +
", abPayment=" + abPayment +
", abPayMode=" + abPayMode +
", abTotalMoney=" + abTotalMoney +
", abType=" + abType +
", abProid=" + abProid +
", abProSiid=" + abProSiid +
", abSiType=" + abSiType +
", abSiName=" + abSiName +
", abSiCode=" + abSiCode +
", abSiPattern=" + abSiPattern +
", abStatus=" + abStatus +
", abRightsStatus=" + abRightsStatus +
", createtime=" + createtime +
", createby=" + createby +
", updatetime=" + updatetime +
", updateby=" + updateby +
", deletetag=" + deletetag +
", unionid=" + unionid +
", transactionSerialNo=" + transactionSerialNo +
", payTime=" + payTime +
", completeTime=" + completeTime +
", orgId=" + orgId +
", registerPhone=" + registerPhone +
"}";
}
}
package com.tanpu.community.dao.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author xudong
* @since 2021-07-14
* @since 2021-07-20
*/
@TableName("user_info")
@ApiModel(value="UserInfoEntity对象", description="")
......@@ -24,6 +25,9 @@ public class UserInfoEntity implements Serializable {
@ApiModelProperty(value = "唯一主键")
private String id;
@ApiModelProperty(value = "账户类型 1普通账号 2机构账号 3机构人员")
private Integer userType;
@ApiModelProperty(value = "微信openId")
private String uiOpenid;
......@@ -253,6 +257,14 @@ public class UserInfoEntity implements Serializable {
this.id = id;
}
public Integer getUserType() {
return userType;
}
public void setUserType(Integer userType) {
this.userType = userType;
}
public String getUiOpenid() {
return uiOpenid;
}
......@@ -889,6 +901,7 @@ public class UserInfoEntity implements Serializable {
public String toString() {
return "UserInfoEntity{" +
"id=" + id +
", userType=" + userType +
", uiOpenid=" + uiOpenid +
", uiUnionid=" + uiUnionid +
", uiTelphone=" + uiTelphone +
......
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.CurriculumPriceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 定价表 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-24
*/
public interface CurriculumPriceMapper extends BaseMapper<CurriculumPriceEntity> {
}
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.CurriculumResEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 课程资源 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-23
*/
public interface CurriculumResMapper extends BaseMapper<CurriculumResEntity> {
}
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.FinProResEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-23
*/
public interface FinProResMapper extends BaseMapper<FinProResEntity> {
}
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.OrderFlowEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-24
*/
public interface OrderFlowMapper extends BaseMapper<OrderFlowEntity> {
}
......@@ -42,6 +42,10 @@ public interface FeignClientForFatools {
@GetMapping(value = "/queryUserInfoNew")
CommonResp<UserInfoNew> queryUsersListNew(@RequestParam("userId") String userId);
@ApiOperation(value = "批量查询查询基本信息")
@GetMapping(value = "/queryUserBaseInfoList")
List<UserInfoNew> queryUserListNew(@RequestParam("userIds") List<String> userIds);
@ApiOperation(value = "根据机构用户id 查询旗下机构用户信息")
@GetMapping(value = "/getUsetInfoByOrgUserId")
CommonResp<List<UserInfoOrg>> getUsetInfoByOrgUserId(@RequestParam("orgUserId") String orgUserId);
......
......@@ -10,6 +10,7 @@ import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -51,6 +52,12 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
return CommonResp.error();
}
@Override
public List<UserInfoNew> queryUserListNew(List<String> userIds) {
log.info("FeignbackForFatools.queryUserListNew", throwable);
return Collections.emptyList();
}
@Override
public CommonResp<List<UserInfoOrg>> getUsetInfoByOrgUserId(String orgUserId) {
log.info("FeignbackForFatools.getUsetInfoByOrgUserId", throwable);
......
......@@ -17,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class CommentManager {
......@@ -68,11 +70,7 @@ public class CommentManager {
}
//是否点赞及点赞数
String commentId = commentQo.getCommentId();
if (likeCommentList.contains(commentId)) {
commentQo.setHasLiked(true);
} else {
commentQo.setHasLiked(false);
}
commentQo.setHasLiked(likeCommentList.contains(commentId));
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId);
......@@ -81,8 +79,10 @@ public class CommentManager {
// List<CommentLv2Qo> commentLv2Qos = ConvertUtil.commentLv2Entity2Qos(CommentLv2Entities);
// commentQo.setCommentLv2Qos(commentLv2Qos);
}
return commentQos;
//排序:点赞降序+时间降序
return commentQos.stream().sorted(Comparator.comparing(CommentQo::getLikeCount,Comparator.reverseOrder()).
thenComparing(CommentQo::getUpdateTime,Comparator.reverseOrder()))
.collect(Collectors.toList());
}
//点赞评论/取消点赞
......
package com.tanpu.community.manager;
import com.google.common.collect.Sets;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.ESThemeQo;
......@@ -9,14 +11,19 @@ import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq;
import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.api.beans.resp.ThemeFullSearchResp;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.service.*;
import com.tanpu.community.service.base.ESService;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.TencentcloudUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -27,6 +34,7 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ThemeManager {
@Resource
......@@ -51,7 +59,7 @@ public class ThemeManager {
private ThemeAttachmentService themeAttachmentService;
@Resource
private ProductService productService;
private BatchFeignCallService batchFeignCallService;
@Autowired
private VisitSummaryService visitSummaryService;
......@@ -62,23 +70,46 @@ public class ThemeManager {
@Autowired
private ESService esService;
public List<ThemeQo> themeFullSearch(String keyword, Integer pageNo, Integer pageSize, String userId) {
@Autowired
private FeignClientForFatools feignClientForFatools;
public ThemeFullSearchResp themeFullSearch(String keyword, Integer pageNo, Integer pageSize, List<String> excludeIds, String userId) {
Integer from = (pageNo - 1) * pageSize;
ThemeFullSearchResp resp = new ThemeFullSearchResp();
// 按时间倒叙查询
List<ESThemeQo> themes = esService.queryThemeIdByContentAndTitle(keyword, from, pageSize);
if (themes.isEmpty()) {
return new ArrayList<>();
// todo redis
List<ESThemeQo> esIds = esService.queryThemeIdByContentAndTitle(keyword, from, pageSize * 5);
if (esIds.isEmpty()) {
return resp;
}
List<ThemeEntity> themeEntities = themeService.queryByThemeIds(themes.stream().map(ESThemeQo::getThemeId).collect(Collectors.toList()));
return convertEntityToQo(themeEntities, userId);
// 排除已经展示过的id
List<String> filterEsIds = esIds.stream().map(ESThemeQo::getThemeId).filter(tId -> {
return !excludeIds.contains(tId);
}).limit(pageSize).collect(Collectors.toList());
resp.themes = convertEntityToQo(themeService.queryByThemeIds(filterEsIds), userId);
resp.excludeIds.addAll(filterEsIds);
return resp;
}
@Transactional
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) {
//TODO 敏感词过滤
//直播类型做转播检查
List<ThemeContentReq> contents = req.getContent();
for (ThemeContentReq content : contents) {
if (content != null && content.getType().equals(RelTypeEnum.LIVE.type)) {
CommonResp<Set<String>> notRelayResp = feignClientForFatools.getNotRelaySet(userId, Sets.newHashSet(content.getValue()));
if (!notRelayResp.isSuccess()) {
throw new BizException("转播失败");
}
if (CollectionUtils.isEmpty(notRelayResp.getData())) {
throw new BizException("9999", "很抱歉!您需要购买或报名成功后才可以添加这个直播哦~");
}
}
}
//保存主题表
ThemeEntity themeEntity = new ThemeEntity();
......@@ -86,6 +117,8 @@ public class ThemeManager {
themeEntity.setAuthorId(userId);
themeEntity.setContent(JsonUtil.toJson(req.getContent()));
//TODO 敏感词过滤
checkContent(themeEntity.getContent());
if (StringUtils.isEmpty(req.getEditThemeId())) {
//新建
......@@ -103,10 +136,16 @@ public class ThemeManager {
}
themeAttachmentService.insertList(themeAttachments);
try {
esService.insertOrUpdateTheme(ConvertUtil.convert(themeEntity));
} catch (Exception e) {
log.error("error in save theme to ES. themeId:{}, error:{}", themeEntity.getThemeId(), ExceptionUtils.getStackTrace(e));
}
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
}
/**
* 返回主题列表
*
......@@ -120,7 +159,7 @@ public class ThemeManager {
// TODO:推荐
// themeEntities = themeService.selectExcludeUser(userId, req.getLastId(), req.getPageSize());
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100);
themeEntities = themeService.queryByThemeIdsExcludeUser( recommendThemeIds,userId, req.getLastId(), req.getPageSize());
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, userId, req.getLastId(), req.getPageSize());
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//根据关注列表查询
......@@ -168,7 +207,7 @@ public class ThemeManager {
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
productService.getAttachDetailByBatch(themeQos);
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
......@@ -198,11 +237,11 @@ public class ThemeManager {
}
return commentThemeList;
case 3://点赞
Set<String> likeThemeIds = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_THEME);
Set<String> likeThemeIds = collectionService.getListByUser(req.getLastId(), CollectionTypeEnum.LIKE_THEME);
themeEntities = themeService.queryByThemeIds(new ArrayList<>(likeThemeIds), req.getLastId(), req.getPageSize());
break;
case 4://收藏
Set<String> collectThemeIds = collectionService.getListByUser(userId, CollectionTypeEnum.COLLECT_THEME);
Set<String> collectThemeIds = collectionService.getListByUser(req.getLastId(), CollectionTypeEnum.COLLECT_THEME);
themeEntities = themeService.queryByThemeIds(new ArrayList<>(collectThemeIds), req.getLastId(), req.getPageSize());
break;
}
......@@ -212,14 +251,13 @@ public class ThemeManager {
//查询正文
// @CacheGet(prefix = "getThemeDetail", expireSeconds = 600)
public ThemeQo getDetail(String themeId, String userId) {
ThemeEntity themeEntity = themeService.queryByThemeId(themeId);
if (themeEntity == null) {
throw new BizException("找不到帖子id:" + themeId);
}
ThemeQo themeQo = ConvertUtil.themeEntityToQo(themeEntity);
productService.getAttachDetail(themeQo);
batchFeignCallService.getAttachDetail(themeQo);
buildThemeQoExtraInfo(userId, themeQo);
return themeQo;
}
......@@ -300,7 +338,7 @@ public class ThemeManager {
//Entity转Qo
List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities);
//批量查询附件detail
productService.getAttachDetailByBatch(themeQos);
batchFeignCallService.getAttachDetailByBatch(themeQos);
//其他信息
for (ThemeQo themeQO : themeQos) {
buildThemeQoExtraInfo(userId, themeQO);
......@@ -350,7 +388,7 @@ public class ThemeManager {
if (formerTheme != null) {
//单个查询详情
productService.getAttachDetail(formerTheme);
batchFeignCallService.getAttachDetail(formerTheme);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(formerTheme);
themeQo.setFormerTheme(f);
}
......@@ -376,4 +414,20 @@ public class ThemeManager {
}
private void checkContent(String content) {
// 腾讯云接口最多支持5000文字校验,超过5000执行2次
// 检查内容是否涉黄违法
CommonResp commonResp = TencentcloudUtils.textModeration(content.length() > 5000 ? content.substring(0, 5000) : content);
if (!commonResp.isSuccess()) {
throw new BizException("内容校验失败,请检查内容后重新发送");
}
if (content.length() > 5000) {
CommonResp commonResp2 = TencentcloudUtils.textModeration(content.substring(5000, content.length()));
if (!commonResp2.isSuccess()) {
throw new BizException("内容校验失败,请检查内容后重新发送");
}
}
return ;
}
}
package com.tanpu.community.model;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class ESWrapper<T> {
@JsonProperty("_index")
public String index;
@JsonProperty("_type")
public String type;
@JsonProperty("_id")
public String id;
@JsonProperty("_score")
public String score;
@JsonProperty("_source")
public T source;
@JsonProperty("sort")
public JSONArray sort;
}
......@@ -11,13 +11,13 @@ import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.vo.ImagesDTO;
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.UserInfoNew;
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
......@@ -35,7 +35,7 @@ import java.util.*;
import java.util.stream.Collectors;
@Service
public class ProductService {
public class BatchFeignCallService {
@Resource
......@@ -93,7 +93,7 @@ public class ProductService {
// 话题标题
Map<String, String> topicMap = Maps.newHashMap();
// 图片信息
Map<String, UserInfoEntity> userMap = Maps.newHashMap();
Map<String, UserInfoNew> userMap = Maps.newHashMap();
// 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, userMap, themeQos);
//逐个装入
......@@ -117,7 +117,7 @@ public class ProductService {
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgMap,
Map<String, String> topicMap,
Map<String, UserInfoEntity> userMap,
Map<String, UserInfoNew> userMap,
List<ThemeQo> themeQos
) {
// 白名单基金id
......@@ -238,12 +238,12 @@ public class ProductService {
}
if (!CollectionUtils.isEmpty(userIds)) {
// 查询用户信息
List<UserInfoEntity> userInfos =
userInfoService.queryUserByIds(setToList(userIds));
List<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUserListNew(setToList(userIds));
if (!CollectionUtils.isEmpty(userIds)) {
userMap.putAll(userInfos.stream().collect(Collectors
.toMap(UserInfoEntity::getId, o -> o)));
userMap.putAll(queryUsersListNew.stream().collect(Collectors
.toMap(UserInfoNew::getUserId, o -> o)));
}
}
this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
}
......@@ -369,16 +369,22 @@ public class ProductService {
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgUrlMap,
Map<String, UserInfoEntity> userMap,
Map<String, UserInfoNew> userMap,
Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) {
if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) {
themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
}
if (!StringUtils.isEmpty(themeQo.getAuthorId()) && userMap.containsKey(themeQo.getAuthorId())) {
themeQo.setNickName(userMap.get(themeQo.getAuthorId()).getUiUsernameMp());
themeQo.setUserImg(userMap.get(themeQo.getAuthorId()).getUiHeadimgMp());
themeQo.setUserIntroduction(userMap.get(themeQo.getAuthorId()).getUiIntroductionMp());
UserInfoNew userInfo = userMap.get(themeQo.getAuthorId());
themeQo.setNickName(userInfo.getNickName());
themeQo.setUserImg(userInfo.getHeadImageUrl());
themeQo.setUserIntroduction(userInfo.getIntroduction());
themeQo.setUserType(userInfo.getUserType());
themeQo.setLevelGrade(userInfo.getLevelGrade());
themeQo.setUserInvestorType(userInfo.getUserInvestorType());
themeQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
themeQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
}
if (themeQo.getContent() == null) {
continue;
......
......@@ -49,7 +49,7 @@ public class ESHelper {
req.source(json, XContentType.JSON);
IndexResponse resp = client.index(req, RequestOptions.DEFAULT);
validStatus(resp.status(), RestStatus.CREATED);
validStatus(resp.status(), RestStatus.CREATED, RestStatus.OK);
} catch (IOException e) {
log.error("ES Helper error:{}", ExceptionUtils.getStackTrace(e));
}
......@@ -64,7 +64,7 @@ public class ESHelper {
req.source(data);
IndexResponse resp = client.index(req, RequestOptions.DEFAULT);
validStatus(resp.status(), RestStatus.CREATED);
validStatus(resp.status(), RestStatus.OK);
} catch (IOException e) {
log.error("ES Helper error:{}", ExceptionUtils.getStackTrace(e));
}
......@@ -86,12 +86,13 @@ public class ESHelper {
}
private void validStatus(RestStatus status, RestStatus expect) {
if (status != expect) {
private void validStatus(RestStatus status, RestStatus... expect) {
for (RestStatus ex : expect) {
if (ex == status) return;
}
log.error("ES Helper fail! status:{}", status.toString());
throw new RuntimeException("ES fail");
}
}
......@@ -111,11 +112,14 @@ public class ESHelper {
public static void main(String[] args) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("1", "2"));
RestClientBuilder builder = RestClient.builder(new HttpHost("42.194.224.208", 9200))
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder;
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
});
......@@ -128,29 +132,30 @@ public class ESHelper {
System.out.println("insert");
Map<String, Object> map = new HashMap<>();
map.put("name", "小行星2");
map.put("context", "这里有一个小行星2");
// helper.insert("test_index", "2", map);
map.put("name", "太阳44444444444444");
map.put("context", "这里有一个小太阳444444444");
// helper.insert("test_index", "", "2", map);
SearchSourceBuilder search = new SearchSourceBuilder();
BoolQueryBuilder boolQb = QueryBuilders.boolQuery();
MatchQueryBuilder matchQb = QueryBuilders.matchQuery("context", "星");
MatchQueryBuilder matchQb = QueryBuilders.matchQuery("textContent", "小星星");
boolQb.must(matchQb);
String[] includes = new String[]{"id"};
String[] excludes = new String[]{};
search.query(boolQb).fetchSource(includes, excludes).from(0).size(50);
// String[] includes = new String[]{"id"};
// String[] excludes = new String[]{};
search.query(boolQb).from(0).size(50);
SearchHit[] hits = helper.selectLike("test_index", search);
SearchHit[] hits = helper.selectLike("theme", search);
System.out.println(hits.length);
for (SearchHit hit : hits) {
System.out.println(hit.toString());
System.out.println(hit.getFields());
}
System.out.println("done");
}
......
package com.tanpu.community.service.base;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.ESThemeQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.model.ESWrapper;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -18,6 +22,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ESService {
......@@ -26,7 +31,13 @@ public class ESService {
private static final String INDEX_THEME = "theme";
public void insertTheme(ESThemeQo qo) {
public void insertOrUpdateThemes(List<ESThemeQo> qos) {
for (ESThemeQo qo : qos) {
insertOrUpdateTheme(qo);
}
}
// 只要设置了_id,则直接覆盖
public void insertOrUpdateTheme(ESThemeQo qo) {
helper.insert(INDEX_THEME, String.valueOf(qo.themeType), qo.themeId, JSON.toJSONString(qo));
}
......@@ -34,7 +45,7 @@ public class ESService {
SearchSourceBuilder search = new SearchSourceBuilder();
BoolQueryBuilder boolQb = QueryBuilders.boolQuery();
MatchQueryBuilder contentQb = QueryBuilders.matchQuery("content", keyword);
MatchQueryBuilder contentQb = QueryBuilders.matchQuery("textContent", keyword);
MatchQueryBuilder titleQb = QueryBuilders.matchQuery("title", keyword);
boolQb.should(contentQb);
boolQb.should(titleQb);
......@@ -42,10 +53,11 @@ public class ESService {
String[] includes = new String[]{"id", "themeId", "createTime"};
String[] excludes = new String[]{};
search.query(boolQb).fetchSource(includes, excludes).sort("createTime", SortOrder.DESC).from(from).size(size);
search.query(boolQb).sort("createTime", SortOrder.DESC).from(from).size(size);
SearchHit[] hits = helper.selectLike(INDEX_THEME, search);
return Arrays.stream(hits).map(h -> {
return JSON.parseObject(h.toString(), ESThemeQo.class);
return JsonUtil.toBean(h.getSourceAsString(), ESThemeQo.class);
}).collect(Collectors.toList());
}
}
......@@ -16,6 +16,9 @@ import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.TemporalField;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -57,6 +60,33 @@ public class ConvertUtil {
return themeEntities.stream().map(ConvertUtil::themeEntityToQo).collect(Collectors.toList());
}
public static ESThemeQo convert(ThemeEntity entity) {
ESThemeQo qo = new ESThemeQo();
BeanUtils.copyProperties(entity, qo);
// 抽取文本内容
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(entity.getContent(), new TypeReference<List<ThemeContentQo>>() {});
StringBuilder sb = new StringBuilder();
themeContentQos.stream().filter(q -> {
// todo enum
return q.getType().equals("108");
}).forEach(q -> {
sb.append(q.getValue());
});
qo.textContent = sb.toString();
Long now = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
if (entity.getCreateTime() == null) {
qo.setCreateTime(now);
qo.setUpdateTime(now);
} else {
qo.setCreateTime(entity.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
qo.setUpdateTime(now);
}
return qo;
}
public static TopicDTO topicEntityToDTO(TopicEntity topicEntity) {
TopicDTO topicDTO = new TopicDTO();
......
package com.tanpu.community.util;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tencentcloudapi.cms.v20190321.CmsClient;
import com.tencentcloudapi.cms.v20190321.models.ImageModerationRequest;
import com.tencentcloudapi.cms.v20190321.models.ImageModerationResponse;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.tms.v20200713.TmsClient;
import com.tencentcloudapi.tms.v20200713.models.TextModerationRequest;
import com.tencentcloudapi.tms.v20200713.models.TextModerationResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
/**
* 腾讯云工具类
*/
@Slf4j
@Configuration
public class TencentcloudUtils {
/**
* 腾讯云的SecretId
*/
private static String secretId;
/**
* 腾讯云的SecretKey
*/
private static String secretKey;
/**
* 腾讯云地区
*/
private static String region;
private static TmsClient tmsClient;
private static CmsClient cmsClient;
@Value("${tencent.cloud.secretId}")
public void setSecretId(String secretId) {
TencentcloudUtils.secretId = secretId;
}
@Value("${tencent.cloud.secretKey}")
public void setSecretKey(String secretKey) {
TencentcloudUtils.secretKey = secretKey;
}
@Value("${tencent.cloud.region}")
public void setRegion(String region) {
TencentcloudUtils.region = region;
}
public static TmsClient getTmsClient() {
if (tmsClient == null) {
tmsClient = new TmsClient(new Credential(secretId, secretKey), region);
}
return tmsClient;
}
public static CmsClient getCmsClient() {
if (cmsClient == null) {
cmsClient = new CmsClient(new Credential(secretId, secretKey), region);
}
return cmsClient;
}
/**
* 文本内容安全
*
* @param text
* @return
*/
public static CommonResp 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")) {
// TODO: 2021/7/20
return CommonResp.error();
// return CommonResp.error(CommonResp.CONTENT_ILLEGAL, getTextLabel(res.getLabel(), res.getKeywords()));
}
} catch (TencentCloudSDKException e) {
log.error("调用腾文本内容安全异常");
e.printStackTrace();
return CommonResp.failed("文本检查异常");
}
return CommonResp.success();
}
/**
* 图片内容检测
*
* @param imageUrl
* @return
*/
public static CommonResp imageModeration(String imageUrl) {
ImageModerationRequest req = new ImageModerationRequest();
req.setFileUrl(imageUrl);
ImageModerationResponse res = null;
try {
res = getCmsClient().ImageModeration(req);
if (res.getData() != null && res.getData().getEvilType() != 100) {
return CommonResp.error(ErrorCodeConstant.CONTENT_ILLEGAL, getImageLabel(res.getData().getEvilType()));
}
} catch (TencentCloudSDKException e) {
log.error("调用腾讯图片内容检测异常");
e.printStackTrace();
return CommonResp.failed("图片检查异常");
}
return CommonResp.success();
}
public static void main(String[] args) {
final Base64.Encoder encoder = Base64.getEncoder();
Credential cred = new Credential("AKIDTjjV2IhK4ZKBm8z5g14vPedNSJuFnTIq", "PaVBZfeQwDVXKr7TZOzM6c9VZNwGJGyA");
TmsClient client = new TmsClient(cred, "ap-shanghai");
CmsClient cmsClient = new CmsClient(cred, "ap-shanghai");
TextModerationRequest req = new TextModerationRequest();
req.setContent(encoder.encodeToString("卖毒品".getBytes(StandardCharsets.UTF_8)));
ImageModerationRequest imgReq = new ImageModerationRequest();
imgReq.setFileUrl("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.08lr.cn%2Fuploads%2Fallimg%2F170513%2F1-1F513164126.jpg&refer=http%3A%2F%2Fwww.08lr.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1617540249&t=2506e9bd61a31ea3bf89d07f4fe49744");
try {
TextModerationResponse res = client.TextModeration(req);
ImageModerationResponse imgRes = cmsClient.ImageModeration(imgReq);
System.out.println(Arrays.toString(res.getKeywords()));
System.out.println(imgRes.getData());
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getTextLabel(String label, String[] keywords) {
StringBuilder message = new StringBuilder("该内容包含");
if (label.equals("Porn")) {
message.append("色情");
} else if (label.equals("Abuse")) {
message.append("谩骂");
} else if (label.equals("Ad")) {
message.append("广告");
} else if (label.equals("Polity")) {
message.append("政治");
} else if (label.equals("Illegal")) {
message.append("违法");
}
message.append("等敏感词");
if (keywords != null && keywords.length > 0) {
message.append(" ");
message.append(Arrays.toString(keywords));
}
return message.toString();
}
public static String getImageLabel(Long label) {
StringBuilder message = new StringBuilder("该图片可能包含");
if (label.equals(20002)) {
message.append("色情");
} else if (label.equals(20007)) {
message.append("谩骂");
} else if (label.equals(20001) || label.equals(24001)) {
message.append("政治");
} else if (label.equals(20006)) {
message.append("违法");
} else if (label.equals(20103)) {
message.append("性感");
}
message.append("敏感内容");
return message.toString();
}
}
apollo.bootstrap.enabled: false
#app.id: tanpu-community
......@@ -98,3 +97,9 @@ es:
port: 9200
userName: 1
userPasswd: 2
tencent:
cloud:
secretId: AKIDTjjV2IhK4ZKBm8z5g14vPedNSJuFnTIq
secretKey: PaVBZfeQwDVXKr7TZOzM6c9VZNwGJGyA
region: ap-shanghai
\ No newline at end of file
......@@ -5,6 +5,7 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.user.UserInfoEntity">
<id column="id" property="id" />
<result column="user_type" property="userType" />
<result column="ui_openid" property="uiOpenid" />
<result column="ui_unionId" property="uiUnionid" />
<result column="ui_telphone" property="uiTelphone" />
......
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