2022-09-11 06:30:20 +00:00
|
|
|
package com.dbnt.faisp.config;
|
2022-08-18 06:21:44 +00:00
|
|
|
|
2022-09-11 06:30:20 +00:00
|
|
|
import com.dbnt.faisp.menuMgt.service.MenuMgtService;
|
|
|
|
|
import com.dbnt.faisp.organMgt.service.OrganConfigService;
|
2022-08-23 02:34:25 +00:00
|
|
|
import com.dbnt.faisp.userInfo.model.UserInfo;
|
2022-09-11 06:30:20 +00:00
|
|
|
import com.dbnt.faisp.codeMgt.service.CodeMgtService;
|
2022-08-29 04:04:40 +00:00
|
|
|
|
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-09-01 09:38:16 +00:00
|
|
|
private final OrganConfigService organConfigService;
|
|
|
|
|
private final MenuMgtService menuMgtService;
|
2022-08-18 06:21:44 +00:00
|
|
|
|
|
|
|
|
@GetMapping("/")
|
2022-09-20 00:53:57 +00:00
|
|
|
public ModelAndView loginCheck(@AuthenticationPrincipal UserInfo loginUser) {
|
2022-08-18 06:21:44 +00:00
|
|
|
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{
|
2022-08-19 05:30:04 +00:00
|
|
|
mav = new ModelAndView("redirect:/dashboard");
|
2022-08-18 06:21:44 +00:00
|
|
|
}
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-18 09:12:57 +00:00
|
|
|
@GetMapping("/login")
|
2022-08-29 04:08:30 +00:00
|
|
|
public ModelAndView goLogin() {
|
2022-08-18 09:12:57 +00:00
|
|
|
ModelAndView mav = new ModelAndView("/login/login");
|
2022-08-29 04:16:37 +00:00
|
|
|
mav.addObject("OgList", codeMgtService.selectCodeMgtList("OG"));
|
|
|
|
|
mav.addObject("OfcList", codeMgtService.selectCodeMgtList("OFC"));
|
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-29 04:16:37 +00:00
|
|
|
mav.addObject("OgList", codeMgtService.selectCodeMgtList("OG"));
|
|
|
|
|
mav.addObject("OfcList", codeMgtService.selectCodeMgtList("OFC"));
|
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-09-20 00:53:57 +00:00
|
|
|
|
|
|
|
|
public void setSession(@AuthenticationPrincipal UserInfo loginUser, HttpSession session){
|
|
|
|
|
loginUser.setOrganCdList(organConfigService.selectOrganListWhereUserOgCd(loginUser.getOgCd()));
|
|
|
|
|
session.setAttribute("menuList", menuMgtService.selectAccessMenuListWhereUserSeq(loginUser.getUserSeq()));
|
|
|
|
|
session.setAttribute("commonCode", codeMgtService.getCommonCode());
|
|
|
|
|
}
|
2022-08-18 06:21:44 +00:00
|
|
|
}
|