package com.bonus.material.cnarea.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.cnarea.service.CnareaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 地址选择
 */
@RestController
@RequestMapping("/cnarea")
@Slf4j
public class CnareaController extends BaseController {

    @Resource
    private CnareaService cnareaService;

    /**
     * 获取所有省份
     */
    @GetMapping("/provinces")
    public AjaxResult getProvinces() {
        return AjaxResult.success(cnareaService.getProvinces());
    }


    /**
     * 根据代码获取城市列表
     */
    @GetMapping("/cities/{provinceCode}")
    public AjaxResult getCities(@PathVariable String provinceCode) {
        return AjaxResult.success(cnareaService.getCities(provinceCode));
    }
}
