package com.bonus.canteen.core.notice.print.v2.factory;

import cn.hutool.core.map.MapUtil;
import com.bonus.canteen.core.device.constants.PrinterModelEnum;
import com.bonus.canteen.core.notice.print.v2.business.NoticePrinterBusiness;
import com.bonus.canteen.core.notice.print.v2.business.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;

@Component
public class NoticePrinterFactory {
   private static final Map<String, NoticePrinterBusiness> serviceMap = MapUtil.newConcurrentHashMap();
   @Autowired
   private NoticePrinterFeiEBusiness feiEBusiness;
   @Autowired
   private NoticePrinterFeiELabelBusiness feiELabelBusiness;
   @Autowired
   private NoticePrinterJiaBoBusiness jiaBoBusiness;
   @Autowired
   private NoticePrinterJiaBoLabelBusiness jiaBoLabelBusiness;
   @Autowired
   private NoticePrinterXinYeBusiness noticePrinterXinYeBusiness;
   @Autowired
   private NoticePrinterXnBusiness noticePrinterXnBusiness;

   @PostConstruct
   public void init() {
      serviceMap.put(PrinterModelEnum.FEI_E.getKey(), this.feiEBusiness);
      serviceMap.put(PrinterModelEnum.FEI_E_LABEL.getKey(), this.feiELabelBusiness);
      serviceMap.put(PrinterModelEnum.JIA_BO.getKey(), this.jiaBoBusiness);
      serviceMap.put(PrinterModelEnum.JIA_BO_LABEL.getKey(), this.jiaBoLabelBusiness);
      serviceMap.put(PrinterModelEnum.XIN_YE.getKey(), this.noticePrinterXinYeBusiness);
      serviceMap.put(PrinterModelEnum.XN.getKey(), this.noticePrinterXnBusiness);
   }

   public NoticePrinterBusiness getNoticePrinterBusiness(String deviceModel) {
      return (NoticePrinterBusiness)serviceMap.get(deviceModel);
   }
}
