SysAreaController.java 1.8 KB
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;
        }
    }


}