2023.10.02 - [웹/Spring vue 웹 개발] - [리팩토링]게시판03 update test code

[리팩토링]게시판03 update test code

2023.10.01 - [웹/Spring vue 웹 개발] - [리팩토링]게시판02(service/controller) [리팩토링]게시판02(service/controller) 이전글: 2023.09.24 - [웹/Spring vue 웹 개발] - [리팩토링] 게시판01(data/repository) [리팩토링] 게시

kwaksh2319.tistory.com

일단 기존 게시판 코드를 전부 변경하였고 그리고 프론트단도 url 같은 경우도 notice로 전부 통일했습니다. 
session 적용을 할 예정이고요 문제없이 잘 작동됩니다. 추가 기능으로 댓글 기능도 넣어볼게요!
영상 아래 변경된 프론트 코드들도  작성했습니다. 백엔드 코드들은 이전링크를 참고해주세요!
 ps 일단 제가 프론트 vue쪽은 독학이어서 좀 부족한 부분이 많습니다. 백엔드도 사내 레거시 코드로 공부하거나 인강으로 공부하다보니 또 다른 회사들은 다르게 개발될수 있어서 부족한 부분 피드백 주시면 감사드립니다.

변경된 메서드
index.js 라우터 

{
      path: '/notice',
      name: 'notice',
      component: PostList,
      props: true
    },

PostList.vue

created() {
    this.axios = axios.create({
      baseURL: this.$myUrl
    });
    try {
      this.axios
        .get('/notice')
        .then(response => {
          this.posts = response.data;
        })
        .catch(error => {
        });
    } catch (error) {
    }
  },

PostForm.vue

try {
        this.axios
          .post('/notice', data,config)
          .then(response => {
            this.$alert('게시판', '등록 성공');
            this.$router.push('/notice');
          })
          .catch(error => {
            this.$alert('게시판', '등록 실패');

          });
      } catch (error) {
        this.$alert('에러', '등록 실패');
      }

PostModify.vue

try {
        this.axios.put(`/notice/${postId}`, data,config)
          .then(response => {
            this.$alert('게시판', '수정 성공');
            this.$router.push('/notice');
          })
          .catch(error => {
            this.$alert('게시판', '수정 실패');
          });
      } catch (error) {
        this.$alert('게시판', '수정 오류');
      }

 

+ Recent posts