package link.at17.mid.tushare.web.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import link.at17.mid.tushare.web.service.WebUserService;

import org.springframework.beans.factory.annotation.Autowired;
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 lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
@RequestMapping("/admin")
public class ManageController {

    @Autowired
    WebUserService adminUserService;

    @Autowired
    HttpServletRequest request;

    @Autowired
    HttpServletResponse response;
    
    @Autowired
    HttpSession session;

    @GetMapping({"/manage", "manage"})
    private String redirectManage() {
        return "redirect:/admin/manage/";
    }

    @GetMapping("/manage/")
    private String manage() {
        return "admin/manage/views/index.html";
    }
    
    @GetMapping("/manage/demo-index")
    private String demoIndex() {
        return "admin/manage/views/demo-index.html";
    }
    
    @GetMapping("/manage/{*routine}")
    private String routine(@PathVariable String routine) {
        routine = routine.replaceAll("\\/+", "/");
        routine = routine.replaceAll("\\\\+", "/");
        routine = routine.replaceFirst("\\/", "");
        return "admin/manage/views/" + routine;
    }

}
