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

主题接口

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