Browse Source

[databank] 권한 작업중

huiwon.seo 4 years ago
parent
commit
88bce2bbcb

+ 30 - 2
src/main/java/com/lemon/lifecenter/common/LifeCenterController.java

@@ -4,13 +4,21 @@ 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();
 
@@ -25,7 +33,7 @@ public class LifeCenterController {
         hashMap.put("_TITLE", "생활치료센터 의료진 시스템");
         hashMap.put("_INCLUDE", "/WEB-INF/jsp/include");
         hashMap.put("_MENUPATH", pathType);
-
+        
         try {
           String sesId         = LifeCenterSessionController.getSession( request, "sesId" );
           String sesName       = LifeCenterSessionController.getSession( request, "sesName" );
@@ -46,7 +54,27 @@ public class LifeCenterController {
           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 );
 

+ 2 - 4
src/main/java/com/lemon/lifecenter/common/LifeCenterInterCeptor.java

@@ -70,6 +70,7 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
                             
                             if( !url.equals( "/mobile/accept/insert" ) && !url.equals( "/mobile/login/logout" ) ) {
                                 LifeCenterFunction.scriptMessage( response, "location.href='/mobile/accept/list';" );
+                                return false;
                             }
                         } else {
 //                            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '약관 동의 후 서비스 이용이 가능합니다.', callBack : function(){  } });" );
@@ -100,8 +101,6 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
                     /* 
                      * 현재경로에대해 권한 체크
                      */
-                    
-                    /*
                     RoleDTO roleDTO = new RoleDTO();
                     roleDTO.setMenuPath( url );
                     int roleCount = roleService.selectNowPathRoleCheckTotal( roleDTO );
@@ -151,8 +150,6 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
                         }
                     }
                     
-                    */
-                    
                     
                     /* 
                      * 약관 동의 체크, 비밀번호 초기화 체크
@@ -163,6 +160,7 @@ public class LifeCenterInterCeptor extends HandlerInterceptorAdapter {
                             
                             if( !url.equals( "/accept/insert" ) && !url.equals( "/login/logout" ) ) {
                                 LifeCenterFunction.scriptMessage( response, "location.href='/accept/list';" );
+                                return false;
                             }
                         } else {
 //                            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '약관 동의 후 서비스 이용이 가능합니다.', callBack : function(){  } });" );

+ 7 - 3
src/main/webapp/WEB-INF/jsp/patient/info.jsp

@@ -92,13 +92,17 @@ function goListPage(){
                                         <div class="row mt-3">
                                             <div class="col-12">
                                                 <div class="text-right">
-                                                    <button type="button" class="btn btn-dark" data-toggle="modal" data-target="#updateCenterInfo" onclick="">생활치료센터 이관</button>
+                                                    <c:if test="${role._UPDATE eq 'Y'}">
+                                                        <button type="button" class="btn btn-dark" data-toggle="modal" data-target="#updateCenterInfo" onclick="">생활치료센터 이관</button>
+                                                    </c:if>
+                                                    
                                                     <button type="button" class="btn btn-warning w100" onclick="location.href='/clinic/info?patientIdx=${patientIdx}';">건강정보</button>
-                                                    <c:if test="${data._SES_GROUP_IDX eq '2'}">
+                                                    
+                                                    <c:if test="${role._DELETE eq 'Y'}">
                                                         <button type="button" class="btn btn-danger w100" onclick="deleteConfirm();">삭제</button>
                                                     </c:if>
                                                     
-                                                    <c:if test="${data._SES_GROUP_IDX ne '1'}">
+                                                    <c:if test="${role._UPDATE eq 'Y'}">
                                                         <button type="button" class="btn btn-secondary w100" onclick="location.href='./edit?patientIdx=${patientIdx}';">수정</button>
                                                     </c:if>
                                                     

+ 4 - 5
src/main/webapp/WEB-INF/jsp/patient/list.jsp

@@ -254,7 +254,6 @@ tr.phr-info td span.no-data{color:#999999;}
                                                                 </select>
                                                             </div>
                                                         </div>
-
                                                         <div class="col-5">
                                                             <div class="form-group mb-xl-0">
                                                                 <select class="custom-select form-control" id="sort" name="sort">
@@ -288,7 +287,7 @@ tr.phr-info td span.no-data{color:#999999;}
                                                 <button class="btn btn-success" data-toggle="modal" data-target="#excelDownMemo">Excel 다운로드</button>
                                             </c:if>
                                             <a class="btn btn-primary" target="_blank" href="/store/manual/survey">입소자 문진표 서식 다운로드</a>
-                                            <c:if test="${sesGroupIdx ne '1'}">
+                                            <c:if test="${role._CREATE eq 'Y'}">
                                                 <button class="btn btn-primary" onclick="location.href='./new';">신규환자등록</button>
                                             </c:if>
                                         </div>
@@ -299,7 +298,7 @@ tr.phr-info td span.no-data{color:#999999;}
                                                 <col style=" width: 5%; ">
                                                 <col style=" width: 7%; ">
                                                 <col style=" width: 10%; ">
-                                                <c:if test="${sesGroupIdx eq '1'}">
+                                                <c:if test="${data._SES_CENTER_CODE eq '0'}">
                                                     <col style=" width: 15%; ">
                                                 </c:if>
                                                 <col style=" width: 12%; ">
@@ -313,7 +312,7 @@ tr.phr-info td span.no-data{color:#999999;}
                                                     <th>번호</th>
                                                     <th>환자명</th>
                                                     <th>호실</th>
-                                                    <c:if test="${sesGroupIdx eq '1'}">
+                                                    <c:if test="${data._SES_CENTER_CODE eq '0'}">
                                                         <th>생활치료센터명</th>
                                                     </c:if>
                                                     <th>성별 / 나이</th>
@@ -341,7 +340,7 @@ tr.phr-info td span.no-data{color:#999999;}
                                                                     </c:if>
                                                                     <c:out value="${l.roomNumber}" />호 
                                                                 </td>
-                                                                <c:if test="${sesGroupIdx eq '1'}">
+                                                                <c:if test="${data._SES_CENTER_CODE eq '0'}">
                                                                     <td><c:out value="${l.centerName}" /></td>
                                                                 </c:if>
                                                                 <td><c:out value="${l.gender} / ${l.age}" /></td>