package com.bonus.canteen.core.order.common.dto;

import cn.hutool.core.map.MapUtil;
import com.bonus.canteen.core.common.utils.HeaderFetchUtil;

import java.util.Map;

public class RequestHeaderDTO {
   private String openid;
   private Integer sourceType;
   private String machineNum;
   private String machineSn;
   private Long custId;

   public static RequestHeaderDTO of(Map<String, String> requestHeader) {
      RequestHeaderDTO headerDTO = new RequestHeaderDTO();
      if (MapUtil.isEmpty(requestHeader)) {
         return headerDTO;
      } else {
         headerDTO.setOpenid(HeaderFetchUtil.getOpenid(requestHeader));
         headerDTO.setSourceType(HeaderFetchUtil.getSourceType(requestHeader));
         headerDTO.setMachineNum(HeaderFetchUtil.getMachineNum(requestHeader));
         headerDTO.setMachineSn(HeaderFetchUtil.getMachineSn(requestHeader));
         headerDTO.setCustId(HeaderFetchUtil.getCustId(requestHeader));
         return headerDTO;
      }
   }

   public String getOpenid() {
      return this.openid;
   }

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

   public String getMachineNum() {
      return this.machineNum;
   }

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

   public Long getCustId() {
      return this.custId;
   }

   public void setOpenid(final String openid) {
      this.openid = openid;
   }

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

   public void setMachineNum(final String machineNum) {
      this.machineNum = machineNum;
   }

   public void setMachineSn(final String machineSn) {
      this.machineSn = machineSn;
   }

   public void setCustId(final Long custId) {
      this.custId = custId;
   }

}
