123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package com.lemon.lifecenter.common;
- import java.util.HashMap;
- import javax.servlet.http.HttpServletRequest;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.context.request.RequestContextHolder;
- import org.springframework.web.context.request.ServletRequestAttributes;
- import org.springframework.web.servlet.ModelAndView;
- import com.lemon.lifecenter.dto.RoleDTO;
- import com.lemon.lifecenter.service.RoleService;
- public class LifeCenterController {
- @Autowired
- private RoleService roleService;
-
- public ModelAndView setMV(String viewPath) {
- HashMap<String, String> hashMap = new HashMap<String, String>();
- HashMap<String, String> roleMap = new HashMap<String, String>();
- HttpServletRequest request = getRequest();
- ModelAndView mv = new ModelAndView();
- String url = request.getRequestURI().toString();
- String[] split = url.split("/");
- String pathType = "";
- String pathType2 = "";
- if (split.length > 0) {
- pathType = split[1].toLowerCase();
- }
-
- if (split.length > 1) {
- pathType2 = split[2].toLowerCase();
- }
- hashMap.put("_TITLE", "생활치료센터 의료진 시스템");
- hashMap.put("_INCLUDE", "/WEB-INF/jsp/include");
- hashMap.put("_MENUPATH", pathType);
- hashMap.put("_MENUPATH2", pathType2);
-
- try {
- String sesId = LifeCenterSessionController.getSession( request, "sesId" );
- String sesName = LifeCenterSessionController.getSession( request, "sesName" );
- String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
- String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" );
- String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
- hashMap.put( "_SES_ID", sesId );
- hashMap.put( "_SES_NAME", sesName );
- hashMap.put( "_SES_CENTER_CODE", sesCenterCode );
- hashMap.put( "_SES_CENTER_NAME", sesCenterName );
- hashMap.put( "_SES_GROUP_IDX", sesGroupIdx );
-
- } catch (NullPointerException e) {
- e.printStackTrace();
-
- } catch (Exception e) {
- e.printStackTrace();
-
- }
-
- /*
- * 현재 메뉴에대한 권한 (C, R, U, D) 리턴 -> View 페이지에서 CRUD 권한에 따른 각각의 버튼 show, hide 제어 하기 위함
- */
- RoleDTO roleDTO = new RoleDTO();
- roleDTO.setMenuPath( url );
- int roleCount = roleService.selectNowPathRoleCheckTotal( roleDTO );
-
- // roleCount가 0인경우는 권한체크하지않음 권한체크가 필요한 경로는 sys_menu_list에 등록 필수
- if( roleCount > 0 ) {
- String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
- roleDTO.setGroupIdx( Integer.valueOf( sesGroupIdx.toString() ) );
- roleDTO = roleService.selectNowPathRoleCheckData( roleDTO );
-
- roleMap.put( "_CREATE", roleDTO.getCreateYn() );
- roleMap.put( "_READ", roleDTO.getReadYn() );
- roleMap.put( "_UPDATE", roleDTO.getUpdateYn() );
- roleMap.put( "_DELETE", roleDTO.getDeleteYn() );
- }
-
- mv.addObject( "role", roleMap );
- mv.addObject( "data", hashMap );
- mv.setViewName( viewPath );
- return mv;
- }
-
- public ModelAndView setMobileMV(String viewPath) {
- HashMap<String, String> hashMap = new HashMap<String, String>();
- HttpServletRequest request = getRequest();
- ModelAndView mv = new ModelAndView();
- String url = request.getRequestURI().toString();
- String[] split = url.split("/");
- String pathType = "";
- String deviceType = "";
- if (split.length > 0) {
- deviceType = split[1].toLowerCase();
- if (split.length > 1) {
- pathType = split[2].toLowerCase();
- }
-
- }
- hashMap.put("_TITLE", "생활치료센터");
- hashMap.put("_INCLUDE", "/WEB-INF/jsp/" + deviceType + "/include");
- hashMap.put("_MENUPATH", pathType);
- // try {
- // String sesId = LifeCenterSessionController.getSession( request, "sesId" );
- // String sesName = LifeCenterSessionController.getSession( request, "sesName" );
- // String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" );
- // String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
- //
- // hashMap.put( "_SES_ID", sesId );
- // hashMap.put( "_SES_NAME", sesName );
- // hashMap.put( "_SES_CENTER_CODE", sesCenterCode );
- // hashMap.put( "_SES_GROUP_IDX", sesGroupIdx );
- //
- // } catch (NullPointerException e) {
- // e.printStackTrace();
- //
- // } catch (Exception e) {
- // e.printStackTrace();
- //
- // }
- //
- mv.addObject( "data", hashMap );
- mv.setViewName( deviceType + "/" + viewPath );
- return mv;
- }
- public HttpServletRequest getRequest() {
- ServletRequestAttributes servletRequestAttribute = (ServletRequestAttributes) RequestContextHolder
- .currentRequestAttributes();
- return servletRequestAttribute.getRequest();
- }
- }
|