package com.cool.store.controller;

import com.cool.store.dto.mdm.AreaSonDTO;
import com.cool.store.entity.MDMAreaDO;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.MDMAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mdm/area")
@Api(tags = "MDM省市信息")
public class MDMAreaController {

    @Autowired
    private MDMAreaService mdmAreaService;

    @PostMapping("/province")
    @ApiOperation("获取MDM省级信息")
    public ResponseResult<List<MDMAreaDO>> getProvince() {
        return ResponseResult.success(mdmAreaService.getProvince());
    }

    @PostMapping("/son")
    @ApiOperation("获取子级区域数据")
    private ResponseResult<List<MDMAreaDO>> getSonArea(@RequestBody AreaSonDTO areaSon) {
        return ResponseResult.success(mdmAreaService.getSonArea(areaSon.getCode()));
    }


}
