package com.gree.mall.manager.controller;

import com.gree.mall.manager.annotation.ApiNotAuth;
import com.gree.mall.manager.exception.RemoteServiceException;
import com.gree.mall.manager.logic.common.CommonLogic;
import lombok.RequiredArgsConstructor;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RequiredArgsConstructor
@Controller
@RequestMapping("/redirect")
public class RedirectController {


    private final CommonLogic commonLogic;

    @ApiNotAuth
    @GetMapping("img/get")
    public void getImg(
            @RequestParam() String key,
            HttpServletResponse response
    ) throws IOException, RemoteServiceException {
        String file = commonLogic.getFileGet(key);
        response.sendRedirect(file);
    }


}
