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

主题接口修改

parent b4d12b79
package com.tanpu.community.api.constants;
public class CommunityConstant {
public static final String OSS_PREFIX_URL ="https://tamp-sit.oss-cn-shanghai.aliyuncs.com";
}
...@@ -14,11 +14,9 @@ import com.tanpu.community.api.beans.vo.feign.CoursePackageDetail; ...@@ -14,11 +14,9 @@ import com.tanpu.community.api.beans.vo.feign.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.ProductInfoVO; import com.tanpu.community.api.beans.vo.feign.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp; import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.ZhiboDetailVO; import com.tanpu.community.api.beans.vo.feign.ZhiboDetailVO;
import com.tanpu.community.api.constants.CommunityConstant;
import com.tanpu.community.api.enums.*; import com.tanpu.community.api.enums.*;
import com.tanpu.community.dao.entity.community.BlackListEntity; import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.community.HomePageEntity;
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.feign.course.FeignClientForCourse; import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.product.FeignClientForProducts; import com.tanpu.community.feign.product.FeignClientForProducts;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom; import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
...@@ -87,6 +85,8 @@ public class ThemeManager { ...@@ -87,6 +85,8 @@ public class ThemeManager {
@Autowired @Autowired
private FeignClientForCourse feignClientForCourse; private FeignClientForCourse feignClientForCourse;
private OSSFileService ossFileService;
public void publishTheme(CreateThemeReq req, String userId) { public void publishTheme(CreateThemeReq req, String userId) {
...@@ -298,10 +298,15 @@ public class ThemeManager { ...@@ -298,10 +298,15 @@ public class ThemeManager {
String packageId = themeContentQo.getValue(); String packageId = themeContentQo.getValue();
CommonResp<CoursePackageDetail> courseIdDetailInfo = feignClientForCourse.getCoursePackageDetailInfo(packageId); CommonResp<CoursePackageDetail> courseIdDetailInfo = feignClientForCourse.getCoursePackageDetailInfo(packageId);
themeContentQo.setDetail(AttachmentDetailVo.builder().coursePackageDetail(courseIdDetailInfo.getData()).build()); themeContentQo.setDetail(AttachmentDetailVo.builder().coursePackageDetail(courseIdDetailInfo.getData()).build());
}else if (RelTypeEnum.SINGLE_IMG.type.equals(type)) {
//单图,根据id传入url
String imgId = themeContentQo.getValue();
FileRecordEntity fileEntity = ossFileService.queryById(imgId);
themeContentQo.setValue(CommunityConstant.OSS_PREFIX_URL+fileEntity.getFileOssKey());
} }
} }
//计算迄今时间 //计算迄今时间
......
...@@ -79,4 +79,8 @@ public class OSSFileService { ...@@ -79,4 +79,8 @@ public class OSSFileService {
return record; return record;
} }
public FileRecordEntity queryById(String fileId) {
return fileRecordMapper.selectById(fileId);
}
} }
...@@ -2,6 +2,7 @@ package com.tanpu.community.util; ...@@ -2,6 +2,7 @@ package com.tanpu.community.util;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.ImagesDTO;
import com.tanpu.community.api.beans.TopicDO; import com.tanpu.community.api.beans.TopicDO;
import com.tanpu.community.api.beans.qo.*; import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq; import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
...@@ -105,17 +106,35 @@ public class ConvertUtil { ...@@ -105,17 +106,35 @@ public class ConvertUtil {
} }
} }
/**
* 解析 List<ThemeContentReq>为Attachment列表
* @param req
* @param themeId
* @return
*/
public static List<ThemeAttachmentEntity> themeReqToAttachmentList(CreateThemeReq req, String themeId) { public static List<ThemeAttachmentEntity> themeReqToAttachmentList(CreateThemeReq req, String themeId) {
List<ThemeContentReq> contents = req.getContent(); List<ThemeContentReq> contents = req.getContent();
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())){
list.add(ThemeAttachmentEntity.builder() //讨论-多图类型,拆开解析到attachment表中
.attachType(Integer.valueOf(content.getType())) if ((content.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type))){
.attachId(content.getValue()) List<ImagesDTO> imgList = content.getImgList();
.themeId(themeId) for (ImagesDTO imagesDTO : imgList) {
.build()); list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(RelTypeEnum.SINGLE_IMG.type))
.attachId(imagesDTO.getRelId())
.themeId(themeId)
.build());
}
}else {
list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(content.getType()))
.attachId(content.getValue())
.themeId(themeId)
.build());
}
} }
} }
return list; return list;
......
...@@ -30,7 +30,7 @@ CREATE TABLE `follow_rel` ( ...@@ -30,7 +30,7 @@ CREATE TABLE `follow_rel` (
CREATE TABLE `theme` ( CREATE TABLE `theme` (
`id` int(32) auto_increment PRIMARY KEY COMMENT 'id', `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
`theme_id` varchar(64) NOT NULL COMMENT 'UUID', `theme_id` varchar(64) NOT NULL COMMENT 'UUID',
`title` varchar(64) NOT NULL COMMENT '标题', `title` varchar(64) COMMENT '标题',
`theme_type` int(4) NOT NULL COMMENT '类型', `theme_type` int(4) NOT NULL COMMENT '类型',
`content` text COMMENT '文本内容', `content` text COMMENT '文本内容',
`attach_type` int(4) NOT NULL COMMENT '附件类型', `attach_type` int(4) NOT NULL COMMENT '附件类型',
......
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