package com.bonus.canteen.core.device.manage.dto;

import cn.hutool.core.bean.BeanUtil;
import com.bonus.canteen.core.common.enums.SourceTypeEnum;
import com.bonus.canteen.core.common.utils.SysUtil;
import com.bonus.canteen.core.device.manage.model.BasicsAppUpdate;
import io.swagger.annotations.ApiModelProperty;

public class BasicsAppUpdateDTO {
   @ApiModelProperty("主键id")
   private Long id;
   @ApiModelProperty("来源")
   private Integer sourceType;
   @ApiModelProperty("设备型号")
   private String deviceModel;
   @ApiModelProperty("app版本")
   private int appVersionCode;
   @ApiModelProperty("app名称")
   private String appVersionName;
   @ApiModelProperty("app下载地址")
   private String appUpdateUrl;
   @ApiModelProperty("是否强制更新")
   private int ifUpdateMust;

   public void setAppUpdateUrl(String appUpdateUrl) {
      if (null != this.sourceType && !SourceTypeEnum.SCAN_CODE_TOLL.getKey().equals(this.sourceType)) {
         this.appUpdateUrl = SysUtil.getCutPath(appUpdateUrl);
      } else {
         this.appUpdateUrl = appUpdateUrl;
      }

   }

   public BasicsAppUpdate convertToEntity() {
      BasicsAppUpdate entity = new BasicsAppUpdate();
      BeanUtil.copyProperties(this, entity, new String[0]);
      return entity;
   }

   public Long getId() {
      return this.id;
   }

   public Integer getSourceType() {
      return this.sourceType;
   }

   public String getDeviceModel() {
      return this.deviceModel;
   }

   public int getAppVersionCode() {
      return this.appVersionCode;
   }

   public String getAppVersionName() {
      return this.appVersionName;
   }

   public String getAppUpdateUrl() {
      return this.appUpdateUrl;
   }

   public int getIfUpdateMust() {
      return this.ifUpdateMust;
   }

   public void setId(final Long id) {
      this.id = id;
   }

   public void setSourceType(final Integer sourceType) {
      this.sourceType = sourceType;
   }

   public void setDeviceModel(final String deviceModel) {
      this.deviceModel = deviceModel;
   }

   public void setAppVersionCode(final int appVersionCode) {
      this.appVersionCode = appVersionCode;
   }

   public void setAppVersionName(final String appVersionName) {
      this.appVersionName = appVersionName;
   }

   public void setIfUpdateMust(final int ifUpdateMust) {
      this.ifUpdateMust = ifUpdateMust;
   }
}
