package com.ningdatech.pmapi.sys.controller;

import com.ningdatech.pmapi.sys.manage.RegionManage;
import com.ningdatech.pmapi.sys.model.vo.RegionTreeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
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;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author LiuXinXin
 * @since 2022-10-08
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/region")
@Api(tags = "系统管理-地域管理")
public class RegionController {

    private final RegionManage regionManage;

    @GetMapping("/tree")
    @ApiOperation("获取区域编码的树状结构")
    public RegionTreeVO getRegionTree(@RequestParam(required = false) String regionCode,
                                      @RequestParam(required = false) Integer regionLevel) {
        return regionManage.getRegionTree(regionCode, regionLevel);
    }

}
