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> blackboard() { List provinceList = regionService.selectList(new EntityWrapper().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> change(@RequestParam String code) { List list = new ArrayList<>(); if (StringUtils.isNotBlank(code)){ Region region = regionService.selectOne(new EntityWrapper().eq("code", code)); if (Objects.nonNull(region)) { list = regionService.selectList(new EntityWrapper().eq("parent_id", region.getId())); } } return ResultUtil.success(list); } }