| package com.xzx.gc.system.service;  | 
|   | 
| import cn.hutool.core.collection.CollUtil;  | 
| import com.xzx.gc.entity.AddressInfo;  | 
| import com.xzx.gc.model.user.AddressReq;  | 
| import com.xzx.gc.model.user.AddressVo;  | 
| import com.xzx.gc.system.mapper.AddressMapper;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.stereotype.Service;  | 
| import org.springframework.transaction.annotation.Transactional;  | 
|   | 
| import java.util.List;  | 
|   | 
| @Service  | 
| @Transactional  | 
| public class AddressService {  | 
|   | 
|     @Autowired  | 
|     private AddressMapper addressMapper;  | 
|   | 
|     public AddressVo findByName(String proviceName,String cityName,String townName){  | 
|         AddressReq addressReq=new AddressReq();  | 
|         addressReq.setProvinceName(proviceName);  | 
|         addressReq.setTownshipName(townName);  | 
|         addressReq.setCityName(cityName);  | 
|         List<AddressVo> addressLevelList= addressMapper.queryAreaIdByName(addressReq);  | 
|         if(CollUtil.isNotEmpty(addressLevelList)){  | 
|             return addressLevelList.get(0);  | 
|         }  | 
|         return null;  | 
|     }  | 
|   | 
|     public AddressVo findByLevelId(String proviceId,String cityId,String townId){  | 
|         AddressReq addressReq=new AddressReq();  | 
|         addressReq.setProvinceId(proviceId);  | 
|         addressReq.setTownshipId(townId);  | 
|         addressReq.setCityId(cityId);  | 
|         List<AddressVo> addressLevelList= addressMapper.queryAreaNameById(addressReq);  | 
|         if(CollUtil.isNotEmpty(addressLevelList)){  | 
|             return addressLevelList.get(0);  | 
|         }  | 
|         return null;  | 
|     }  | 
|   | 
|     public AddressInfo findById(Long id){  | 
|         return addressMapper.selectByPrimaryKey(id);  | 
|     }  | 
|   | 
|   | 
|   | 
| }  |