package cn.reghao.oss.store.model.po;

import cn.reghao.jutil.jdk.db.BaseObject;
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> {
    // 原始文件的 objectId
    private String imageFileId;
    private String objectId;
    private String format;
    private String url;
    private Integer width;
    private Integer height;
    private Boolean horizontal;

    public ImageFile(String imageFileId, String objectId, String format, String url, Integer width, Integer height) {
        this.imageFileId = imageFileId;
        this.objectId = objectId;
        this.format = format;
        this.url = url;
        this.width = width;
        this.height = height;
        this.horizontal = width > height;
    }

    public ImageFile(String imageFileId, String objectId, String url, ImageFile imageFile) {
        this.imageFileId = imageFileId;
        this.objectId = objectId;
        this.format = imageFile.getFormat();
        this.url = url;
        this.width = imageFile.getWidth();
        this.height = imageFile.getHeight();
        this.horizontal = imageFile.getHorizontal();
    }
}
