package com.zd.airbottle.utils;

import com.zd.airbottle.domain.QpSupplier;
import com.zd.airbottle.service.IQpSupplierService;
import com.zd.common.core.exception.ServiceException;
import com.zd.common.security.service.TokenService;

import java.util.List;

public class SupplierUtil {

    public static QpSupplier getSupplier(TokenService tokenService, IQpSupplierService supplierService) {
        Long userId = tokenService.getLoginUser().getSysUser().getUserId();
        QpSupplier supplier = new QpSupplier();
        supplier.setAccountId(userId);
        List<QpSupplier> suppliers = supplierService.getList(supplier);
        if (suppliers.size() != 1) {
            throw new ServiceException("供应商出错");
        }
        return suppliers.get(0);
    }
}
