Просмотр исходного кода

환자관리 입소일자 검색 로직 수정, 의료진 삭제 기능 추가

huiwon.seo 4 лет назад
Родитель
Сommit
6fde308719

+ 33 - 2
src/main/java/com/lemon/lifecenter/controller/StaffController.java

@@ -11,6 +11,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -26,6 +28,7 @@ import com.lemon.lifecenter.common.LifeCenterSessionController;
 import com.lemon.lifecenter.dto.CenterInfoDTO;
 import com.lemon.lifecenter.dto.GroupListDTO;
 import com.lemon.lifecenter.dto.LoginDTO;
+import com.lemon.lifecenter.dto.PatientDTO;
 import com.lemon.lifecenter.dto.StaffDTO;
 import com.lemon.lifecenter.service.CenterService;
 import com.lemon.lifecenter.service.GroupListService;
@@ -132,7 +135,7 @@ public class StaffController extends LifeCenterController {
     @RequestMapping("/info")
     public ModelAndView staffInfo(
             HttpServletRequest request,HttpServletResponse response,
-            @RequestParam(value="staffId", required=false, defaultValue="") String staffID) {
+            @RequestParam(value="staffId", required=false, defaultValue="") String staffID) throws Exception {
         String sesId  = LifeCenterSessionController.getSession( request, "sesId" );
         
         
@@ -143,9 +146,12 @@ public class StaffController extends LifeCenterController {
         
         dto.setPhoneNumber( LifeCenterFunction.phone( dto.getPhoneNumber() ) );
         
+        String enMemberId = LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, staffID );
+        
         ModelAndView mv = setMV("staff/info");
-        mv.addObject("info", dto);
+        mv.addObject( "info", dto );
         mv.addObject( "sesId", sesId );
+        mv.addObject( "enMemberId", enMemberId );
         
         return mv;
     }
@@ -343,4 +349,29 @@ public class StaffController extends LifeCenterController {
         
         return result;
     }
+    
+    @RequestMapping("/delete")
+    @Transactional(propagation=Propagation.REQUIRED)
+    public String memberDelete( @RequestParam( value="enMemberId", required = true ) String enMemberId,
+            HttpServletRequest request,HttpServletResponse response ) throws Exception {
+        String memberId = LifeCenterFunction.aesDecrypt( config.aesKey, config.IV, enMemberId );
+        
+        StaffDTO dto = new StaffDTO();
+        dto.setId( memberId );
+        
+        LoginDTO loginDTO = new LoginDTO();
+        loginDTO.setId( memberId );
+        
+        int total = loginService.selectMemberIdCount( loginDTO );
+        
+        if( total == 0 ) {
+            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '이미 삭제되었거나 존재하지않는 사용자입니다.', callBack : function(){ history.back(); } });" );
+            return "/common/blank";
+        } else {
+            memberService.deleteMember(dto);
+        }
+        
+        LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '사용자가 삭제되었습니다. ', callBack : function(){ location.href='./list'; } });" );
+        return "/common/blank";
+    }
 }

+ 1 - 0
src/main/java/com/lemon/lifecenter/mapper/StaffMapper.java

@@ -21,4 +21,5 @@ public interface StaffMapper {
     public void insertStaff(StaffDTO dto);
     public Integer updateMemberPwReset(StaffDTO dto);
     public Integer updateEditMember(StaffDTO dto);
+    public void deleteMember(StaffDTO dto);
 }

+ 3 - 0
src/main/java/com/lemon/lifecenter/service/StaffService.java

@@ -53,4 +53,7 @@ public class StaffService {
     public Integer updateEditMember(StaffDTO dto) {
         return mapper.updateEditMember(dto);
     }
+    public void deleteMember( StaffDTO dto ) {
+        mapper.deleteMember(dto);
+    }
 }

+ 40 - 8
src/main/resources/mybatis/mapper/patient/patient.xml

@@ -23,11 +23,28 @@
                AND PATIENT_NAME LIKE CONCAT('%', #{patientName}, '%')
             ]]>
         </if>
