package com.flossom.miniProgram.controller;

import com.flossom.common.core.constant.SysRegionConstants;
import com.flossom.common.core.web.domain.AjaxResult;
import com.flossom.miniProgram.service.ISysRegionService;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * 区域
 */
@RestController
@RequestMapping("/region")
public class SysRegionController {

    @Autowired
    private ISysRegionService sysRegionService;

    @GetMapping("/getProvince")
    public AjaxResult getProvince() {
        return AjaxResult.success(sysRegionService.selectSysAreaByPid(SysRegionConstants.PROVINCE_PID));
    }

    @GetMapping("/getAreaListByPid")
    public AjaxResult getAreaListByPid(@RequestParam(value = "pid") Integer pid) {
        if (pid == null) {
            return AjaxResult.success();
        }
        return AjaxResult.success(sysRegionService.selectSysAreaByPid(pid));
    }

}
