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

根据文件id获取url

parent 78c5df18
...@@ -8,4 +8,6 @@ public final class CommunityConstant { ...@@ -8,4 +8,6 @@ public final class CommunityConstant {
public static final String PACKAGE_BASE = "com.tanpu.community"; public static final String PACKAGE_BASE = "com.tanpu.community";
public static final String OSS_PREFIX_URL ="https://tamp-sit.oss-cn-shanghai.aliyuncs.com";
} }
package com.tanpu.community.api.beans.req.homepage; package com.tanpu.community.api.beans.req.homepage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class AddIdolReq { public class AddIdolReq {
public String idolId;
@ApiModelProperty(value = "关注对象Id")
private String followUserId;
@ApiModelProperty(value = "粉丝Id")
private String followerId;
} }
...@@ -14,7 +14,7 @@ public class CreateThemeReq { ...@@ -14,7 +14,7 @@ public class CreateThemeReq {
@NotNull(message = "类型不能为空") @NotNull(message = "类型不能为空")
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题") @ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题 3:转发")
private Integer themeType; private Integer themeType;
......
package com.tanpu.community.api.constants;
public class CommunityConstant {
public static final String OSS_PREFIX_URL ="https://tamp-sit.oss-cn-shanghai.aliyuncs.com";
}
...@@ -4,7 +4,8 @@ public enum ThemeTypeEnum { ...@@ -4,7 +4,8 @@ public enum ThemeTypeEnum {
DISCUSSION(1,"讨论无标题"), DISCUSSION(1,"讨论无标题"),
LONG_TEXT(2,"长文有标题"); LONG_TEXT(2,"长文有标题"),
FORWARD(3,"转发");
private Integer code; private Integer code;
private String type; private String type;
......
...@@ -51,7 +51,7 @@ public class HomePageController { ...@@ -51,7 +51,7 @@ public class HomePageController {
@ResponseBody @ResponseBody
public CommonResp addIdol(@RequestBody AddIdolReq req) { public CommonResp addIdol(@RequestBody AddIdolReq req) {
String userId = "123"; String userId = "123";
homePageManager.addIdol(req.idolId, userId); homePageManager.addIdol(req.getFollowUserId(), userId);
return CommonResp.success(); return CommonResp.success();
} }
......
...@@ -3,6 +3,7 @@ package com.tanpu.community.dao.entity.community; ...@@ -3,6 +3,7 @@ package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.tanpu.community.api.CommunityConstant;
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;
...@@ -56,6 +57,10 @@ public class FileRecordEntity implements Serializable { ...@@ -56,6 +57,10 @@ public class FileRecordEntity implements Serializable {
private String extInfo; private String extInfo;
public String getUrl(){
return CommunityConstant.OSS_PREFIX_URL+ fileOssKey;
}
public Integer getId() { public Integer getId() {
return id; return id;
......
...@@ -10,6 +10,9 @@ import org.springframework.stereotype.Service; ...@@ -10,6 +10,9 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
...@@ -33,4 +36,9 @@ public class FileManager { ...@@ -33,4 +36,9 @@ public class FileManager {
String originalName = file.getOriginalFilename(); String originalName = file.getOriginalFilename();
return ossFileService.uploadFile(data, originalName); return ossFileService.uploadFile(data, originalName);
} }
public Map<String,String> getFileUrlByIds(List<String> fileIds){
return ossFileService.queryByIds(fileIds).stream()
.collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl));
}
} }
...@@ -3,6 +3,7 @@ package com.tanpu.community.manager; ...@@ -3,6 +3,7 @@ package com.tanpu.community.manager;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
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.CommunityConstant;
import com.tanpu.community.api.beans.qo.AttachmentDetailVo; import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
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.ThemeContentQo;
...@@ -10,7 +11,6 @@ import com.tanpu.community.api.beans.qo.ThemeQo; ...@@ -10,7 +11,6 @@ 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.vo.feign.*; import com.tanpu.community.api.beans.vo.feign.*;
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.*; import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.feign.course.FeignClientForCourse; import com.tanpu.community.feign.course.FeignClientForCourse;
...@@ -174,7 +174,7 @@ public class ThemeManager { ...@@ -174,7 +174,7 @@ public class ThemeManager {
.topicId(req.getTopicId()) .topicId(req.getTopicId())
.formerThemeId(req.getFormerThemeId()) .formerThemeId(req.getFormerThemeId())
.authorId(userId) .authorId(userId)
.themeType(ThemeTypeEnum.DISCUSSION.getCode()) .themeType(ThemeTypeEnum.FORWARD.getCode())
.build(); .build();
themeService.insertTheme(newTheme); themeService.insertTheme(newTheme);
......
...@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
@Slf4j @Slf4j
@Service @Service
...@@ -83,4 +84,7 @@ public class OSSFileService { ...@@ -83,4 +84,7 @@ public class OSSFileService {
return fileRecordMapper.selectById(fileId); return fileRecordMapper.selectById(fileId);
} }
public List<FileRecordEntity> queryByIds(List<String> fileIds) {
return fileRecordMapper.selectBatchIds(fileIds);
}
} }
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