SupplierServiceImpl.java 1.52 KB
package com.huaheng.pc.config.supplier.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.supplier.mapper.SupplierMapper;
import com.huaheng.pc.config.supplier.domain.Supplier;

import java.util.List;
import java.util.Map;

@Service("SupplierService")
public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements SupplierService{

    @Override
    public List<Map<String, Object>> getCode(){
        LambdaQueryWrapper<Supplier> lambda = Wrappers.lambdaQuery();
        lambda.select(Supplier::getCode, Supplier::getId, Supplier::getName)
                .eq(Supplier::getWarehouseCode, ShiroUtils.getWarehouseCode())
                .eq(Supplier::getDeleted,false)
                .eq(Supplier::getEnable,true);
        return this.listMaps(lambda);
    }

    @Override
    public String getSuppierNameByCode(String code){
        if(StringUtils.isNotEmpty(code)){
            LambdaQueryWrapper<Supplier> lambda = Wrappers.lambdaQuery();
            lambda.eq(Supplier::getCode, code);
            lambda.last("limit 1");
            Supplier supplier= this.getOne(lambda);
            if(supplier!=null){
                return supplier.getName();
            }
        }
        return null;
    }
}