-        <if test='startDate != null and startDate != "" and endDate != null and endDate != ""'>
+<!--         <if test='startDate != null and startDate != "" and endDate != null and endDate != ""'> -->
             <![CDATA[
-               AND DATE_FORMAT(HOSPITALIZATION_DATE, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+               AND DATE_FORMAT(HOSPITALIZATION_DATE, '%Y-%m-%d') BETWEEN 
             ]]>
-        </if>
+            
+            <choose>
+                <when test='startDate != null and startDate != ""'>#{startDate}</when>
+                <when test='startDate != null and startDate == ""'>'1900-01-01'</when>
+                <otherwise>'1900-01-01'</otherwise>
+            </choose>
+            
+            <![CDATA[
+               AND 
+               ]]>
+               
+            <choose>
+                <when test='endDate != null and endDate != ""'>#{endDate}</when>
+                <when test='endDate != null and endDate == ""'>DATE_FORMAT( NOW(), '%Y-%m-%d' )</when>
+                <otherwise>DATE_FORMAT( NOW(), '%Y-%m-%d' )</otherwise>
+            </choose>
+               
+<!--         </if> -->
     </select>
     
     <select id="selectPatientList" parameterType="PatientDTO" resultType="PatientDTO">
@@ -72,11 +89,26 @@
             AND PATIENT_NAME LIKE CONCAT('%', #{patientName}, '%')
         ]]>
     </if>
-    <if test='startDate != null and startDate != "" and endDate != null and endDate != ""'>
-        <![CDATA[
-            AND DATE_FORMAT(HOSPITALIZATION_DATE, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
-        ]]>
-    </if>
+            <![CDATA[
+               AND DATE_FORMAT(HOSPITALIZATION_DATE, '%Y-%m-%d') BETWEEN 
+            ]]>
+            
+            <choose>
+                <when test='startDate != null and startDate != ""'>#{startDate}</when>
+                <when test='startDate != null and startDate == ""'>'1900-01-01'</when>
+                <otherwise>'1900-01-01'</otherwise>
+            </choose>
+            
+            <![CDATA[
+               AND 
+            ]]>
+               
+            <choose>
+                <when test='endDate != null and endDate != ""'>#{endDate}</when>
+                <when test='endDate != null and endDate == ""'>DATE_FORMAT( NOW(), '%Y-%m-%d' )</when>
+                <otherwise>DATE_FORMAT( NOW(), '%Y-%m-%d' )</otherwise>
+            </choose>
+            
         <![CDATA[
              ORDER BY 
         ]]>

+ 10 - 0
src/main/resources/mybatis/mapper/staff/staff.xml

@@ -226,4 +226,14 @@
              WHERE 1 = 1
         ]]>
     </select>
+    
+    
+    <!-- member 삭제 / 생치 관리자만 삭제가능 -->
+    <delete id="deleteMember" parameterType="StaffDTO">
+        <![CDATA[
+            DELETE 
+              FROM member
+             WHERE id = #{id}
+        ]]>
+    </delete>
 </mapper>

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

