Commit f43ac197 authored by 张辰's avatar 张辰

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

# Conflicts:
#	community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeContentQo.java
#	community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
parents 7132ad8e 1ddb2104
...@@ -2,17 +2,19 @@ package com.tanpu.community.api.beans.qo; ...@@ -2,17 +2,19 @@ package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("关注列表") @ApiModel("关注列表")
public class FollowQo { public class FollowQo {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private String userId; private String userId;
......
...@@ -26,9 +26,24 @@ public class FormerThemeQo implements Serializable { ...@@ -26,9 +26,24 @@ public class FormerThemeQo implements Serializable {
private String userImg; private String userImg;
@ApiModelProperty(value = "被转发的主题Id") @ApiModelProperty(value = "被转发的主题Id")
private String formerThemeId; private String themeId;
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发 ")
private Integer themeType;
@ApiModelProperty(value = "被转发的主题标题")
private String title;
@ApiModelProperty(value = "被转发的主题的话题名称")
private String topicTitle;
@ApiModelProperty(value = "被转发的主题所属的话题")
private String topicId;
@ApiModelProperty(value = "被转发的主题的作者id")
private String authorId;
@ApiModelProperty(value = "转发内容") @ApiModelProperty(value = "转发内容")
private List<ThemeContentQo> forwardContent; private List<ThemeContentQo> content;
} }
...@@ -3,16 +3,19 @@ package com.tanpu.community.api.beans.qo; ...@@ -3,16 +3,19 @@ package com.tanpu.community.api.beans.qo;
import com.tanpu.community.api.beans.ImagesDTO; import com.tanpu.community.api.beans.ImagesDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List; import java.util.List;
@Data @Data
@ApiModel(value = "主题内容") @ApiModel(value = "主题内容")
public class ThemeContentQo implements Serializable { @Builder
@AllArgsConstructor
private static final long serialVersionUID = 100042751824238477L; @NoArgsConstructor
public class ThemeContentQo {
@ApiModelProperty(value = "RelTypeEnum类型,8:文本,88:产品 3:直播 6:短视频 2:课程,9:图片 10:多图(讨论)") @ApiModelProperty(value = "RelTypeEnum类型,8:文本,88:产品 3:直播 6:短视频 2:课程,9:图片 10:多图(讨论)")
private String type; private String type;
......
...@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.qo; ...@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.qo;
import com.tanpu.community.api.beans.ImagesDTO; import com.tanpu.community.api.beans.ImagesDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@Data @Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("主题信息流对象") @ApiModel("主题信息流对象")
public class ThemeQo implements Serializable { public class ThemeQo implements Serializable {
...@@ -24,7 +30,7 @@ public class ThemeQo implements Serializable { ...@@ -24,7 +30,7 @@ public class ThemeQo implements Serializable {
@ApiModelProperty(value = "标题") @ApiModelProperty(value = "标题")
private String title; private String title;
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发") @ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发 4:评论")
private Integer themeType; private Integer themeType;
@ApiModelProperty(value = "内容") @ApiModelProperty(value = "内容")
...@@ -75,6 +81,9 @@ public class ThemeQo implements Serializable { ...@@ -75,6 +81,9 @@ public class ThemeQo implements Serializable {
@ApiModelProperty(value = "转发的主题") @ApiModelProperty(value = "转发的主题")
private FormerThemeQo formerTheme; private FormerThemeQo formerTheme;
@ApiModelProperty(value = "评论Id(我的评论列表使用)")
private String commentId;
private Long createTime; private Long createTime;
private Long updateTime; private Long updateTime;
......
...@@ -18,5 +18,8 @@ public class TopicTitileQo { ...@@ -18,5 +18,8 @@ public class TopicTitileQo {
private String topicTitle; private String topicTitle;
@ApiModelProperty("讨论数") @ApiModelProperty("讨论数")
private Integer discussionCount; private String discussionCount;
@ApiModelProperty("浏览量")
private String viewCount;
} }
...@@ -5,13 +5,12 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -5,13 +5,12 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
@ApiModel @ApiModel
@Data @Data
public class CreateCommentReq { public class CreateCommentReq {
@NotEmpty(message = "主题id不能为空") @NotBlank(message = "主题id不能为空")
@ApiModelProperty(value = "主题Id") @ApiModelProperty(value = "主题Id")
private String themeId; private String themeId;
......
...@@ -4,10 +4,13 @@ import io.swagger.annotations.ApiModel; ...@@ -4,10 +4,13 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ApiModel(value = "点赞/取消点赞评论") import javax.validation.constraints.NotBlank;
@Data @Data
@ApiModel(value = "点赞/取消点赞评论")
public class LikeCommentReq { public class LikeCommentReq {
@NotBlank
@ApiModelProperty(value = "评论Id") @ApiModelProperty(value = "评论Id")
private String commentId; private String commentId;
......
...@@ -4,11 +4,11 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,11 +4,11 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class AddIdolReq { public class FollowRelReq {
@ApiModelProperty(value = "关注对象Id") @ApiModelProperty(value = "关注对象Id")
private String followUserId; private String followUserId;
@ApiModelProperty(value = "粉丝Id") @ApiModelProperty(value = "关注类型,1:关注 2:取消关注")
private String followerId; private Integer type;
} }
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Data @Data
...@@ -11,12 +12,14 @@ import javax.validation.constraints.NotNull; ...@@ -11,12 +12,14 @@ import javax.validation.constraints.NotNull;
public class QueryRecordThemeReq { public class QueryRecordThemeReq {
@ApiModelProperty("用户Id") @ApiModelProperty("用户Id")
@NotBlank
private String userId; private String userId;
@ApiModelProperty(value = "操作类型 1:发布 2:点赞 3:收藏") @NotNull
@ApiModelProperty(value = "操作类型 1:发布 2:回复 3:点赞 4:收藏")
private Integer recordType; private Integer recordType;
@ApiModelProperty(value = "当前浏览的最后一个themeId,可以为空") @ApiModelProperty(value = "当前浏览的最后一个themeId/commentId,可以为空")
private String lastId; private String lastId;
@NotNull(message = "PageSize不能为空") @NotNull(message = "PageSize不能为空")
......
...@@ -26,11 +26,11 @@ public class CreateThemeReq { ...@@ -26,11 +26,11 @@ public class CreateThemeReq {
private List<ThemeContentReq> content; private List<ThemeContentReq> content;
@ApiModelProperty(value = "所属的话题id") @ApiModelProperty(value = "所属的话题id")
private String topicId; private String topicId="";
@ApiModelProperty(value = "修改,则传入正在编辑的ThemeId") @ApiModelProperty(value = "修改,则传入正在编辑的ThemeId")
private String editThemeId; private String editThemeId="";
} }
...@@ -4,25 +4,25 @@ import io.swagger.annotations.ApiModel; ...@@ -4,25 +4,25 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@Data @Data
@ApiModel(value = "转发主题") @ApiModel(value = "转发主题")
public class ForwardThemeReq { public class ForwardThemeReq {
@NotEmpty(message = "转发对象id不能为空") @NotBlank(message = "转发对象id不能为空")
@ApiModelProperty(value = "转发的主题Id") @ApiModelProperty(value = "转发的主题Id")
private String formerThemeId; private String formerThemeId;
@NotNull(message = "内容不能为空") @NotEmpty(message = "内容不能为空")
@ApiModelProperty(value = "转发的讨论内容") @ApiModelProperty(value = "转发的讨论内容")
private List<ThemeContentReq> content; private List<ThemeContentReq> content;
@ApiModelProperty(value = "话题Id") @ApiModelProperty(value = "话题Id")
private String topicId; private String topicId="";
@ApiModelProperty(value = "修改,则传入正在编辑的ThemeId") @ApiModelProperty(value = "修改,则传入正在编辑的ThemeId")
private String editThemeId; private String editThemeId="";
} }
...@@ -4,14 +4,22 @@ package com.tanpu.community.api.beans.req.theme; ...@@ -4,14 +4,22 @@ package com.tanpu.community.api.beans.req.theme;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull;
@Data @Data
public class ThemeListByTopicReq { public class ThemeListByTopicReq {
@ApiModelProperty(value = "当前浏览的最后一个themeId") @ApiModelProperty(value = "当前浏览的最后一个themeId")
private String lastId; private String lastId="";
@NotNull
@ApiModelProperty(value = "页面大小") @ApiModelProperty(value = "页面大小")
private Integer PageSize; private Integer PageSize;
@NotNull
@ApiModelProperty(value = "类型,1:最热 2:最新") @ApiModelProperty(value = "类型,1:最热 2:最新")
private Integer type; private Integer type;
@NotNull
@ApiModelProperty(value = "话题Id") @ApiModelProperty(value = "话题Id")
private String topicId; private String topicId;
......
...@@ -18,7 +18,7 @@ public class ThemeListReq { ...@@ -18,7 +18,7 @@ public class ThemeListReq {
private String topicId; private String topicId;
@ApiModelProperty(value = "当前浏览的最后一个themeId,可以为空") @ApiModelProperty(value = "当前浏览的最后一个themeId,可以为空")
private String lastId; private String lastId="";
@NotNull(message = "PageSize不能为空") @NotNull(message = "PageSize不能为空")
@ApiModelProperty(value = "页面大小") @ApiModelProperty(value = "页面大小")
......
...@@ -8,7 +8,7 @@ import lombok.Data; ...@@ -8,7 +8,7 @@ import lombok.Data;
@Data @Data
public class TopicSearchReq { public class TopicSearchReq {
@ApiModelProperty(value = "搜索关键字,可以为空") @ApiModelProperty(value = "搜索关键字,可以为空")
private String searchKeyword; private String searchKeyword="";
@ApiModelProperty(value = "分页") @ApiModelProperty(value = "分页")
private Pageable page; private Pageable page;
......
package com.tanpu.community.api.beans.resp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel(value = "创建主题")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateThemeResp {
@ApiModelProperty(value = "主题id")
private String themeId;
}
package com.tanpu.community.api.enums;
/**
* 通用操作类型枚举,包括点赞/取消点赞,收藏/取消收藏,关注/取消关注
*/
public enum OperationTypeEnum {
CONFIRM(1,"确认操作"),
CANCEL(2,"取消操作");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
OperationTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
...@@ -14,6 +14,7 @@ import com.tanpu.community.util.PageUtils; ...@@ -14,6 +14,7 @@ import com.tanpu.community.util.PageUtils;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -34,7 +35,7 @@ public class CommentController { ...@@ -34,7 +35,7 @@ public class CommentController {
@AuthLogin @AuthLogin
@PostMapping(value = "/publishComment") @PostMapping(value = "/publishComment")
@ResponseBody @ResponseBody
public CommonResp<Void> publishCommet(@RequestBody CreateCommentReq req) { public CommonResp<Void> publishCommet(@Validated @RequestBody CreateCommentReq req) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
commentManager.comment(req, userId); commentManager.comment(req, userId);
return CommonResp.success(); return CommonResp.success();
...@@ -44,7 +45,7 @@ public class CommentController { ...@@ -44,7 +45,7 @@ public class CommentController {
@AuthLogin @AuthLogin
@PostMapping(value = "/queryComment") @PostMapping(value = "/queryComment")
@ResponseBody @ResponseBody
public CommonResp<Page<CommentQo>> queryComment(@RequestBody QueryCommentReq req) { public CommonResp<Page<CommentQo>> queryComment(@Validated @RequestBody QueryCommentReq req) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId); List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId);
return CommonResp.success(PageUtils.page(req.getPage(), result)); return CommonResp.success(PageUtils.page(req.getPage(), result));
...@@ -54,7 +55,7 @@ public class CommentController { ...@@ -54,7 +55,7 @@ public class CommentController {
@PostMapping(value = "/likeComment") @PostMapping(value = "/likeComment")
@AuthLogin @AuthLogin
@ResponseBody @ResponseBody
public CommonResp<Void> likeComment(@RequestBody LikeCommentReq req) { public CommonResp<Void> likeComment(@Validated @RequestBody LikeCommentReq req) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
commentManager.likeComment(req, userId); commentManager.likeComment(req, userId);
return CommonResp.success(); return CommonResp.success();
......
package com.tanpu.community.controller; package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.AuthLogin;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.FollowQo; import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.qo.ThemeQo; import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.HomePageReq; import com.tanpu.community.api.beans.req.HomePageReq;
import com.tanpu.community.api.beans.req.homepage.AddIdolReq; import com.tanpu.community.api.beans.req.homepage.FollowRelReq;
import com.tanpu.community.api.beans.req.homepage.QueryFollowReq; import com.tanpu.community.api.beans.req.homepage.QueryFollowReq;
import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq; import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq;
import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.page.Page;
...@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
...@@ -29,6 +32,9 @@ public class HomePageController { ...@@ -29,6 +32,9 @@ public class HomePageController {
@Autowired @Autowired
private ThemeManager themeManager; private ThemeManager themeManager;
@Resource
private UserHolder userHolder;
@PostMapping(value = "/editInfo") @PostMapping(value = "/editInfo")
@ApiOperation("编辑圈子个人资料") @ApiOperation("编辑圈子个人资料")
@ResponseBody @ResponseBody
...@@ -41,27 +47,37 @@ public class HomePageController { ...@@ -41,27 +47,37 @@ public class HomePageController {
@PostMapping(value = "/followList") @PostMapping(value = "/followList")
@ApiOperation("查询关注/粉丝列表") @ApiOperation("查询关注/粉丝列表")
@ResponseBody @ResponseBody
@AuthLogin
public CommonResp<Page<FollowQo>> queryMyFans(@RequestBody QueryFollowReq req) { public CommonResp<Page<FollowQo>> queryMyFans(@RequestBody QueryFollowReq req) {
String userId = "123"; String userId = userHolder.getUserId();
return CommonResp.success(homePageManager.queryFollow(req)); return CommonResp.success(homePageManager.queryFollow(req,userId));
} }
@PostMapping(value = "/addIdol") @PostMapping(value = "/addIdol")
@ApiOperation("关注他人") @ApiOperation("关注/取消关注他人")
@ResponseBody @ResponseBody
public CommonResp addIdol(@RequestBody AddIdolReq req) { public CommonResp addIdol(@RequestBody FollowRelReq req) {
String userId = "123"; String userId = userHolder.getUserId();
homePageManager.addIdol(req.getFollowUserId(), req.getFollowUserId()); homePageManager.addFollowRel(req,userId);
return CommonResp.success(); return CommonResp.success();
} }
@PostMapping(value = "/themeList") @PostMapping(value = "/themeList")
@ApiOperation("用户的帖子列表") @ApiOperation("用户的帖子列表")
@ResponseBody @ResponseBody
public CommonResp<List<ThemeQo>> likeList(@RequestBody QueryRecordThemeReq req){ @AuthLogin
String userId="123"; public CommonResp<List<ThemeQo>> likeList(@Validated @RequestBody QueryRecordThemeReq req){
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.queryThemesByUser(req,userId)); return CommonResp.success(themeManager.queryThemesByUser(req,userId));
} }
// @PostMapping(value = "/commentThemeList")
// @ApiOperation("用户评论过的帖子列表")
// @ResponseBody
// public CommonResp<List<ThemeQo>> commentThemeList(@RequestBody QueryRecordThemeReq req){
// String userId="123";
//
// return CommonResp.success(themeManager.queryThemesByUser(req,userId));
// }
} }
...@@ -25,6 +25,6 @@ public class TestController { ...@@ -25,6 +25,6 @@ public class TestController {
@GetMapping(value = "/1") @GetMapping(value = "/1")
@ResponseBody @ResponseBody
public Object sendKafka() { public Object sendKafka() {
return userInfoService.selectById("USER_INFO15912897523789"); return userInfoService.queryUserById("USER_INFO15912897523789");
} }
} }
...@@ -7,6 +7,7 @@ import com.tanpu.common.auth.UserHolder; ...@@ -7,6 +7,7 @@ import com.tanpu.common.auth.UserHolder;
import com.tanpu.common.exception.BizException; import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.qo.ThemeQo; import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.theme.*; import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.manager.ThemeManager; import com.tanpu.community.manager.ThemeManager;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -32,13 +33,12 @@ public class ThemeController { ...@@ -32,13 +33,12 @@ public class ThemeController {
@ApiOperation("发表主题") @ApiOperation("发表主题")
@PostMapping(value = "/publish") @PostMapping(value = "/publish")
@ResponseBody @ResponseBody
public CommonResp<Void> publishTheme(@Validated @RequestBody CreateThemeReq req) { public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
if(StringUtils.isEmpty(userId)){ if(StringUtils.isEmpty(userId)){
throw new BizException("用户为空"); throw new BizException("用户为空");
} }
themeManager.publishTheme(req, userId); return CommonResp.success(themeManager.publishTheme(req, userId));
return CommonResp.success();
} }
@AuthLogin @AuthLogin
......
...@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq; ...@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.comment.LikeCommentReq; import com.tanpu.community.api.beans.req.comment.LikeCommentReq;
import com.tanpu.community.api.enums.CollectionTypeEnum; import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.CommentTypeEnum; import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.dao.entity.community.CommentEntity; import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.user.UserInfoEntity; import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.service.CollectionService; import com.tanpu.community.service.CollectionService;
...@@ -50,7 +51,7 @@ public class CommentManager { ...@@ -50,7 +51,7 @@ public class CommentManager {
} }
//查询 //查询
public List<CommentQo> queryComments(String themeId,String userId) { public List<CommentQo> queryComments(String themeId, String userId) {
List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null); List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities); List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
...@@ -60,19 +61,19 @@ public class CommentManager { ...@@ -60,19 +61,19 @@ public class CommentManager {
for (CommentQo commentQo : commentQos) { for (CommentQo commentQo : commentQos) {
//用户信息 //用户信息
String authorId = commentQo.getAuthorId(); String authorId = commentQo.getAuthorId();
UserInfoEntity userInfo = userInfoService.selectById(authorId); UserInfoEntity userInfo = userInfoService.queryUserById(authorId);
if (userInfo!=null){ if (userInfo != null) {
commentQo.setUserImg(userInfo.getUiHeadimg()); commentQo.setUserImg(userInfo.getUiHeadimg());
commentQo.setNickName(userInfo.getUiNickname()); commentQo.setNickName(userInfo.getUiNickname());
} }
//是否点赞及点赞数 //是否点赞及点赞数
String commentId = commentQo.getCommentId(); String commentId = commentQo.getCommentId();
if (likeCommentList.contains(commentId)){ if (likeCommentList.contains(commentId)) {
commentQo.setHasLiked(true); commentQo.setHasLiked(true);
}else { } else {
commentQo.setHasLiked(false); commentQo.setHasLiked(false);
} }
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId,CollectionTypeEnum.LIKE_COMMENT); Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId); commentQo.setLikeCount(countByTypeAndId);
//二级评论,本期不上线 //二级评论,本期不上线
...@@ -86,10 +87,9 @@ public class CommentManager { ...@@ -86,10 +87,9 @@ public class CommentManager {
//点赞评论/取消点赞 //点赞评论/取消点赞
public void likeComment(LikeCommentReq req, String userId) { public void likeComment(LikeCommentReq req, String userId) {
//todo 枚举值 if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) {
if (1==req.getType()){
collectionService.addIfNotExist(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT); collectionService.addIfNotExist(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
}else if (2==req.getType()) { } else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
collectionService.delete(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT); collectionService.delete(req.getCommentId(), userId, CollectionTypeEnum.LIKE_COMMENT);
} }
......
package com.tanpu.community.manager; package com.tanpu.community.manager;
import com.tanpu.community.api.beans.qo.FollowQo; import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.req.HomePageReq; import com.tanpu.community.api.beans.req.homepage.FollowRelReq;
import com.tanpu.community.api.beans.req.homepage.QueryFollowReq; import com.tanpu.community.api.beans.req.homepage.QueryFollowReq;
import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.api.enums.QueryFollowTypeEnum; import com.tanpu.community.api.enums.QueryFollowTypeEnum;
import com.tanpu.community.dao.entity.community.HomePageEntity; import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.service.FollowRelService; import com.tanpu.community.service.FollowRelService;
import com.tanpu.community.service.HomePageService; import com.tanpu.community.service.UserInfoService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.PageUtils; import com.tanpu.community.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -25,42 +25,26 @@ public class HomePageManager { ...@@ -25,42 +25,26 @@ public class HomePageManager {
@Autowired @Autowired
private FollowRelService followRelService; private FollowRelService followRelService;
@Resource
private HomePageService homePageService;
// public void editUserInfo(HomePageReq req,String userId) { @Autowired
// HomePageEntity entity = HomePageEntity.builder() private UserInfoService userInfoService;
// .userId(userId)
// .nickName(req.getNickName())
// .headImg(req.getHeadImg())
// .introduction(req.getIntroduction())
// .sex(req.getSex())
// .location(req.getLocation())
// .build();
// if(homePageService.selectByUserId(userId) == null){
// homePageService.insert(entity);
// }else {
// homePageService.update(entity);
// }
// return;
// }
//获取用户关注、粉丝列表 //获取用户关注、粉丝列表
public Page<FollowQo> queryFollow(QueryFollowReq req) { public Page<FollowQo> queryFollow(QueryFollowReq req, String userId) {
List<String> userIds = QueryFollowTypeEnum.QUERY_FANS.getCode().equals(req.getQueryType())? List<String> userIds = QueryFollowTypeEnum.QUERY_FANS.getCode().equals(req.getQueryType()) ?
followRelService.queryFansByIdolId(req.getUserId()):followRelService.queryFansByFollowerId(req.getUserId()); followRelService.queryFansByIdolId(req.getUserId()) : followRelService.queryFansByFollowerId(req.getUserId());
List<HomePageEntity> list = homePageService.selectListByUserIds(userIds); List<UserInfoEntity> userInfos = userInfoService.queryUserByIds(userIds);
List<FollowQo> collect = list.stream().map(ConvertUtil::homePageEntity2FollowQo).collect(Collectors.toList()); List<FollowQo> collect = userInfos.stream().map(ConvertUtil::homePageEntity2FollowQo).collect(Collectors.toList());
List<FollowQo> followQos = judgeFollowed(collect, req.getUserId()); List<FollowQo> followQos = judgeFollowed(collect, userId);
return PageUtils.page(req.getPage(),followQos); return PageUtils.page(req.getPage(), followQos);
} }
//判断返回列表中的用户是否被当前用户关注 //判断返回列表中的用户是否被当前用户关注
public List<FollowQo> judgeFollowed(List<FollowQo> followQos,String followerId){ public List<FollowQo> judgeFollowed(List<FollowQo> followQos, String followerId) {
Set<String> idolSet = new HashSet<>(followRelService.queryFansByFollowerId(followerId)); Set<String> idolSet = new HashSet<>(followRelService.queryFansByFollowerId(followerId));
return followQos.stream().map(o->{ return followQos.stream().map(o -> {
if (idolSet.contains(o.getUserId())){ if (idolSet.contains(o.getUserId())) {
o.setFollowed(true); o.setFollowed(true);
} }
return o; return o;
...@@ -68,7 +52,11 @@ public class HomePageManager { ...@@ -68,7 +52,11 @@ public class HomePageManager {
} }
public void addIdol(String idolId, String followerId) { public void addFollowRel(FollowRelReq req, String followerId) {
followRelService.addFans(idolId, followerId); if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) {
followRelService.addFollowRel(req.getFollowUserId(), followerId);
} else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
followRelService.deleteFollowRel(req.getFollowUserId(), followerId);
}
} }
} }
...@@ -3,22 +3,28 @@ package com.tanpu.community.manager; ...@@ -3,22 +3,28 @@ package com.tanpu.community.manager;
import com.tanpu.common.exception.BizException; import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.FormerThemeQo; import com.tanpu.community.api.beans.qo.FormerThemeQo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo; import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq; import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq;
import com.tanpu.community.api.beans.req.theme.*; import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.api.enums.BlockTypeEnum; import com.tanpu.community.api.enums.BlockTypeEnum;
import com.tanpu.community.api.enums.CollectionTypeEnum; import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.ThemeListTypeEnum; import com.tanpu.community.api.enums.ThemeListTypeEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum; import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.cache.CacheGet; 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.service.*; import com.tanpu.community.service.*;
import com.tanpu.community.service.other.BlackListService; import com.tanpu.community.service.BlackListService;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
...@@ -57,7 +63,8 @@ public class ThemeManager { ...@@ -57,7 +63,8 @@ public class ThemeManager {
private OSSFileService ossFileService; private OSSFileService ossFileService;
public void publishTheme(CreateThemeReq req, String userId) { @Transactional
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) {
//TODO 敏感词过滤 //TODO 敏感词过滤
...@@ -66,17 +73,18 @@ public class ThemeManager { ...@@ -66,17 +73,18 @@ public class ThemeManager {
BeanUtils.copyProperties(req, themeEntity); BeanUtils.copyProperties(req, themeEntity);
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);
}else { } else {
//修改 //修改
themeService.update(themeEntity,req.getEditThemeId()); themeService.update(themeEntity, req.getEditThemeId());
} }
//保存附件表 //保存附件表
List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId()); List<ThemeAttachmentEntity> themeAttachments = ConvertUtil.themeReqToAttachmentList(req, themeEntity.getThemeId());
themeAttachmentService.insertList(themeAttachments); themeAttachmentService.insertList(themeAttachments);
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
} }
// 返回推荐主题文章 // 返回推荐主题文章
...@@ -110,28 +118,60 @@ public class ThemeManager { ...@@ -110,28 +118,60 @@ public class ThemeManager {
List<ThemeEntity> themeEntities = Collections.emptyList(); List<ThemeEntity> themeEntities = Collections.emptyList();
switch (req.getRecordType()) { switch (req.getRecordType()) {
case 1://发布 case 1://发布
themeEntities = themeService.queryThemeIdsByUserId(req.getUserId()); themeEntities = themeService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
break; break;
case 2://点赞 case 2://回复
List<ThemeQo> commentThemeList = new ArrayList<>();
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
productService.transferAttachments(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.nickName(userInfoEntity.getUiNickname())
.userImg(userInfoEntity.getUiHeadimg())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.build();
commentThemeList.add(commentThemeQo);
}
return commentThemeList;
case 3://点赞
Set<String> likeThemeIds = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_THEME); Set<String> likeThemeIds = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_THEME);
themeEntities = themeService.queryByThemeIds(new ArrayList<>(likeThemeIds)); themeEntities = themeService.queryByThemeIds(new ArrayList<>(likeThemeIds), req.getLastId(), req.getPageSize());
break; break;
case 3://收藏 case 4://收藏
Set<String> collectThemeIds = collectionService.getListByUser(userId, CollectionTypeEnum.COLLECT_THEME); Set<String> collectThemeIds = collectionService.getListByUser(userId, CollectionTypeEnum.COLLECT_THEME);
themeEntities = themeService.queryByThemeIds(new ArrayList<>(collectThemeIds)); themeEntities = themeService.queryByThemeIds(new ArrayList<>(collectThemeIds), req.getLastId(), req.getPageSize());
break; break;
} }
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId); List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
return themeQos; return themeQos;
} }
public List<ThemeQo> queryThemesByUserComment(QueryRecordThemeReq req, String userId) {
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
List<ThemeEntity> themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
return null;
}
//查询正文 //查询正文
@CacheGet(prefix = "getThemeDetail", expireSeconds = 600) @CacheGet(prefix = "getThemeDetail", expireSeconds = 600)
...@@ -147,10 +187,9 @@ public class ThemeManager { ...@@ -147,10 +187,9 @@ public class ThemeManager {
// 点赞/取消点赞 // 点赞/取消点赞
public void like(LikeThemeReq req, String userId) { public void like(LikeThemeReq req, String userId) {
//todo 枚举值 if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) {
if (1 == req.getType()) {
collectionService.addIfNotExist(req.getThemeId(), userId, CollectionTypeEnum.LIKE_THEME); collectionService.addIfNotExist(req.getThemeId(), userId, CollectionTypeEnum.LIKE_THEME);
} else if (2 == req.getType()) { } else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
collectionService.delete(req.getThemeId(), userId, CollectionTypeEnum.LIKE_THEME); collectionService.delete(req.getThemeId(), userId, CollectionTypeEnum.LIKE_THEME);
} }
...@@ -158,10 +197,9 @@ public class ThemeManager { ...@@ -158,10 +197,9 @@ public class ThemeManager {
//收藏/取消收藏 //收藏/取消收藏
public void collect(CollectThemeReq req, String userId) { public void collect(CollectThemeReq req, String userId) {
//todo 枚举值 if (OperationTypeEnum.CONFIRM.getCode().equals(req.getType())) {
if (1 == req.getType()) {
collectionService.addIfNotExist(req.getThemeId(), userId, CollectionTypeEnum.COLLECT_THEME); collectionService.addIfNotExist(req.getThemeId(), userId, CollectionTypeEnum.COLLECT_THEME);
} else if (2 == req.getType()) { } else if (OperationTypeEnum.CANCEL.getCode().equals(req.getType())) {
collectionService.delete(req.getThemeId(), userId, CollectionTypeEnum.COLLECT_THEME); collectionService.delete(req.getThemeId(), userId, CollectionTypeEnum.COLLECT_THEME);
} }
} }
...@@ -177,21 +215,16 @@ public class ThemeManager { ...@@ -177,21 +215,16 @@ public class ThemeManager {
.themeType(ThemeTypeEnum.FORWARD.getCode()) .themeType(ThemeTypeEnum.FORWARD.getCode())
.build(); .build();
if (StringUtils.isEmpty(req.getEditThemeId())){ if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId() == req.getFormerThemeId()) {
//新建 //新建
themeService.insertTheme(newTheme); themeService.insertTheme(newTheme);
}else { } else {
//修改 //修改
themeService.update(newTheme,req.getEditThemeId()); themeService.update(newTheme, req.getEditThemeId());
} }
} }
//投诉(主题)
public void complaint(String themeId, String user) {
//TODO
}
// 屏蔽(用户) // 屏蔽(用户)
public void blockUser(String blockUser, String userId) { public void blockUser(String blockUser, String userId) {
BlackListEntity selectOne = blackListService.selectOne(blockUser, userId, BlockTypeEnum.USER.getCode()); BlackListEntity selectOne = blackListService.selectOne(blockUser, userId, BlockTypeEnum.USER.getCode());
...@@ -230,6 +263,7 @@ public class ThemeManager { ...@@ -230,6 +263,7 @@ public class ThemeManager {
for (ThemeQo themeQO : themeQos) { for (ThemeQo themeQO : themeQos) {
buildThemeQoExtraInfo(userId, themeQO); buildThemeQoExtraInfo(userId, themeQO);
} }
return themeQos; return themeQos;
} }
...@@ -263,15 +297,13 @@ public class ThemeManager { ...@@ -263,15 +297,13 @@ public class ThemeManager {
//组装正文详情 //组装正文详情
private void buildMainTestExtraInfo(ThemeQo themeQo, String userId) { private void buildMainTestExtraInfo(ThemeQo themeQo, String userId) {
//附件列表 //附件列表
String themeId = themeQo.getThemeId();
productService.transferAttachement(themeQo); productService.transferAttachement(themeQo);
//转发原文 //转发原文
buildFormerTheme(themeQo); buildFormerTheme(themeQo);
return; return;
} }
//组装被转发主题
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)) {
...@@ -280,18 +312,20 @@ public class ThemeManager { ...@@ -280,18 +312,20 @@ public class ThemeManager {
throw new BizException("转发主题Id错误,id:" + formerThemeId); throw new BizException("转发主题Id错误,id:" + formerThemeId);
} }
productService.transferAttachement(formerTheme); productService.transferAttachement(formerTheme);
FormerThemeQo f = FormerThemeQo.builder().formerThemeId(formerThemeId) FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(formerTheme);
.forwardContent(formerTheme.getContent())
.userImg(formerTheme.getUserImg())
.nickName(formerTheme.getNickName())
.build();
themeQo.setFormerTheme(f); themeQo.setFormerTheme(f);
} }
} }
//逻辑删除
public void delete(String themeId) { public void delete(String themeId) {
themeService.deleteById(themeId); themeService.deleteById(themeId);
} }
//投诉(主题)
public void complaint(String themeId, String user) {
//TODO
}
} }
...@@ -68,7 +68,11 @@ public class TopicManager { ...@@ -68,7 +68,11 @@ public class TopicManager {
//讨论数=发布主题贴数+回复总数 //讨论数=发布主题贴数+回复总数
List<String> themeIds = themeService.queryThemeIdsByTopic(topicQo.getTopicId()); List<String> themeIds = themeService.queryThemeIdsByTopic(topicQo.getTopicId());
Integer commentCount = commentService.getCommentCountByThemeIds(themeIds); Integer commentCount = commentService.getCommentCountByThemeIds(themeIds);
topicQo.setDiscussionCount(themeIds.size() + commentCount); topicQo.setDiscussionCount(String.valueOf(themeIds.size() + commentCount));
//浏览量
Integer topicPV = visitSummaryService.queryTopicDetailVisit(topicQo.getTopicId());
Integer themePV = visitSummaryService.queryThemeVisit(themeIds);
topicQo.setViewCount(String.valueOf(topicPV + themePV));
} }
//TODO 判断顶置 //TODO 判断顶置
return PageUtils.page(req.getPage(), topicTitileQos); return PageUtils.page(req.getPage(), topicTitileQos);
......
package com.tanpu.community.service.other; 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.common.exception.BizException;
......
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.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;
...@@ -8,6 +9,7 @@ import com.tanpu.community.api.enums.TopicStatusEnum; ...@@ -8,6 +9,7 @@ import com.tanpu.community.api.enums.TopicStatusEnum;
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;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -74,4 +76,22 @@ public class CommentService { ...@@ -74,4 +76,22 @@ public class CommentService {
.eq(CommentEntity::getCommentType, CommentTypeEnum.THEME.getCode()) .eq(CommentEntity::getCommentType, CommentTypeEnum.THEME.getCode())
.eq(CommentEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())); .eq(CommentEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode()));
} }
public List<CommentEntity> queryThemesByUserId(String userId, String lastId,Integer pageSize) {
LambdaQueryWrapper<CommentEntity> queryWrapper = new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getAuthorId, userId)
.eq(CommentEntity::getCommentType, CommentTypeEnum.THEME.getCode())
.eq(CommentEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
if (StringUtils.isNotEmpty(lastId)) {
CommentEntity commentEntity = commentMapper.selectOne(new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getCommentId,lastId));
if (commentEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(CommentEntity::getUpdateTime, commentEntity.getCreateTime());
}
if (pageSize!=null){
queryWrapper.last("limit "+pageSize);
}
return commentMapper.selectList(queryWrapper);
}
} }
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.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.FollowRelEntity; import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.mapper.community.FollowRelMapper; import com.tanpu.community.dao.mapper.community.FollowRelMapper;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
...@@ -8,6 +10,7 @@ import org.springframework.stereotype.Service; ...@@ -8,6 +10,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -20,24 +23,61 @@ public class FollowRelService { ...@@ -20,24 +23,61 @@ public class FollowRelService {
public List<String> queryFansByFollowerId(String followerId) { public List<String> queryFansByFollowerId(String followerId) {
return followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>() return followRelMapper.selectList(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowerId, followerId)) .eq(FollowRelEntity::getFollowerId, followerId)
.stream().map(FollowRelEntity::getFollowUserId).collect(Collectors.toList()); .eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()))
.stream().map(FollowRelEntity::getFollowUserId)
.collect(Collectors.toList());
} }
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator") // @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public List<String> queryFansByIdolId(String idolId) { public List<String> queryFansByIdolId(String idolId) {
LambdaQueryWrapper<FollowRelEntity> queryWrapper = new LambdaQueryWrapper<FollowRelEntity>() LambdaQueryWrapper<FollowRelEntity> queryWrapper = new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowUserId, idolId); .eq(FollowRelEntity::getFollowUserId, idolId)
.eq(FollowRelEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return followRelMapper.selectList(queryWrapper) return followRelMapper.selectList(queryWrapper)
.stream().map(FollowRelEntity::getFollowerId).collect(Collectors.toList()); .stream().map(FollowRelEntity::getFollowerId).collect(Collectors.toList());
} }
@Transactional @Transactional
public void addFans(String idolId, String followerId) { public void addFollowRel(String idolId, String followerId) {
FollowRelEntity rel = new FollowRelEntity(); FollowRelEntity searchResult = queryRecord(idolId, followerId);
rel.setFollowUserId(idolId); if (searchResult==null){
rel.setFollowerId(followerId); FollowRelEntity entity = FollowRelEntity.builder()
.followUserId(idolId)
.followerId(followerId)
.followTime(LocalDateTime.now())
.build();
followRelMapper.insert(rel); followRelMapper.insert(entity);
}else {
searchResult.setFollowTime(LocalDateTime.now());
searchResult.setDeleteTag(DeleteTagEnum.NOT_DELETED.getCode());
followRelMapper.updateById(searchResult);
}
}
/**
* 逻辑删除关注关系
* @param idolId
* @param followerId
*/
@Transactional
public void deleteFollowRel(String idolId, String followerId) {
FollowRelEntity searchResult = queryRecord(idolId, followerId);
if (searchResult==null){
throw new BizException("未找到关注关系");
}
searchResult.setUnfollowTime(LocalDateTime.now());
searchResult.setDeleteTag(DeleteTagEnum.DELETED.getCode());
followRelMapper.updateById(searchResult);
} }
public FollowRelEntity queryRecord(String idolId, String followerId){
return followRelMapper.selectOne(new LambdaQueryWrapper<FollowRelEntity>()
.eq(FollowRelEntity::getFollowUserId,idolId)
.eq(FollowRelEntity::getFollowerId,followerId));
}
} }
...@@ -116,7 +116,8 @@ public class OSSFileService { ...@@ -116,7 +116,8 @@ public class OSSFileService {
} }
public FileRecordEntity queryById(String fileId) { public FileRecordEntity queryById(String fileId) {
return fileRecordMapper.selectById(fileId); return fileRecordMapper.selectOne(new LambdaQueryWrapper<FileRecordEntity>()
.eq(FileRecordEntity::getFileId,fileId));
} }
public List<FileRecordEntity> queryByIds(List<String> fileIds) { public List<FileRecordEntity> queryByIds(List<String> fileIds) {
......
package com.tanpu.community.service; package com.tanpu.community.service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.common.enums.fund.ProductTypeEnum; import com.tanpu.common.enums.fund.ProductTypeEnum;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
...@@ -31,10 +31,7 @@ import org.springframework.util.CollectionUtils; ...@@ -31,10 +31,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -98,9 +95,9 @@ public class ProductService { ...@@ -98,9 +95,9 @@ public class ProductService {
// 图片信息 // 图片信息
Map<String, UserInfoEntity> userMap = Maps.newHashMap(); Map<String, UserInfoEntity> userMap = Maps.newHashMap();
// 批量查询资源信息 // 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap,userMap, themeQos); this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, userMap, themeQos);
//逐个装入 //逐个装入
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap,userMap, topicMap); setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, userMap, topicMap);
} }
...@@ -121,32 +118,32 @@ public class ProductService { ...@@ -121,32 +118,32 @@ public class ProductService {
Map<String, FileRecordEntity> imgMap, Map<String, FileRecordEntity> imgMap,
Map<String, String> topicMap, Map<String, String> topicMap,
Map<String, UserInfoEntity> userMap, Map<String, UserInfoEntity> userMap,
List<ThemeQo> themeQos List<ThemeQo> themeQos
) { ) {
// 白名单基金id // 白名单基金id
List<String> tanpuFundIds = Lists.newArrayList(); HashSet<String> tanpuFundIds = Sets.newHashSet();
// 私募基金id // 私募基金id
List<String> fundIds = Lists.newArrayList(); HashSet<String> fundIds = Sets.newHashSet();
// 理财师导入 // 理财师导入
List<String> ifaFundIds = Lists.newArrayList(); HashSet<String> ifaFundIds = Sets.newHashSet();
// 公募基金id // 公募基金id
List<String> publicFundIds = Lists.newArrayList(); HashSet<String> publicFundIds = Sets.newHashSet();
// 无净值产品id // 无净值产品id
List<String> notNetFundIds = Lists.newArrayList(); HashSet<String> notNetFundIds = Sets.newHashSet();
// 短视频id // 短视频id
List<String> shortVideoIds = Lists.newArrayList(); HashSet<String> shortVideoIds = Sets.newHashSet();
// 直播id // 直播id
List<String> zhiboIds = Lists.newArrayList(); HashSet<String> zhiboIds = Sets.newHashSet();
// 课程id // 课程id
List<String> curriculumIds = Lists.newArrayList(); HashSet<String> curriculumIds = Sets.newHashSet();
// 新课程id // 新课程id
List<String> courseIds = Lists.newArrayList(); HashSet<String> courseIds = Sets.newHashSet();
// 图片id // 图片id
List<String> imageIds = Lists.newArrayList(); HashSet<String> imageIds = Sets.newHashSet();
// 话题id // 话题id
List<String> topicIds = Lists.newArrayList(); HashSet<String> topicIds = Sets.newHashSet();
// 用户id // 用户id
List<String> userIds = Lists.newArrayList(); HashSet<String> userIds = Sets.newHashSet();
// 获取关联资源id // 获取关联资源id
if (themeQos != null) { if (themeQos != null) {
themeQos.forEach(o -> { themeQos.forEach(o -> {
...@@ -157,75 +154,83 @@ public class ProductService { ...@@ -157,75 +154,83 @@ public class ProductService {
}); });
themeQos.forEach(o -> o.getContent().forEach(c -> { themeQos.forEach(o -> o.getContent().forEach(c -> {
if (c.getType().equals(RelTypeEnum.LIVE.type)) { if (c.getType().equals(RelTypeEnum.LIVE.type)) {
zhiboIds.add(c.getValue()); zhiboIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) { } else if (c.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
shortVideoIds.add(c.getValue()); shortVideoIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.FUND.type)) { } else if (c.getType().equals(RelTypeEnum.FUND.type)) {
if (c.getProductType() == ProductTypeEnum.PUBLIC.type) { if (c.getProductType() == ProductTypeEnum.PUBLIC.type) {
publicFundIds.add(c.getValue()); publicFundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.PRIVATE.type) { } else if (c.getProductType() == ProductTypeEnum.PRIVATE.type) {
fundIds.add(c.getValue()); fundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.TAMP.type) { } else if (c.getProductType() == ProductTypeEnum.TAMP.type) {
tanpuFundIds.add(c.getValue()); tanpuFundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.CUSTOMER_IMPORT.type) { } else if (c.getProductType() == ProductTypeEnum.CUSTOMER_IMPORT.type) {
ifaFundIds.add(c.getValue()); ifaFundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.NOT_NET_PRODUCT.type) { } else if (c.getProductType() == ProductTypeEnum.NOT_NET_PRODUCT.type) {
notNetFundIds.add(c.getValue()); notNetFundIds.add(c.getValue());
}
} else if (c.getType().equals(RelTypeEnum.VIDEO.type) || c.getType().equals(RelTypeEnum.AUDIO.type)) {
curriculumIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
courseIds.add(c.getValue());
} }
})
} else if (c.getType().equals(RelTypeEnum.VIDEO.type) || c.getType().equals(RelTypeEnum.AUDIO.type)) {
curriculumIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
courseIds.add(c.getValue());
}
})
); );
} }
if (!CollectionUtils.isEmpty(shortVideoIds)) { if (!CollectionUtils.isEmpty(shortVideoIds)) {
// 短视频列表 // 短视频列表
CommonResp<List<ShortVideoBaseInfoResp>> commonResp = feignClientForTanpuroom.getShortVideoBaseInfo(shortVideoIds); CommonResp<List<ShortVideoBaseInfoResp>> commonResp =
feignClientForTanpuroom.getShortVideoBaseInfo(setToList(shortVideoIds));
if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) { if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
shortVideoMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(ShortVideoBaseInfoResp::getSourceId, item -> item))); shortVideoMap.putAll(commonResp.getData().stream()
.collect(Collectors.toMap(ShortVideoBaseInfoResp::getSourceId, item -> item)));
} }
} }
if (!CollectionUtils.isEmpty(curriculumIds)) { if (!CollectionUtils.isEmpty(curriculumIds)) {
// 课程列表 // 课程列表
List<ShortVideoBaseInfoResp> commonResp = feignClientForFatools.getCurriculumByColumnRelId(curriculumIds); List<ShortVideoBaseInfoResp> commonResp =
feignClientForFatools.getCurriculumByColumnRelId(setToList(curriculumIds));
if (commonResp != null && !CollectionUtils.isEmpty(commonResp)) { if (commonResp != null && !CollectionUtils.isEmpty(commonResp)) {
curriculumMap.putAll(commonResp.stream().collect(Collectors.toMap(ShortVideoBaseInfoResp::getColumnRelId, item -> item))); curriculumMap.putAll(commonResp.stream()
.collect(Collectors.toMap(ShortVideoBaseInfoResp::getColumnRelId, item -> item)));
} }
} }
if (!CollectionUtils.isEmpty(courseIds)) { if (!CollectionUtils.isEmpty(courseIds)) {
// 新版课程列表 // 新版课程列表
CommonResp<List<CourseSimpleResp>> commonResp = feignForCourse.getCourseSimpleList(courseIds); CommonResp<List<CourseSimpleResp>> commonResp =
feignForCourse.getCourseSimpleList(setToList(courseIds));
if (commonResp.isSuccess() & !CollectionUtils.isEmpty(commonResp.getData())) { if (commonResp.isSuccess() & !CollectionUtils.isEmpty(commonResp.getData())) {
courseMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(CourseSimpleResp::getCourseId, item -> item))); courseMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(CourseSimpleResp::getCourseId, item -> item)));
} }
} }
if (!CollectionUtils.isEmpty(zhiboIds)) { if (!CollectionUtils.isEmpty(zhiboIds)) {
// 直播列表 // 直播列表
CommonResp<List<ZhiboListResp>> commonResp = feignClientForZhibo.simpleList(zhiboIds); CommonResp<List<ZhiboListResp>> commonResp =
feignClientForZhibo.simpleList(setToList(zhiboIds));
if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) { if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
zhiboMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item))); zhiboMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item)));
} }
} }
if (!CollectionUtils.isEmpty(imageIds)) { if (!CollectionUtils.isEmpty(imageIds)) {
// 查询图片 // 查询图片
List<FileRecordEntity> fileRecordEntities = ossFileService.queryByIds(imageIds); List<FileRecordEntity> fileRecordEntities =
ossFileService.queryByIds(setToList(imageIds));
if (!CollectionUtils.isEmpty(fileRecordEntities)) { if (!CollectionUtils.isEmpty(fileRecordEntities)) {
imgMap.putAll(fileRecordEntities.stream().collect(Collectors imgMap.putAll(fileRecordEntities.stream().collect(Collectors
.toMap(FileRecordEntity::getFileId, o->o))); .toMap(FileRecordEntity::getFileId, o -> o)));
} }
} }
if (!CollectionUtils.isEmpty(topicIds)) { if (!CollectionUtils.isEmpty(topicIds)) {
// 查询话题标题 // 查询话题标题
List<TopicEntity> topicEntities = topicService.queryByIds(topicIds); List<TopicEntity> topicEntities =
topicService.queryByIds(setToList(topicIds));
if (!CollectionUtils.isEmpty(topicEntities)) { if (!CollectionUtils.isEmpty(topicEntities)) {
topicMap.putAll(topicEntities.stream().collect(Collectors topicMap.putAll(topicEntities.stream().collect(Collectors
.toMap(TopicEntity::getTopicId, TopicEntity::getTopicTitle))); .toMap(TopicEntity::getTopicId, TopicEntity::getTopicTitle)));
...@@ -233,10 +238,11 @@ public class ProductService { ...@@ -233,10 +238,11 @@ public class ProductService {
} }
if (!CollectionUtils.isEmpty(userIds)) { if (!CollectionUtils.isEmpty(userIds)) {
// 查询用户信息 // 查询用户信息
List<UserInfoEntity> userInfos = userInfoService.selectByIds(userIds); List<UserInfoEntity> userInfos =
userInfoService.queryUserByIds(setToList(userIds));
if (!CollectionUtils.isEmpty(userIds)) { if (!CollectionUtils.isEmpty(userIds)) {
userMap.putAll(userInfos.stream().collect(Collectors userMap.putAll(userInfos.stream().collect(Collectors
.toMap(UserInfoEntity::getId, o->o))); .toMap(UserInfoEntity::getId, o -> o)));
} }
} }
this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap); this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
...@@ -250,11 +256,11 @@ public class ProductService { ...@@ -250,11 +256,11 @@ public class ProductService {
* @param publicFundIds * @param publicFundIds
* @param fundMap * @param fundMap
*/ */
private void getFundInfo(List<String> tanpuFundIds, private void getFundInfo(Set<String> tanpuFundIds,
List<String> fundIds, Set<String> fundIds,
List<String> publicFundIds, Set<String> publicFundIds,
List<String> ifaFundIds, Set<String> ifaFundIds,
List<String> notNetFundIds, Set<String> notNetFundIds,
Map<String, FundInfoBaseResp> fundMap) { Map<String, FundInfoBaseResp> fundMap) {
Map<String, FundInfoBaseResp> tampFundMap = null; Map<String, FundInfoBaseResp> tampFundMap = null;
Map<String, FundInfoBaseResp> privateFundMap = null; Map<String, FundInfoBaseResp> privateFundMap = null;
...@@ -266,7 +272,8 @@ public class ProductService { ...@@ -266,7 +272,8 @@ public class ProductService {
// .fundIds(Lists.newArrayList(tanpuFundIds)) // .fundIds(Lists.newArrayList(tanpuFundIds))
// .build(); // .build();
// 探普产品 // 探普产品
CommonResp<List<ProductInfoVO>> commonResp = feignForProduct.getProductInfoByIds(tanpuFundIds); CommonResp<List<ProductInfoVO>> commonResp =
feignForProduct.getProductInfoByIds(setToList(tanpuFundIds));
if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) { if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = commonResp.getData().stream().map(item -> { List<FundInfoBaseResp> fundInfoBaseRespList = commonResp.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build(); FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
...@@ -283,7 +290,8 @@ public class ProductService { ...@@ -283,7 +290,8 @@ public class ProductService {
// 私募产品 // 私募产品
if (!CollectionUtils.isEmpty(fundIds)) { if (!CollectionUtils.isEmpty(fundIds)) {
// 私募产品 // 私募产品
CommonResp<List<ProductInfoVO>> fundResult = feignForFund.getProductList(fundIds); CommonResp<List<ProductInfoVO>> fundResult =
feignForFund.getProductList(setToList(fundIds));
if (fundResult.isSuccess() && !CollectionUtils.isEmpty(fundResult.getData())) { if (fundResult.isSuccess() && !CollectionUtils.isEmpty(fundResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = fundResult.getData().stream().map(item -> { List<FundInfoBaseResp> fundInfoBaseRespList = fundResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build(); FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
...@@ -300,7 +308,8 @@ public class ProductService { ...@@ -300,7 +308,8 @@ public class ProductService {
// 理财师导入产品 // 理财师导入产品
if (!CollectionUtils.isEmpty(ifaFundIds)) { if (!CollectionUtils.isEmpty(ifaFundIds)) {
CommonResp<List<ProductInfoVO>> ifaFundResult = feignForFund.getPrivateFundList(ifaFundIds); CommonResp<List<ProductInfoVO>> ifaFundResult =
feignForFund.getPrivateFundList(setToList(ifaFundIds));
if (ifaFundResult.isSuccess() && !CollectionUtils.isEmpty(ifaFundResult.getData())) { if (ifaFundResult.isSuccess() && !CollectionUtils.isEmpty(ifaFundResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = ifaFundResult.getData().stream().map(item -> { List<FundInfoBaseResp> fundInfoBaseRespList = ifaFundResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build(); FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
...@@ -317,7 +326,8 @@ public class ProductService { ...@@ -317,7 +326,8 @@ public class ProductService {
if (!CollectionUtils.isEmpty(publicFundIds)) { if (!CollectionUtils.isEmpty(publicFundIds)) {
// 公募产品 // 公募产品
CommonResp<List<ProductInfoVO>> publicFundResult = feignForPublicFund.getProductList(publicFundIds); CommonResp<List<ProductInfoVO>> publicFundResult =
feignForPublicFund.getProductList(setToList(publicFundIds));
if (publicFundResult.isSuccess() && !CollectionUtils.isEmpty(publicFundResult.getData())) { if (publicFundResult.isSuccess() && !CollectionUtils.isEmpty(publicFundResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = publicFundResult.getData().stream().map(item -> { List<FundInfoBaseResp> fundInfoBaseRespList = publicFundResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build(); FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
...@@ -333,7 +343,8 @@ public class ProductService { ...@@ -333,7 +343,8 @@ public class ProductService {
if (!CollectionUtils.isEmpty(notNetFundIds)) { if (!CollectionUtils.isEmpty(notNetFundIds)) {
// 无净值产品 // 无净值产品
CommonResp<List<ProductInfoVO>> notNetInfoResult = feignForFund.getProductListNotNetInfo(notNetFundIds); CommonResp<List<ProductInfoVO>> notNetInfoResult =
feignForFund.getProductListNotNetInfo(setToList(notNetFundIds));
if (notNetInfoResult.isSuccess() && !CollectionUtils.isEmpty(notNetInfoResult.getData())) { if (notNetInfoResult.isSuccess() && !CollectionUtils.isEmpty(notNetInfoResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = notNetInfoResult.getData().stream().map(item -> { List<FundInfoBaseResp> fundInfoBaseRespList = notNetInfoResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build(); FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
...@@ -359,7 +370,7 @@ public class ProductService { ...@@ -359,7 +370,7 @@ public class ProductService {
Map<String, FundInfoBaseResp> fundMap, Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgUrlMap, Map<String, FileRecordEntity> imgUrlMap,
Map<String, UserInfoEntity> userMap, Map<String, UserInfoEntity> userMap,
Map<String, String> topicMap) { Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) { for (ThemeQo themeQo : themeQos) {
if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) { if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) {
themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId())); themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
...@@ -408,7 +419,7 @@ public class ProductService { ...@@ -408,7 +419,7 @@ public class ProductService {
if (imgUrlMap.containsKey(themeContent.getValue())) { if (imgUrlMap.containsKey(themeContent.getValue())) {
FileRecordEntity imgEntity = imgUrlMap.get(themeContent.getValue()); FileRecordEntity imgEntity = imgUrlMap.get(themeContent.getValue());
String extInfo = imgEntity.getExtInfo(); String extInfo = imgEntity.getExtInfo();
if (!StringUtils.isEmpty(extInfo)){ if (!StringUtils.isEmpty(extInfo)) {
Map<String, Object> extMap = JsonUtil.toMap(extInfo); Map<String, Object> extMap = JsonUtil.toMap(extInfo);
ImagesDTO imagesDTO = ImagesDTO.builder().imgHeight((Integer) extMap.get("height")) ImagesDTO imagesDTO = ImagesDTO.builder().imgHeight((Integer) extMap.get("height"))
.imgWidth((Integer) extMap.get("width")) .imgWidth((Integer) extMap.get("width"))
...@@ -419,11 +430,16 @@ public class ProductService { ...@@ -419,11 +430,16 @@ public class ProductService {
} }
} }
} }
} }
} }
} }
private List<String> setToList(Set<String> set) {
List<String> l = new ArrayList<>();
l.addAll(set);
return l;
}
} }
...@@ -44,30 +44,69 @@ public class ThemeService { ...@@ -44,30 +44,69 @@ public class ThemeService {
.eq(ThemeEntity::getThemeId,themeId)); .eq(ThemeEntity::getThemeId,themeId));
} }
public List<ThemeEntity> queryThemeIdsByUserId(String userId) { public List<ThemeEntity> queryThemesByUserId(String userId) {
return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>() return themeMapper.selectList(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getAuthorId,userId) .eq(ThemeEntity::getAuthorId,userId)
.eq(ThemeEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())); .eq(ThemeEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(ThemeEntity::getId));
}
public List<ThemeEntity> queryThemesByUserId(String userId, String lastId, Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getAuthorId, userId)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.orderByDesc(ThemeEntity::getId);
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);
}
return themeMapper.selectList(queryWrapper);
}
//根据ids返回主题详情
public List<ThemeEntity> queryByThemeIds(List<String> themeIds, String lastId,Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
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);
}
return themeMapper.selectList(queryWrapper);
} }
//根据ids返回主题详情 //根据ids返回主题详情
public List<ThemeEntity> queryByThemeIds(List<String> themeIds) { public List<ThemeEntity> queryByThemeIds(List<String> themeIds) {
return themeMapper.selectList(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());
return themeMapper.selectList(queryWrapper);
} }
//分页倒叙lastId之前的主题 //分页倒叙lastId之前的主题
public List<ThemeEntity> selectAll(String lastId,Integer pageSize) { public List<ThemeEntity> selectAll(String lastId,Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>();
.orderByDesc(ThemeEntity::getUpdateTime);
if (StringUtils.isNotEmpty(lastId)) { if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryByThemeId(lastId); ThemeEntity lastEntity = queryByThemeId(lastId);
if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId); if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime()); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
} }
queryWrapper.last("limit "+pageSize); queryWrapper.last("limit "+pageSize);
queryWrapper.orderByDesc(ThemeEntity::getId); queryWrapper.orderByDesc(ThemeEntity::getId);
queryWrapper.orderByDesc(ThemeEntity::getCreateTime);
queryWrapper.eq(ThemeEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
...@@ -79,18 +118,19 @@ public class ThemeService { ...@@ -79,18 +118,19 @@ public class ThemeService {
* @param pageSize 查询数量 * @param pageSize 查询数量
* @return * @return
*/ */
public List<ThemeEntity> queryByTopic(String topidId, String lastId,Integer pageSize) { public List<ThemeEntity> queryByTopic(String topidId, String lastId, Integer pageSize) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getTopicId, topidId); .eq(ThemeEntity::getTopicId, topidId);
if (StringUtils.isNotEmpty(lastId)) { if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryByThemeId(lastId); ThemeEntity lastEntity = queryByThemeId(lastId);
if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId); if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime()); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
} }
if (pageSize!=null){ if (pageSize!=null){
queryWrapper.last("limit "+pageSize); queryWrapper.last("limit "+pageSize);
} }
queryWrapper.orderByDesc(ThemeEntity::getId); queryWrapper.orderByDesc(ThemeEntity::getCreateTime);
queryWrapper.eq(ThemeEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
...@@ -109,15 +149,15 @@ public class ThemeService { ...@@ -109,15 +149,15 @@ public class ThemeService {
//关注的主题列表 //关注的主题列表
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);
.orderByDesc(ThemeEntity::getUpdateTime);
if (StringUtils.isNotEmpty(lastId)) { if (StringUtils.isNotEmpty(lastId)) {
ThemeEntity lastEntity = queryByThemeId(lastId); ThemeEntity lastEntity = queryByThemeId(lastId);
if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId); if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId);
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime()); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getCreateTime());
} }
queryWrapper.last("limit "+pageSize); queryWrapper.last("limit "+pageSize);
queryWrapper.orderByDesc(ThemeEntity::getCreateTime);
queryWrapper.eq(ThemeEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
...@@ -145,7 +185,8 @@ public class ThemeService { ...@@ -145,7 +185,8 @@ public class ThemeService {
@Transactional @Transactional
public void deleteById(String themeId) { public void deleteById(String themeId) {
ThemeEntity themeEntity = themeMapper.selectById(themeId); ThemeEntity themeEntity = themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getThemeId, themeId));
if (themeEntity==null){ if (themeEntity==null){
throw new BizException("主题未找到,id:"+themeId); throw new BizException("主题未找到,id:"+themeId);
} }
......
...@@ -7,12 +7,14 @@ import com.tanpu.community.api.enums.DeleteTagEnum; ...@@ -7,12 +7,14 @@ import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.TopicStatusEnum; import com.tanpu.community.api.enums.TopicStatusEnum;
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.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -83,11 +85,14 @@ public class TopicService { ...@@ -83,11 +85,14 @@ public class TopicService {
} }
public List<TopicEntity> queryByIds(List<String> topicIds) { public List<TopicEntity> queryByIds(List<String> 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) { public void modifyViewCount(String topicId, long Count) {
TopicEntity topicEntity = topicMapper.selectById(topicId); TopicEntity topicEntity = queryById(topicId);
Long oldCount = topicEntity.getviewCntAdjust(); Long oldCount = topicEntity.getviewCntAdjust();
topicEntity.setViewAmountModify(topicEntity.getviewCntAdjust() + Count); topicEntity.setViewAmountModify(topicEntity.getviewCntAdjust() + Count);
topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>() topicMapper.update(topicEntity, new LambdaUpdateWrapper<TopicEntity>()
......
...@@ -14,11 +14,11 @@ public class UserInfoService { ...@@ -14,11 +14,11 @@ public class UserInfoService {
private UserInfoMapper userInfoMapper; private UserInfoMapper userInfoMapper;
public UserInfoEntity selectById(String userId) { public UserInfoEntity queryUserById(String userId) {
return userInfoMapper.selectById(userId); return userInfoMapper.selectById(userId);
} }
public List<UserInfoEntity> selectByIds(List<String> ids) { public List<UserInfoEntity> queryUserByIds(List<String> ids) {
return userInfoMapper.selectBatchIds(ids); return userInfoMapper.selectBatchIds(ids);
} }
} }
package com.tanpu.community.service.other; package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.user.UserRistRzEntity; import com.tanpu.community.dao.entity.user.UserRistRzEntity;
......
package com.tanpu.community.service.other;
import com.tanpu.community.dao.entity.user.CurriculumPriceEntity;
import com.tanpu.community.dao.mapper.user.CurriculumPriceMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class CurriculumPriceService {
@Resource
private CurriculumPriceMapper curriculumPriceMapper;
public CurriculumPriceEntity selectById(String id){
return curriculumPriceMapper.selectById(id);
}
public List<CurriculumPriceEntity> selectByIds(List<String> ids){
if (CollectionUtils.isEmpty(ids)){
return Collections.emptyList();
}
return curriculumPriceMapper.selectBatchIds(ids);
}
}
package com.tanpu.community.service.other;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.enums.CurriculumEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.user.CurriculumResEntity;
import com.tanpu.community.dao.mapper.user.CurriculumResMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 短视频详情
*/
@Service
public class CurriculumResService {
@Resource
private CurriculumResMapper curriculumResMapper;
public CurriculumResEntity selectById(String id) {
return curriculumResMapper.selectById(id);
}
public CurriculumResEntity selectShortVideo(String id){
return curriculumResMapper.selectOne(new LambdaQueryWrapper<CurriculumResEntity>()
.eq(CurriculumResEntity::getId,id)
.eq(CurriculumResEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.eq(CurriculumResEntity::getStatus, CurriculumEnum.CcStatus.up));
}
}
package com.tanpu.community.service.other;
import com.tanpu.community.dao.entity.user.FinProResEntity;
import com.tanpu.community.dao.mapper.user.FinProResMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 产品详情
*/
@Service
public class FinProResService {
@Resource
private FinProResMapper finProResMapper;
public FinProResEntity selectById(String id){
return finProResMapper.selectById(id);
}
}
package com.tanpu.community.service.other;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.user.OrderFlowEntity;
import com.tanpu.community.dao.mapper.user.OrderFlowMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class OrderFlowService {
@Resource
private OrderFlowMapper orderFlowMapper;
public OrderFlowEntity selectById(String id){
return orderFlowMapper.selectById(id);
}
public List<OrderFlowEntity> selectByIds(List<String> ids){
if (CollectionUtils.isEmpty(ids)){
return Collections.emptyList();
}
return orderFlowMapper.selectBatchIds(ids);
}
public OrderFlowEntity queryByUserAndProId(String proId,String userId){
return orderFlowMapper.selectOne(new LambdaQueryWrapper<OrderFlowEntity>()
.eq(OrderFlowEntity::getCreateby,userId)
.eq(OrderFlowEntity::getAbProid,proId)
.eq(OrderFlowEntity::getDeletetag, DeleteTagEnum.NOT_DELETED.getCode())
.eq(OrderFlowEntity::getAbStatus,"SUCCESS"));
}
}
package com.tanpu.community.service.other;
import com.tanpu.community.dao.entity.zhibo.ZhiboThemeEntity;
import com.tanpu.community.dao.mapper.zhibo.ZhiboThemeMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 直播详情
*/
@Service
public class ZhiboService {
@Resource
private ZhiboThemeMapper zhiboThemeMapper;
public ZhiboThemeEntity selectByid(String id) {
return zhiboThemeMapper.selectById(id);
}
}
...@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.theme.ThemeContentReq; ...@@ -10,6 +10,7 @@ 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.dao.entity.community.*; import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -19,20 +20,21 @@ import java.util.stream.Collectors; ...@@ -19,20 +20,21 @@ import java.util.stream.Collectors;
public class ConvertUtil { public class ConvertUtil {
public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) { public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
if (themeEntity==null){ if (themeEntity == null) {
return null; return null;
} }
ThemeQo themeQO = new ThemeQo(); ThemeQo themeQO = new ThemeQo();
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()));
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 ThemeQo themeEntityToQo2(ThemeEntity themeEntity) {
if (themeEntity==null){ if (themeEntity == null) {
return null; return null;
} }
ThemeQo themeQO = new ThemeQo(); ThemeQo themeQO = new ThemeQo();
...@@ -40,12 +42,13 @@ public class ConvertUtil { ...@@ -40,12 +42,13 @@ public class ConvertUtil {
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())); 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>>() {
});
//首页列表使用,限制附件个数为1(1文本+1附件),-》已经改为全部返回 //首页列表使用,限制附件个数为1(1文本+1附件),-》已经改为全部返回
// if (themeContentQos != null && themeContentQos.size() > 2) { // if (themeContentQos != null && themeContentQos.size() > 2) {
// themeQO.setContent(themeContentQos.subList(0, 2)); // themeQO.setContent(themeContentQos.subList(0, 2));
// }else{ // }else{
themeQO.setContent(themeContentQos); themeQO.setContent(themeContentQos);
// } // }
return themeQO; return themeQO;
...@@ -60,6 +63,7 @@ public class ConvertUtil { ...@@ -60,6 +63,7 @@ public class ConvertUtil {
/** /**
* 首页主题列表,限制附件个数为1(1文本+1附件) * 首页主题列表,限制附件个数为1(1文本+1附件)
*
* @param themeEntities * @param themeEntities
* @return * @return
*/ */
...@@ -80,7 +84,7 @@ public class ConvertUtil { ...@@ -80,7 +84,7 @@ public class ConvertUtil {
return topicHotQo; return topicHotQo;
} }
public static List<TopicHotQo> topicEntityToHotQos(List<TopicEntity> topicEntities){ public static List<TopicHotQo> topicEntityToHotQos(List<TopicEntity> topicEntities) {
return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList()); return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList());
} }
...@@ -89,6 +93,7 @@ public class ConvertUtil { ...@@ -89,6 +93,7 @@ public class ConvertUtil {
BeanUtils.copyProperties(topicEntity, topicTitileQo); BeanUtils.copyProperties(topicEntity, topicTitileQo);
return topicTitileQo; return topicTitileQo;
} }
public static CommentQo commentEntity2Qo(CommentEntity entity) { public static CommentQo commentEntity2Qo(CommentEntity entity) {
CommentQo qo = new CommentQo(); CommentQo qo = new CommentQo();
BeanUtils.copyProperties(entity, qo); BeanUtils.copyProperties(entity, qo);
...@@ -96,7 +101,7 @@ public class ConvertUtil { ...@@ -96,7 +101,7 @@ public class ConvertUtil {
return qo; return qo;
} }
public static List<CommentQo> commentEntity2Qos(List<CommentEntity> entities){ public static List<CommentQo> commentEntity2Qos(List<CommentEntity> entities) {
return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList()); return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList());
} }
...@@ -106,7 +111,7 @@ public class ConvertUtil { ...@@ -106,7 +111,7 @@ public class ConvertUtil {
return qo; return qo;
} }
public static List<CommentLv2Qo> commentLv2Entity2Qos(List<CommentEntity> entities){ public static List<CommentLv2Qo> commentLv2Entity2Qos(List<CommentEntity> entities) {
return entities.stream().map(ConvertUtil::commentLv2Entity2Qo).collect(Collectors.toList()); return entities.stream().map(ConvertUtil::commentLv2Entity2Qo).collect(Collectors.toList());
} }
...@@ -119,8 +124,6 @@ public class ConvertUtil { ...@@ -119,8 +124,6 @@ public class ConvertUtil {
} }
public static DeleteTagEnum deleteTagShift(DeleteTagEnum deleteTagEnum) { public static DeleteTagEnum deleteTagShift(DeleteTagEnum deleteTagEnum) {
if (deleteTagEnum.getCode().equals(DeleteTagEnum.NOT_DELETED.getCode())) { if (deleteTagEnum.getCode().equals(DeleteTagEnum.NOT_DELETED.getCode())) {
return DeleteTagEnum.DELETED; return DeleteTagEnum.DELETED;
...@@ -139,6 +142,7 @@ public class ConvertUtil { ...@@ -139,6 +142,7 @@ public class ConvertUtil {
/** /**
* 解析 List<ThemeContentReq>为Attachment列表 * 解析 List<ThemeContentReq>为Attachment列表
*
* @param req * @param req
* @param themeId * @param themeId
* @return * @return
...@@ -148,9 +152,9 @@ public class ConvertUtil { ...@@ -148,9 +152,9 @@ public class ConvertUtil {
List<ThemeAttachmentEntity> list = new ArrayList<>(); List<ThemeAttachmentEntity> list = new ArrayList<>();
for (ThemeContentReq content : contents) { for (ThemeContentReq content : contents) {
if (!RelTypeEnum.TEXT.type.equals(content.getType())){ if (!RelTypeEnum.TEXT.type.equals(content.getType())) {
//讨论-多图类型,拆开解析到attachment表中 //讨论-多图类型,拆开解析到attachment表中
if ((content.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type))){ if ((content.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type))) {
List<ImagesDTO> imgList = content.getImgList(); List<ImagesDTO> imgList = content.getImgList();
for (ImagesDTO imagesDTO : imgList) { for (ImagesDTO imagesDTO : imgList) {
list.add(ThemeAttachmentEntity.builder() list.add(ThemeAttachmentEntity.builder()
...@@ -159,7 +163,7 @@ public class ConvertUtil { ...@@ -159,7 +163,7 @@ public class ConvertUtil {
.themeId(themeId) .themeId(themeId)
.build()); .build());
} }
}else { } else {
list.add(ThemeAttachmentEntity.builder() list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(content.getType())) .attachType(Integer.valueOf(content.getType()))
.attachId(content.getValue()) .attachId(content.getValue())
...@@ -171,14 +175,33 @@ public class ConvertUtil { ...@@ -171,14 +175,33 @@ public class ConvertUtil {
return list; return list;
} }
public static FollowQo homePageEntity2FollowQo(HomePageEntity entity) { public static FollowQo homePageEntity2FollowQo(UserInfoEntity entity) {
if (entity == null) { if (entity == null) {
return null; return null;
} }
FollowQo followQo = new FollowQo(); return FollowQo.builder().userId(entity.getId())
BeanUtils.copyProperties(entity, followQo); .nickName(entity.getUiNickname())
return followQo; .headImg(entity.getUiHeadimg())
.introduction(entity.getUiIntroduction())
.build();
} }
public static FormerThemeQo themeQo2FormerThemeQo(ThemeQo formerTheme) {
if (formerTheme == null) {
return null;
}
return FormerThemeQo.builder().themeId(formerTheme.getThemeId())
.content(formerTheme.getContent())
.userImg(formerTheme.getUserImg())
.nickName(formerTheme.getNickName())
.title(formerTheme.getTitle())
.topicId(formerTheme.getTopicId())
.topicTitle(formerTheme.getTopicTitle())
.authorId(formerTheme.getAuthorId())
.themeType(formerTheme.getThemeType())
.build();
}
} }
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