Commit c4ae9478 authored by 张辰's avatar 张辰

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

# Conflicts:
#	community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
parents 09525de6 3a21d0b1
......@@ -11,9 +11,6 @@ import java.util.List;
@ApiModel("评论对象")
public class CommentQo {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "uuid")
private String commentId;
......
......@@ -2,24 +2,23 @@ package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ThemeAnalysDO {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "UUID")
@ApiModelProperty(value = "主题Id")
private String themeId;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "类型")
private Integer themeType;
@ApiModelProperty(value = "文本内容")
private String content;
@ApiModelProperty(value = "作者id")
private String authorId;
......@@ -38,7 +37,21 @@ public class ThemeAnalysDO {
@ApiModelProperty(value = "点赞量")
private Integer likeCount;
@ApiModelProperty(value = "收藏量")
private Integer collectCount;
@ApiModelProperty(value = "收藏量")
private Integer viewCount;
@ApiModelProperty(value = "距今时间")
private Long timeTillNow;
private Long minuteTillNow;
public Double getRank(){
double p = (double) (viewCount + forwardCount + commentCount + likeCount + collectCount);
double t = Double.valueOf(minuteTillNow);
double g =1.8;
double rank=(p)/Math.pow(t+2,g);
return rank;
}
}
......@@ -28,6 +28,6 @@ public class TopicHotQo {
* @return
*/
public Integer getRank(){
return this.viewCount+this.disscussCount*5;
return this.viewCount+this.disscussCount*3;
}
}
......@@ -15,10 +15,10 @@ import java.util.List;
* @create: 2021-07-15 14:37
**/
@Data
@Builder
@ApiModel(description = "用户信息 圈子使用")
public class UserInfoNew implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主页等级 1普通主页 2首席投顾主页 3机构主页")
private Integer personalCenterType;
......@@ -85,59 +85,11 @@ public class UserInfoNew implements Serializable {
private String workshopIntroduction;//工作室简介
//↓↓↓↓↓首席投顾↓↓↓↓↓↓
@ApiModelProperty(value = "姓名")
private String userName;
@ApiModelProperty(value = "头像背图url")
private String backImageUrl;
@ApiModelProperty(value = "是否展示专访视频 0不展示 1展示")
private Integer interviewVideoIsShow;
@ApiModelProperty(value = "专访视频 标题")
private String interviewVideoTitle;
@ApiModelProperty(value = "专访视频 url")
private String interviewVideoUrl;
@ApiModelProperty(value = "个人简介")
private String personalProfile;
@ApiModelProperty(value = "管理规模")
private String managementScale;
@ApiModelProperty(value = "从业年限 (单位:年)")
private String workingYears;
@ApiModelProperty(value = "投资理念")
private String investmentPhilosophy;
@ApiModelProperty(value = "擅长领域")
private String areasOfExpertise;
@ApiModelProperty(value = "证书 json")
private String credentials;
@ApiModelProperty(value = "成功案例客户id")
private String clientId;
//↓↓↓↓ 机构 ↓↓↓↓
@ApiModelProperty(value = "申请用户id")
private String applyUserId;
@ApiModelProperty(value = "机构id")
private String userIdOrg;
@ApiModelProperty(value = "公司名称")
private String companyName;
@ApiModelProperty(value = "公司全称")
private String companyFullName;
@ApiModelProperty(value = "营业执照账号")
private String businessLicenseNumber;
@ApiModelProperty(value = "营业执照 图片url")
private String businessLicenseImageUrl;
@ApiModelProperty(value = "机构用户身份公函 url")
private String identityLetterUrl;
@ApiModelProperty(value = "机构认证信息登记表 url")
private String orgAuthInfoFormUrl;
@ApiModelProperty(value = "运营人员 职位")
private String position;
@ApiModelProperty(value = "审核状态 1初始提交 2审核不通过 3审核通过")
private Integer auditStatus;
@ApiModelProperty(value = "认证名称")
private String certName;
@ApiModelProperty(value = "是否匹配现有基金公司 0不匹配 1匹配")
private Integer isExistOrg;
@ApiModelProperty(value = "所属基金公司id")
private String belongOrgId;
@ApiModelProperty(value = "所属基金公司类型 0公募 1私募")
private Integer belongOrgType;
@ApiModelProperty(value = "首席投顾")
private UserInfoNewChief userInfoNewChief;
//↓↓↓↓↓机构用户信息↓↓↓↓↓↓
@ApiModelProperty(value = "机构用户信息")
private UserInfoNewOrg userInfoNewOrg;
}
\ No newline at end of file
package com.tanpu.community.api.beans.vo.feign.fatools;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 用户信息 圈子使用
* @author: zejia zj wu
* @create: 2021-07-15 14:37
**/
@Data
@Builder
@ApiModel(description = "用户信息 首席投顾专用信息")
public class UserInfoNewChief implements Serializable {
private static final long serialVersionUID = 1L;
//↓↓↓↓↓首席投顾↓↓↓↓↓↓
@ApiModelProperty(value = "姓名")
private String userName;
@ApiModelProperty(value = "头像背图url")
private String backImageUrl;
@ApiModelProperty(value = "是否展示专访视频 0不展示 1展示")
private Integer interviewVideoIsShow;
@ApiModelProperty(value = "专访视频 标题")
private String interviewVideoTitle;
@ApiModelProperty(value = "专访视频 url")
private String interviewVideoUrl;
@ApiModelProperty(value = "个人简介")
private String personalProfile;
@ApiModelProperty(value = "管理规模")
private String managementScale;
@ApiModelProperty(value = "从业年限 (单位:年)")
private String workingYears;
@ApiModelProperty(value = "投资理念")
private String investmentPhilosophy;
@ApiModelProperty(value = "擅长领域")
private String areasOfExpertise;
@ApiModelProperty(value = "证书 json")
private String credentials;
@ApiModelProperty(value = "成功案例客户id")
private String clientId;
}
\ No newline at end of file
package com.tanpu.community.api.beans.vo.feign.fatools;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 用户信息 机构
* @author: zejia zj wu
* @create: 2021-07-15 14:37
**/
@Data
@Builder
@ApiModel(description = "用户信息 机构")
public class UserInfoNewOrg implements Serializable {
private static final long serialVersionUID = 1L;
//↓↓↓↓ 机构 ↓↓↓↓
@ApiModelProperty(value = "申请用户id")
private String applyUserId;
@ApiModelProperty(value = "机构id")
private String userIdOrg;
@ApiModelProperty(value = "公司名称")
private String companyName;
@ApiModelProperty(value = "公司全称")
private String companyFullName;
@ApiModelProperty(value = "营业执照账号")
private String businessLicenseNumber;
@ApiModelProperty(value = "营业执照 图片url")
private String businessLicenseImageUrl;
@ApiModelProperty(value = "机构用户身份公函 url")
private String identityLetterUrl;
@ApiModelProperty(value = "机构认证信息登记表 url")
private String orgAuthInfoFormUrl;
@ApiModelProperty(value = "运营人员 职位")
private String position;
@ApiModelProperty(value = "审核状态 1初始提交 2审核不通过 3审核通过")
private Integer auditStatus;
@ApiModelProperty(value = "认证名称")
private String certName;
@ApiModelProperty(value = "是否匹配现有基金公司 0不匹配 1匹配")
private Integer isExistOrg;
@ApiModelProperty(value = "所属基金公司id")
private String belongOrgId;
@ApiModelProperty(value = "所属基金公司类型 0公募 1私募")
private Integer belongOrgType;
}
\ No newline at end of file
package com.tanpu.community.api.enums;
public enum StatusEnum {
TRUE(1,true),FALSE(0,false);
private Integer code;
private boolean status;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
StatusEnum(Integer code, boolean status) {
this.code = code;
this.status = status;
}
}
......@@ -2,10 +2,16 @@ package com.tanpu.community.api.enums;
public enum TopicStatusEnum {
TRUE(1,true),FALSE(0,false);
HOTTEST(1,"最热"),
NEWEST(2,"最新");;
private Integer code;
private boolean status;
private String type;
TopicStatusEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
public Integer getCode() {
return code;
......@@ -15,18 +21,11 @@ public enum TopicStatusEnum {
this.code = code;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
public String getType() {
return type;
}
TopicStatusEnum(Integer code, boolean status) {
this.code = code;
this.status = status;
public void setType(String type) {
this.type = type;
}
}
......@@ -52,16 +52,6 @@ public class ThemeController {
return CommonResp.success(result);
}
@AuthLogin
@ApiOperation("主题搜索")
@PostMapping(value = "/search")
@ResponseBody
public CommonResp<List<ThemeQo>> searchInterestList(@Validated @RequestBody ThemeSearchReq req) {
String userId = userHolder.getUserId();
List<ThemeQo> result = themeManager.searchThemes(req, userId);
return CommonResp.success(result);
}
@AuthLogin
@ApiOperation("主题正文")
@GetMapping(value = "/detail")
......@@ -146,4 +136,12 @@ public class ThemeController {
return CommonResp.success(themeManager.getFollowUpdateCount(userId));
}
}
@AuthLogin
@GetMapping(value = "/test")
@ResponseBody
public CommonResp<Integer> test() {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.getFollowUpdateCount(userId));
}
}
......@@ -21,13 +21,13 @@ public class CodeAutoGenerator {
String author = "xudong";
String mysqlUserName = "dev";
String mysqlPassword = "qimeng123";
String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_user";
String[] tables = new String[]{"user_info"};
String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_community";
String[] tables = new String[]{"visit_summary"};
// String[] tables = new String[]{"follow_rel", "black_list","collection","comment","follow_rel","file_record","home_page","theme","topic","theme_attachment"};
String basePackage = "com.tanpu.community";
String mapperPackage = "dao.mapper.user";
String entityPackage = "dao.entity.user";
String xmlPath = "D:\\IdeaProjects\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\user";
String mapperPackage = "dao.mapper.community";
String entityPackage = "dao.entity.community";
String xmlPath = "D:\\IdeaProjects\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\community";
AutoGenerator autoGenerator = new AutoGenerator();
//全局配置
GlobalConfig gc = new GlobalConfig();
......
......@@ -36,6 +36,13 @@ public class FeignBackClientForCourse implements FallbackFactory<FeignClientForC
log.error("FeignClientForCourse.getCoursePackageDetailInfo-查询课程包id:{}", id);
return CommonResp.failed("调用getCoursePackageDetailInfo失败");
}
@Override
public CommonResp<Integer> getStudyCourseCount(String userId) {
log.error("请求信息", throwable);
log.error("FeignClientForCourse.getStudyCourseCount-查询userid:{}", userId);
return CommonResp.failed("调用getStudyCourseCount失败");
}
};
}
}
......@@ -4,7 +4,6 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.course.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.feign.product.FeignBackClientForProducts;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -14,8 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "${tamp-course-order-svc:}")
@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://172.20.1.249:8060/course")
@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://tp-course-svc", path = "/course")
//@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://172.20.1.249:8060/course")
public interface FeignClientForCourse {
......@@ -33,4 +32,8 @@ public interface FeignClientForCourse {
@ApiOperation("详情页信息")
@GetMapping("/course/detail")
CommonResp<CoursePackageDetail> getCoursePackageDetailInfo(@ApiParam(value = "课程包id", required = true) @RequestParam("id") String id);
@ApiOperation("查询已学习课程包总数")
@GetMapping("/course/getStudyCourseCount")
CommonResp<Integer> getStudyCourseCount(@ApiParam(value = "用户id") @RequestParam(value = "userId",required = false) String userId);
}
......@@ -2,10 +2,6 @@ package com.tanpu.community.feign.diagnose;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.resp.Customer;
import com.tanpu.community.api.beans.vo.feign.course.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.course.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.feign.product.FeignBackClientForProducts;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -15,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, url = "${tamp-diagnose-svc:}")
@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, path = "http://172.20.1.249:8201/diagnose")
@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, url = "http://tp-diagnose-svc", path = "/diagnose")
//@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, path = "http://172.20.1.249:8201/diagnose")
public interface FeignClientForDiagnose {
@ApiOperation("查询理财师关联客户信息")
......
......@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.beans.vo.feign.user.FileQueryResp;
import com.tanpu.community.api.beans.vo.feign.user.UserInfoVo;
import com.tanpu.community.feign.diagnose.FeignBackClientForDiagnose;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -16,7 +17,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
@FeignClient(value = "fatools", fallbackFactory = FeignbackForFatools.class, url = "http://tp-fatools-svc/fatools")
@FeignClient(value = "fatools", contextId = "fatools", fallbackFactory = FeignbackForFatools.class, url = "http://tp-fatools-svc", path = "/fatools")
//@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public interface FeignClientForFatools {
......
......@@ -2,6 +2,7 @@ package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
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;
......@@ -10,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-product", url = "${tanpu.feo-product.svc:}", fallbackFactory = FeignBackClientForProducts.class, path = "/product")
@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://172.20.0.68:8194/product")
@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://tp-product-svc", path = "/product")
//@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://172.20.0.68:8194/product")
public interface FeignClientForProducts {
@ApiOperation("获取产品详情")
......
......@@ -11,7 +11,8 @@ 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", path = "/fund")
@FeignClient(value = "service-fund", contextId = "fund", fallbackFactory = FeignbackForFund.class, url = "http://tp-fund-svc", path = "/fund")
//@FeignClient(value = "service-fund", path = "/fund")
public interface FeignForFund {
@ApiOperation("获取产品详情")
......
......@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-fundpublic", url = "http://127.0.0.1:8194/fundpublic")
@FeignClient(value = "service-fundpublic",path = "/fundpublic")
@FeignClient(value = "service-fundpublic", contextId = "fundpublic", fallbackFactory = FeignbackForPublicFund.class, url = "http://tp-fundpublic-svc", path = "/fundpublic")
//@FeignClient(value = "service-fundpublic",path = "/fundpublic")
public interface FeignForPublicFund {
@ApiOperation("获取产品详情")
......
......@@ -31,12 +31,6 @@ public class FeignBackClientForTanpuroom implements FallbackFactory<FeignClientF
return null;
}
@Override
public CommonResp<Integer> myOrderCount(String userId) {
log.error("请求信息", throwable);
log.error("FeignBackClientForTanpuroom.myOrderCount-userId:{}", userId);
return null;
}
};
}
}
......@@ -4,6 +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;
......@@ -14,8 +15,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-tanpuroom", url = "${tanpu.feo-tanpuroom.svc:}", fallbackFactory = FeignBackClientForTanpuroom.class, path = "/tanpuroom")
@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://172.20.0.183:8086/tanpuroom")
@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://tp-tanpuroom-svc", path = "/tanpuroom")
//@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://172.20.0.183:8086/tanpuroom")
public interface FeignClientForTanpuroom {
......@@ -27,7 +28,4 @@ public interface FeignClientForTanpuroom {
@PostMapping(value = "/curriculumInfos/detail", produces = {"application/json"})
CommonResp<CurriculumDetailVo> queryCurriculumDetail(@RequestBody CurriCulumInfoDetailDto req);
@ApiOperation("已购总数")
@GetMapping("/my/order/count")
CommonResp<Integer> myOrderCount(@ApiParam(value = "userId", required = true) @RequestParam("userId") String userId);
}
......@@ -3,6 +3,7 @@ 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,7 +15,8 @@ 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", fallbackFactory = FeignbackForZhibo.class, url = "http://172.20.0.169:8183/zhibo")
@FeignClient(value = "service-zhibo", contextId = "zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://tp-zhibo-svc", path = "/zhibo")
//@FeignClient(value = "service-zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://172.20.0.169:8183/zhibo")
public interface FeignClientForZhibo {
@ApiOperation(value = "根据直播间id查询直播间信息")
......
package com.tanpu.community.manager;
import com.tanpu.community.service.RankService;
import com.tanpu.community.service.RedisService;
import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Slf4j
@Service
@Configuration
......@@ -21,6 +22,9 @@ public class ConJobManager {
@Autowired
private RedisService redisService;
@Autowired
private RankService rankService;
/**
* 定时统计 话题 访问数据,并刷到redis
*/
......@@ -30,4 +34,14 @@ public class ConJobManager {
Integer detailVisitTimes = visitSummaryService.queryTopicDetailVisit(topicId);
redisService.set("topicVisitorStats", detailVisitTimes);
}
/**
* 定时统计主题排行
*/
@Scheduled(cron = "0 */2 * * * ?")
public void themeRank() {
System.out.println(LocalDateTime.now());
rankService.rankThemes();
rankService.rankTopics();
}
}
......@@ -24,6 +24,7 @@ import com.tanpu.community.dao.mapper.fund.CompanyInfoMapper;
import com.tanpu.community.dao.mapper.fund.FundInfoMapper;
import com.tanpu.community.dao.mapper.jydb.MfAdvisorscalerankMapper;
import com.tanpu.community.dao.mapper.jydb.MfInvestadvisoroutlineMapper;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.diagnose.FeignClientForDiagnose;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
......@@ -46,9 +47,9 @@ import java.util.stream.Collectors;
@Service
public class HomePageManager {
@Autowired
@Resource
private FollowRelService followRelService;
@Autowired
@Resource
private UserInfoService userInfoService;
@Resource
private FeignClientForFatools feignClientForFatools;
......@@ -66,13 +67,14 @@ public class HomePageManager {
private FeignClientForTanpuroom feignClientForTanpuroom;
@Resource
private FeignClientForDiagnose feignClientForDiagnose;
@Resource
private FeignClientForCourse feignClientForCourse;
//查询 个人中心 相关信息
public UserInfoNew queryUsersListNew(String userIdMyself, String userId) {
CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (userInfoNewCommonResp.isNotSuccess()) new BizException("内部接口调用失败");
UserInfoNew userInfoNew = userInfoNewCommonResp.getData();
CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败");
UserInfoNew userInfoNew = queryUsersListNew.getData();
// 关注 按钮的显示逻辑
if (StringUtils.isNotBlank(userId)) { //查询别人的个人主页
userInfoNew.setIsShowFollowButton(0);
......@@ -97,37 +99,37 @@ public class HomePageManager {
// 首席投顾 添加专栏信息 (前端自己取)
// 成功案例客户
// 默认显示该投顾管理的客户里,总资产最高的客户
if (StringUtils.isBlank(userInfoNew.getClientId())) {
if (StringUtils.isBlank(userInfoNew.getUserInfoNewChief().getClientId())) {
List<Customer> customers = queryUserCustomerList(userId);
Optional<Customer> first = customers.stream().sorted(Comparator.comparing(Customer::getTotalMarket)).findFirst();
Optional<Customer> first = customers.stream().max(Comparator.comparing(Customer::getTotalMarket));
if (first.isPresent()) {
userInfoNew.setClientId(first.get().getUserId());
userInfoNew.getUserInfoNewChief().setClientId(first.get().getUserId());
} else {
userInfoNew.setClientId(null);
userInfoNew.getUserInfoNewChief().setClientId(null);
}
}
} else if (2 == userInfoNew.getUserType()){
// 机构账号
userInfoNew.setPersonalCenterType(3);
if (0 == userInfoNew.getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getBelongOrgId())){ // 公募
if (0 == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 公募
//设置 基金数
MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>()
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getBelongOrgId())
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
.last("limit 1"));
userInfoNew.setFundNumber(ObjectUtils.anyNotNull(mfAdvisorscalerank) ? mfAdvisorscalerank.getTotalfundn() : null);
//设置成立时间 和 备案编号(公募没有备案编号)
MfInvestadvisoroutline mfInvestadvisoroutline = mfInvestadvisoroutlineMapper.selectOne(new LambdaQueryWrapper<MfInvestadvisoroutline>()
.eq(MfInvestadvisoroutline::getInvestadvisorcode, userInfoNew.getBelongOrgId())
.eq(MfInvestadvisoroutline::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
.last("limit 1"));
userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null);
}
if(1 == userInfoNew.getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getBelongOrgId())){ // 私募
if(1 == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 私募
//设置 基金数
Integer integer = fundInfoMapper.selectCount(new LambdaQueryWrapper<FundInfo>().eq(FundInfo::getTrustId, userInfoNew.getBelongOrgId()));
Integer integer = fundInfoMapper.selectCount(new LambdaQueryWrapper<FundInfo>().eq(FundInfo::getTrustId, userInfoNew.getUserInfoNewOrg().getBelongOrgId()));
userInfoNew.setFundNumber(integer);
//设置成立时间 和 备案编号
CompanyInfo companyInfo = companyInfoMapper.selectById(userInfoNew.getBelongOrgId());
CompanyInfo companyInfo = companyInfoMapper.selectById(userInfoNew.getUserInfoNewOrg().getBelongOrgId());
if (ObjectUtils.anyNotNull(companyInfo)) {
userInfoNew.setFounded(companyInfo.getEstablishDate().getTime());
userInfoNew.setRecordNumber(companyInfo.getRegisterNumber());
......@@ -153,8 +155,8 @@ public class HomePageManager {
} else {
//普通主页
userInfoNew.setPersonalCenterType(1);
//设置课程数
CommonResp<Integer> integerCommonResp = feignClientForTanpuroom.myOrderCount(userId);
//设置课程数(学习数)
CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId);
if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData());
}
return userInfoNew;
......
......@@ -11,20 +11,13 @@ 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.api.enums.BlockTypeEnum;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.ThemeListTypeEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.cache.CacheGet;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.service.*;
import com.tanpu.community.service.BlackListService;
import com.tanpu.community.service.base.ESService;
import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.BeanUtils;
......@@ -67,6 +60,9 @@ public class ThemeManager {
@Autowired
private VisitSummaryService visitSummaryService;
@Autowired
private RankService rankService;
@Autowired
private ESService esService;
......@@ -103,6 +99,7 @@ public class ThemeManager {
themeEntity.setAuthorId(userId);
themeEntity.setContent(JsonUtil.toJson(req.getContent()));
if (StringUtils.isEmpty(req.getEditThemeId())) {
//新建
themeService.insertTheme(themeEntity);
......@@ -130,6 +127,7 @@ public class ThemeManager {
/**
* 返回主题列表
*
* @param req
* @param userId
* @return
......@@ -138,10 +136,10 @@ public class ThemeManager {
List<ThemeEntity> themeEntities = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
// TODO:推荐
themeEntities = themeService.selectExcludeUser(userId,req.getLastId(), req.getPageSize());
Set<String> recomondThemeIds;
Set<String> hotThemeIds;
Set<String> newThemeIds;
// themeEntities = themeService.selectExcludeUser(userId, req.getLastId(), req.getPageSize());
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100);
themeEntities = themeService.queryByThemeIdsExcludeUser( recommendThemeIds,userId, req.getLastId(), req.getPageSize());
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//根据关注列表查询
List<String> fansList = followRelService.queryFansByFollowerId(userId);
......@@ -162,7 +160,7 @@ public class ThemeManager {
public List<ThemeQo> searchThemes(ThemeSearchReq req, String userId) {
List<ThemeEntity> themeEntities= themeService.search(req.getKeyword(),req.getLastId(), req.getPageSize());
List<ThemeEntity> themeEntities = themeService.search(req.getKeyword(), req.getLastId(), req.getPageSize());
return convertEntityToQo(themeEntities, userId);
}
......@@ -205,6 +203,7 @@ public class ThemeManager {
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
......@@ -231,7 +230,6 @@ public class ThemeManager {
//查询正文
@CacheGet(prefix = "getThemeDetail", expireSeconds = 600)
public ThemeQo getDetail(String themeId, String userId) {
ThemeEntity themeEntity = themeService.queryByThemeId(themeId);
if (themeEntity == null) {
......@@ -365,7 +363,7 @@ public class ThemeManager {
private void buildFormerTheme(ThemeQo themeQo) {
String formerThemeId = themeQo.getFormerThemeId();
if (StringUtils.isNotEmpty(formerThemeId)) {
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId));
ThemeQo formerTheme = ConvertUtil.themeEntityToQo(themeService.queryByThemeId(formerThemeId));
if (formerTheme != null) {
//单个查询详情
......@@ -393,4 +391,6 @@ public class ThemeManager {
List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime);
}
}
package com.tanpu.community.manager;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.vo.TopicDTO;
import com.tanpu.community.api.beans.vo.TopicDataAnalysDTO;
import com.tanpu.community.api.beans.qo.TopicDetailQo;
import com.tanpu.community.api.beans.qo.TopicHotQo;
import com.tanpu.community.api.beans.qo.TopicTitileQo;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.api.beans.vo.TopicDTO;
import com.tanpu.community.api.beans.vo.TopicDataAnalysDTO;
import com.tanpu.community.api.constants.RedisKeyConstant;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.dao.entity.community.TopicEntity;
......@@ -22,7 +22,6 @@ import org.springframework.stereotype.Service;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class TopicManager {
......@@ -44,6 +43,8 @@ public class TopicManager {
@Autowired
private VisitSummaryService visitSummaryService;
@Autowired
private RankService rankService;
//新增话题
public void insertTopic(String topicTitle, String userId) {
......@@ -106,25 +107,11 @@ public class TopicManager {
public List<TopicHotQo> getHotTopicTitles() {
List<TopicEntity> topicEntities = topicService.queryAll();
List<TopicHotQo> topicHotQos = ConvertUtil.topicEntityToHotQos(topicEntities);
for (TopicHotQo topic : topicHotQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
//浏览量
Integer topicPV = visitSummaryService.queryTopicDetailVisit(topic.getTopicId());
Integer themePV = visitSummaryService.queryThemeVisit(themeIds);
topic.setViewCount(topicPV + themePV);
//讨论数=发布主题贴数+回复总数
Integer commentCount = commentService.getCommentCountByThemeIds(themeIds);
topic.setDisscussCount(themeIds.size() + commentCount);
List<TopicHotQo> rankTopicList = rankService.rankTopicList;
if (rankTopicList.size()==0){
rankService.rankTopics();
}
topicHotQos.stream().collect(Collectors.toMap(TopicHotQo::getRank, o->o));
//TODO 添加类型:热 新 顶
topicHotQos.get(0).setType(1);
topicHotQos.get(2).setType(2);
return topicHotQos;
return rankService.rankTopicList;
}
public void setTopTopic(String topicId, boolean setTop) {
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity;
......@@ -96,7 +95,8 @@ public class CollectionService {
queryCollection.setUncollectionTime(LocalDateTime.now());
collectionMapper.updateById(queryCollection);
} else {
throw new BizException("Collection对象未找到,themeId:" + themeId + ",userId:" + userId + ",type:" + type.getCode());
// throw new BizException("Collection对象未找到,themeId:" + themeId + ",userId:" + userId + ",type:" + type.getCode());
return;
}
}
}
......@@ -5,7 +5,7 @@ import com.tanpu.common.exception.BizException;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.api.enums.StatusEnum;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.mapper.community.CommentMapper;
import org.apache.commons.collections4.CollectionUtils;
......@@ -66,7 +66,7 @@ public class CommentService {
LambdaQueryWrapper<CommentEntity> queryWrapper = new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getThemeId, themeId)
.eq(CommentEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.eq(CommentEntity::getIsBlock, TopicStatusEnum.FALSE.getCode())
.eq(CommentEntity::getIsBlock, StatusEnum.FALSE.getCode())
.orderByDesc(CommentEntity::getCreateTime);
if (parentId == null) {
queryWrapper.isNull(CommentEntity::getParentId);
......
package com.tanpu.community.service;
import com.tanpu.community.api.beans.qo.ThemeAnalysDO;
import com.tanpu.community.api.beans.qo.TopicHotQo;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.util.ConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class RankService {
@Autowired
private ThemeService themeService;
@Autowired
private CollectionService collectionService;
@Autowired
private CommentService commentService;
@Autowired
private TopicService topicService;
@Autowired
private VisitSummaryService visitSummaryService;
public List<String> rankThemeList = new ArrayList<>();
public List<TopicHotQo> rankTopicList = new ArrayList<>();
public void rankThemes() {
List<ThemeEntity> themeEntities = themeService.queryAll();
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId();
Integer likeCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME);
Integer bookCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.COLLECT_THEME);
Integer commentCount = commentService.getCommentCountByThemeId(themeId);
Integer forwardCount = themeService.getForwardCountById(themeId);
Integer viewCount = visitSummaryService.queryThemeVisit(themeId);
theme.setCommentCount(commentCount);
theme.setLikeCount(likeCount);
theme.setForwardCount(forwardCount);
theme.setCollectCount(bookCount);
theme.setViewCount(viewCount);
}
Map<ThemeAnalysDO, Double> map = themeAnalysDOS.stream().collect(Collectors.toMap(o -> o, ThemeAnalysDO::getRank));
rankThemeList = map.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).map(e -> e.getKey().getThemeId()).collect(Collectors.toList());
}
/**
* 计算话题热度
*
* @return
*/
public void rankTopics() {
List<TopicEntity> topicEntities = topicService.queryAll();
List<TopicHotQo> topicHotQos = ConvertUtil.topicEntityToHotQos(topicEntities);
if (topicHotQos.size() == 0) {
return;
}
for (TopicHotQo topic : topicHotQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
//浏览量
Integer topicPV = visitSummaryService.queryTopicDetailVisit(topic.getTopicId());
Integer themePV = visitSummaryService.queryThemeVisit(themeIds);
topic.setViewCount(topicPV + themePV);
//讨论数=发布主题贴数+回复总数
Integer commentCount = commentService.getCommentCountByThemeIds(themeIds);
topic.setDisscussCount(themeIds.size() + commentCount);
}
Map<TopicHotQo, Integer> map = topicHotQos.stream().collect(Collectors.toMap(o -> o, TopicHotQo::getRank));
List<TopicHotQo> rankList = map.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).map(e -> e.getKey()).limit(4).collect(Collectors.toList());
rankList.get(0).setType(TopicStatusEnum.HOTTEST.getCode());
rankTopicList = rankList;
return;
}
public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount) {
Set<String> hotThemeIds = this.rankThemeList.stream().limit(hotCount).collect(Collectors.toSet());
Set<String> newThemeIds = themeService.selectExcludeUser(null, null, newCount)
.stream().map(ThemeEntity::getThemeId).collect(Collectors.toSet());
hotThemeIds.addAll(newThemeIds);
return new ArrayList<>(hotThemeIds);
}
}
......@@ -40,6 +40,17 @@ public class ThemeService {
themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId));
}
/**
* 根据主题Id查询列表
* @return
*/
public List<ThemeEntity> queryAll() {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper);
}
//根据id返回主题详情(未删)
public ThemeEntity queryByThemeId(String themeId) {
return themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
......@@ -72,6 +83,9 @@ public class ThemeService {
//根据ids返回主题详情,带分页
public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize) {
if (CollectionUtils.isEmpty(themeIds)){
return Collections.emptyList();
}
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
......@@ -86,8 +100,15 @@ public class ThemeService {
return themeMapper.selectList(queryWrapper);
}
//根据ids返回主题详情
/**
* 根据主题Id查询列表
* @param themeIds
* @return
*/
public List<ThemeEntity> queryByThemeIds(List<String> themeIds) {
if (CollectionUtils.isEmpty(themeIds)){
return Collections.emptyList();
}
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
......@@ -95,8 +116,10 @@ public class ThemeService {
return themeMapper.selectList(queryWrapper);
}
/**
* 分页查询,非当前用户的主题
* 查询非传入作者的主题(可分页)
* @param lastId
* @param pageSize
* @param userId
......@@ -113,8 +136,42 @@ public class ThemeService {
if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
}
if (pageSize!=null){
queryWrapper.last("limit " + pageSize);
}
queryWrapper.orderByDesc(ThemeEntity::getId);
queryWrapper.orderByDesc(ThemeEntity::getCreateTime);
queryWrapper.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper);
}
/**
* 查询非传入作者的主题(可分页)
* @param lastId
* @param pageSize
* @param userId
* @return
*/
public List<ThemeEntity> queryByThemeIdsExcludeUser(List<String> themeIds,String userId,String lastId, Integer pageSize) {
if (CollectionUtils.isEmpty(themeIds)){
return Collections.emptyList();
}
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds);
if (!StringUtils.isEmpty(userId)){
queryWrapper.ne(ThemeEntity::getAuthorId,userId);
}
if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryByThemeId(lastId);
if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
}
if (pageSize!=null){
queryWrapper.last("limit " + pageSize);
}
queryWrapper.orderByDesc(ThemeEntity::getId);
queryWrapper.orderByDesc(ThemeEntity::getCreateTime);
queryWrapper.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
......@@ -122,7 +179,7 @@ public class ThemeService {
}
/**
* 根据条件查询最新主题
* 根据话题查询最新主题(可分页)
*
* @param topidId 话题Id
* @param lastId 查询此主题Id之前的主题
......@@ -157,7 +214,13 @@ public class ThemeService {
}
//关注的主题列表
/**
* 根据作者查询主题列表(可分页)
* @param userIds
* @param lastId
* @param pageSize
* @return
*/
public List<ThemeEntity> queryByUserIds(List<String> userIds, String lastId, Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getAuthorId, userIds);
......
......@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.api.enums.StatusEnum;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.mapper.community.TopicMapper;
import org.apache.commons.collections4.CollectionUtils;
......@@ -30,13 +30,15 @@ public class TopicService {
public List<TopicEntity> queryAll() {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(TopicEntity::getCreateTime));
}
public List<TopicEntity> queryByKeyword(String keyword) {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
.like(TopicEntity::getTopicTitle,keyword)
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
.like(TopicEntity::getTopicTitle, keyword)
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(TopicEntity::getCreateTime));
}
@Transactional
......@@ -44,8 +46,8 @@ public class TopicService {
TopicEntity entity = TopicEntity.builder()
.topicId(uuidGenHelper.getUuidStr())
.topicTitle(topicTitle)
.isTop(TopicStatusEnum.FALSE.getCode())
.isConceal(TopicStatusEnum.FALSE.getCode())
.isTop(StatusEnum.FALSE.getCode())
.isConceal(StatusEnum.FALSE.getCode())
.build();
topicMapper.insert(entity);
......@@ -54,41 +56,41 @@ public class TopicService {
public void updateTopicToTop(String topicId) {
TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsTop(TopicStatusEnum.TRUE.getCode());
topicEntity.setIsTop(StatusEnum.TRUE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId));
}
public void updateTopicNotTop(String topicId) {
TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsTop(TopicStatusEnum.FALSE.getCode());
topicEntity.setIsTop(StatusEnum.FALSE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId));
}
public void updateTopicToConceal(String topicId) {
TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsConceal(TopicStatusEnum.TRUE.getCode());
topicEntity.setIsConceal(StatusEnum.TRUE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId));
}
public void updateTopicNotConceal(String topicId) {
TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsConceal(TopicStatusEnum.FALSE.getCode());
topicEntity.setIsConceal(StatusEnum.FALSE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId));
}
public TopicEntity queryById(String topicId) {
return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId,topicId));
return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId, topicId));
}
public List<TopicEntity> queryByIds(List<String> topicIds) {
if (CollectionUtils.isEmpty(topicIds)){
if (CollectionUtils.isEmpty(topicIds)) {
return Collections.emptyList();
}
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId,topicIds));
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId, topicIds));
}
public void modifyViewCount(String topicId, long Count) {
......
......@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.springframework.beans.BeanUtils;
......@@ -19,6 +20,7 @@ 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;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -33,48 +35,29 @@ public class ConvertUtil {
BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
});
themeQO.setContent(themeContentQos);
return themeQO;
}
public static ThemeQo themeEntityToQo2(ThemeEntity themeEntity) {
public static ThemeAnalysDO themeEntityToAnalysDO(ThemeEntity themeEntity) {
if (themeEntity == null) {
return null;
}
ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
});
//首页列表使用,限制附件个数为1(1文本+1附件),-》已经改为全部返回
// if (themeContentQos != null && themeContentQos.size() > 2) {
// themeQO.setContent(themeContentQos.subList(0, 2));
// }else{
themeQO.setContent(themeContentQos);
// }
return themeQO;
ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
BeanUtils.copyProperties(themeEntity, themeAnalysDO);
themeAnalysDO.setMinuteTillNow(TimeUtil.calMinuteTillNow(themeEntity.getCreateTime()));
return themeAnalysDO;
}
public static ThemeEntity themeDTOToEntity(ThemeQo themeQO) {
ThemeEntity themeEntity = new ThemeEntity();
BeanUtils.copyProperties(themeQO, themeEntity);
return themeEntity;
public static List<ThemeAnalysDO> themeEntityToAnalysDOs(List<ThemeEntity> themeEntities) {
return themeEntities.stream().map(ConvertUtil::themeEntityToAnalysDO).collect(Collectors.toList());
}
/**
* 首页主题列表,限制附件个数为1(1文本+1附件)
*
* @param themeEntities
* @return
*/
public static List<ThemeQo> themeEntitiesToDTOs(List<ThemeEntity> themeEntities) {
return themeEntities.stream().map(ConvertUtil::themeEntityToQo2).collect(Collectors.toList());
return themeEntities.stream().map(ConvertUtil::themeEntityToQo).collect(Collectors.toList());
}
public static ESThemeQo convert(ThemeEntity entity) {
......@@ -114,10 +97,17 @@ public class ConvertUtil {
public static TopicHotQo topicEntityToHotQo(TopicEntity topicEntity) {
TopicHotQo topicHotQo = new TopicHotQo();
BeanUtils.copyProperties(topicEntity, topicHotQo);
//2小时内发帖,添加新话题标签
if(TimeUtil.calMinuteTillNow(topicEntity.getCreateTime())<120){
topicHotQo.setType(TopicStatusEnum.NEWEST.getCode());
}
return topicHotQo;
}
public static List<TopicHotQo> topicEntityToHotQos(List<TopicEntity> topicEntities) {
if (topicEntities==null){
return Collections.emptyList();
}
return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList());
}
......
......@@ -35,4 +35,10 @@ public class TimeUtil {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
//计算迄今时间
public static long calMinuteTillNow(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
return between.toMinutes();
}
}
......@@ -22,14 +22,6 @@ spring.datasource:
maxActive: 2
minIdle: 2
initialSize: 2
course:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_course?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
username: dev
password: qimeng123
maxActive: 2
minIdle: 2
initialSize: 2
user:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
......@@ -38,27 +30,19 @@ spring.datasource:
maxActive: 2
minIdle: 2
initialSize: 2
zhibo:
jydb:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_zhibo?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
jdbc-url: jdbc:mysql://47.101.189.151:31931/jydb?autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false
username: dev
password: qimeng123
maxActive: 2
minIdle: 2
initialSize: 2
jydb:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://tamper.mysql.polardb.rds.aliyuncs.com:3306/jydb?autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false
username: jydb
password: '@juyuan123'
maxActive: 2
minIdle: 2
initialSize: 2
fund:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://tamper.mysql.polardb.rds.aliyuncs.com:3306/tamp_fund?autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false
username: tamp
password: "@imeng123"
jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_fund?autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false
username: dev
password: qimeng123
maxActive: 2
minIdle: 2
initialSize: 2
......
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