package com.wgb.system.service.controller;

import com.data.model.restful.response.InternalResponse;
import com.tool.data.external.domain.request.Lbs.DistrictRequest;
import com.tool.data.external.domain.response.lbs.DistrictResponse;
import com.wgb.system.service.domain.response.LayuiTableResponse;
import com.wgb.system.service.service.LBSService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/lbs")
@RestController
@Slf4j
public class LBSconteoller {

    private final LBSService lbsService;

    public LBSconteoller(LBSService lbsService) {
        this.lbsService = lbsService;
    }

//    @ApiOperation(value = "/获取高德地图行政区域查询", response = LayuiTableResponse.class)
//    @ResponseBody
//    @RequestMapping(value = "/getDistrict",method = {RequestMethod.POST})
    public InternalResponse getDistrict(@RequestBody DistrictRequest request){
        DistrictResponse districtResponse= lbsService.getDistrict(request);
        return InternalResponse.success().withBody(districtResponse);
    }


    @ApiOperation(value = "/根据父节点Id获取省市区", response = LayuiTableResponse.class)
    @RequestMapping(value = "/getLbsMapList",method = RequestMethod.GET)
    @ResponseBody
    public InternalResponse getLbsMapList(@RequestParam(name = "parentCode",required = true)  Integer parentCode){
        return InternalResponse.success().withBody(lbsService.getRegionList(parentCode));
    }

    @ApiOperation(value = "/根据ID获取省市区信息", response = LayuiTableResponse.class)
    @RequestMapping(value = "/getLbsMapById",method = RequestMethod.GET)
    @ResponseBody
    public InternalResponse getLbsMapById(@RequestParam(name = "id",required = true)  Integer id){
        return InternalResponse.success().withBody(lbsService.getRegionById(id));
    }
}
