SysAreaController.java
1.8 KB
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
package com.skua.modules.system.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.core.api.vo.Result;
import com.skua.modules.system.entity.SysArea;
import com.skua.modules.system.service.ISysAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/area")
@Api(value = "省市县", tags = "省市县")
public class SysAreaController {
@Autowired
private ISysAreaService areaService;
@GetMapping(value = "/findProvince")
@ApiOperation(value = "获取省级列表")
public Result<List<SysArea>> city(@RequestParam(value = "id") Integer id) {
Result<List<SysArea>> result = new Result<>();
QueryWrapper<SysArea> wrapper = new QueryWrapper<>();
if (id == -1) {
wrapper.eq("parent_id", id);
List<SysArea> provinceList = areaService.list(wrapper);
result.success("查询成功");
result.setResult(provinceList);
return result;
}else {
wrapper.eq("parent_id", id);
List<SysArea> provinceList = areaService.list(wrapper);
result.success("查询成功");
result.setResult(provinceList);
return result;
}
}
}