package com.jwipc.sys.client.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwipc.sys.client.StockLocationClient;
import com.jwipc.sys.client.dto.StockLocationDTO;
import com.jwipc.sys.client.convert.StockLocationClientConvert;
import com.jwipc.sys.entity.StockLocation;
import com.jwipc.sys.service.IStockLocationService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Service
@RequiredArgsConstructor
public class StockLocationClientImpl implements StockLocationClient {
    private final IStockLocationService stockLocationService;
    private final StockLocationClientConvert stockLocationClientConvert;

    public StockLocationDTO getByCode(String code) {
        final StockLocation stockLocation = stockLocationService.getOne(
                new LambdaQueryWrapper<StockLocation>().eq(StockLocation::getLocationCode, code));
        return stockLocationClientConvert.entity2Dto(stockLocation);
    }
}
