package com.bb.config;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

@ControllerAdvice
public class GlobalModelAdvice {

    @ModelAttribute("currentURI")
    public String currentURI(HttpServletRequest request) {
        String uri = request.getRequestURI();
        String query = request.getQueryString();
        
        // 쿼리 스트링이 있다면 URI 뒤에 붙여서 반환 (예: /insurance/betList?updown=up)
        if (query != null && !query.isEmpty()) {
            return uri + "?" + query;
        }
        return uri;
    }
}