package com.qs.mp.web.controller.api.common;

import com.alibaba.fastjson.JSONObject;
import com.qs.mp.common.core.domain.AjaxResult;
import com.qs.mp.common.domain.Area;
import com.qs.mp.common.service.IAreaService;
import com.qs.mp.web.controller.common.BaseApiController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * 省市区通用查询，渠道、用户端共用
 * @author zhongcp on 2022/3/2.
 */
@RestController
@RequestMapping("/api/v1/mp")
@Api(tags="省市区接口")
public class AreaQueryController extends BaseApiController {

    @Autowired
    private IAreaService areaService;

    /**
	 * 分页获取
	 */
    @PostMapping("/area/listByPid")
    @ApiOperation(value="获取省市区信息", notes="根据省市区的pid获取地址信息")
	public AjaxResult listByPid(@RequestBody JSONObject jsonObject){
      Long pid = jsonObject.getLong("pid");
		  List<Area> list = areaService.listByPid(pid);
		  return AjaxResult.success(list);
	}

}
