FAISP/src/main/java/com/dbnt/faisp/controller/BaseController.java

61 lines
1.7 KiB
Java
Raw Normal View History

2022-08-18 06:21:44 +00:00
package com.dbnt.faisp.controller;
import com.dbnt.faisp.model.UserInfo;
2022-08-22 09:35:33 +00:00
import com.dbnt.faisp.service.CodeMgtService;
2022-08-18 06:21:44 +00:00
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpSession;
@RestController
@RequiredArgsConstructor
public class BaseController {
2022-08-22 09:35:33 +00:00
private final CodeMgtService codeMgtService;
2022-08-18 06:21:44 +00:00
@GetMapping("/")
public ModelAndView loginCheck(@AuthenticationPrincipal UserInfo loginUser, HttpSession session) {
ModelAndView mav = null;
if(loginUser == null){
2022-08-18 09:12:57 +00:00
mav = new ModelAndView("redirect:/login");
2022-08-18 06:21:44 +00:00
}else{
session.setAttribute("commonCodeList", codeMgtService.selectCommonCodeList());
2022-08-19 05:30:04 +00:00
mav = new ModelAndView("redirect:/dashboard");
2022-08-18 06:21:44 +00:00
}
return mav;
}
@GetMapping("/refreshSession")
public void getSession(HttpSession session){
session.setAttribute("commonCodeList", codeMgtService.selectCommonCodeList());
2022-08-18 06:21:44 +00:00
}
2022-08-18 09:12:57 +00:00
@GetMapping("/login")
2022-08-18 06:21:44 +00:00
public ModelAndView goLogin() {
2022-08-18 09:12:57 +00:00
ModelAndView mav = new ModelAndView("/login/login");
2022-08-18 06:21:44 +00:00
return mav;
}
@GetMapping("/login-error")
public ModelAndView loginError() {
2022-08-18 09:12:57 +00:00
ModelAndView mav = new ModelAndView("/login/login");
2022-08-18 06:21:44 +00:00
mav.addObject("loginError", true);
return mav;
}
@GetMapping("/denied")
public ModelAndView doDenied() {
ModelAndView mav = new ModelAndView("login/denied");
return mav;
}
2022-08-19 05:30:04 +00:00
@GetMapping("/dashboard")
public ModelAndView dashboard() {
ModelAndView mav = new ModelAndView("login/dashboard");
return mav;
}
2022-08-18 06:21:44 +00:00
}