/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.disk.domain;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qiwenshare.common.util.DateUtil;
import com.qiwenshare.ufop.operation.upload.domain.UploadFileResult;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * RESOURCE_FILE实体
 *
 * @author honorfire
 * @date  2025/06/26 09:26
 **/
@Getter
@Setter
@TableName("RESOURCE_FILE")
public class ResourceFile {

    /** FILE_ID */
    @TableId
    @ApiModelProperty(value = "FILE_ID", position = 1)
    private String fileId;

    /** CREATE_TIME */
    @ApiModelProperty(value = "CREATE_TIME", position = 2)
    @TableField(fill = FieldFill.INSERT)
    private String createTime;

    /** CREATE_USER_ID */
    @ApiModelProperty(value = "CREATE_USER_ID", position = 3)
    private String createUserId;

    /** FILE_SIZE */
    @ApiModelProperty(value = "FILE_SIZE", position = 4)
    private Long fileSize;

    /** FILE_STATUS */
    @ApiModelProperty(value = "FILE_STATUS", position = 5)
    private Integer fileStatus;

    /** FILE_URL */
    @ApiModelProperty(value = "FILE_URL", position = 6)
    private String fileUrl;

    /** IDENTIFIER */
    @ApiModelProperty(value = "IDENTIFIER", position = 7)
    private String identifier;

    /** MODIFY_TIME */
    @ApiModelProperty(value = "MODIFY_TIME", position = 8)
    private String modifyTime;

    /** MODIFY_USER_ID */
    @ApiModelProperty(value = "MODIFY_USER_ID", position = 9)
    private String modifyUserId;

    /** STORAGE_TYPE */
    @ApiModelProperty(value = "STORAGE_TYPE", position = 10)
    private Integer storageType;

    /** FILE_RESOURCE */
    @ApiModelProperty(value = "FILE_RESOURCE", position = 11)
    private Integer fileResource;

    @TableField(value="PRIVIEW_FILE_URL")
    private String previewFileUrl;

    public ResourceFile(){

    }

    public ResourceFile(UploadFileResult uploadFileResult) {
        this.fileId = IdUtil.getSnowflakeNextIdStr();
        this.fileUrl = uploadFileResult.getFileUrl();
        this.fileSize = uploadFileResult.getFileSize();
        this.fileStatus = 1;
        this.storageType = uploadFileResult.getStorageType().getCode();
        this.identifier = uploadFileResult.getIdentifier();
        this.createTime = DateUtil.getCurrentTime();

    }

    public ResourceFile(String fileUrl, Long fileSize, Integer storageType, String identifier, String userId) {
        this.fileId = IdUtil.getSnowflakeNextIdStr();
        this.fileUrl = fileUrl;
        this.fileSize = fileSize;
        this.fileStatus = 1;
        this.storageType = storageType;
        this.identifier = identifier;
        this.createTime = DateUtil.getCurrentTime();
        this.createUserId = userId;

    }
}
