Преглед изворни кода

feat: 补充交流区分页接口,添加枚举类

191250028 пре 3 година
родитељ
комит
ceb770ed2c

+ 13 - 0
seecoder-portal-common/src/main/java/cn/seecoder/seecoderportalcommon/enums/CommunicationSortStrategyEnum.java

@@ -0,0 +1,13 @@
+package cn.seecoder.seecoderportalcommon.enums;
+
+/**
+ * @author fanyanpeng
+ * @date 2023/7/12 0:53
+ */
+public enum CommunicationSortStrategyEnum {
+    // 发布时间从早到晚排序,即最早发布的在前面
+    PUBLISH_TIME_ASC,
+
+    // 发布时间从晚到早排序,即最新发布的在前面
+    PUBLISH_TIME_DESC,
+}

+ 12 - 0
seecoder-portal-common/src/main/java/cn/seecoder/seecoderportalcommon/enums/CommunicationTypeEnum.java

@@ -0,0 +1,12 @@
+package cn.seecoder.seecoderportalcommon.enums;
+
+/**
+ * @author fanyanpeng
+ * @date 2023/7/12 1:03
+ */
+public enum CommunicationTypeEnum {
+    //难题
+    PROBLEM,
+    //通知
+    NOTICE,
+}

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

@@ -11,14 +11,66 @@ public class CommunicationFileVO {
 
     private String fileName;
 
-//    枚举形
-//    private String fileType;
-
     private Integer fileSize;
 
     private String fileUrl;
 
-    private String fileExtention;
+    private String fileExtension;
 
     private Integer fileOwnerId;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public CommunicationFileVO setId(Long id) {
+        this.id = id;
+        return this;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public CommunicationFileVO setFileName(String fileName) {
+        this.fileName = fileName;
+        return this;
+    }
+
+    public Integer getFileSize() {
+        return fileSize;
+    }
+
+    public CommunicationFileVO setFileSize(Integer fileSize) {
+        this.fileSize = fileSize;
+        return this;
+    }
+
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    public CommunicationFileVO setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+        return this;
+    }
+
+    public String getFileExtension() {
+        return fileExtension;
+    }
+
+    public CommunicationFileVO setFileExtension(String fileExtension) {
+        this.fileExtension = fileExtension;
+        return this;
+    }
+
+    public Integer getFileOwnerId() {
+        return fileOwnerId;
+    }
+
+    public CommunicationFileVO setFileOwnerId(Integer fileOwnerId) {
+        this.fileOwnerId = fileOwnerId;
+        return this;
+    }
 }

+ 146 - 1
seecoder-portal-common/src/main/java/cn/seecoder/seecoderportalcommon/vo/CommunicationVO.java

@@ -1,5 +1,7 @@
 package cn.seecoder.seecoderportalcommon.vo;
 
+import cn.seecoder.seecoderportalcommon.enums.CommunicationTypeEnum;
+
 import java.util.Date;
 import java.util.List;
 
