无关风月
2025-04-16 58b9f4d4521b21f0dbd2ed717cfa35e92d02a527
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
52
53
54
55
56
package com.dsh.guns.modular.system.controller.code;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dsh.guns.modular.system.model.TCity;
import com.dsh.guns.modular.system.model.TOperator;
import com.dsh.guns.modular.system.service.ICityService;
import com.dsh.guns.modular.system.service.TOperatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.stream.Collectors;
 
@RestController
@RequestMapping("/base")
public class CommontController {
    @Autowired
    private ICityService cityService;
    @Autowired
    private TOperatorService operatorService;
 
 
    /**
     * 获取所有省份
     */
    @RequestMapping("/region/getProvince")
    public List<TCity> getProvince() {
        return cityService.list(new LambdaQueryWrapper<TCity>()
                .eq(TCity::getParentId, 0));
    }
 
    /**
     * 获取所有城市
     */
    @RequestMapping("/region/getCity")
    public List<TCity> getCity() {
        List<Integer> ids = cityService.list(new LambdaQueryWrapper<TCity>()
                        .eq(TCity::getParentId, 0))
                .stream()
                .map(TCity::getId)
                .collect(Collectors.toList());
        return cityService.list(new LambdaQueryWrapper<TCity>()
                .in(TCity::getParentId, ids)
                .isNotNull(TCity::getCitycode));
    }
 
    /**
     * 获取所有的运营商
     */
    @RequestMapping("/operator/getOperator")
    public List<TOperator> getOperator() {
        return operatorService.list();
    }
 
}