@@ -7,7 +7,7 @@
 <script type="text/javascript">
 function deleteConfirm(){
     alertBox({ type : "confirm", 
-               txt : "정말로 삭제할까요?", 
+               txt : "정말로 삭제할까요? (기록된 환자의 모든정보가 삭제되며 복구가 불가능합니다)", 
                callBack : function( result ){
             	   console.log( result );
                    if( result ){

+ 86 - 16
src/main/webapp/WEB-INF/jsp/patient/list.jsp

@@ -8,29 +8,99 @@
 var startDate = "<c:out value='${startDate}'/>";
 var endDate   = "<c:out value='${endDate}'/>";
 
-    $(function() {
-        $("input[name=\"startDate\"]").daterangepicker({
+$(function() {
+    $("input.date-no-req").daterangepicker({
+        singleDatePicker : true,
+        showDropdowns : true,
+        locale : {
+            format : "YYYY-MM-DD"
+        },
+        autoUpdateInput: false,
+        maxDate : new Date()
+    }).on('apply.daterangepicker', function(ev, picker) {
+        $(this).val(picker.startDate.format('YYYY-MM-DD'));
+        
+        $(this).trigger( "change" );
+    }).on( "change", function(){
+        if( $( this ).val() > getNowYmd() ) {
+            $( this ).val( getNowYmd() );
+        }
+    });
+    
+    
+//     $("input[name='endDate']").daterangepicker({
+//      singleDatePicker : true,
+//         showDropdowns : true,
+//         locale : {
+//             format : "YYYY-MM-DD"
+//         },
+//         autoUpdateInput: false,
+//         maxDate : new Date()
+//     }).on('apply.daterangepicker', function(ev, picker) {
+        
+//         $(this).val(picker.startDate.format('YYYY-MM-DD'));
+//         $(this).trigger( "change" );
+//     });
+    
+    $("input.date-no-req").on( "change", function(){
+        console.log( $( this ).val() );
+        
+        $("input[name='startDate']").daterangepicker({
             singleDatePicker : true,
             showDropdowns : true,
-//             startDate : "<c:out value='${startDate}'/>",
             locale : {
-                //format : "M/DD hh:mm A"
                 format : "YYYY-MM-DD"
-            }
+            },
+            autoUpdateInput: false,
+            maxDate : $("input[name='endDate']").val()
+        }).on('apply.daterangepicker', function(ev, picker) {
+            $(this).val(picker.startDate.format('YYYY-MM-DD'));
+            $(this).trigger( "change" );
         });
-        $("input[name=\"endDate\"]").daterangepicker({
-            singleDatePicker : true,
-            showDropdowns : true,
-//             startDate : "<c:out value='${endDate}'/>",
-            locale : {
-                //format : "M/DD hh:mm A"
-                format : "YYYY-MM-DD"
+        
+        if( $("input[name='endDate']").val() != "" ){
+            if( $("input[name='startDate']").val() > $("input[name='endDate']").val() ) {
+                $("input[name='startDate']").val( $( this ).val() );
             }
-        });
+        }
         
-        $("input[name=\"startDate\"]").val( startDate );
-        $("input[name=\"endDate\"]").val( endDate );
+        if( $("input[name='endDate']").val() != "" ){
+            if( $("input[name='startDate']").val() > $("input[name='endDate']").val() ) {
+                $("input[name='startDate']").val( $("input[name='endDate']").val() );
+            }
+        }
+    });
+    
+    
+    $( "#searchForm" ).validate({
+        rules: {
+            startDate : {
+                date : true
+            },
+            endDate : {
+                date : true
+            }
+        },
+        onkeyup: function( element, event ) {
+            $( element ).valid();
+        },
+        onfocusout: function (element) {
+            $( element ).val( $.trim( $( element ).val() ) );
+            $( element ).valid();
+        },
+        submitHandler: function(form) {
+            form.submit();
+        }
     });
+    
+    if( startDate != "" ){
+        $("input[name='startDate']").val( startDate );
+    }
+    
+    if( endDate != "" ){
+        $("input[name='endDate']").val( endDate );
+    }
+});
 </script>
 </head>
 <body>
@@ -60,7 +130,7 @@ var endDate   = "<c:out value='${endDate}'/>";
                     <div class="row">
                         <div class="col-12">
                             <div class="card">
-                                <form action="?" method="get">
+                                <form action="?" method="get" id="searchForm">
                                     <div class="card-body">
                                         <table class="table mobile-table">
                                             <colgroup>

+ 99 - 79
src/main/webapp/WEB-INF/jsp/staff/info.jsp

@@ -20,7 +20,18 @@ function reset() {
         });
     }
 }
-
+function deleteConfirm(){
+    alertBox({ type : "confirm", 
+               txt : "정말로 삭제할까요? (해당사용자의 모든정보가 삭제되며 복구가 불가능합니다)", 
+               callBack : function( result ){
+                   if( result ){
+                       $( "#mForm" ).attr( "action", "./delete" );
+                       $( "#mForm" ).submit();
+                   }
+               }
+    });
+    return false;
+}
 </script>
 </head>
 <body>
@@ -73,87 +84,96 @@ function reset() {
                                             </div>
                                         </div>
                                     </div>
-                                    <table class="table mobile-table">
-                                        <colgroup>
-                                            <col style="width:15%">
-                                            <col style="width:35%">
-                                            <col style="width:15%">
-                                            <col style="width:35%">
-                                        </colgroup>
-                                        <tr>
-                                            <th>아이디</th>
-                                            <td>
-                                                <c:out value="${info.id}" />
-                                                <input type="hidden" id="staffId" name="staffId" value="<c:out value="${info.id}" />">
-                                            </td>
-                                            <th>이름</th>
-                                            <td>
-                                                <c:out value="${info.name}" />
-                                            </td>
-                                        </tr>
-                                        <tr>
-                                            <th>휴대폰번호</th>
-                                            <td>
-                                                <c:out value="${info.phoneNumber}" />
-                                            </td>
-                                            <th>치료센터</th>
-                                            <td>
-                                                <c:out value="${info.centerName}" />
-                                            </td>
-                                        </tr>
-                                        <tr>
-                                            <th>권한</th>
-                                            <td>
-                                                <c:if test="${info.groupIdx eq 1}">시스템관리자</c:if>
-                                                <c:if test="${info.groupIdx eq 2}">관리자</c:if>
-                                                <c:if test="${info.groupIdx eq 3}">일반사용자</c:if>
-                                            </td>
-                                            <th>상태</th>
-                                            <td>
-                                                <c:choose>
-                                                    <c:when test="${info.useYn == 'Y'}">
-                                                        활성
-                                                    </c:when>
-                                                    <c:otherwise>
-                                                        비활성
-                                                    </c:otherwise>
-                                                
-                                                </c:choose>
-                                            </td>
-                                        </tr>
-                                        <tr>
-                                            <th>최종접속일시</th>
-                                            <td>
-                                                <c:out value="${info.lastLoginTime}" />
-                                            </td>
-                                            <th>등록일시</th>
-                                            <td>
-                                                <c:out value="${info.createDate}" />
-                                            </td>
-                                        </tr>
-                                        <tr>
-                                            <th>변경일시</th>
-                                            <td>
-                                                <c:out value="${info.updateDate}" />
-                                            </td>
-                                            <th>처리자</th>
-                                            <td>
-                                                <c:out value="${info.updateById}" />
-                                            </td>
-                                        </tr>
-                                    </table>
-                                    <div class="row mt-3">
-                                        <div class="col-12">
-                                            <div class="text-right">
-                                                <c:if test="${info.id ne sesId}">
-                                                    <c:if test="${data._SES_GROUP_IDX ne '1'}">
-                                                        <button class="btn btn-warning w150" onclick="reset();">비밀번호 초기화</button>
+                                    
+                                    <form method="post" id="mForm">
+                                        <input type="hidden" name="enMemberId" value="<c:out value="${enMemberId}" />">
+                                        
+                                        <table class="table mobile-table">
+                                            <colgroup>
+                                                <col style="width:15%">
+                                                <col style="width:35%">
+                                                <col style="width:15%">
+                                                <col style="width:35%">
+                                            </colgroup>
+                                            <tr>
+                                                <th>아이디</th>
+                                                <td>
+                                                    <c:out value="${info.id}" />
+                                                    <input type="hidden" id="staffId" name="staffId" value="<c:out value="${info.id}" />">
+                                                </td>
+                                                <th>이름</th>
+                                                <td>
+                                                    <c:out value="${info.name}" />
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <th>휴대폰번호</th>
+                                                <td>
+                                                    <c:out value="${info.phoneNumber}" />
+                                                </td>
+                                                <th>치료센터</th>
+                                                <td>
+                                                    <c:out value="${info.centerName}" />
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <th>권한</th>
+                                                <td>
+                                                    <c:if test="${info.groupIdx eq 1}">시스템관리자</c:if>
+                                                    <c:if test="${info.groupIdx eq 2}">관리자</c:if>
+                                                    <c:if test="${info.groupIdx eq 3}">일반사용자</c:if>
+                                                </td>
+                                                <th>상태</th>
+                                                <td>
+                                                    <c:choose>
+                                                        <c:when test="${info.useYn == 'Y'}">
+                                                            활성
+                                                        </c:when>
+                                                        <c:otherwise>
+                                                            비활성
+                                                        </c:otherwise>
+                                                    
+                                                    </c:choose>
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <th>최종접속일시</th>
+                                                <td>
+                                                    <c:out value="${info.lastLoginTime}" />
+                                                </td>
+                                                <th>등록일시</th>
+                                                <td>
+                                                    <c:out value="${info.createDate}" />
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <th>변경일시</th>
+                                                <td>
+                                                    <c:out value="${info.updateDate}" />
+                                                </td>
+                                                <th>처리자</th>
+                                                <td>
+                                                    <c:out value="${info.updateById}" />
+                                                </td>
+                                            </tr>
+                                        </table>
+                                        <div class="row mt-3">
+                                            <div class="col-12">
+                                                <div class="text-right">
+                                                    <c:if test="${info.id ne sesId}">
+                                                        <c:if test="${data._SES_GROUP_IDX eq '2'}">
+                                                            <button type="button" class="btn btn-danger w100" onclick="deleteConfirm();">삭제</button>
+                                                        </c:if>
+                                                    
+                                                        <c:if test="${data._SES_GROUP_IDX ne '1'}">
+                                                            <button class="btn btn-warning w150" onclick="reset();">비밀번호 초기화</button>
+                                                        </c:if>
                                                     </c:if>
-                                                </c:if>
-                                                <button class="btn btn-primary w100" onclick="location.href='./list';">확인</button>
+                                                    <button class="btn btn-primary w100" onclick="location.href='./list';">확인</button>
+                                                </div>
                                             </div>
                                         </div>
-                                    </div>
+                                    </form>
                                 </div>
                             </div>
                         </div>