| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package space.anyi.serve.entity.post;
- import io.swagger.v3.oas.annotations.media.Schema;
- import java.math.BigDecimal;
- import java.time.LocalDateTime;
- import java.util.ArrayList;
- import java.util.List;
- @Schema(description = "帖子响应视图")
- public class PostVo {
- private String id;
- private String expertId;
- private String expertName;
- private String expertAvatar;
- private String title;
- private String contentIntro;
- private String contentPaid;
- private BigDecimal price;
- private String hitStatus;
- private Integer viewCount;
- private Boolean isPublic;
- private Boolean isPaid;
- private LocalDateTime publishTime;
- private LocalDateTime expireTime;
- public static PostVo from(Post post) {
- if (post == null) return null;
- PostVo vo = new PostVo();
- vo.setId(post.getId().toString());
- vo.setExpertId(post.getExpertId().toString());
- vo.setTitle(post.getTitle());
- vo.setContentIntro(post.getContentIntro());
- vo.setContentPaid(post.getContentPaid());
- vo.setPrice(post.getPrice());
- vo.setHitStatus(post.getHitStatus());
- vo.setViewCount(post.getViewCount());
- vo.setPublishTime(post.getPublishTime());
- vo.setExpireTime(post.getExpireTime());
- vo.setIsPublic(LocalDateTime.now().isAfter(post.getExpireTime()));
- return vo;
- }
- public static List<PostVo> from(List<Post> list) {
- List<PostVo> res = new ArrayList<>();
- for (Post p : list) res.add(from(p));
- return res;
- }
- public String getId() { return id; }
- public void setId(String id) { this.id = id; }
- public String getExpertId() { return expertId; }
- public void setExpertId(String expertId) { this.expertId = expertId; }
- public String getExpertName() { return expertName; }
- public void setExpertName(String expertName) { this.expertName = expertName; }
- public String getExpertAvatar() { return expertAvatar; }
- public void setExpertAvatar(String expertAvatar) { this.expertAvatar = expertAvatar; }
- public String getTitle() { return title; }
- public void setTitle(String title) { this.title = title; }
- public String getContentIntro() { return contentIntro; }
- public void setContentIntro(String contentIntro) { this.contentIntro = contentIntro; }
- public String getContentPaid() { return contentPaid; }
- public void setContentPaid(String contentPaid) { this.contentPaid = contentPaid; }
- public BigDecimal getPrice() { return price; }
- public void setPrice(BigDecimal price) { this.price = price; }
- public String getHitStatus() { return hitStatus; }
- public void setHitStatus(String hitStatus) { this.hitStatus = hitStatus; }
- public Integer getViewCount() { return viewCount; }
- public void setViewCount(Integer viewCount) { this.viewCount = viewCount; }
- public Boolean getIsPublic() { return isPublic; }
- public void setIsPublic(Boolean isPublic) { this.isPublic = isPublic; }
- public Boolean getIsPaid() { return isPaid; }
- public void setIsPaid(Boolean isPaid) { this.isPaid = isPaid; }
- public LocalDateTime getPublishTime() { return publishTime; }
- public void setPublishTime(LocalDateTime publishTime) { this.publishTime = publishTime; }
- public LocalDateTime getExpireTime() { return expireTime; }
- public void setExpireTime(LocalDateTime expireTime) { this.expireTime = expireTime; }
- }
|