2022-09-11 06:30:20 +00:00
|
|
|
package com.dbnt.faisp.config;
|
2022-08-18 06:21:44 +00:00
|
|
|
|
2022-11-22 09:48:10 +00:00
|
|
|
import com.dbnt.faisp.main.codeMgt.model.CodeMgt;
|
2022-10-27 00:02:05 +00:00
|
|
|
import com.dbnt.faisp.main.menuMgt.service.MenuMgtService;
|
|
|
|
|
import com.dbnt.faisp.main.organMgt.service.OrganConfigService;
|
|
|
|
|
import com.dbnt.faisp.main.userInfo.model.UserInfo;
|
|
|
|
|
import com.dbnt.faisp.main.codeMgt.service.CodeMgtService;
|
2022-08-29 04:04:40 +00:00
|
|
|
|
2022-10-27 00:02:05 +00:00
|
|
|
import com.dbnt.faisp.main.userInfo.service.UserInfoService;
|
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;
|
2022-11-22 09:48:10 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
2022-08-18 06:21:44 +00:00
|
|
|
|
|
|
|
|
@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-10-13 09:34:32 +00:00
|
|
|
private final UserInfoService userInfoService;
|
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-09-26 00:40:11 +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-09-26 00:40:11 +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-09-20 00:53:57 +00:00
|
|
|
|
2022-11-04 09:51:58 +00:00
|
|
|
@GetMapping("/selectBoxOptions")
|
|
|
|
|
public ModelAndView codeMgtPage(String categoryCd, String selectedCd) {
|
|
|
|
|
ModelAndView mav = new ModelAndView("common/selectBox/options");
|
2022-11-17 02:34:57 +00:00
|
|
|
mav.addObject("codeList", codeMgtService.selectCodeMgtList(categoryCd, ""));
|
2022-11-04 09:51:58 +00:00
|
|
|
mav.addObject("selectedCd", selectedCd);
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 00:53:57 +00:00
|
|
|
public void setSession(@AuthenticationPrincipal UserInfo loginUser, HttpSession session){
|
2022-09-20 05:09:20 +00:00
|
|
|
loginUser.setDownOrganCdList(organConfigService.selectDownOrganListWhereUserOgCd(loginUser.getOgCd()));
|
|
|
|
|
loginUser.setUpOrganCdList(organConfigService.selectUpOrganListWhereUserOgCd(loginUser.getOgCd()));
|
2022-09-20 00:53:57 +00:00
|
|
|
session.setAttribute("menuList", menuMgtService.selectAccessMenuListWhereUserSeq(loginUser.getUserSeq()));
|
2022-11-22 09:48:10 +00:00
|
|
|
Map<String, List<CodeMgt>> codeMap = codeMgtService.getCommonCode();
|
|
|
|
|
session.setAttribute("commonCode", codeMap);
|
|
|
|
|
String belongValue = "";
|
|
|
|
|
belongValue += searchCodeValue(loginUser.getOgCd(), codeMap.get("OG"));
|
|
|
|
|
belongValue += searchCodeValue(loginUser.getOfcCd(), codeMap.get("OFC"));
|
|
|
|
|
belongValue += searchCodeValue(loginUser.getTitleCd(), codeMap.get("JT"));
|
|
|
|
|
belongValue += loginUser.getUserNm()+"("+loginUser.getUserId()+")";
|
|
|
|
|
session.setAttribute("belongValue", belongValue);
|
|
|
|
|
}
|
|
|
|
|
private String searchCodeValue(String itemCd, List<CodeMgt> codeList){
|
|
|
|
|
if(itemCd==null){
|
|
|
|
|
return "";
|
|
|
|
|
}else{
|
|
|
|
|
for(CodeMgt code: codeList){
|
|
|
|
|
if(itemCd.equals(code.getItemCd())){
|
|
|
|
|
return code.getItemValue()+" ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
2022-09-20 00:53:57 +00:00
|
|
|
}
|
2022-08-18 06:21:44 +00:00
|
|
|
}
|