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: BaiduMapStaticController
 * @Description: 百度地图静态文件
 * @Author: wanggeng
 * @Date: 2021/10/20 10:13 上午
 * @Version: 1.0
 */
@Controller
@RequestMapping("static/baidu-map")
public class BaiduMapStaticController {

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

}
