package com.cirle.scientific.controller.miniapp;

import com.cirle.scientific.po.SysRegion;
import com.cirle.scientific.pojo.Result;
import com.cirle.scientific.service.SysRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/sys")
@Api("后台配置相关接口")
@Slf4j
public class SysController {

    @Autowired
    SysRegionService sysRegionService;

    @GetMapping("/getRegion")
    @ApiOperation(value = "获取二级联动的省市信息")
    @ResponseBody
    public Result<List<SysRegion>> getRegion(
            @ApiParam(name = "parentId", value = "父ID") @RequestParam(name = "parentId", required = false) Integer parentId
    ) {
       return Result.success(sysRegionService.getRegion(parentId));
    }




}
