liujie
2025-11-24 8601dadb2ac1f3c59b7619ef037b1dcdf426bf4c
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
57
58
59
60
61
62
63
64
65
66
67
68
package com.stylefeng.guns.modular.api;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.model.Region;
import com.stylefeng.guns.modular.system.service.INoticeService;
import com.stylefeng.guns.modular.system.service.IRegionService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
 
/**
 * 总览信息
 *
 * @author fengshuonan
 * @Date 2017年3月4日23:05:54
 */
@Api(tags = "区域管理")
@RestController
@RequestMapping("/region")
public class RegionController extends BaseController {
 
    @Autowired
    private IRegionService regionService;
 
    /**
     * 获取省份列表
     */
    @ApiOperation("获取省份列表")
    @GetMapping("/province")
    public ResultUtil<List<Region>> blackboard() {
        List<Region> provinceList = regionService.selectList(new EntityWrapper<Region>().eq("parent_id", 0));
        return ResultUtil.success(provinceList);
    }
 
    /**
     * 根据区域编码获取下级列表
     * @param code
     * @return
     */
    @ApiOperation("根据区域编码获取下级列表")
    @GetMapping(value = "/change")
    @ApiImplicitParam(name = "code", value = "区域编码", required = true, dataType = "String", paramType = "query")
    public ResultUtil<List<Region>> change(@RequestParam String code) {
        List<Region> list = new ArrayList<>();
        if (StringUtils.isNotBlank(code)){
            Region region = regionService.selectOne(new EntityWrapper<Region>().eq("code", code));
            if (Objects.nonNull(region)) {
                list = regionService.selectList(new EntityWrapper<Region>().eq("parent_id", region.getId()));
            }
        }
        return ResultUtil.success(list);
    }
}