package com.bonus.canteen.core.drp.api;

import com.bonus.canteen.core.auth.api.MgrAuthApi;
import com.bonus.common.houqin.constant.LeConstants;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DrpAuthorityApi {
   public static final String DRP_DEVICE_NOT_BIND_AREA = "drp.device-not-bind-area";
   @Resource
   @Lazy
   private MgrAuthApi mgrAuthApi;
//   @Autowired
//   @Lazy
//   private DrpSupplierMapper drpSupplierMapper;
//   @Autowired
//   @Lazy
//   private DeviceApi deviceApi;
//
//   public List<Long> listWarehouseAuthority() {
//      List<DrpWarehouseAllVO> tenantWarehouse = this.mgrAuthApi.getTenantWarehouse();
//      return (List)tenantWarehouse.stream().map(DrpWarehouseAllVO::getWarehouseId).collect(Collectors.toList());
//   }
//
//   public Long listSupplierAuthority() {
//      Long userId = (Long)SecureManager.getSubjectId().get();
//      DrpSupplierVO drpSupplierVO = this.drpSupplierMapper.listSupplierByUserId(userId);
//      return ObjectUtil.isEmpty(drpSupplierVO) ? -1L : drpSupplierVO.getSupplierId();
//   }

   public List<Long> listAreaAuth() {
      return this.mgrAuthApi.getTenantAreaIdList(LeConstants.COMMON_YES);
   }
//
//   public MgrUserAuthPO getUserAuthPO() {
//      return this.mgrAuthApi.getUserAuthPO();
//   }
//
//   public List<Long> authAreaList(List<Long> areaIdList) {
//      if (this.mgrAuthApi.isSuperAdmin()) {
//         return areaIdList;
//      } else {
//         List<Long> authArea = this.mgrAuthApi.getTenantAreaIdList();
//         if (CollUtil.isEmpty(areaIdList)) {
//            return authArea;
//         } else {
//            authArea.retainAll(areaIdList);
//            return (List)(CollUtil.isEmpty(authArea) ? CollUtil.newArrayList(new Long[]{-1L}) : authArea);
//         }
//      }
//   }
//
//   public Long getAreaByDeviceSn(String machineSn) {
//      try {
//         return ((DeviceBind)this.deviceApi.listBindByDeviceSn(machineSn).get(0)).getAreaId();
//      } catch (Exception var3) {
//         throw new LeException(I18n.getMessage("drp.device-not-bind-area", new Object[0]));
//      }
//   }
//
//   public List<Long> getAreaListByDeviceSn(Map<String, String> headers) {
//      try {
//         String machineSn = HeaderFetchUtil.getMachineSn(headers);
//         Assert.notBlank(machineSn, () -> {
//            return new LeException(I18n.getMessage("drp.device-sn-not-null", new Object[0]));
//         });
//         return CollUtil.toList(new Long[]{((DeviceBind)this.deviceApi.listBindByDeviceSn(machineSn).get(0)).getAreaId()});
//      } catch (Exception var3) {
//         throw new LeException(I18n.getMessage("drp.device-not-bind-area", new Object[0]));
//      }
//   }
//
//   public Long getAreaIdByDeviceSn(Map<String, String> headers) {
//      try {
//         String machineSn = HeaderFetchUtil.getMachineSn(headers);
//         Assert.notBlank(machineSn, () -> {
//            return new LeException(I18n.getMessage("drp.device-sn-not-null", new Object[0]));
//         });
//         return ((DeviceBind)this.deviceApi.listBindByDeviceSn(machineSn).get(0)).getAreaId();
//      } catch (Exception var3) {
//         throw new LeException(I18n.getMessage("drp.device-not-bind-area", new Object[0]));
//      }
//   }
}
