package incheon.cmm.g3f.sample.web;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import incheon.cmm.g3f.sample.dto.G3FBuildingInfo;
import incheon.cmm.g3f.sample.service.G3FSampleService;
import incheon.com.cmm.api.DefaultApiResponse;

@RequestMapping("/cmm/g3f/sample")
@Controller
public class G3FSampleController {

    private final G3FSampleService g3fSampleService;

    public G3FSampleController(G3FSampleService g3fSampleService) {
        this.g3fSampleService = g3fSampleService;
    }
     
    @GetMapping("/sample.do")
    public String sample() {
        return "/cmm/g3f/sample/sample";
    }

    @GetMapping(value = "/building", produces = "application/json")
    @ResponseBody
    public ResponseEntity<DefaultApiResponse<G3FBuildingInfo>> basemaps(
            @RequestParam(value = "lon") double lon,
            @RequestParam(value = "lat") double lat
    ) {
        G3FBuildingInfo buildingData = g3fSampleService.getBuildingInfoByLocation(lon, lat);

        return ResponseEntity.ok(DefaultApiResponse.success(buildingData));
    }

}
