Переглянути джерело

의료진 관리, 공통함수수정

huiwon.seo 4 роки тому
батько
коміт
6625dec19b

+ 9 - 1
src/main/java/com/lemon/lifecenter/controller/PatientController.java

@@ -106,9 +106,17 @@ public class PatientController extends LifeCenterController {
         CenterInfoDTO dto = new CenterInfoDTO();
         dto.setCenterCode( Integer.valueOf( sesCenterCode ) );
         
-        String centerName = centerService.selectCenterInfo( dto ).getCenterName();
+        int centerCount   = centerService.selectCenterCount( dto );
         
+        String centerName = "";
+        
+        if( centerCount > 0 ) {
+            centerName = centerService.selectCenterInfo( dto ).getCenterName();
+        }
+        
+        System.out.println("centerCount : " + centerCount );
         mv.addObject( "centerName", centerName );
+        mv.addObject( "centerCount", centerCount );
         
         return mv;
     }

+ 45 - 14
src/main/java/com/lemon/lifecenter/controller/StaffController.java

@@ -20,10 +20,10 @@ import com.lemon.lifecenter.common.LifeCenterController;
 import com.lemon.lifecenter.common.LifeCenterFunction;
 import com.lemon.lifecenter.common.LifeCenterPaging;
 import com.lemon.lifecenter.dto.CenterInfoDTO;
-import com.lemon.lifecenter.dto.LocationDTO;
+import com.lemon.lifecenter.dto.GroupListDTO;
 import com.lemon.lifecenter.dto.LoginDTO;
 import com.lemon.lifecenter.dto.StaffDTO;
-import com.lemon.lifecenter.service.CenterService;
+import com.lemon.lifecenter.service.GroupListService;
 import com.lemon.lifecenter.service.LoginService;
 import com.lemon.lifecenter.service.StaffService;
 
@@ -32,38 +32,69 @@ import com.lemon.lifecenter.service.StaffService;
 @RequestMapping("/staff")
 public class StaffController extends LifeCenterController {
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    private LifeCenterPaging paging;
     
     @Autowired
     private LoginService loginService;
+    
     @Autowired
     private StaffService memberService;
+    
     @Autowired
     private LifeCenterConfigVO config;
-    private LifeCenterPaging paging;
+    
+    @Autowired
+    private GroupListService groupListService;
     
     @RequestMapping("/new")
-    public ModelAndView staffNew() {
-        
+    public ModelAndView staffNew() throws Exception {
         List<CenterInfoDTO> centerList = memberService.selectCenterList();
         
         ModelAndView mv = setMV("staff/new");
-        mv.addObject("centerList", centerList);
+        
+        GroupListDTO dto = new GroupListDTO();
+        List<GroupListDTO> groupList = groupListService.selectGroupList(dto);
+        
+        for( GroupListDTO data : groupList ) {
+//            data.setPermissions( LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, data.getPermissions() ) );
+            data.setEncryptIdx( LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, String.valueOf( data.getIdx() ) ) );
+        }
+        
+        
+        mv.addObject( "centerList", centerList );
+        mv.addObject( "groupList", groupList );
+        
         return mv;
     }
     
-    @RequestMapping("/newRegist")
+    @RequestMapping("/new/regist")
     public String staffNewRegist(
             @ModelAttribute("dto") final StaffDTO dto,
-            @RequestParam(value="centerCode", required=true) String centerCode,
-            @RequestParam(value="passwordConfirm", required=true) String passwordConfirm) throws Exception {
+            @RequestParam(value="encryptIdx", required=true) String encryptIdx,
+            @RequestParam(value="passwordConfirm", required=true) String passwordConfirm ) throws Exception {
+        
+        // 의료진 관리 -> 의료진 신규등록 컨트롤러
+        // 의료진 신규등록시 -> 계정 권한은 일반사용자 권한으로 생성? -> 관리자로도 생성?
+        // 센터하나당 관리자 권한 계정은 1개임 (시스템관리자가 센터생성할때 관리자 계정 1개 발급)
+//        System.out.println( "permissions : " + permissions );
+//        System.out.println( "permissions : " + LifeCenterFunction.aesDecrypt( config.aesKey, config.IV, permissions ) );
+        System.out.println( "encIdx : " + encryptIdx );
+        
+        String decryptIdx = LifeCenterFunction.aesDecrypt( config.aesKey, config.IV, encryptIdx );
+        
+        // password 일치확인
+        String password = dto.getPassword();
+        
+        if( !password.equals( passwordConfirm ) ) {
+            // redirect page back
+        }
         
-        String pw = dto.getPassword();
-        dto.setPassword(LifeCenterFunction.aesEncrypt(config.aesKey, config.IV, pw));
-        dto.setGroupIdx("3");
+        dto.setGroupIdx( Integer.valueOf( decryptIdx ) );
+        dto.setPassword( LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, password ) );
         
-        memberService.insertStaff(dto);
+        memberService.insertStaff( dto );
         
-        return "redirect:./info?staffId=" + dto.getId();
+        return "redirect:../info?staffId=" + dto.getId();
     }
     
     @RequestMapping("/info")

