package com.miaxis.pc.controller.area;

import com.miaxis.area.domain.AreaInfo;
import com.miaxis.area.service.IAreaInfoService;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.page.ResponsePageInfo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【地区】Controller
 *
 * @author miaxis
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/area/info")
@Api(tags={"【PC-地区】"})
public class AreaInfoController extends BaseController{
    @Autowired
    private IAreaInfoService areaInfoService;

    /**
     * 查询地区列表
     */
    @GetMapping("/list")
    @ApiOperation("查询地区列表")
        @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<AreaInfo> list(@ModelAttribute AreaInfo areaInfo){
        startPage();
        List<AreaInfo> list = areaInfoService.selectAreaInfoList(areaInfo);
        return toResponsePageInfo(list);
    }
    

    /**
     * 获取地区详细信息
     */
    @GetMapping(value = "/{code}")
    @ApiOperation("获取地区详细信息")
    public Response<AreaInfo> getInfo(
            @ApiParam(name = "code", value = "地区参数", required = true)
            @PathVariable("code") String code
    ){
        return Response.success(areaInfoService.getById(code));
    }



}
