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

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

/**
 * 图像文件
 *
 * @author reghao
 * @date 2021-12-08 13:52:01
 */
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
public class ImageFile extends BaseObject<Integer> {
    private Long albumId;
    private Integer channelCode;
    // 原始文件的 objectId
    private String imageFileId;
    private String objectId;
    private String format;
    private String url;
    private Integer width;
    private Integer height;
    private Boolean horizontal;

    public ImageFile(Long albumId, int channelCode, ImageInfo imageInfo) {
        this.albumId = albumId;
        this.channelCode = channelCode;
        this.imageFileId = imageInfo.getImageFileId();
        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();
    }
}
