package incheon.tmp.crud.web;

import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.nio.file.Files;
import java.nio.file.Path;

@RestController
@RequestMapping("/demo/map")
public class DemoMapApiController {
	
    @GetMapping(value = "/umd.json", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public String umd() throws Exception {
        ClassPathResource resource = new ClassPathResource("static/demo/map/umd.json");
        return Files.readString(Path.of(resource.getURI()));
    }
	
    @GetMapping(value = "/seoul.json", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
	public String seoul() throws Exception {
	    // static/demo/map/umd.json 파일 읽기
	    ClassPathResource resource = new ClassPathResource("static/demo/map/seoul.json");
	    return Files.readString(Path.of(resource.getURI()));
	}
	
    @GetMapping(value = "/park.json", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
	public String park() throws Exception {
	    // static/demo/map/umd.json 파일 읽기
	    ClassPathResource resource = new ClassPathResource("static/demo/map/park.json");
	    return Files.readString(Path.of(resource.getURI()));
	}
	
    @GetMapping(value = "/school.json", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
	public String school() throws Exception {
	    // static/demo/map/umd.json 파일 읽기
	    ClassPathResource resource = new ClassPathResource("static/demo/map/school.json");
	    return Files.readString(Path.of(resource.getURI()));
	}
	
    @GetMapping(value = "/sgg.json", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
	public String sgg() throws Exception {
	    // static/demo/map/umd.json 파일 읽기
	    ClassPathResource resource = new ClassPathResource("static/demo/map/sgg.json");
	    return Files.readString(Path.of(resource.getURI()));
	}
	
}