@@ -15,7 +17,7 @@ public class CommunicationVO {
 
     private String title;
 
-//    private CommunicationTypeEnum type;
+    private CommunicationTypeEnum type;
 
     private String description;
 
@@ -42,4 +44,147 @@ public class CommunicationVO {
     //是否已经收藏
     private Boolean starred;
 
+    public Long getId() {
+        return id;
+    }
+
+    public CommunicationVO setId(Long id) {
+        this.id = id;
+        return this;
+    }
+
+    public Long getPublisherId() {
+        return publisherId;
+    }
+
+    public CommunicationVO setPublisherId(Long publisherId) {
+        this.publisherId = publisherId;
+        return this;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public CommunicationVO setTitle(String title) {
+        this.title = title;
+        return this;
+    }
+
+    public CommunicationTypeEnum getType() {
+        return type;
+    }
+
+    public CommunicationVO setType(CommunicationTypeEnum type) {
+        this.type = type;
+        return this;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public CommunicationVO setDescription(String description) {
+        this.description = description;
+        return this;
+    }
+
+    public String getOrganization() {
+        return organization;
+    }
+
+    public CommunicationVO setOrganization(String organization) {
+        this.organization = organization;
+        return this;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public CommunicationVO setPhone(String phone) {
+        this.phone = phone;
+        return this;
+    }
+
+    public String getWechat() {
+        return wechat;
+    }
+
+    public CommunicationVO setWechat(String wechat) {
+        this.wechat = wechat;
+        return this;
+    }
+
+    public String getQq() {
+        return qq;
+    }
+
+    public CommunicationVO setQq(String qq) {
+        this.qq = qq;
+        return this;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public CommunicationVO setEmail(String email) {
+        this.email = email;
+        return this;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public CommunicationVO setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+        return this;
+    }
+
+    public Date getDeadline() {
+        return deadline;
+    }
+
+    public CommunicationVO setDeadline(Date deadline) {
+        this.deadline = deadline;
+        return this;
+    }
+
+    public List<CommunicationFileVO> getPhotos() {
+        return photos;
+    }
+
+    public CommunicationVO setPhotos(List<CommunicationFileVO> photos) {
+        this.photos = photos;
+        return this;
+    }
+
+    public List<CommunicationFileVO> getAttachments() {
+        return attachments;
+    }
+
+    public CommunicationVO setAttachments(List<CommunicationFileVO> attachments) {
+        this.attachments = attachments;
+        return this;
+    }
+
+    public String getPublisherName() {
+        return publisherName;
+    }
+
+    public CommunicationVO setPublisherName(String publisherName) {
+        this.publisherName = publisherName;
+        return this;
+    }
+
+    public Boolean getStarred() {
+        return starred;
+    }
+
+    public CommunicationVO setStarred(Boolean starred) {
+        this.starred = starred;
+        return this;
+    }
 }

+ 33 - 0
seecoder-portal-common/src/main/java/cn/seecoder/seecoderportalcommon/vo/PageVO.java

@@ -0,0 +1,33 @@
+package cn.seecoder.seecoderportalcommon.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @author fanyanpeng
+ * @date 2023/7/12 0:23
+ */
+@ApiModel
+public class PageVO<T> {
+
+    @ApiModelProperty("当前页包含的元素")
+    private List<T> content;
+
+    @ApiModelProperty("总元素个数")
+    private Integer totalElements;
+
+    @ApiModelProperty("当前页数")
+    private Integer pageNumber;
+
+    @ApiModelProperty("当前页数元素个数")
+    private Integer numberOfElements;
+
+    @ApiModelProperty("总页数")
+    private Integer totalPages;
+
+    @ApiModelProperty("是否为最后一页")
+    private Boolean last;
+
+}

+ 2 - 1
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/domain/Communication.java

@@ -1,5 +1,6 @@
 package cn.seecoder.seecoderportalserver.domain;
 
+import cn.seecoder.seecoderportalcommon.enums.CommunicationTypeEnum;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationFileVO;
 
 import javax.persistence.Entity;
@@ -23,7 +24,7 @@ public class Communication {
 
     private String title;
 
-//    private CommunicationTypeEnum type;
+    private CommunicationTypeEnum type;
 
     private String description;
 

+ 1 - 4
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/domain/CommunicationFile.java

@@ -17,14 +17,11 @@ public class CommunicationFile {
 
     private String fileName;
 
-//    枚举形
-//    private String fileType;
-
     private Integer fileSize;
 
     private String fileUrl;
 
-    private String fileExtention;
+    private String fileExtension;
 
     private Integer fileOwnerId;
 }

+ 34 - 22
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/CommunicationController.java

@@ -1,8 +1,10 @@
 package cn.seecoder.seecoderportalserver.web.rest;
-
+import cn.seecoder.seecoderportalcommon.enums.CommunicationSortStrategyEnum;
 import cn.seecoder.seecoderportalcommon.vo.CommunicationVO;
+import cn.seecoder.seecoderportalcommon.vo.PageVO;
 import cn.seecoder.seecoderportalcommon.vo.UserVO;
 import cn.seecoder.seecoderportalserver.utility.OkResponse;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -16,53 +18,63 @@ import java.util.List;
 @RequestMapping("/api/communication")
 public class CommunicationController {
 
+    @ApiOperation("上传交流文件")
     @PostMapping("/upload")
     public OkResponse<UserVO> uploadCommunicationFile(@RequestParam MultipartFile file) {
         return null;
     }
 
-    @GetMapping
-    public OkResponse<List<CommunicationVO>> getAllCommunications(@RequestParam(value = "userId")Integer userId,
-                                                            @RequestParam(value = "page")Integer page,
-                                                            @RequestParam(value = "size")Integer size,
-                                                            @RequestParam(value = "sort")String sort){
-        return null;
-    }
-
+    @ApiOperation("发布交流")
     @PostMapping
     public OkResponse<CommunicationVO> postCommunication(@RequestBody CommunicationVO communicationVO){
         return null;
     }
 
-    @GetMapping("/detail/{communicationId}")
+    @ApiOperation("获得单个交流详情")
+    @GetMapping("/{communicationId}")
     public OkResponse<CommunicationVO> getCommunicationDetail(@PathVariable(value = "communicationId")Integer communicationId){
         return null;
     }
 
-    @GetMapping("/{userId}")
-    public OkResponse<List<CommunicationVO>> getUserCommunications(@PathVariable(value = "userId")Integer userId){
+    @ApiOperation("分页获取用户发布的交流")
+    @GetMapping("/users/{userId}")
+    public OkResponse<PageVO<CommunicationVO>> getCommunicationPageByUserId(@PathVariable(value = "userId")String userId,
+                                                                           @RequestParam(value = "page") Integer page,
+                                                                           @RequestParam(value = "size")Integer size){
         return null;
     }
 
-    @PostMapping("/star")
-    public OkResponse<Boolean> starCommunication(@RequestParam(value = "userId")Integer userId,
-                                                 @RequestParam(value = "communicationId")Integer communicationId){
+    @ApiOperation("分页获取交流列表")
+    @GetMapping
+    public OkResponse<PageVO<CommunicationVO>> getCommunicationPage(@RequestParam(value = "page") Integer page,
+                                                                  @RequestParam(value = "size")Integer size,
+                                                                  @RequestParam(value = "sort") CommunicationSortStrategyEnum sort){
         return null;
     }
 
-    @GetMapping("/star")
-    public OkResponse<List<CommunicationVO>> getStarCommunications(@RequestParam(value = "userId")Integer userId){
+
+    @ApiOperation("用户收藏交流")
+    @PostMapping("/{communicationId}/stars")
+    public OkResponse<Boolean> starCommunication(@PathVariable(value = "communicationId")Integer communicationId){
         return null;
     }
 
-    @PostMapping("/star/cancel")
-    public OkResponse<Boolean> cancelStarCommunication(@RequestParam(value = "userId")Integer userId,
-                                                       @RequestParam(value = "communicationId")Integer communicationId){
+    @ApiOperation("取消收藏交流")
+    @DeleteMapping("/{communicationId}/stars")
+    public OkResponse<Boolean> cancelStarCommunication(@PathVariable(value = "communicationId")Integer communicationId){
         return null;
     }
 
-    @GetMapping("/watchStarMan/{communicationId}")
-    public OkResponse<List<UserVO>> watchStarMan(@PathVariable(value = "communicationId")Integer communicationId){
+    @ApiOperation("分页查看个人收藏夹")
+    @GetMapping("/stars/users/{userId}")
+    public OkResponse<PageVO<CommunicationVO>> getStarredCommunicationPage(@PathVariable(value = "userId") String userId){
+        return null;
+    }
+
+
+    @ApiOperation("查看交流的收藏者")
+    @GetMapping("/{communicationId}/stars/users")
+    public OkResponse<List<UserVO>> starredUsers(@PathVariable(value = "communicationId")Integer communicationId){
         return null;
     }
 }