Commit 32018643 authored by 刘基明's avatar 刘基明

主题接口

parent f3456d0c
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Data @Data
public class ThemeDTO { public class ThemeDTO {
...@@ -16,18 +17,12 @@ public class ThemeDTO { ...@@ -16,18 +17,12 @@ public class ThemeDTO {
@ApiModelProperty(value = "标题") @ApiModelProperty(value = "标题")
private String title; private String title;
@ApiModelProperty(value = "类型 1:讨论无标题 2:常温有标题") @ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题")
private Integer themeType; private Integer themeType;
@ApiModelProperty(value = "文本内容") @ApiModelProperty(value = "文本内容")
private String content; private String content;
@ApiModelProperty(value = "附件类型 1:产品 2:直播 3:短视频 4:课程")
private Integer attachType;
@ApiModelProperty(value = "附件内容")
private String attachment;
@ApiModelProperty(value = "作者id") @ApiModelProperty(value = "作者id")
private String authorId; private String authorId;
...@@ -40,6 +35,9 @@ public class ThemeDTO { ...@@ -40,6 +35,9 @@ public class ThemeDTO {
@ApiModelProperty(value = "用户头像") @ApiModelProperty(value = "用户头像")
private String userImg; private String userImg;
@ApiModelProperty(value = "是否关注")
private boolean follow;
@ApiModelProperty(value = "认证") @ApiModelProperty(value = "认证")
private String authLabel; private String authLabel;
...@@ -58,6 +56,9 @@ public class ThemeDTO { ...@@ -58,6 +56,9 @@ public class ThemeDTO {
@ApiModelProperty(value = "点赞量") @ApiModelProperty(value = "点赞量")
private Long likeAmount; private Long likeAmount;
@ApiModelProperty("附件")
private List<Object> attachment;
private String createBy; private String createBy;
private LocalDateTime createTime; private LocalDateTime createTime;
......
...@@ -37,7 +37,8 @@ public class ThemeController { ...@@ -37,7 +37,8 @@ public class ThemeController {
@RequestMapping(value = "/recmend_list") @RequestMapping(value = "/recmend_list")
@ResponseBody @ResponseBody
public List<ThemeDTO> selectHotList(){ public List<ThemeDTO> selectHotList(){
return null; String userId="liujm";
return themeManager.selectHotThemes(userId);
} }
@ApiOperation("获取关注的圈文") @ApiOperation("获取关注的圈文")
...@@ -45,7 +46,7 @@ public class ThemeController { ...@@ -45,7 +46,7 @@ public class ThemeController {
@ResponseBody @ResponseBody
public List<ThemeDTO> selectInterestList(){ public List<ThemeDTO> selectInterestList(){
String userId="liujm012"; String userId="liujm012";
return null; return themeManager.selectInterestThemes(userId);
} }
@ApiOperation("评论") @ApiOperation("评论")
...@@ -68,16 +69,16 @@ public class ThemeController { ...@@ -68,16 +69,16 @@ public class ThemeController {
@ApiOperation("点赞主题") @ApiOperation("点赞主题")
@RequestMapping(value = "/like") @GetMapping(value = "/like")
@ResponseBody @ResponseBody
public String likeOnTheme(String themeId){ public String likeOnTheme(@RequestParam String themeId){
String user="liujm"; String user="liujm";
themeManager.like(themeId,user); themeManager.like(themeId,user);
return "success"; return "success";
} }
@ApiOperation("分享主题") @ApiOperation("分享主题")
@RequestMapping(value = "/share") @GetMapping(value = "/share")
@ResponseBody @ResponseBody
public String shareTheme(String themeId){ public String shareTheme(String themeId){
return "success"; return "success";
...@@ -93,9 +94,9 @@ public class ThemeController { ...@@ -93,9 +94,9 @@ public class ThemeController {
} }
@ApiOperation("举报主题") @ApiOperation("举报主题")
@RequestMapping(value = "/complaint") @GetMapping(value = "/complaint")
@ResponseBody @ResponseBody
public String complaintTheme(String themeId){ public String complaintTheme(@RequestParam String themeId){
return "功能暂未开放"; return "功能暂未开放";
} }
......
...@@ -21,12 +21,12 @@ public class CodeAutoGenerator { ...@@ -21,12 +21,12 @@ public class CodeAutoGenerator {
String author = "xudong"; String author = "xudong";
String mysqlUserName = "tamp_admin"; String mysqlUserName = "tamp_admin";
String mysqlPassword = "@imeng123"; String mysqlPassword = "@imeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user"; String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community";
String[] tables = new String[]{"order_flow","curriculum_price"}; String[] tables = new String[]{"collection"};
// String[] tables = new String[]{"visit_summary", "black_list","collection","comment","fans_rel","file_record","home_page","theme","topic"}; // String[] tables = new String[]{"visit_summary", "black_list","collection","comment","fans_rel","file_record","home_page","theme","topic"};
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:\\code\\backend\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\user"; String xmlPath = "D:\\code\\backend\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\user";
AutoGenerator autoGenerator = new AutoGenerator(); AutoGenerator autoGenerator = new AutoGenerator();
//全局配置 //全局配置
......
package com.tanpu.community.dao.entity.community; package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
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.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 主题内容 * 主题内容
* </p> * </p>
* *
* @author xudong * @author xudong
* @since 2021-06-10 * @since 2021-06-28
*/ */
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
...@@ -38,12 +39,6 @@ public class ThemeEntity implements Serializable { ...@@ -38,12 +39,6 @@ public class ThemeEntity implements Serializable {
@ApiModelProperty(value = "文本内容") @ApiModelProperty(value = "文本内容")
private String content; private String content;
@ApiModelProperty(value = "附件类型")
private Integer attachType;
@ApiModelProperty(value = "附件内容")
private String attachment;
@ApiModelProperty(value = "作者id") @ApiModelProperty(value = "作者id")
private String authorId; private String authorId;
...@@ -96,22 +91,6 @@ public class ThemeEntity implements Serializable { ...@@ -96,22 +91,6 @@ public class ThemeEntity implements Serializable {
this.content = content; this.content = content;
} }
public Integer getAttachType() {
return attachType;
}
public void setAttachType(Integer attachType) {
this.attachType = attachType;
}
public String getAttachment() {
return attachment;
}
public void setAttachment(String attachment) {
this.attachment = attachment;
}
public String getAuthorId() { public String getAuthorId() {
return authorId; return authorId;
} }
...@@ -183,8 +162,6 @@ public class ThemeEntity implements Serializable { ...@@ -183,8 +162,6 @@ public class ThemeEntity implements Serializable {
", title=" + title + ", title=" + title +
", themeType=" + themeType + ", themeType=" + themeType +
", content=" + content + ", content=" + content +
", attachType=" + attachType +
", attachment=" + attachment +
", authorId=" + authorId + ", authorId=" + authorId +
", formerThemeId=" + formerThemeId + ", formerThemeId=" + formerThemeId +
", topicId=" + topicId + ", topicId=" + topicId +
......
...@@ -5,16 +5,12 @@ import com.tanpu.community.api.beans.ThemeDTO; ...@@ -5,16 +5,12 @@ import com.tanpu.community.api.beans.ThemeDTO;
import com.tanpu.community.api.constants.BlockTypeEnum; import com.tanpu.community.api.constants.BlockTypeEnum;
import com.tanpu.community.api.constants.CollectionTypeEnum; import com.tanpu.community.api.constants.CollectionTypeEnum;
import com.tanpu.community.api.constants.CommentTypeEnum; import com.tanpu.community.api.constants.CommentTypeEnum;
import com.tanpu.community.dao.entity.community.BlackListEntity; import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.community.FansRelEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.user.CurriculumResEntity; import com.tanpu.community.dao.entity.user.CurriculumResEntity;
import com.tanpu.community.dao.entity.user.FinProResEntity;
import com.tanpu.community.dao.entity.user.OrderFlowEntity; import com.tanpu.community.dao.entity.user.OrderFlowEntity;
import com.tanpu.community.dao.entity.zhibo.ZhiboThemeEntity;
import com.tanpu.community.service.*; import com.tanpu.community.service.*;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -23,6 +19,7 @@ import java.time.Duration; ...@@ -23,6 +19,7 @@ import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -57,6 +54,9 @@ public class ThemeManager { ...@@ -57,6 +54,9 @@ public class ThemeManager {
@Autowired @Autowired
private OrderFlowService orderFlowService; private OrderFlowService orderFlowService;
@Autowired
private ThemeAttachmentService themeAttachmentService;
// 返回推荐主题文章 // 返回推荐主题文章
public List<ThemeDTO> selectHotThemes(String userId) { public List<ThemeDTO> selectHotThemes(String userId) {
// TODO:根据算法计算推荐主题 // TODO:根据算法计算推荐主题
...@@ -181,36 +181,46 @@ public class ThemeManager { ...@@ -181,36 +181,46 @@ public class ThemeManager {
//查询话题所需关联信息 //查询话题所需关联信息
private void fillDTOExtraInfo(ThemeDTO themeDTO, String userId) { private void fillDTOExtraInfo(ThemeDTO themeDTO,String userId) {
switch (themeDTO.getAttachType()) { List<ThemeAttachmentEntity> attachments = themeAttachmentService.selectByThemeId(themeDTO.getId());
if (CollectionUtils.isEmpty(attachments)){
return;
}
List<Object> obs = attachments.stream().map(themeAttachmentEntity -> transferAttachment(themeAttachmentEntity, userId)).collect(Collectors.toList());
themeDTO.setAttachment(obs);
//是否关注
themeDTO.setUpToNowTime(calUpToNowTime(themeDTO.getCreateTime()));
String authorId = themeDTO.getCreateBy();
Map<String, FansRelEntity> fansMap = fansRelService.queryFansByFollowerId(userId).stream().collect(Collectors.toMap(FansRelEntity::getIdolId, c -> c));
if (fansMap.containsKey(authorId)) {
themeDTO.setFollow(true);
}else {
themeDTO.setFollow(false);
}
//TODO 添加用户名、头像、认证、是否关注
}
public Object transferAttachment(ThemeAttachmentEntity themeAttachment,String userId){
switch (themeAttachment.getAttachType()) {
//附件类型 1:产品 2:直播 3:短视频 4:课程 //附件类型 1:产品 2:直播 3:短视频 4:课程
//TODO ENTITY 转 DTO //TODO ENTITY 转 DTO
case 1: case 1:
FinProResEntity finProResEntity = finProResService.selectById(themeDTO.getAttachment()); return finProResService.selectById(themeAttachment.getAttchId());
themeDTO.setAttachmentInfo(finProResEntity);
break;
case 2: case 2:
ZhiboThemeEntity zhiboThemeEntity = zhiboService.selectByid(themeDTO.getAttachment()); return zhiboService.selectByid(themeAttachment.getAttchId());
themeDTO.setAttachmentInfo(zhiboThemeEntity);
break;
case 3: case 3:
CurriculumResEntity curriculumResEntity = curriculumResService.selectShortVideo(themeDTO.getAttachment()); CurriculumResEntity curriculumResEntity = curriculumResService.selectShortVideo(themeAttachment.getAttchId());
themeDTO.setAttachmentInfo(curriculumResEntity); return curriculumResEntity;
break;
case 4: case 4:
curriculumResEntity = curriculumResService.selectById(themeAttachment.getAttchId());
//todo 栏目详情,需要判断当前用户是否购买 //todo 栏目详情,需要判断当前用户是否购买
curriculumResEntity = curriculumResService.selectById(themeDTO.getAttachment()); OrderFlowEntity orderFlowEntity = orderFlowService.queryByUserAndProId(themeAttachment.getThemeId(), userId);
themeDTO.setAttachmentInfo(curriculumResEntity); return curriculumResEntity;
OrderFlowEntity orderFlowEntity = orderFlowService.queryByUserAndProId(themeDTO.getId(), userId);
break;
default: default:
break; return null;
} }
themeDTO.setUpToNowTime(calUpToNowTime(themeDTO.getCreateTime()));
//TODO 添加用户名、头像、认证
} }
} }
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.mapper.community.ThemeAttachmentMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class ThemeAttachmentService {
@Resource
private ThemeAttachmentMapper themeAttachmentMapper;
public List<ThemeAttachmentEntity> selectByThemeId(String themeId){
return themeAttachmentMapper.selectList(new LambdaQueryWrapper<ThemeAttachmentEntity>()
.eq(ThemeAttachmentEntity::getThemeId,themeId));
}
}
...@@ -4,8 +4,13 @@ import com.tanpu.community.api.beans.ThemeDTO; ...@@ -4,8 +4,13 @@ import com.tanpu.community.api.beans.ThemeDTO;
import com.tanpu.community.api.beans.TopicBriefInfoDTO; import com.tanpu.community.api.beans.TopicBriefInfoDTO;
import com.tanpu.community.api.beans.TopicDTO; import com.tanpu.community.api.beans.TopicDTO;
import com.tanpu.community.api.constants.DeleteTagEnum; import com.tanpu.community.api.constants.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TopicEntity; import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.user.CurriculumResEntity;
import com.tanpu.community.dao.entity.user.FinProResEntity;
import com.tanpu.community.dao.entity.user.OrderFlowEntity;
import com.tanpu.community.dao.entity.zhibo.ZhiboThemeEntity;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.util.List; import java.util.List;
...@@ -71,4 +76,5 @@ public class ConvertUtil { ...@@ -71,4 +76,5 @@ public class ConvertUtil {
return DeleteTagEnum.NOT_DELETED.getCode(); return DeleteTagEnum.NOT_DELETED.getCode();
} }
} }
} }
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