package shop.alien.storeplatform.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 讨论回复分页返回对象 ()
 */
@Data
@ApiModel(value = "StorePlatformDiscussionReplyVo对象", description = "讨论回复分页返回对象")
public class StorePlatformDiscussionReplyVo {

    @ApiModelProperty(value = "原问题/主贴信息")
    private StorePlatformDiscussionUserVo topic;

    @ApiModelProperty(value = "回复列表")
    private List<StorePlatformDiscussionUserVo> replies;

    @ApiModelProperty(value = "总页数")
    private long pages;

    @ApiModelProperty(value = "当前页")
    private long current;

    @ApiModelProperty(value = "总条数")
    private long total;

    public static StorePlatformDiscussionReplyVo fromPage(StorePlatformDiscussionUserVo topic, IPage<StorePlatformDiscussionUserVo> page) {
        StorePlatformDiscussionReplyVo vo = new StorePlatformDiscussionReplyVo();
        vo.setTopic(topic);
        vo.setReplies(page.getRecords());
        vo.setPages(page.getPages());
        vo.setCurrent(page.getCurrent());
        vo.setTotal(page.getTotal());
        return vo;
    }
}

