package com.wms.service.serviceImplements;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wms.entity.table.Goods;
import com.wms.mapper.GoodsMapper;
import com.wms.service.GoodsService;
import com.wms.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class GoodsServiceImplements extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
    private final GoodsMapper goodsMapper;

    /**
     * 验证物料编号
     * @param goodsId 物料编号
     * @return 验证结果
     */
    @Override
    public boolean validateGoodsId(String goodsId) {
        if (StringUtils.isEmpty(goodsId)) {
            return false;
        }
        LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<Goods>()
                .eq(Goods::getGoodsId, goodsId);
        return goodsMapper.exists(queryWrapper);
    }
}
