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 getProvince() { return cityService.list(new LambdaQueryWrapper() .eq(TCity::getParentId, 0)); } /** * 获取所有城市 */ @RequestMapping("/region/getCity") public List getCity() { List ids = cityService.list(new LambdaQueryWrapper() .eq(TCity::getParentId, 0)) .stream() .map(TCity::getId) .collect(Collectors.toList()); return cityService.list(new LambdaQueryWrapper() .in(TCity::getParentId, ids) .isNotNull(TCity::getCitycode)); } /** * 获取所有的运营商 */ @RequestMapping("/operator/getOperator") public List getOperator() { return operatorService.list(); } }