package ink.wgink.module.map.controller.staticfile;

import ink.wgink.util.ResourceUtil;
import ink.wgink.util.request.StaticResourceRequestUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

/**
 * @ClassName: SuperMapStaticController
 * @Description: 超图静态资源
 * @Author: wanggeng
 * @Date: 2021/12/18 10:16 PM
 * @Version: 1.0
 */
@Controller
@RequestMapping("static/super-map")
public class SuperMapStaticController {

    @GetMapping("css/{fileName}")
    public void css(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
        InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/super-map/css/" + fileName);
        StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
    }

    @GetMapping("js/{fileName}")
    public void js(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
        InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/super-map/js/" + fileName);
        StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
    }

}
