하관우 하관우 04-11
2025-04-11 하관우 오륲코드 수정정
@204fae3dabc2eab80c01001fe573bc00d3a75378
client/views/pages/ctgry/CategoryManagement.vue
--- client/views/pages/ctgry/CategoryManagement.vue
+++ client/views/pages/ctgry/CategoryManagement.vue
@@ -30,7 +30,7 @@
                     </thead>
                     <tbody>
                         <tr v-if="selectedCategories.length === 0">
-                            <td colspan="3" style="text-align: center;">등록된 카테고리리가 없습니다.</td>
+                            <td colspan="3" style="text-align: center;">등록된 카테고리가 없습니다.</td>
                         </tr>
                         <tr v-for="item in selectedCategories" :key="item.ctgryId"
                             :class="{ 'delete-member': item.useAt === 'N' }" @click="selectCategory(item)">
@@ -78,11 +78,13 @@
                                 <img :src="erroricon" alt="">
                                 <span>등록시 사용유무는 변경 하실 수 없습니다.</span>
                             </div>
-                            <div class="invalid-feedback border" v-if="selectedCategory.useAt === 'Y' && newInsertCheck">
+                            <div class="invalid-feedback border"
+                                v-if="selectedCategory.useAt === 'Y' && newInsertCheck">
                                 <img :src="erroricon" alt="">
                                 <span>삭제버튼을 누를 시 사용여부가 변경됩니다.</span>
                             </div>
-                            <div class="invalid-feedback border" v-if="selectedCategory.useAt === 'N' && newInsertCheck">
+                            <div class="invalid-feedback border"
+                                v-if="selectedCategory.useAt === 'N' && newInsertCheck">
                                 <img :src="erroricon" alt="">
                                 <span>복구버튼을 누를 시 사용여부가 변경됩니다.</span>
                             </div>
@@ -244,12 +246,14 @@
                     if (confirm("카테고리 등록을 하시겠습니까?")) {
                         try {
                             const response = await saveCategory(this.selectedCategory);
-                            if (response.status === 200) {
+                            if (response.data.result) { // 성공 여부 체크
                                 alert("등록되었습니다.");
                                 window.location.reload();
                             }
                         } catch (error) {
-                            alert("등록이 실패하였습니다.");
+                            // HTTP 오류가 발생한 경우 
+                            const errorMessage = error.response?.data?.message || "등록이 실패하였습니다.";
+                            alert(errorMessage); // 오류 메시지 표시
                             this.searchCategories();
                         }
                     }
@@ -265,7 +269,9 @@
                                     this.searchCategories();
                                 }
                             } catch (error) {
-                                alert("수정이 실패하였습니다.");
+                                // HTTP 오류가 발생한 경우 
+                                const errorMessage = error.response?.data?.message || "수정이 실패하였습니다.";
+                                alert(errorMessage); // 오류 메시지 표시
                                 this.searchCategories();
                             }
                         }
@@ -278,7 +284,9 @@
                                     this.searchCategories();
                                 }
                             } catch (error) {
-                                alert("수정이 실패하였습니다.");
+                                // HTTP 오류가 발생한 경우 
+                                const errorMessage = error.response?.data?.message || "수정이이 실패하였습니다.";
+                                alert(errorMessage); // 오류 메시지 표시
                                 this.searchCategories();
                             }
                         }
