package com.jeequan.jeepay.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("merchant")
public class WebController {

    @RequestMapping("/auth/{qrNo}")
    public String customQrCode(@PathVariable String qrNo, Model model){
        model.addAttribute("qrNo",qrNo);
        return "index";

    }




    @GetMapping("/auth1/{qrNo}")
    public void qrNo(@PathVariable String qrNo, HttpServletRequest request, HttpServletResponse response){

        try {
            request.getRequestDispatcher("/templates/index.html").forward(request,response);
        } catch (ServletException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }





    @RequestMapping("/auth2/{qrNo}")
    public String qrNo(@PathVariable String qrNo, Model model){
        model.addAttribute("qrNo",qrNo);
        return "index";
    }



}
