package com.bonus.canteen.core.device.manage.controller.deprecated.vo;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

@ApiModel("操作设备入参")
public class MachineCounterTypeDto {
   @ApiModelProperty("食堂ID")
   private Long canteenId;
   /** @deprecated */
   @ApiModelProperty("原食堂id")
   private Long diningId;
   @ApiModelProperty("店铺档口id")
   @TableField(
      updateStrategy = FieldStrategy.NOT_EMPTY
   )
   private Long shopstallId;
   @ApiModelProperty("设备sn码")
   private String machineSn;
   @ApiModelProperty("设备编号")
   private @NotBlank(
   message = "设备编号不可为空"
) String mchNum;
   @ApiModelProperty("设备名称")
   private @NotBlank(
   message = "设备名称不可为空"
) String mchName;
   @ApiModelProperty("设备类型")
   private Integer mchType;
   @ApiModelProperty("设备类型")
   private @NotNull(
   message = "设备类型不可为空"
) List<Integer> mchTypeList;

   public void setMachineSn(String machineSn) {
      if (StrUtil.isNotBlank(machineSn)) {
         this.machineSn = machineSn.trim();
      }

   }

   public void setMchName(String mchName) {
      if (StrUtil.isNotBlank(mchName)) {
         this.mchName = mchName.trim();
      }

   }

   public void setMchNum(String mchNum) {
      if (StrUtil.isNotBlank(mchNum)) {
         this.mchNum = mchNum.trim();
      }

   }

   public List<Integer> getMchTypeList() {
      return CollUtil.isEmpty(this.mchTypeList) && this.mchType != null ? CollUtil.toList(new Integer[]{this.mchType}) : ListUtil.toList(this.mchTypeList);
   }

   public Long getCanteenId() {
      return this.canteenId == null && this.diningId != null ? this.diningId : this.canteenId;
   }

   /** @deprecated */
   @Deprecated
   public Long getDiningId() {
      return this.diningId;
   }

   public Long getShopstallId() {
      return this.shopstallId;
   }

   public String getMachineSn() {
      return this.machineSn;
   }

   public String getMchNum() {
      return this.mchNum;
   }

   public String getMchName() {
      return this.mchName;
   }

   public Integer getMchType() {
      return this.mchType;
   }

   public void setCanteenId(final Long canteenId) {
      this.canteenId = canteenId;
   }

   /** @deprecated */
   @Deprecated
   public void setDiningId(final Long diningId) {
      this.diningId = diningId;
   }

   public void setShopstallId(final Long shopstallId) {
      this.shopstallId = shopstallId;
   }

   public void setMchType(final Integer mchType) {
      this.mchType = mchType;
   }

   public void setMchTypeList(final List<Integer> mchTypeList) {
      this.mchTypeList = mchTypeList;
   }

}