client/views/pages/member/MemberManagement.vue
--- client/views/pages/member/MemberManagement.vue
+++ client/views/pages/member/MemberManagement.vue
@@ -249,20 +249,32 @@
         },
         // 등록 및 수정
         async insertByUpdateUser() {
-            if (!this.isValidationUser()) {
+            if (!this.newInsertCheck) {
                 if (this.userId == null || this.userId == '') {
                     this.updateUser();
                     if (confirm("회원가입을 하시겠습니까?")) {
-                        try {
-                            const response = await join(this.joinDTO);
-                            if (response.status === 200) {
-                                alert("회원가입되었습니다.");
-                                window.location.reload();
+                        if (this.$isEmpty(this.joinDTO.loginId)) {
+                            alert("아이디를 확인해주세요.")
+                        } else if (this.$isEmpty(this.password) && this.$isEmpty(this.passwordCheck)) {
+                            alert("비밀번호를 확인해주세요.")
+                        } else if (this.password != this.passwordCheck) {
+                            alert("비밀번호가 일치하지 않습니다.")
+                        } else if (this.$isEmpty(this.joinDTO.userNm)) {
+                            alert("이름을 확인해주세요.")
+                        } else {
+                            try {
+                                const response = await join(this.joinDTO);
+                                if (response.status === 200) {
+                                    alert("회원가입되었습니다.");
+                                    window.location.reload();
 
+                                }
+                            } catch (error) {
+                                // HTTP 오류가 발생한 경우 
+                                const errorMessage = error.response?.data?.message || "회원가입이 실패하였습니다.";
+                                alert(errorMessage); // 오류 메시지 표시
+                                this.searchUsers();
                             }
-                        } catch (error) {
-                            alert("회원가입이 실패하였습니다.");
-                            this.searchUsers();
                         }
                     }
                 } else {
@@ -278,7 +290,9 @@
                                     this.searchUsers();
                                 }
                             } catch (error) {
-                                alert("수정이 실패하였습니다.");
+                                // HTTP 오류가 발생한 경우 
+                                const errorMessage = error.response?.data?.message || "수정이 실패하였습니다.";
+                                alert(errorMessage); // 오류 메시지 표시
                                 this.searchUsers();
                             }
                         }
@@ -292,7 +306,9 @@
                                     this.searchUsers();
                                 }
                             } catch (error) {
-                                alert("수정이 실패하였습니다.");
+                                // HTTP 오류가 발생한 경우 
+                                const errorMessage = error.response?.data?.message || "수정이 실패하였습니다.";
+                                alert(errorMessage); // 오류 메시지 표시
                                 this.searchUsers();
                             }
                         }
@@ -302,14 +318,7 @@
                 alert("필수 항목 값을 입력해주세요");
             }
         },
-        //사용자 벨류데이션 체크
-        isValidationUser() {
-            if (this.newInsertCheck) {
-                return this.selectedUser.userNm == null || this.selectedUser.userNm == '' || this.loginId == null || this.loginId == '';
-            } else {
-                return this.selectedUser.userNm == null || this.selectedUser.userNm == '' || this.loginId == null || this.loginId == '' || this.password == null || this.password == '';
-            }
-        },
+
         validatePassword() {
             // 빈 문자열이나 null 체크
             if (!this.password) {
@@ -367,7 +376,7 @@
                         this.copySelectedCategory = 'N'
                         const response = await updateUsers(this.userId, this.selectedUser);
                         if (response.status === 200) {
-                            alert("탈퇴되었습니다..");
+                            alert("탈퇴되었습니다.");
                             this.copySelectedUser.useAt = 'N';
                             this.searchUsers();
                         }
@@ -384,7 +393,7 @@
                         this.copySelectedCategory = 'Y'
                         const response = await updateUsers(this.userId, this.selectedUser);
                         if (response.status === 200) {
-                            alert("복구되었습니다..");
+                            alert("복구되었습니다.");
                             this.copySelectedUser.useAt = 'Y';
                             this.searchUsers();
                         }
@@ -405,13 +414,14 @@
                     try {
                         const response = await updatePassword(this.userId, this.passwordResetAt);
                         if (response.status === 200) {
-                            alert("초기화화되었습니다..");
+                            alert("초기화되었습니다.");
                             this.searchUsers();
                         }
                     } catch (error) {
-                        alert("초기화가 실패하였습니다.");
+                        // HTTP 오류가 발생한 경우 
+                        const errorMessage = error.response?.data?.message || "비밀번호 초기화에 실패하였습니다.";
+                        alert(errorMessage); // 오류 메시지 표시
                         this.searchUsers();
-
                     }
                 }
             }