+ 3 - 3
src/main/java/com/lemon/lifecenter/dto/StaffDTO.java

@@ -11,7 +11,7 @@ public class StaffDTO {
     private String lastLoginTime = "";
     private int failCount = 0;
     private String useYn = "";
-    private String groupIdx = "";
+    private int groupIdx = 0;
     private int centerCode = 0;
     private String updateById = "";
     private String centerName = "";
@@ -79,10 +79,10 @@ public class StaffDTO {
     public void setUseYn(String useYn) {
         this.useYn = useYn;
     }
-    public String getGroupIdx() {
+    public int getGroupIdx() {
         return groupIdx;
     }
-    public void setGroupIdx(String groupIdx) {
+    public void setGroupIdx(int groupIdx) {
         this.groupIdx = groupIdx;
     }
     public int getCenterCode() {

+ 2 - 2
src/main/resources/mybatis/mapper/staff/staff.xml

@@ -115,8 +115,8 @@
         </selectKey>
         <![CDATA[
             INSERT INTO MEMBER
-                        (ID,    PASSWORD,    CREATE_DATE,   NAME,    PHONE_NUMBER,   USE_YN,   CENTER_CODE)
-                  VALUE (#{id}, #{password}, NOW(),         #{name}, #{phoneNumber}, #{useYn}, #{centerCode})
+                        (ID,    PASSWORD,    CREATE_DATE,   NAME,    PHONE_NUMBER,   USE_YN,   GROUP_IDX,   CENTER_CODE)
+                  VALUE (#{id}, #{password}, NOW(),         #{name}, #{phoneNumber}, #{useYn}, #{groupIdx}, #{centerCode})
         ]]>
     </insert>
     

+ 36 - 2
src/main/webapp/WEB-INF/jsp/login/staff.jsp

@@ -29,6 +29,10 @@
 </script>
 <script type="text/javascript">
 $( function(){
+    setCookieCheck();
+    
+    $( "#id" ).focus();
+    
     $( "#loginForm" ).validate({
         onfocusout: function (element) {
             $( element ).valid();
@@ -68,11 +72,41 @@ $( function(){
                     $( "#submitBtn" ).toggleClass( "d-none", false );
                 }
             }).done( function(){
-                
+                if( $( "#saveId" ).is( ":checked" ) ) {
+                    setCookie( "userInputId", $( "#id" ).val(), 365 );
+                } else {
+                    deleteCookie( "userInputId" );
+                }
             });
         }
     });
 });
+
+function setCookieCheck() {
+    var cookieId   = $.trim( getCookie( "userInputId" ) );
+    var cookieSave = $.trim( getCookie( "saveIdChecked" ) );
+    
+    if( cookieId != "" ) { 
+        $( "#id" ).val( cookieId );
+    }
+    
+    if( cookieSave != "" ){
+        cookieSave = ( cookieSave === 'true' );
+        $( "#saveId" ).prop( "checked", cookieSave );
+    }
+    
+    $( "#saveId" ).on( "change", function(){
+        var $this = $( this );
+        
+        console.log( $this );
+        console.log( $this.is( ":checked" ) );
+        
+        if( $this.is( ":checked" ) === false ) {
+            deleteCookie( "userInputId" );
+        }
+        setCookie( "saveIdChecked", $this.is( ":checked" ), 365 );
+    });
+};
 </script>
 </head>
 <body>
@@ -100,7 +134,7 @@ $( function(){
                                         </div>
                                         <div class="form-group">
                                             <label>비밀번호</label>
-                                            <input id="password" class="form-control form-control-lg" type="password" name="password" placeholder="비밀번호" autocomplete="off" tabindex="2" maxlength="20" required>
+                                            <input id="password" class="form-control form-control-lg" type="password" name="password" placeholder="비밀번호" autocomplete="off" tabindex="2" maxlength="15" required>
                                         </div>
                                         <div>
                                             <div class="custom-control custom-checkbox align-items-center text-right">

+ 15 - 8
src/main/webapp/WEB-INF/jsp/staff/new.jsp

@@ -32,7 +32,10 @@ $( function(){
             password : {
                 minlength : 8,
                 maxlength : 15,
-                passwordValid : true
+                passwordValid : true,
+            },
+            passwordConfirm : {
+                equalTo: "#password",
             }
         },
         messages : {
@@ -42,6 +45,9 @@ $( function(){
             password : {
                 minlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)",
                 maxlength : "비밀번호를 확인하세요 (영문, 숫자, 특수문자를 혼합하여 8 ~ 15자 이내)"
+            },
+            passwordConfirm : {
+                equalTo: "비밀번호가 일치하지 않습니다.",
             }
         },
         onkeyup: function( element, event ) {
@@ -87,7 +93,7 @@ $( function(){
                     <div class="row">
                         <div class="col-12">
                             <div class="card">
-                                <form action="./newRegist" method="post" id="newForm">
+                                <form action="./new/regist" method="post" id="newForm">
                                     <div class="card-body">
                                         <table class="table mobile-table">
                                             <colgroup>
@@ -110,19 +116,19 @@ $( function(){
                                             <tr>
                                                 <th><span class="fix">*</span>비밀번호</th>
                                                 <td colspan="3">
-                                                    <input type="password" class="form-control" name="password" required>
+                                                    <input type="password" id="password" class="form-control pass-group" name="password" placeholder="숫자, 영문, 특수문자 조합 8~15자 이내" required>
                                                 </td>
                                             </tr>
                                             <tr>
                                                 <th><span class="fix">*</span>비밀번호 확인</th>
                                                 <td colspan="3">
-                                                    <input type="password" class="form-control" name="passwordConfirm" required>
+                                                    <input type="password" id="passwordConfirm" class="form-control" name="passwordConfirm" placeholder="비밀번호 확인을 위해 비밀번호를 한번 더 입력하세요." required>
                                                 </td>
                                             </tr>
                                             <tr>
                                                 <th><span class="fix">*</span>휴대폰번호</th>
                                                 <td>
-                                                    <input type="text" class="form-control" name="phoneNumber" placeholder="01012341234" required>
+                                                    <input type="text" class="form-control" name="phoneNumber" placeholder="'-'를 제외한 숫자만 입력하세요" required>
                                                 </td>
                                                 <th>치료센터</th>
                                                 <td>
@@ -138,9 +144,10 @@ $( function(){
                                             <tr>
                                                 <th><span class="fix">*</span>권한</th>
                                                 <td>
-                                                    <select class="custom-select" name="groupIdx">
-                                                        <option selected="">센터-1</option>
-                                                        <option selected="">센터-2</option>
+                                                    <select class="custom-select" name="encryptIdx">
+                                                        <c:forEach var="gl" items="${groupList}"> 
+                                                            <option value="${gl.encryptIdx}"><c:out value="${gl.groupName}"/></option>
+                                                        </c:forEach>
                                                     </select>
                                                 </td>
                                                 <th><span class="fix">*</span>상태</th>

+ 26 - 0
src/main/webapp/resources/js/common/common.js

@@ -93,4 +93,30 @@ function juso() {
             
         }
     }).open();
+}
+function setCookie(cookieName, value, exdays){
+    var exdate = new Date();
+    exdate.setDate(exdate.getDate() + exdays);
+    var cookieValue = escape(value) + ((exdays==null) ? "" : "; expires=" + exdate.toGMTString());
+    document.cookie = cookieName + "=" + cookieValue;
+}
+ 
+function deleteCookie(cookieName){
+    var expireDate = new Date();
+    expireDate.setDate(expireDate.getDate() - 1);
+    document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString();
+}
+ 
+function getCookie(cookieName) {
+    cookieName = cookieName + '=';
+    var cookieData = document.cookie;
+    var start = cookieData.indexOf(cookieName);
+    var cookieValue = '';
+    if(start != -1){
+        start += cookieName.length;
+        var end = cookieData.indexOf(';', start);
+        if(end == -1)end = cookieData.length;
+        cookieValue = cookieData.substring(start, end);
+    }
+    return unescape(cookieValue);
 }