package com.ruoyi.web.controller.erp;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.erp.service.IRegionService;
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 javax.annotation.Resource;

@RestController
@RequestMapping("/erp/region")
public class RegionController extends BaseController {

    @Resource
    private IRegionService regionService;

    @GetMapping("/provinces")
    public R<?> provinces() {
        return R.ok(regionService.listProvinces());
    }

    @GetMapping("/cities")
    public R<?> cities(@RequestParam Integer provId) {
        return R.ok(regionService.listCities(provId));
    }

    @GetMapping("/areas")
    public R<?> areas(@RequestParam Integer provId, @RequestParam Integer cityId) {
        return R.ok(regionService.listAreas(provId, cityId));
    }
}


