74 lines
2.6 KiB
Java
74 lines
2.6 KiB
Java
package com.dbnt.faisp.config;
|
|
|
|
import com.dbnt.faisp.menuMgt.service.MenuMgtService;
|
|
import com.dbnt.faisp.organMgt.service.OrganConfigService;
|
|
import com.dbnt.faisp.userInfo.model.UserInfo;
|
|
import com.dbnt.faisp.codeMgt.service.CodeMgtService;
|
|
|
|
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 {
|
|
|
|
private final CodeMgtService codeMgtService;
|
|
private final OrganConfigService organConfigService;
|
|
private final MenuMgtService menuMgtService;
|
|
|
|
@GetMapping("/")
|
|
public ModelAndView loginCheck(@AuthenticationPrincipal UserInfo loginUser, HttpSession session) {
|
|
ModelAndView mav = null;
|
|
if(loginUser == null){
|
|
mav = new ModelAndView("redirect:/login");
|
|
}else{
|
|
loginUser.setOrganCdList(organConfigService.selectOrganListWhereUserOgCd(loginUser.getOgCd()));
|
|
session.setAttribute("menuList", menuMgtService.selectAccessMenuListWhereUserSeq(loginUser.getUserSeq()));
|
|
session.setAttribute("commonCode", codeMgtService.getCommonCode());
|
|
mav = new ModelAndView("redirect:/dashboard");
|
|
}
|
|
return mav;
|
|
}
|
|
|
|
@GetMapping("/refreshSession")
|
|
public void getSession(@AuthenticationPrincipal UserInfo loginUser, HttpSession session){
|
|
loginUser.setOrganCdList(organConfigService.selectOrganListWhereUserOgCd(loginUser.getOgCd()));
|
|
session.setAttribute("menuList", menuMgtService.selectAccessMenuListWhereUserSeq(loginUser.getUserSeq()));
|
|
session.setAttribute("commonCode", codeMgtService.getCommonCode());
|
|
}
|
|
|
|
@GetMapping("/login")
|
|
public ModelAndView goLogin() {
|
|
ModelAndView mav = new ModelAndView("/login/login");
|
|
mav.addObject("OgList", codeMgtService.selectCodeMgtList("OG"));
|
|
mav.addObject("OfcList", codeMgtService.selectCodeMgtList("OFC"));
|
|
return mav;
|
|
}
|
|
|
|
@GetMapping("/login-error")
|
|
public ModelAndView loginError() {
|
|
ModelAndView mav = new ModelAndView("/login/login");
|
|
mav.addObject("OgList", codeMgtService.selectCodeMgtList("OG"));
|
|
mav.addObject("OfcList", codeMgtService.selectCodeMgtList("OFC"));
|
|
mav.addObject("loginError", true);
|
|
return mav;
|
|
}
|
|
|
|
@GetMapping("/denied")
|
|
public ModelAndView doDenied() {
|
|
ModelAndView mav = new ModelAndView("login/denied");
|
|
return mav;
|
|
}
|
|
|
|
@GetMapping("/dashboard")
|
|
public ModelAndView dashboard() {
|
|
ModelAndView mav = new ModelAndView("login/dashboard");
|
|
return mav;
|
|
}
|
|
}
|