client/views/pages/user/MyInfo.vue
--- client/views/pages/user/MyInfo.vue
+++ client/views/pages/user/MyInfo.vue
@@ -22,9 +22,7 @@
                 <dd>
                     <label for="name" class="require">이름</label>
                     <input type="text" id="name" v-model="userInfo.userNm">
-
                 </dd>
-
             </dl>
         </form>
         <h3>비밀번호 변경</h3>
@@ -145,67 +143,90 @@
         },
         async fnUpdateUser() {
             if (this.isValidationUser()) {
-                if (this.isValidationPasswdord()) {
-                    alert("수정 할 내용이 없습니다.");
+                if (this.$isEmpty(this.userPassword.oldPassword)) {
+                    alert("비밀번호를 확인해주세요.")
+                } else if (this.$isEmpty(this.userPassword.newPassword)) {
+                    alert("새 비밀번호를 확인해주세요.")
+                } else if (this.userPassword.newPassword != this.newPasswordCheck) {
+                    alert("새 비밀번호를 확인해주세요.")
                 } else {
-                    if (confirm("비밀번호 변경을 하시겠습니까?")) {
-                        try {
-                            const response = await updatePassword(this.$store.state.userId, this.userPassword);
-                            if (response.status === 200) {
-                                this.resetForm();
-                                alert("비밀번호가 변경되었습니다.");
-                                window.location.reload(); // 페이지 새로 고침
-                            }
-                        } catch (error) {
-                            if (error.response && error.response.status === 401) {
-                                alert("비밀번호 변경이 실패하였습니다.");
-                                window.location.reload(); // 페이지 새로 고침
-                            }
+                    try {
+                        const response = await updatePassword(this.$store.state.userId, this.userPassword);
+                        if (response.status === 200) {
+                            this.resetForm();
+                            alert("비밀번호가 변경되었습니다.");
+                            window.location.reload(); // 페이지 새로 고침
                         }
+                    } catch (error) {
+                        // HTTP 오류가 발생한 경우 
+                        const errorMessage = error.response?.data?.message || "비밀번호 변경이 실패하였습니다.";
+                        alert(errorMessage); // 오류 메시지 표시
+                        window.location.reload(); // 페이지 새로 고침
                     }
                 }
             } else {
                 if (this.$store.state.userNm !== this.userInfo.userNm) {
                     if (this.isValidationPasswdord()) {
-                        if (confirm("회원정보를 변경을 하시겠습니까?")) {
-                            try {
-                                const response = await updateUsers(this.$store.state.userId, this.userInfo);
-                                if (response.status === 200) {
-                                    this.$store.commit("setUserNm", this.userInfo.userNm);
-                                    this.resetForm();
-                                    alert("회원정보가 변경되었습니다.");
+                        if (confirm("회원정보를 변경을 하시겠습니까?\n(이름은 2자 이상 50자 이하여야 합니다. 특수문자 제외)")) {
+                            if (
+                                this.userInfo.userNm &&
+                                this.userInfo.userNm.length >= 2 &&
+                                this.userInfo.userNm.length <= 50 &&
+                                /^[\u3131-\u3163\uAC00-\uD7A3a-zA-Z0-9]*$/.test(this.userInfo.userNm) // 특수문자 제외
+                            ) {
+                                try {
+                                    const response = await updateUsers(this.$store.state.userId, this.userInfo);
+                                    if (response.status === 200) {
+                                        this.$store.commit("setUserNm", this.userInfo.userNm);
+                                        this.resetForm();
+                                        alert("회원정보가 변경되었습니다.");
+                                        window.location.reload(); // 페이지 새로 고침
+                                    }
+                                } catch (error) {
+                                    // HTTP 오류가 발생한 경우 
+                                    const errorMessage = error.response?.data?.message || "회원정보 변경이 실패하였습니다.";
+                                    alert(errorMessage); // 오류 메시지 표시
                                     window.location.reload(); // 페이지 새로 고침
                                 }
-                            } catch (error) {
-                                if (error.response && error.response.status === 401) {
-                                    alert("회원정보 변경이 실패하였습니다.");
-                                    window.location.reload(); // 페이지 새로 고침
-                                }
+                            } else {
+                                alert("이름은 2자 이상 50자 이하여야 합니다. 특수문자 제외");
                             }
                         }
                     } else {
                         if (confirm("회원과 비밀번호를 변경하시겠습니까?")) {
-                            try {
-                                const res = await updateUsers(this.$store.state.userId, this.userInfo);
-                                const response = await updatePassword(this.$store.state.userId, this.userPassword);
-                                if (res.status === 200 && response.status === 200) {
-                                    this.resetForm();
-                                    alert("회원과 비밀번호를 변경되었습니다.");
-                                    window.location.reload(); // 페이지 새로 고침
-                                }
-                            } catch (error) {
-                                if (error.response && error.response.status === 401) {
-                                    alert("회원 및 비밀번호 변경이 실패하였습니다.");
+                            if (this.$isEmpty(this.userPassword.oldPassword)) {
+                                alert("비밀번호를 확인해주세요.")
+                            } else if (this.$isEmpty(this.userPassword.newPassword)) {
+                                alert("새 비밀번호를 확인해주세요.")
+                            } else if (this.userPassword.newPassword != this.newPasswordCheck) {
+                                alert("새 비밀번호를 확인해주세요.")
+                            } else {
+                                try {
+                                    const res = await updateUsers(this.$store.state.userId, this.userInfo);
+                                    const response = await updatePassword(this.$store.state.userId, this.userPassword);
+                                    if (res.status === 200 && response.status === 200) {
+                                        this.resetForm();
+                                        alert("회원과 비밀번호를 변경되었습니다.");
+                                        window.location.reload(); // 페이지 새로 고침
+                                    }
+                                } catch (error) {
+                                    // HTTP 오류가 발생한 경우 
+                                    const errorMessage = error.response?.data?.message || "비밀번호 변경이 실패하였습니다.";
+                                    alert(errorMessage); // 오류 메시지 표시
                                     window.location.reload(); // 페이지 새로 고침
                                 }
                             }
                         }
                     }
                 } else {
-                    if (this.isValidationPasswdord()) {
-                        alert("수정 할 내용이 없습니다.");
-                    } else {
-                        if (confirm("비밀번호 변경을 하시겠습니까?")) {
+                    if (confirm("비밀번호 변경을 하시겠습니까?")) {
+                        if (this.$isEmpty(this.userPassword.oldPassword)) {
+                            alert("비밀번호를 확인해주세요.")
+                        } else if (this.$isEmpty(this.userPassword.newPassword)) {
+                            alert("새 비밀번호를 확인해주세요.")
+                        } else if (this.userPassword.newPassword != this.newPasswordCheck) {
+                            alert("새 비밀번호를 확인해주세요.")
+                        } else {
                             try {
                                 const response = await updatePassword(this.$store.state.userId, this.userPassword);
                                 if (response.status === 200) {
@@ -214,10 +235,10 @@
                                     window.location.reload(); // 페이지 새로 고침
                                 }
                             } catch (error) {
-                                if (error.response && error.response.status === 401) {
-                                    alert("비밀번호 변경이 실패하였습니다.");
-                                    window.location.reload(); // 페이지 새로 고침
-                                }
+                                // HTTP 오류가 발생한 경우 
+                                const errorMessage = error.response?.data?.message || "비밀번호 변경이 실패하였습니다.";
+                                alert(errorMessage); // 오류 메시지 표시
+                                window.location.reload(); // 페이지 새로 고침
                             }
                         }
                     }
Add a comment
List