/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.youchain.appupdate.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author liuxue
* @date 2023-07-17
**/
@Entity
@Data
@Table(name="sys_app_update")
public class SysAppUpdate implements Serializable {

    @Id
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id=0;


    @Column(name = "`app_name`")
    @ApiModelProperty(value = "项目名称")
    private String appName;


    @Column(name = "`update_status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "更新状态:0表示不更新,1表示版本更新,不需要强制升级,2表示版本更新和强制升级。")
    private Integer updateStatus;

    @Column(name = "`version_code`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "版本代码:版本编号,自递增.用来比较这个版本是否是最新的版本.")
    private Integer versionCode;

    @Column(name = "`version_name`")
    @ApiModelProperty(value = "版本名称:显示版本名称.")
    private String versionName;

    @Column(name = "`modify_content`")
    @ApiModelProperty(value = "修改内容:版本更新的内容。")
    private String modifyContent;

    @Column(name = "`download_url`")
    @ApiModelProperty(value = "下载网站:下载应用程序APK文件的地址。")
    private String downloadUrl;

    @Column(name = "`apk_size`")
    @ApiModelProperty(value = "程序大小:应用程序APK文件的文件大小,单位为kb。")
    private Integer apkSize;

    @Column(name = "`apk_md5`")
    @ApiModelProperty(value = "APKMD5:应用APK文件的MD5值。如果没有,则不能保证APK是完整的,每次都将再次下载。框架默认情况下使用MD5加密。")
    private String apkMd5;

    public void copy(SysAppUpdate source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
