AddressServiceImpl.java 1.36 KB
package com.huaheng.pc.config.address.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.config.address.domain.Address;
import com.huaheng.pc.config.address.mapper.AddressMapper;
import org.springframework.stereotype.Service;

@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService {

    @Override
    public String selectAddress(String param) {
        if(StringUtils.isEmpty(param)){
            throw new ServiceException("参数为空");
        }

        LambdaQueryWrapper<Address> addressLam = Wrappers.lambdaQuery();
        addressLam.eq(Address::getParam,param)
                .eq(Address::getWarehouseCode, ShiroUtils.getWarehouseCode());
        Address address=this.getOne(addressLam);
        if(address == null){
            throw new ServiceException("参数错误,系统没有此参数对应的地址");
        }
        if(StringUtils.isEmpty(address.getUrl())){
            throw new ServiceException("地址为空");
        }
        return address.getUrl();
    }
}