package cn.reghao.tnb.content.app.vod.model.po;

import cn.reghao.jutil.jdk.db.BaseObject;
import cn.reghao.oss.sdk.model.dto.media.ImageInfo;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * @author reghao
 * @date 2024-10-31 13:57:28
 */
@NoArgsConstructor
@Getter
public class PostItem extends BaseObject<Integer> {
    private Long albumId;
    private String postId;
    private Integer pos;
    private Integer channelCode;
    private String objectId;
    private String format;
    private String url;
    private Integer width;
    private Integer height;
    private Boolean horizontal;
    @Deprecated
    private LocalDateTime addedAt;

    public PostItem(long albumId, String postId) {
        this.albumId = albumId;
        this.postId = postId;
        this.pos = 1;
        this.channelCode = 0;
        this.objectId = "";
        this.format = "";
        this.url = "";
        this.width = 0;
        this.height = 0;
        this.horizontal = false;
        this.addedAt = LocalDateTime.now();
    }

    public PostItem(long albumId, int channelCode, ImageInfo imageInfo) {
        this.albumId = albumId;
        this.postId = "";
        this.pos = 1;
        this.channelCode = channelCode;
        this.objectId = imageInfo.getObjectId();
        this.format = imageInfo.getFormat();
        this.url = imageInfo.getUrl();
        this.width = imageInfo.getWidth();
        this.height = imageInfo.getHeight();
        this.horizontal = imageInfo.getWidth() > imageInfo.getHeight();
    }
}
