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; ...@@ -11,9 +11,6 @@ import java.util.List;
@ApiModel("评论对象") @ApiModel("评论对象")
public class CommentQo { public class CommentQo {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "uuid") @ApiModelProperty(value = "uuid")
private String commentId; private String commentId;
......
...@@ -2,24 +2,23 @@ package com.tanpu.community.api.beans.qo; ...@@ -2,24 +2,23 @@ package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ThemeAnalysDO { public class ThemeAnalysDO {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "UUID") @ApiModelProperty(value = "主题Id")
private String themeId; private String themeId;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "类型")
private Integer themeType;
@ApiModelProperty(value = "文本内容")
private String content;
@ApiModelProperty(value = "作者id") @ApiModelProperty(value = "作者id")
private String authorId; private String authorId;
...@@ -38,7 +37,21 @@ public class ThemeAnalysDO { ...@@ -38,7 +37,21 @@ public class ThemeAnalysDO {
@ApiModelProperty(value = "点赞量") @ApiModelProperty(value = "点赞量")
private Integer likeCount; private Integer likeCount;
@ApiModelProperty(value = "收藏量")
private Integer collectCount;
@ApiModelProperty(value = "收藏量")
private Integer viewCount;
@ApiModelProperty(value = "距今时间") @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 { ...@@ -28,6 +28,6 @@ public class TopicHotQo {
* @return * @return
*/ */
public Integer getRank(){ public Integer getRank(){
return this.viewCount+this.disscussCount*5; return this.viewCount+this.disscussCount*3;
} }
} }
...@@ -15,10 +15,10 @@ import java.util.List; ...@@ -15,10 +15,10 @@ import java.util.List;
* @create: 2021-07-15 14:37 * @create: 2021-07-15 14:37
**/ **/
@Data @Data
@Builder
@ApiModel(description = "用户信息 圈子使用") @ApiModel(description = "用户信息 圈子使用")
public class UserInfoNew implements Serializable { public class UserInfoNew implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主页等级 1普通主页 2首席投顾主页 3机构主页") @ApiModelProperty("主页等级 1普通主页 2首席投顾主页 3机构主页")
private Integer personalCenterType; private Integer personalCenterType;
...@@ -85,59 +85,11 @@ public class UserInfoNew implements Serializable { ...@@ -85,59 +85,11 @@ public class UserInfoNew implements Serializable {
private String workshopIntroduction;//工作室简介 private String workshopIntroduction;//工作室简介
//↓↓↓↓↓首席投顾↓↓↓↓↓↓ //↓↓↓↓↓首席投顾↓↓↓↓↓↓
@ApiModelProperty(value = "姓名") @ApiModelProperty(value = "首席投顾")
private String userName; private UserInfoNewChief userInfoNewChief;
@ApiModelProperty(value = "头像背图url")
private String backImageUrl; //↓↓↓↓↓机构用户信息↓↓↓↓↓↓
@ApiModelProperty(value = "是否展示专访视频 0不展示 1展示") @ApiModelProperty(value = "机构用户信息")
private Integer interviewVideoIsShow; private UserInfoNewOrg userInfoNewOrg;
@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;
} }
\ 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; ...@@ -2,10 +2,16 @@ package com.tanpu.community.api.enums;
public enum TopicStatusEnum { public enum TopicStatusEnum {
TRUE(1,true),FALSE(0,false); HOTTEST(1,"最热"),
NEWEST(2,"最新");;
private Integer code; private Integer code;
private boolean status; private String type;
TopicStatusEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
public Integer getCode() { public Integer getCode() {
return code; return code;
...@@ -15,18 +21,11 @@ public enum TopicStatusEnum { ...@@ -15,18 +21,11 @@ public enum TopicStatusEnum {
this.code = code; this.code = code;
} }
public boolean isStatus() { public String getType() {
return status; return type;
}
public void setStatus(boolean status) {
this.status = status;
} }
TopicStatusEnum(Integer code, boolean status) { public void setType(String type) {
this.code = code; this.type = type;
this.status = status;
} }
} }
...@@ -52,16 +52,6 @@ public class ThemeController { ...@@ -52,16 +52,6 @@ public class ThemeController {
return CommonResp.success(result); 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 @AuthLogin
@ApiOperation("主题正文") @ApiOperation("主题正文")
@GetMapping(value = "/detail") @GetMapping(value = "/detail")
...@@ -146,4 +136,12 @@ public class ThemeController { ...@@ -146,4 +136,12 @@ public class ThemeController {
return CommonResp.success(themeManager.getFollowUpdateCount(userId)); 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 { ...@@ -21,13 +21,13 @@ public class CodeAutoGenerator {
String author = "xudong"; String author = "xudong";
String mysqlUserName = "dev"; String mysqlUserName = "dev";
String mysqlPassword = "qimeng123"; String mysqlPassword = "qimeng123";
String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_user"; String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_community";
String[] tables = new String[]{"user_info"}; 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[] 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 basePackage = "com.tanpu.community";
String mapperPackage = "dao.mapper.user"; String mapperPackage = "dao.mapper.community";
String entityPackage = "dao.entity.user"; String entityPackage = "dao.entity.community";
String xmlPath = "D:\\IdeaProjects\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\user"; String xmlPath = "D:\\IdeaProjects\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\community";
AutoGenerator autoGenerator = new AutoGenerator(); AutoGenerator autoGenerator = new AutoGenerator();
//全局配置 //全局配置
GlobalConfig gc = new GlobalConfig(); GlobalConfig gc = new GlobalConfig();
......
...@@ -36,6 +36,13 @@ public class FeignBackClientForCourse implements FallbackFactory<FeignClientForC ...@@ -36,6 +36,13 @@ public class FeignBackClientForCourse implements FallbackFactory<FeignClientForC
log.error("FeignClientForCourse.getCoursePackageDetailInfo-查询课程包id:{}", id); log.error("FeignClientForCourse.getCoursePackageDetailInfo-查询课程包id:{}", id);
return CommonResp.failed("调用getCoursePackageDetailInfo失败"); 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; ...@@ -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.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.course.CoursePackageDetail; import com.tanpu.community.api.beans.vo.feign.course.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -14,8 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -14,8 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; 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://tp-course-svc", path = "/course")
@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://172.20.1.249:8060/course")
public interface FeignClientForCourse { public interface FeignClientForCourse {
...@@ -33,4 +32,8 @@ public interface FeignClientForCourse { ...@@ -33,4 +32,8 @@ public interface FeignClientForCourse {
@ApiOperation("详情页信息") @ApiOperation("详情页信息")
@GetMapping("/course/detail") @GetMapping("/course/detail")
CommonResp<CoursePackageDetail> getCoursePackageDetailInfo(@ApiParam(value = "课程包id", required = true) @RequestParam("id") String id); 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; ...@@ -2,10 +2,6 @@ package com.tanpu.community.feign.diagnose;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.resp.Customer; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -15,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -15,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; 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, url = "http://tp-diagnose-svc", path = "/diagnose")
@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, path = "http://172.20.1.249:8201/diagnose")
public interface FeignClientForDiagnose { public interface FeignClientForDiagnose {
@ApiOperation("查询理财师关联客户信息") @ApiOperation("查询理财师关联客户信息")
......
...@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew; ...@@ -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.fatools.UserInfoOrg;
import com.tanpu.community.api.beans.vo.feign.user.FileQueryResp; import com.tanpu.community.api.beans.vo.feign.user.FileQueryResp;
import com.tanpu.community.api.beans.vo.feign.user.UserInfoVo; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -16,7 +17,7 @@ import java.util.List; ...@@ -16,7 +17,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; 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") //@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public interface FeignClientForFatools { public interface FeignClientForFatools {
......
...@@ -2,6 +2,7 @@ package com.tanpu.community.feign.product; ...@@ -2,6 +2,7 @@ package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -10,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -10,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; 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://tp-product-svc", 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://172.20.0.68:8194/product")
public interface FeignClientForProducts { public interface FeignClientForProducts {
@ApiOperation("获取产品详情") @ApiOperation("获取产品详情")
......
...@@ -11,7 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -11,7 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
//@FeignClient(value = "service-fund", url = "http://127.0.0.1:8194/fund") //@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 { public interface FeignForFund {
@ApiOperation("获取产品详情") @ApiOperation("获取产品详情")
......
...@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
//@FeignClient(value = "service-fundpublic", url = "http://127.0.0.1:8194/fundpublic") @FeignClient(value = "service-fundpublic", contextId = "fundpublic", fallbackFactory = FeignbackForPublicFund.class, url = "http://tp-fundpublic-svc", path = "/fundpublic")
@FeignClient(value = "service-fundpublic",path = "/fundpublic") //@FeignClient(value = "service-fundpublic",path = "/fundpublic")
public interface FeignForPublicFund { public interface FeignForPublicFund {
@ApiOperation("获取产品详情") @ApiOperation("获取产品详情")
......
...@@ -31,12 +31,6 @@ public class FeignBackClientForTanpuroom implements FallbackFactory<FeignClientF ...@@ -31,12 +31,6 @@ public class FeignBackClientForTanpuroom implements FallbackFactory<FeignClientF
return null; 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; ...@@ -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.CurriCulumInfoDetailDto;
import com.tanpu.community.api.beans.vo.feign.course.CurriculumDetailVo; import com.tanpu.community.api.beans.vo.feign.course.CurriculumDetailVo;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -14,8 +15,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -14,8 +15,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; 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://tp-tanpuroom-svc", 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://172.20.0.183:8086/tanpuroom")
public interface FeignClientForTanpuroom { public interface FeignClientForTanpuroom {
...@@ -27,7 +28,4 @@ public interface FeignClientForTanpuroom { ...@@ -27,7 +28,4 @@ public interface FeignClientForTanpuroom {
@PostMapping(value = "/curriculumInfos/detail", produces = {"application/json"}) @PostMapping(value = "/curriculumInfos/detail", produces = {"application/json"})
CommonResp<CurriculumDetailVo> queryCurriculumDetail(@RequestBody CurriCulumInfoDetailDto req); 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; ...@@ -3,6 +3,7 @@ package com.tanpu.community.feign.zhibo;
import com.tanpu.common.api.CommonResp; 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.ZhiboDetailVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp; 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.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -14,7 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -14,7 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
//@FeignClient(value = "service-zhibo", url = "${tanpu.feo-zhibo.svc:}", fallbackFactory = FeignbackForZhibo.class, path = "/zhibo") //@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 { public interface FeignClientForZhibo {
@ApiOperation(value = "根据直播间id查询直播间信息") @ApiOperation(value = "根据直播间id查询直播间信息")
......
package com.tanpu.community.manager; package com.tanpu.community.manager;
import com.tanpu.community.service.RankService;
import com.tanpu.community.service.RedisService; import com.tanpu.community.service.RedisService;
import com.tanpu.community.service.VisitSummaryService; import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; 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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Slf4j @Slf4j
@Service @Service
@Configuration @Configuration
...@@ -21,6 +22,9 @@ public class ConJobManager { ...@@ -21,6 +22,9 @@ public class ConJobManager {
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired
private RankService rankService;
/** /**
* 定时统计 话题 访问数据,并刷到redis * 定时统计 话题 访问数据,并刷到redis
*/ */
...@@ -30,4 +34,14 @@ public class ConJobManager { ...@@ -30,4 +34,14 @@ public class ConJobManager {
Integer detailVisitTimes = visitSummaryService.queryTopicDetailVisit(topicId); Integer detailVisitTimes = visitSummaryService.queryTopicDetailVisit(topicId);
redisService.set("topicVisitorStats", detailVisitTimes); 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; ...@@ -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.fund.FundInfoMapper;
import com.tanpu.community.dao.mapper.jydb.MfAdvisorscalerankMapper; import com.tanpu.community.dao.mapper.jydb.MfAdvisorscalerankMapper;
import com.tanpu.community.dao.mapper.jydb.MfInvestadvisoroutlineMapper; 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.diagnose.FeignClientForDiagnose;
import com.tanpu.community.feign.fatools.FeignClientForFatools; import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom; import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
...@@ -46,9 +47,9 @@ import java.util.stream.Collectors; ...@@ -46,9 +47,9 @@ import java.util.stream.Collectors;
@Service @Service
public class HomePageManager { public class HomePageManager {
@Autowired @Resource
private FollowRelService followRelService; private FollowRelService followRelService;
@Autowired @Resource
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Resource @Resource
private FeignClientForFatools feignClientForFatools; private FeignClientForFatools feignClientForFatools;
...@@ -66,13 +67,14 @@ public class HomePageManager { ...@@ -66,13 +67,14 @@ public class HomePageManager {
private FeignClientForTanpuroom feignClientForTanpuroom; private FeignClientForTanpuroom feignClientForTanpuroom;
@Resource @Resource
private FeignClientForDiagnose feignClientForDiagnose; private FeignClientForDiagnose feignClientForDiagnose;
@Resource
private FeignClientForCourse feignClientForCourse;
//查询 个人中心 相关信息 //查询 个人中心 相关信息
public UserInfoNew queryUsersListNew(String userIdMyself, String userId) { public UserInfoNew queryUsersListNew(String userIdMyself, String userId) {
CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself); CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (userInfoNewCommonResp.isNotSuccess()) new BizException("内部接口调用失败"); if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败");
UserInfoNew userInfoNew = userInfoNewCommonResp.getData(); UserInfoNew userInfoNew = queryUsersListNew.getData();
// 关注 按钮的显示逻辑 // 关注 按钮的显示逻辑
if (StringUtils.isNotBlank(userId)) { //查询别人的个人主页 if (StringUtils.isNotBlank(userId)) { //查询别人的个人主页
userInfoNew.setIsShowFollowButton(0); userInfoNew.setIsShowFollowButton(0);
...@@ -97,37 +99,37 @@ public class HomePageManager { ...@@ -97,37 +99,37 @@ public class HomePageManager {
// 首席投顾 添加专栏信息 (前端自己取) // 首席投顾 添加专栏信息 (前端自己取)
// 成功案例客户 // 成功案例客户
// 默认显示该投顾管理的客户里,总资产最高的客户 // 默认显示该投顾管理的客户里,总资产最高的客户
if (StringUtils.isBlank(userInfoNew.getClientId())) { if (StringUtils.isBlank(userInfoNew.getUserInfoNewChief().getClientId())) {
List<Customer> customers = queryUserCustomerList(userId); 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()) { if (first.isPresent()) {
userInfoNew.setClientId(first.get().getUserId()); userInfoNew.getUserInfoNewChief().setClientId(first.get().getUserId());
} else { } else {
userInfoNew.setClientId(null); userInfoNew.getUserInfoNewChief().setClientId(null);
} }
} }
} else if (2 == userInfoNew.getUserType()){ } else if (2 == userInfoNew.getUserType()){
// 机构账号 // 机构账号
userInfoNew.setPersonalCenterType(3); 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>() MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>()
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getBelongOrgId()) .eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
.last("limit 1")); .last("limit 1"));
userInfoNew.setFundNumber(ObjectUtils.anyNotNull(mfAdvisorscalerank) ? mfAdvisorscalerank.getTotalfundn() : null); userInfoNew.setFundNumber(ObjectUtils.anyNotNull(mfAdvisorscalerank) ? mfAdvisorscalerank.getTotalfundn() : null);
//设置成立时间 和 备案编号(公募没有备案编号) //设置成立时间 和 备案编号(公募没有备案编号)
MfInvestadvisoroutline mfInvestadvisoroutline = mfInvestadvisoroutlineMapper.selectOne(new LambdaQueryWrapper<MfInvestadvisoroutline>() MfInvestadvisoroutline mfInvestadvisoroutline = mfInvestadvisoroutlineMapper.selectOne(new LambdaQueryWrapper<MfInvestadvisoroutline>()
.eq(MfInvestadvisoroutline::getInvestadvisorcode, userInfoNew.getBelongOrgId()) .eq(MfInvestadvisoroutline::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
.last("limit 1")); .last("limit 1"));
userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null); 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); userInfoNew.setFundNumber(integer);
//设置成立时间 和 备案编号 //设置成立时间 和 备案编号
CompanyInfo companyInfo = companyInfoMapper.selectById(userInfoNew.getBelongOrgId()); CompanyInfo companyInfo = companyInfoMapper.selectById(userInfoNew.getUserInfoNewOrg().getBelongOrgId());
if (ObjectUtils.anyNotNull(companyInfo)) { if (ObjectUtils.anyNotNull(companyInfo)) {
userInfoNew.setFounded(companyInfo.getEstablishDate().getTime()); userInfoNew.setFounded(companyInfo.getEstablishDate().getTime());
userInfoNew.setRecordNumber(companyInfo.getRegisterNumber()); userInfoNew.setRecordNumber(companyInfo.getRegisterNumber());
...@@ -153,8 +155,8 @@ public class HomePageManager { ...@@ -153,8 +155,8 @@ public class HomePageManager {
} else { } else {
//普通主页 //普通主页
userInfoNew.setPersonalCenterType(1); userInfoNew.setPersonalCenterType(1);
//设置课程数 //设置课程数(学习数)
CommonResp<Integer> integerCommonResp = feignClientForTanpuroom.myOrderCount(userId); CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId);
if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData()); if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData());
} }
return userInfoNew; return userInfoNew;
......
...@@ -11,20 +11,13 @@ import com.tanpu.community.api.beans.req.theme.*; ...@@ -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.CreateThemeResp;
import com.tanpu.community.api.beans.resp.ThemeFullSearchResp; import com.tanpu.community.api.beans.resp.ThemeFullSearchResp;
import com.tanpu.community.api.enums.*; 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.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity; import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.service.*; import com.tanpu.community.service.*;
import com.tanpu.community.service.BlackListService;
import com.tanpu.community.service.base.ESService; import com.tanpu.community.service.base.ESService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -67,6 +60,9 @@ public class ThemeManager { ...@@ -67,6 +60,9 @@ public class ThemeManager {
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitSummaryService visitSummaryService;
@Autowired
private RankService rankService;
@Autowired @Autowired
private ESService esService; private ESService esService;
...@@ -103,6 +99,7 @@ public class ThemeManager { ...@@ -103,6 +99,7 @@ public class ThemeManager {
themeEntity.setAuthorId(userId); themeEntity.setAuthorId(userId);
themeEntity.setContent(JsonUtil.toJson(req.getContent())); themeEntity.setContent(JsonUtil.toJson(req.getContent()));
if (StringUtils.isEmpty(req.getEditThemeId())) { if (StringUtils.isEmpty(req.getEditThemeId())) {
//新建 //新建
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
...@@ -130,6 +127,7 @@ public class ThemeManager { ...@@ -130,6 +127,7 @@ public class ThemeManager {
/** /**
* 返回主题列表 * 返回主题列表
*
* @param req * @param req
* @param userId * @param userId
* @return * @return
...@@ -138,10 +136,10 @@ public class ThemeManager { ...@@ -138,10 +136,10 @@ public class ThemeManager {
List<ThemeEntity> themeEntities = new ArrayList<>(); List<ThemeEntity> themeEntities = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
// TODO:推荐 // TODO:推荐
themeEntities = themeService.selectExcludeUser(userId,req.getLastId(), req.getPageSize()); // themeEntities = themeService.selectExcludeUser(userId, req.getLastId(), req.getPageSize());
Set<String> recomondThemeIds; List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100);
Set<String> hotThemeIds; themeEntities = themeService.queryByThemeIdsExcludeUser( recommendThemeIds,userId, req.getLastId(), req.getPageSize());
Set<String> newThemeIds;
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//根据关注列表查询 //根据关注列表查询
List<String> fansList = followRelService.queryFansByFollowerId(userId); List<String> fansList = followRelService.queryFansByFollowerId(userId);
...@@ -162,7 +160,7 @@ public class ThemeManager { ...@@ -162,7 +160,7 @@ public class ThemeManager {
public List<ThemeQo> searchThemes(ThemeSearchReq req, String userId) { 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); return convertEntityToQo(themeEntities, userId);
} }
...@@ -205,6 +203,7 @@ public class ThemeManager { ...@@ -205,6 +203,7 @@ public class ThemeManager {
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo); FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中 //ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder() ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp()) .nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp()) .userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent)) .content(Arrays.asList(commentContent))
...@@ -231,7 +230,6 @@ public class ThemeManager { ...@@ -231,7 +230,6 @@ public class ThemeManager {
//查询正文 //查询正文
@CacheGet(prefix = "getThemeDetail", expireSeconds = 600)
public ThemeQo getDetail(String themeId, String userId) { public ThemeQo getDetail(String themeId, String userId) {
ThemeEntity themeEntity = themeService.queryByThemeId(themeId); ThemeEntity themeEntity = themeService.queryByThemeId(themeId);
if (themeEntity == null) { if (themeEntity == null) {
...@@ -348,7 +346,7 @@ public class ThemeManager { ...@@ -348,7 +346,7 @@ public class ThemeManager {
Integer forwardCountByUser = themeService.getForwardCountByUser(themeId, userId); Integer forwardCountByUser = themeService.getForwardCountByUser(themeId, userId);
themeQo.setHasForward(forwardCountByUser > 0); themeQo.setHasForward(forwardCountByUser > 0);
//是否收藏 //是否收藏
CollectionEntity collectionEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.COLLECT_THEME); CollectionEntity collectionEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.COLLECT_THEME);
themeQo.setHasCollect(collectionEntity != null); themeQo.setHasCollect(collectionEntity != null);
//点赞,收藏,转发 //点赞,收藏,转发
Integer likeCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME); Integer likeCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME);
...@@ -365,7 +363,7 @@ public class ThemeManager { ...@@ -365,7 +363,7 @@ public class ThemeManager {
private void buildFormerTheme(ThemeQo themeQo) { private void buildFormerTheme(ThemeQo themeQo) {
String formerThemeId = themeQo.getFormerThemeId(); String formerThemeId = themeQo.getFormerThemeId();
if (StringUtils.isNotEmpty(formerThemeId)) { if (StringUtils.isNotEmpty(formerThemeId)) {
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId)); ThemeQo formerTheme = ConvertUtil.themeEntityToQo(themeService.queryByThemeId(formerThemeId));
if (formerTheme != null) { if (formerTheme != null) {
//单个查询详情 //单个查询详情
...@@ -393,4 +391,6 @@ public class ThemeManager { ...@@ -393,4 +391,6 @@ public class ThemeManager {
List<String> fansList = followRelService.queryFansByFollowerId(userId); List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime); return themeService.queryCountFromLastTime(fansList, lastViewTime);
} }
} }
package com.tanpu.community.manager; package com.tanpu.community.manager;
import com.tanpu.common.exception.BizException; 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.TopicDetailQo;
import com.tanpu.community.api.beans.qo.TopicHotQo; import com.tanpu.community.api.beans.qo.TopicHotQo;
import com.tanpu.community.api.beans.qo.TopicTitileQo; import com.tanpu.community.api.beans.qo.TopicTitileQo;
import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq; 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.constants.RedisKeyConstant;
import com.tanpu.community.api.enums.CollectionTypeEnum; import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.dao.entity.community.TopicEntity; import com.tanpu.community.dao.entity.community.TopicEntity;
...@@ -22,7 +22,6 @@ import org.springframework.stereotype.Service; ...@@ -22,7 +22,6 @@ import org.springframework.stereotype.Service;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
@Service @Service
public class TopicManager { public class TopicManager {
...@@ -44,6 +43,8 @@ public class TopicManager { ...@@ -44,6 +43,8 @@ public class TopicManager {
@Autowired @Autowired
private VisitSummaryService visitSummaryService; private VisitSummaryService visitSummaryService;
@Autowired
private RankService rankService;
//新增话题 //新增话题
public void insertTopic(String topicTitle, String userId) { public void insertTopic(String topicTitle, String userId) {
...@@ -106,25 +107,11 @@ public class TopicManager { ...@@ -106,25 +107,11 @@ public class TopicManager {
public List<TopicHotQo> getHotTopicTitles() { public List<TopicHotQo> getHotTopicTitles() {
List<TopicEntity> topicEntities = topicService.queryAll(); List<TopicHotQo> rankTopicList = rankService.rankTopicList;
List<TopicHotQo> topicHotQos = ConvertUtil.topicEntityToHotQos(topicEntities); if (rankTopicList.size()==0){
for (TopicHotQo topic : topicHotQos) { rankService.rankTopics();
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);
} }
topicHotQos.stream().collect(Collectors.toMap(TopicHotQo::getRank, o->o)); return rankService.rankTopicList;
//TODO 添加类型:热 新 顶
topicHotQos.get(0).setType(1);
topicHotQos.get(2).setType(2);
return topicHotQos;
} }
public void setTopTopic(String topicId, boolean setTop) { public void setTopTopic(String topicId, boolean setTop) {
......
package com.tanpu.community.service; package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.CollectionTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity; import com.tanpu.community.dao.entity.community.CollectionEntity;
...@@ -96,7 +95,8 @@ public class CollectionService { ...@@ -96,7 +95,8 @@ public class CollectionService {
queryCollection.setUncollectionTime(LocalDateTime.now()); queryCollection.setUncollectionTime(LocalDateTime.now());
collectionMapper.updateById(queryCollection); collectionMapper.updateById(queryCollection);
} else { } 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; ...@@ -5,7 +5,7 @@ import com.tanpu.common.exception.BizException;
import com.tanpu.common.uuid.UuidGenHelper; import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.CommentTypeEnum; import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum; 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.entity.community.CommentEntity;
import com.tanpu.community.dao.mapper.community.CommentMapper; import com.tanpu.community.dao.mapper.community.CommentMapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -66,7 +66,7 @@ public class CommentService { ...@@ -66,7 +66,7 @@ public class CommentService {
LambdaQueryWrapper<CommentEntity> queryWrapper = new LambdaQueryWrapper<CommentEntity>() LambdaQueryWrapper<CommentEntity> queryWrapper = new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getThemeId, themeId) .eq(CommentEntity::getThemeId, themeId)
.eq(CommentEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()) .eq(CommentEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.eq(CommentEntity::getIsBlock, TopicStatusEnum.FALSE.getCode()) .eq(CommentEntity::getIsBlock, StatusEnum.FALSE.getCode())
.orderByDesc(CommentEntity::getCreateTime); .orderByDesc(CommentEntity::getCreateTime);
if (parentId == null) { if (parentId == null) {
queryWrapper.isNull(CommentEntity::getParentId); 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 { ...@@ -40,6 +40,17 @@ public class ThemeService {
themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId)); 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返回主题详情(未删) //根据id返回主题详情(未删)
public ThemeEntity queryByThemeId(String themeId) { public ThemeEntity queryByThemeId(String themeId) {
return themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>() return themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
...@@ -72,6 +83,9 @@ public class ThemeService { ...@@ -72,6 +83,9 @@ public class ThemeService {
//根据ids返回主题详情,带分页 //根据ids返回主题详情,带分页
public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize) { public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId, Integer pageSize) {
if (CollectionUtils.isEmpty(themeIds)){
return Collections.emptyList();
}
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds) .in(ThemeEntity::getThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()); .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
...@@ -86,8 +100,15 @@ public class ThemeService { ...@@ -86,8 +100,15 @@ public class ThemeService {
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
//根据ids返回主题详情 /**
* 根据主题Id查询列表
* @param themeIds
* @return
*/
public List<ThemeEntity> queryByThemeIds(List<String> themeIds) { public List<ThemeEntity> queryByThemeIds(List<String> themeIds) {
if (CollectionUtils.isEmpty(themeIds)){
return Collections.emptyList();
}
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds) .in(ThemeEntity::getThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()); .eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
...@@ -95,8 +116,10 @@ public class ThemeService { ...@@ -95,8 +116,10 @@ public class ThemeService {
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
/** /**
* 分页查询,非当前用户的主题 * 查询非传入作者的主题(可分页)
* @param lastId * @param lastId
* @param pageSize * @param pageSize
* @param userId * @param userId
...@@ -113,8 +136,10 @@ public class ThemeService { ...@@ -113,8 +136,10 @@ public class ThemeService {
if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId); if (lastEntity == null) throw new BizException("主题未找到,id:" + lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime()); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
} }
if (pageSize!=null){
queryWrapper.last("limit " + pageSize);
}
queryWrapper.last("limit " + pageSize);
queryWrapper.orderByDesc(ThemeEntity::getId); queryWrapper.orderByDesc(ThemeEntity::getId);
queryWrapper.orderByDesc(ThemeEntity::getCreateTime); queryWrapper.orderByDesc(ThemeEntity::getCreateTime);
queryWrapper.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()); queryWrapper.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
...@@ -122,7 +147,39 @@ public class ThemeService { ...@@ -122,7 +147,39 @@ public class ThemeService {
} }
/** /**
* 根据条件查询最新主题 * 查询非传入作者的主题(可分页)
* @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());
return themeMapper.selectList(queryWrapper);
}
/**
* 根据话题查询最新主题(可分页)
* *
* @param topidId 话题Id * @param topidId 话题Id
* @param lastId 查询此主题Id之前的主题 * @param lastId 查询此主题Id之前的主题
...@@ -157,7 +214,13 @@ public class ThemeService { ...@@ -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) { public List<ThemeEntity> queryByUserIds(List<String> userIds, String lastId, Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getAuthorId, userIds); .in(ThemeEntity::getAuthorId, userIds);
......
...@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.common.uuid.UuidGenHelper; import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum; 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.entity.community.TopicEntity;
import com.tanpu.community.dao.mapper.community.TopicMapper; import com.tanpu.community.dao.mapper.community.TopicMapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -30,13 +30,15 @@ public class TopicService { ...@@ -30,13 +30,15 @@ public class TopicService {
public List<TopicEntity> queryAll() { public List<TopicEntity> queryAll() {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>() 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) { public List<TopicEntity> queryByKeyword(String keyword) {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>() return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
.like(TopicEntity::getTopicTitle,keyword) .like(TopicEntity::getTopicTitle, keyword)
.eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())); .eq(TopicEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(TopicEntity::getCreateTime));
} }
@Transactional @Transactional
...@@ -44,8 +46,8 @@ public class TopicService { ...@@ -44,8 +46,8 @@ public class TopicService {
TopicEntity entity = TopicEntity.builder() TopicEntity entity = TopicEntity.builder()
.topicId(uuidGenHelper.getUuidStr()) .topicId(uuidGenHelper.getUuidStr())
.topicTitle(topicTitle) .topicTitle(topicTitle)
.isTop(TopicStatusEnum.FALSE.getCode()) .isTop(StatusEnum.FALSE.getCode())
.isConceal(TopicStatusEnum.FALSE.getCode()) .isConceal(StatusEnum.FALSE.getCode())
.build(); .build();
topicMapper.insert(entity); topicMapper.insert(entity);
...@@ -54,41 +56,41 @@ public class TopicService { ...@@ -54,41 +56,41 @@ public class TopicService {
public void updateTopicToTop(String topicId) { public void updateTopicToTop(String topicId) {
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsTop(TopicStatusEnum.TRUE.getCode()); topicEntity.setIsTop(StatusEnum.TRUE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>() topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId)); .eq(TopicEntity::getId, topicId));
} }
public void updateTopicNotTop(String topicId) { public void updateTopicNotTop(String topicId) {
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsTop(TopicStatusEnum.FALSE.getCode()); topicEntity.setIsTop(StatusEnum.FALSE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>() topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId)); .eq(TopicEntity::getId, topicId));
} }
public void updateTopicToConceal(String topicId) { public void updateTopicToConceal(String topicId) {
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsConceal(TopicStatusEnum.TRUE.getCode()); topicEntity.setIsConceal(StatusEnum.TRUE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>() topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId)); .eq(TopicEntity::getId, topicId));
} }
public void updateTopicNotConceal(String topicId) { public void updateTopicNotConceal(String topicId) {
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsConceal(TopicStatusEnum.FALSE.getCode()); topicEntity.setIsConceal(StatusEnum.FALSE.getCode());
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>() topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
.eq(TopicEntity::getId, topicId)); .eq(TopicEntity::getId, topicId));
} }
public TopicEntity queryById(String 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) { public List<TopicEntity> queryByIds(List<String> topicIds) {
if (CollectionUtils.isEmpty(topicIds)){ if (CollectionUtils.isEmpty(topicIds)) {
return Collections.emptyList(); 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) { public void modifyViewCount(String topicId, long Count) {
......
...@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.theme.CreateThemeReq; ...@@ -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.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.RelTypeEnum; 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.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity; import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -19,6 +20,7 @@ import java.time.LocalDateTime; ...@@ -19,6 +20,7 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.temporal.TemporalField; import java.time.temporal.TemporalField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -33,48 +35,29 @@ public class ConvertUtil { ...@@ -33,48 +35,29 @@ public class ConvertUtil {
BeanUtils.copyProperties(themeEntity, themeQO); BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime())); themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime())); themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() { List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
}); });
themeQO.setContent(themeContentQos); themeQO.setContent(themeContentQos);
return themeQO; return themeQO;
} }
public static ThemeQo themeEntityToQo2(ThemeEntity themeEntity) { public static ThemeAnalysDO themeEntityToAnalysDO(ThemeEntity themeEntity) {
if (themeEntity == null) { if (themeEntity == null) {
return null; return null;
} }
ThemeQo themeQO = new ThemeQo(); ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
BeanUtils.copyProperties(themeEntity, themeQO); BeanUtils.copyProperties(themeEntity, themeAnalysDO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime())); themeAnalysDO.setMinuteTillNow(TimeUtil.calMinuteTillNow(themeEntity.getCreateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime())); return themeAnalysDO;
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;
} }
public static List<ThemeAnalysDO> themeEntityToAnalysDOs(List<ThemeEntity> themeEntities) {
public static ThemeEntity themeDTOToEntity(ThemeQo themeQO) { return themeEntities.stream().map(ConvertUtil::themeEntityToAnalysDO).collect(Collectors.toList());
ThemeEntity themeEntity = new ThemeEntity();
BeanUtils.copyProperties(themeQO, themeEntity);
return themeEntity;
} }
/**
* 首页主题列表,限制附件个数为1(1文本+1附件)
*
* @param themeEntities
* @return
*/
public static List<ThemeQo> themeEntitiesToDTOs(List<ThemeEntity> themeEntities) { 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) { public static ESThemeQo convert(ThemeEntity entity) {
...@@ -114,10 +97,17 @@ public class ConvertUtil { ...@@ -114,10 +97,17 @@ public class ConvertUtil {
public static TopicHotQo topicEntityToHotQo(TopicEntity topicEntity) { public static TopicHotQo topicEntityToHotQo(TopicEntity topicEntity) {
TopicHotQo topicHotQo = new TopicHotQo(); TopicHotQo topicHotQo = new TopicHotQo();
BeanUtils.copyProperties(topicEntity, topicHotQo); BeanUtils.copyProperties(topicEntity, topicHotQo);
//2小时内发帖,添加新话题标签
if(TimeUtil.calMinuteTillNow(topicEntity.getCreateTime())<120){
topicHotQo.setType(TopicStatusEnum.NEWEST.getCode());
}
return topicHotQo; return topicHotQo;
} }
public static List<TopicHotQo> topicEntityToHotQos(List<TopicEntity> topicEntities) { public static List<TopicHotQo> topicEntityToHotQos(List<TopicEntity> topicEntities) {
if (topicEntities==null){
return Collections.emptyList();
}
return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList()); return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList());
} }
......
...@@ -35,4 +35,10 @@ public class TimeUtil { ...@@ -35,4 +35,10 @@ public class TimeUtil {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); 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: ...@@ -22,14 +22,6 @@ spring.datasource:
maxActive: 2 maxActive: 2
minIdle: 2 minIdle: 2
initialSize: 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: user:
driver-class-name: com.mysql.cj.jdbc.Driver 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 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: ...@@ -38,27 +30,19 @@ spring.datasource:
maxActive: 2 maxActive: 2
minIdle: 2 minIdle: 2
initialSize: 2 initialSize: 2
zhibo: jydb:
driver-class-name: com.mysql.cj.jdbc.Driver 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 username: dev
password: qimeng123 password: qimeng123
maxActive: 2 maxActive: 2
minIdle: 2 minIdle: 2
initialSize: 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: fund:
driver-class-name: com.mysql.cj.jdbc.Driver 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 jdbc-url: jdbc:mysql://47.101.189.151:31931/tamp_fund?autoReconnect=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false
username: tamp username: dev
password: "@imeng123" password: qimeng123
maxActive: 2 maxActive: 2
minIdle: 2 minIdle: 2
initialSize: 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