fix
Helius
2021-09-15 7ab7943de217a9e5d4a489c22c7ae27a29692d55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);
    }
 
 
 
}