Commit 99c987c2 by 段启岩

Post返回pictures改为数组

parent e198b3a6
......@@ -10,16 +10,19 @@ import cn.meteor.beyondclouds.modules.post.entity.Post;
import cn.meteor.beyondclouds.modules.post.exception.PostServiceException;
import cn.meteor.beyondclouds.modules.post.form.PostForm;
import cn.meteor.beyondclouds.modules.post.service.IPostService;
import cn.meteor.beyondclouds.modules.post.vo.PostVO;
import cn.meteor.beyondclouds.modules.project.exception.ProjectServiceException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
/**
......@@ -100,9 +103,20 @@ public class PostApi {
@Anonymous
@ApiOperation("动态列表")
@GetMapping("/posts")
public Response<PageVO<Post>> getPostPage (@Valid PageForm pageForm) {
public Response<PageVO<PostVO>> getPostPage (@Valid PageForm pageForm) {
IPage<Post> postPage = postService.getPostPage(pageForm.getPage(),pageForm.getSize());
PageVO<Post> postPageVO = new PageVO<>(postPage);
List<PostVO> postVOList = postPage.getRecords().stream()
.map(post -> {
PostVO postVO = new PostVO();
BeanUtils.copyProperties(post, postVO);
if (StringUtils.isEmpty(post.getPictures())) {
postVO.setPictures(post.getPictures().split(","));
}
return postVO;
}).collect(Collectors.toList());
PageVO<PostVO> postPageVO = new PageVO<>();
postPageVO.setTotalPage(postPage.getPages());
postPageVO.setDataList(postVOList);
return Response.success(postPageVO);
}
......
package cn.meteor.beyondclouds.modules.post.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author meteor
*/
@Data
public class PostVO {
private static final long serialVersionUID=1L;
private String postId;
private String userId;
private Integer type;
private String content;
private String[] pictures;
private String video;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
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