package com.jwipc.sys.client.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwipc.sys.client.ProductStockClient;
import com.jwipc.sys.entity.ProductStock;
import com.jwipc.sys.service.IProductInfoStockService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Service
@RequiredArgsConstructor
public class ProductStockClientImpl implements ProductStockClient {
    private final IProductInfoStockService productInfoStockService;

    @Override
    public String getStockLocation(String materialCode) {
        final ProductStock one = productInfoStockService.getOne(
                new LambdaQueryWrapper<ProductStock>().eq(ProductStock::getMaterialCode, materialCode), false);
        return Objects.nonNull(one) ? one.getStockLocation() : StrUtil.EMPTY;
    }
}
