puzhibing
2023-06-13 7860e5cb6db60aeb82c640651998f8294635df5b
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
package com.dsh.course.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.course.entity.HotAddress;
import com.dsh.course.entity.OpenCity;
import com.dsh.course.mapper.HotAddressMapper;
import com.dsh.course.service.IHotAddressService;
import com.dsh.course.service.IOpenCityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Objects;
 
 
@Service
public class HotAddressServiceImpl extends ServiceImpl<HotAddressMapper, HotAddress> implements IHotAddressService {
 
    @Autowired
    private IOpenCityService openCityService;
 
 
    @Override
    public List<HotAddress> selectHotAddressByCityId(Integer cityId) {
        OpenCity openCity = openCityService.getBaseMapper().selectById(cityId);
        LambdaQueryWrapper<HotAddress> queryWrapper = new LambdaQueryWrapper<>();
        if(Objects.nonNull(cityId)) {
            queryWrapper.eq(HotAddress::getCityId,openCity.getCityId());
        }
        queryWrapper.last("limit 10");
        return this.baseMapper.selectList(queryWrapper);
    }
}