Jelajahi Sumber

feat: 实现文件上传,交流发布、用户交流查看

191250028 3 tahun lalu
induk
melakukan
ba8236fc7a

+ 6 - 6
seecoder-portal-common/src/main/java/cn/seecoder/seecoderportalcommon/vo/CommunicationFileVO.java

@@ -11,13 +11,13 @@ public class CommunicationFileVO {
 
     private String fileName;
 
-    private Integer fileSize;
+    private Long fileSize;
 
     private String fileUrl;
 
     private String fileExtension;
 
-    private Integer fileOwnerId;
+    private Long fileOwnerId;
 
 
     public Long getId() {
@@ -38,11 +38,11 @@ public class CommunicationFileVO {
         return this;
     }
 
-    public Integer getFileSize() {
+    public Long getFileSize() {
         return fileSize;
     }
 
-    public CommunicationFileVO setFileSize(Integer fileSize) {
+    public CommunicationFileVO setFileSize(Long fileSize) {
         this.fileSize = fileSize;
         return this;
     }
@@ -65,11 +65,11 @@ public class CommunicationFileVO {
         return this;
     }
 
-    public Integer getFileOwnerId() {
+    public Long getFileOwnerId() {
         return fileOwnerId;
     }
 
-    public CommunicationFileVO setFileOwnerId(Integer fileOwnerId) {
+    public CommunicationFileVO setFileOwnerId(Long fileOwnerId) {
         this.fileOwnerId = fileOwnerId;
         return this;
     }

+ 139 - 6
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/domain/Communication.java

@@ -2,11 +2,10 @@ package cn.seecoder.seecoderportalserver.domain;
 
 import cn.seecoder.seecoderportalcommon.enums.CommunicationTypeEnum;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
+import org.hibernate.annotations.Fetch;
+import org.hibernate.annotations.FetchMode;
 
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
+import javax.persistence.*;
 import java.util.Date;
 import java.util.List;
 
@@ -18,12 +17,15 @@ import java.util.List;
 @Table(name = "communication")
 public class Communication {
     @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;
 
     private Long publisherId;
 
     private String title;
 
+    @Column
+    @Enumerated(EnumType.STRING)
     private CommunicationTypeEnum type;
 
     private String description;
@@ -42,9 +44,140 @@ public class Communication {
 
     private Date deadline;
 
-    @OneToMany
+    //Hibernate throws MultipleBagFetchException -
+    // cannot simultaneously fetch multiple bags
+    // in order to solve this problem,
+    // we need to add @Fetch annotation
+    @OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
     private List<CommunicationFile> photos;
 
-    @OneToMany
+    @OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
     private List<CommunicationFile> attachments;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public Communication setId(Long id) {
+        this.id = id;
+        return this;
+    }
+
+    public Long getPublisherId() {
+        return publisherId;
+    }
+
+    public Communication setPublisherId(Long publisherId) {
+        this.publisherId = publisherId;
+        return this;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public Communication setTitle(String title) {
+        this.title = title;
+        return this;
+    }
+
+    public CommunicationTypeEnum getType() {
+        return type;
+    }
+
+    public Communication setType(CommunicationTypeEnum type) {
+        this.type = type;
+        return this;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Communication setDescription(String description) {
+        this.description = description;
+        return this;
+    }
+
+    public String getOrganization() {
+        return organization;
+    }
+
+    public Communication setOrganization(String organization) {
+        this.organization = organization;
+        return this;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public Communication setPhone(String phone) {
+        this.phone = phone;
+        return this;
+    }
+
+    public String getWechat() {
+        return wechat;
+    }
+
+    public Communication setWechat(String wechat) {
+        this.wechat = wechat;
+        return this;
+    }
+
+    public String getQq() {
+        return qq;
+    }
+
+    public Communication setQq(String qq) {
+        this.qq = qq;
+        return this;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public Communication setEmail(String email) {
+        this.email = email;
+        return this;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public Communication setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+        return this;
+    }
+
+    public Date getDeadline() {
+        return deadline;
+    }
+
+    public Communication setDeadline(Date deadline) {
+        this.deadline = deadline;
+        return this;
+    }
+
+    public List<CommunicationFile> getPhotos() {
+        return photos;
+    }
+
+    public Communication setPhotos(List<CommunicationFile> photos) {
+        this.photos = photos;
+        return this;
+    }
+
+    public List<CommunicationFile> getAttachments() {
+        return attachments;
+    }
+
+    public Communication setAttachments(List<CommunicationFile> attachments) {
+        this.attachments = attachments;
+        return this;
+    }
 }

+ 58 - 5
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/domain/CommunicationFile.java

@@ -1,8 +1,6 @@
 package cn.seecoder.seecoderportalserver.domain;
 
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import javax.persistence.*;
 
 /**
  * @author fanyanpeng
@@ -13,15 +11,70 @@ import javax.persistence.Table;
 public class CommunicationFile {
 
     @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;
 
     private String fileName;
 
-    private Integer fileSize;
+    private Long fileSize;
 
     private String fileUrl;
 
     private String fileExtension;
 
-    private Integer fileOwnerId;
+    private Long fileOwnerId;
+
+    public Long getId() {
+        return id;
+    }
+
+    public CommunicationFile setId(Long id) {
+        this.id = id;
+        return this;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public CommunicationFile setFileName(String fileName) {
+        this.fileName = fileName;
+        return this;
+    }
+
+    public Long getFileSize() {
+        return fileSize;
+    }
+
+    public CommunicationFile setFileSize(Long fileSize) {
+        this.fileSize = fileSize;
+        return this;
+    }
+
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    public CommunicationFile setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+        return this;
+    }
+
+    public String getFileExtension() {
+        return fileExtension;
+    }
+
+    public CommunicationFile setFileExtension(String fileExtension) {
+        this.fileExtension = fileExtension;
+        return this;
+    }
+
+    public Long getFileOwnerId() {
+        return fileOwnerId;
+    }
+
+    public CommunicationFile setFileOwnerId(Long fileOwnerId) {
+        this.fileOwnerId = fileOwnerId;
+        return this;
+    }
 }

+ 40 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/domain/CommunicationStar.java

@@ -1,8 +1,48 @@
 package cn.seecoder.seecoderportalserver.domain;
 
+import javax.persistence.*;
+import java.util.Date;
+
 /**
+ * 一张双向索引表
  * @author fanyanpeng
  * @date 2023/7/11 12:30
  */
+@Entity
+@Table(name = "communication_star",indexes = {
+        @Index(name = "communication_star_user_id",columnList = "user_id"),
+        @Index(name = "communication_star_communication_id",columnList = "communication_id")
+})
 public class CommunicationStar {
+    @Id
+    @GeneratedValue(strategy = GenerationType.SEQUENCE)
+    @Column(name = "id", nullable = false)
+    private Long id;
+
+    @Column(name = "user_id",nullable = false)
+    private Long userId;
+    @Column(name = "communication_id",nullable = false)
+    private Long communicationId;
+
+    public Long getId() {return id;}
+
+    public void setId(Long id) {this.id = id;}
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public CommunicationStar setUserId(Long userId) {
+        this.userId = userId;
+        return this;
+    }
+
+    public Long getCommunicationId() {
+        return communicationId;
+    }
+
+    public CommunicationStar setCommunicationId(Long communicationId) {
+        this.communicationId = communicationId;
+        return this;
+    }
 }

+ 17 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/mapper/CommunicationFileMapper.java

@@ -0,0 +1,17 @@
+package cn.seecoder.seecoderportalserver.mapper;
+
+import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
+import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
+import cn.seecoder.seecoderportalserver.domain.Communication;
+import cn.seecoder.seecoderportalserver.domain.CommunicationFile;
+
+/**
+ * @author fanyanpeng
+ * @date 2023/7/12 14:05
+ */
+public interface CommunicationFileMapper {
+
+    CommunicationFileVO toCommunicationFileVO(CommunicationFile CommunicationFile);
+
+    CommunicationFile toCommunicationFile(CommunicationFileVO CommunicationFileVO);
+}

+ 2 - 1
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/mapper/CommunicationMapper.java

@@ -9,7 +9,8 @@ import cn.seecoder.seecoderportalserver.domain.Communication;
  */
 public interface CommunicationMapper {
 
-    CommunicationVO toCommunicationVO(Communication communication);
+    CommunicationVO toCommunicationVO(Communication communication, Long userId);
+
 
     Communication toCommunication(CommunicationVO communicationVO);
 

+ 28 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/mapper/impl/CommunicationFileMapperImpl.java

@@ -0,0 +1,28 @@
+package cn.seecoder.seecoderportalserver.mapper.impl;
+
+import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
+import cn.seecoder.seecoderportalserver.domain.CommunicationFile;
+import cn.seecoder.seecoderportalserver.mapper.CommunicationFileMapper;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author fanyanpeng
+ * @date 2023/7/12 14:08
+ */
+@Component
+public class CommunicationFileMapperImpl implements CommunicationFileMapper {
+    @Override
+    public CommunicationFileVO toCommunicationFileVO(CommunicationFile communicationFile) {
+        CommunicationFileVO communicationFileVO = new CommunicationFileVO();
+        BeanUtils.copyProperties(communicationFile,communicationFileVO);
+        return communicationFileVO;
+    }
+
+    @Override
+    public CommunicationFile toCommunicationFile(CommunicationFileVO communicationFileVO) {
+        CommunicationFile communicationFile = new CommunicationFile();
+        BeanUtils.copyProperties(communicationFileVO,communicationFile);
+        return communicationFile;
+    }
+}

+ 48 - 2
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/mapper/impl/CommunicationMapperImpl.java

@@ -1,11 +1,20 @@
 package cn.seecoder.seecoderportalserver.mapper.impl;
 
+import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
 import cn.seecoder.seecoderportalserver.domain.Communication;
+import cn.seecoder.seecoderportalserver.domain.CommunicationFile;
+import cn.seecoder.seecoderportalserver.domain.CommunicationStar;
+import cn.seecoder.seecoderportalserver.mapper.CommunicationFileMapper;
 import cn.seecoder.seecoderportalserver.mapper.CommunicationMapper;
+import cn.seecoder.seecoderportalserver.repository.CommunicationStarRepository;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
 /**
  * @author fanyanpeng
  * @date 2023/7/12 11:40
@@ -13,10 +22,37 @@ import org.springframework.stereotype.Component;
 @Component
 public class CommunicationMapperImpl implements CommunicationMapper {
 
+    private final CommunicationFileMapper communicationFileMapper;
+
+    private final CommunicationStarRepository communicationStarRepository;
+
+    public CommunicationMapperImpl(CommunicationFileMapper communicationFileMapper, CommunicationStarRepository communicationStarRepository) {
+        this.communicationFileMapper = communicationFileMapper;
+        this.communicationStarRepository = communicationStarRepository;
+    }
+
     @Override
-    public CommunicationVO toCommunicationVO(Communication communication) {
+    public CommunicationVO toCommunicationVO(Communication communication, Long userId) {
         CommunicationVO communicationVO = new CommunicationVO();
         BeanUtils.copyProperties(communication,communicationVO);
+
+        List<CommunicationFileVO> photoVOList = communication.getPhotos()
+                .stream()
+                .map(communicationFileMapper::toCommunicationFileVO)
+                .collect(Collectors.toList());
+        List<CommunicationFileVO> attachmentVOList = communication.getAttachments()
+                .stream()
+                .map(communicationFileMapper::toCommunicationFileVO)
+                .collect(Collectors.toList());
+        communicationVO.setPhotos(photoVOList);
+        communicationVO.setAttachments(attachmentVOList);
+
+        Optional<CommunicationStar> communicationStar =
+                communicationStarRepository.findByUserIdAndCommunicationId(userId, communication.getId());
+
+        // 完成收藏判断
+        communicationVO.setStarred(false);
+        communicationStar.ifPresent(value -> communicationVO.setStarred(true));
         return communicationVO;
     }
 
@@ -24,8 +60,18 @@ public class CommunicationMapperImpl implements CommunicationMapper {
     public Communication toCommunication(CommunicationVO communicationVO) {
         Communication communication = new Communication();
         BeanUtils.copyProperties(communicationVO,communication);
-        //todo: 2023/7/12 未完成 补充file文件的逐个转换,补充收藏情况的验证
 
+        List<CommunicationFile> photoPOList = communicationVO.getPhotos()
+                .stream()
+                .map(communicationFileMapper::toCommunicationFile)
+                .collect(Collectors.toList());
+        List<CommunicationFile> attachmentPOList = communicationVO.getAttachments()
+                .stream()
+                .map(communicationFileMapper::toCommunicationFile)
+                .collect(Collectors.toList());
+
+        communication.setPhotos(photoPOList);
+        communication.setAttachments(attachmentPOList);
 
         return communication;
     }

+ 15 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/repository/CommunicationStarRepository.java

@@ -0,0 +1,15 @@
+package cn.seecoder.seecoderportalserver.repository;
+
+import cn.seecoder.seecoderportalserver.domain.CommunicationStar;
+
+import java.util.Optional;
+
+/**
+ * @author fanyanpeng
+ * @date 2023/7/12 16:06
+ */
+public interface CommunicationStarRepository {
+
+
+    Optional<CommunicationStar> findByUserIdAndCommunicationId(Long userId, Long id);
+}

+ 4 - 3
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/CommunicationService.java

@@ -1,6 +1,7 @@
 package cn.seecoder.seecoderportalserver.service;
 
 import cn.seecoder.seecoderportalcommon.enums.CommunicationSortStrategyEnum;
+import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
 import cn.seecoder.seecoderportalcommon.vo.PageVO;
 import cn.seecoder.seecoderportalcommon.vo.UserVO;
@@ -13,11 +14,11 @@ import java.util.List;
  * @date 2023/7/11 12:21
  */
 public interface CommunicationService {
-    String uploadCommunicationFile(MultipartFile file);
+    CommunicationFileVO uploadCommunicationFile(MultipartFile file, Long userId);
 
-    CommunicationVO postCommunication(CommunicationVO communicationVO);
+    CommunicationVO postCommunication(CommunicationVO communicationVO, Long userId);
 
-    CommunicationVO getCommunicationDetail(Long communicationId);
+    CommunicationVO getCommunicationDetail(Long communicationId, Long userId);
 
     PageVO<CommunicationVO> getCommunicationPageByUserId(Long userId, Integer page, Integer size);
 

+ 67 - 24
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/serviceImpl/CommunicationServiceImpl.java

@@ -1,35 +1,29 @@
 package cn.seecoder.seecoderportalserver.serviceImpl;
 
 import cn.seecoder.seecoderportalcommon.enums.CommunicationSortStrategyEnum;
+import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
 import cn.seecoder.seecoderportalcommon.vo.PageVO;
 import cn.seecoder.seecoderportalcommon.vo.UserVO;
-import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
-import cn.seecoder.seecoderportalcommon.vo.PageVO;
-import cn.seecoder.seecoderportalserver.domain.Communication;
-import cn.seecoder.seecoderportalserver.mapper.CommunicationMapper;
-import cn.seecoder.seecoderportalserver.repository.CommunicationRepository;
 import cn.seecoder.seecoderportalserver.domain.Communication;
+import cn.seecoder.seecoderportalserver.mapper.CommunicationFileMapper;
 import cn.seecoder.seecoderportalserver.mapper.CommunicationMapper;
 import cn.seecoder.seecoderportalserver.repository.CommunicationRepository;
 import cn.seecoder.seecoderportalserver.service.CommunicationService;
+import cn.seecoder.seecoderportalserver.utility.OssUtil;
+import cn.seecoder.seecoderportalserver.web.rest.errors.CustomErrorException;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
-import cn.seecoder.seecoderportalserver.utility.OkResponse;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Optional;
 
 /**
  * @author fanyanpeng
@@ -40,18 +34,25 @@ public class CommunicationServiceImpl implements CommunicationService {
 
     private final CommunicationRepository communicationRepository;
     private final CommunicationMapper communicationMapper;
+    private final CommunicationFileMapper communicationFileMapper;
 
-    public CommunicationServiceImpl(CommunicationRepository communicationRepository, CommunicationMapper communicationMapper){
+    private final OssUtil ossUtil;
+
+
+    public CommunicationServiceImpl(CommunicationRepository communicationRepository, CommunicationMapper communicationMapper, CommunicationFileMapper communicationFileMapper, OssUtil ossUtil){
         this.communicationRepository = communicationRepository;
         this.communicationMapper = communicationMapper;
+        this.communicationFileMapper = communicationFileMapper;
+        this.ossUtil = ossUtil;
     }
 
 
+    @Transactional
     @Override
     public PageVO<CommunicationVO> getCommunicationPageByUserId(Long userId, Integer page, Integer size) {
         Pageable pageable = PageRequest.of(page,size);
         Page<Communication> communicationPage = communicationRepository.findByPublisherId(userId,pageable);
-        return toPageVO(communicationPage);
+        return toPageVO(communicationPage, userId);
     }
 
     /**
@@ -61,14 +62,14 @@ public class CommunicationServiceImpl implements CommunicationService {
      * @param communicationPage
      * @return cn.seecoder.seecoderportalcommon.vo.PageVO<cn.seecoder.seecoderportalcommon.vo.CommunicationVO>
      */
-    private PageVO<CommunicationVO> toPageVO(Page<Communication> communicationPage){
+    private PageVO<CommunicationVO> toPageVO(Page<Communication> communicationPage,Long userId){
         PageVO<CommunicationVO> communicationVOPageVO = new PageVO<>();
 
         //转换分页的内容
         List<Communication> communicationList = communicationPage.getContent();
         List<CommunicationVO> communicationVOList = new ArrayList<>();
         for(Communication communication:communicationList){
-            communicationVOList.add(communicationMapper.toCommunicationVO(communication));
+            communicationVOList.add(communicationMapper.toCommunicationVO(communication,userId));
         }
         communicationVOPageVO.setContent(communicationVOList);
 
@@ -86,20 +87,62 @@ public class CommunicationServiceImpl implements CommunicationService {
 
 
     @Override
-    public String uploadCommunicationFile(MultipartFile file) {
-        return null;
+    public CommunicationFileVO uploadCommunicationFile(MultipartFile file, Long userId) {
+        String ossUrl = null;
+        String fileExtension = null;
+        String fileName = String.format("%s/%s-%s",userId,new Date().getTime(),file.getOriginalFilename());
+
+        try{
+            fileExtension = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
+        }catch (NullPointerException nullPointerException){
+            throw new CustomErrorException("文件扩展名获取失败");
+        }
+
+        try{
+            ossUrl = ossUtil.upload(fileName,file.getInputStream());
+        }catch (IOException ioException){
+            throw new CustomErrorException("文件上传失败");
+        }
+
+        //文件上传成功,新建文件VO对象返回
+        CommunicationFileVO communicationFileVO = new CommunicationFileVO();
+        communicationFileVO.setFileOwnerId(userId);
+        communicationFileVO.setFileName(file.getOriginalFilename());
+        communicationFileVO.setFileSize(file.getSize());
+        communicationFileVO.setFileUrl(ossUrl);
+        communicationFileVO.setFileExtension(fileExtension);
+
+        return communicationFileVO;
     }
 
     @Override
-    public CommunicationVO postCommunication(CommunicationVO communicationVO) {
-        return null;
+    public CommunicationVO postCommunication(CommunicationVO communicationVO, Long userId) {
+        Communication communication = communicationMapper.toCommunication(communicationVO);
+        communication.setPublisherId(userId);
+        communication.setPublishTime(new Date());
+
+        communicationRepository.save(communication);
+
+        return communicationMapper.toCommunicationVO(communication,userId);
     }
 
+
+    @Transactional
     @Override
-    public CommunicationVO getCommunicationDetail(Long communicationId) {
-        return null;
+    public CommunicationVO getCommunicationDetail(Long communicationId, Long userId) {
+        Optional<Communication> optional = communicationRepository.findById(communicationId);
+        if(!optional.isPresent()){
+            throw new CustomErrorException("交流信息不存在");
+        }
+        Communication communication = optional.get();
+        return communicationMapper.toCommunicationVO(communication,userId);
     }
 
+
+
+
+
+
     @Override
     public PageVO<CommunicationVO> getCommunicationPage(Integer page, Integer size, CommunicationSortStrategyEnum sort) {
         return null;

+ 13 - 4
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/CommunicationController.java

@@ -1,8 +1,11 @@
 package cn.seecoder.seecoderportalserver.web.rest;
 import cn.seecoder.seecoderportalcommon.enums.CommunicationSortStrategyEnum;
+import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
 import cn.seecoder.seecoderportalcommon.vo.PageVO;
 import cn.seecoder.seecoderportalcommon.vo.UserVO;
+import cn.seecoder.seecoderportalserver.security.DomainUserDetails;
+import cn.seecoder.seecoderportalserver.security.SecurityUtils;
 import cn.seecoder.seecoderportalserver.service.CommunicationService;
 import cn.seecoder.seecoderportalserver.utility.OkResponse;
 import io.swagger.annotations.ApiOperation;
@@ -25,20 +28,26 @@ public class CommunicationController {
 
     @ApiOperation("上传交流文件")
     @PostMapping("/upload")
-    public OkResponse<String> uploadCommunicationFile(@RequestParam MultipartFile file) {
-        return OkResponse.of(communicationService.uploadCommunicationFile(file));
+    public OkResponse<CommunicationFileVO> uploadCommunicationFile(@RequestParam MultipartFile file) {
+        DomainUserDetails user = SecurityUtils.getCurrentUser();
+        Long userId = user.getId();
+        return OkResponse.of(communicationService.uploadCommunicationFile(file, userId));
     }
 
     @ApiOperation("发布交流")
     @PostMapping
     public OkResponse<CommunicationVO> postCommunication(@RequestBody CommunicationVO communicationVO){
-        return OkResponse.of(communicationService.postCommunication(communicationVO));
+        DomainUserDetails user = SecurityUtils.getCurrentUser();
+        Long userId = user.getId();
+        return OkResponse.of(communicationService.postCommunication(communicationVO, userId));
     }
 
     @ApiOperation("获得单个交流详情")
     @GetMapping("/{communicationId}")
     public OkResponse<CommunicationVO> getCommunicationDetail(@PathVariable(value = "communicationId")Long communicationId){
-        return OkResponse.of(communicationService.getCommunicationDetail(communicationId));
+        DomainUserDetails user = SecurityUtils.getCurrentUser();
+        Long userId = user.getId();
+        return OkResponse.of(communicationService.getCommunicationDetail(communicationId, userId));
     }
 
     @ApiOperation("分页获取用户发布的交流")