diff --git a/src/common/axios-interceptor.js b/src/common/axios-interceptor.js index 6af0940..08bf871 100644 --- a/src/common/axios-interceptor.js +++ b/src/common/axios-interceptor.js @@ -2,7 +2,7 @@ import axios from "axios"; import router from "@/router/index"; const $api = axios.create({ - baseURL: import.meta.env.VITE_API_URL, + baseURL: 'http://localhost:10325/api/', timeout: 300000, withCredentials : true }) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 6128c7d..e71b3ee 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -36,6 +36,7 @@ import BoardComentArea from './BoardComentArea.vue'; import { ref, computed } from 'vue'; import Pagination from '../pagination/Pagination.vue'; import PlusButton from '../button/PlusBtn.vue'; +import { defineEmits } from 'vue'; const comment = ref(false); @@ -43,6 +44,9 @@ const toggleComment = () => { comment.value = !comment.value }; +// emits 정의 +const emit = defineEmits(['submitComment']); + \ No newline at end of file + diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index d747800..c8a90c3 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -24,72 +24,98 @@
diff --git a/src/components/calendar/SampleCalendar.vue b/src/components/calendar/SampleCalendar.vue index f3362f3..b564c98 100644 --- a/src/components/calendar/SampleCalendar.vue +++ b/src/components/calendar/SampleCalendar.vue @@ -67,7 +67,7 @@ import dayGridPlugin from '@fullcalendar/daygrid'; import interactionPlugin from '@fullcalendar/interaction'; import CenterModal from '@c/modal/CenterModal.vue'; import { inject, onMounted, reactive, ref } from 'vue'; -import axios from 'axios'; +import axios from '@api'; import { isEmpty } from '@/common/utils'; import FormInput from '../input/FormInput.vue'; import FlatPickr from 'vue-flatpickr-component'; diff --git a/src/components/input/FormInput.vue b/src/components/input/FormInput.vue index 5987627..12a8e79 100644 --- a/src/components/input/FormInput.vue +++ b/src/components/input/FormInput.vue @@ -5,22 +5,26 @@ *
- -
{{ title }}을 확인해주세요.
+ :placeholder="title" + /> +
+ {{ title }}을 확인해주세요. +
diff --git a/src/components/list/BoardCardList.vue b/src/components/list/BoardCardList.vue new file mode 100644 index 0000000..6e0b651 --- /dev/null +++ b/src/components/list/BoardCardList.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/router/index.js b/src/router/index.js index 417ef6c..a19d7da 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,5 +1,4 @@ import { createRouter, createWebHistory } from 'vue-router' -import BoardWrite from '@v/board/BoardWrite.vue'; // 초기 렌더링 속도를 위해 지연 로딩 사용 const routes = [ @@ -14,6 +13,7 @@ const routes = [ children: [ { path: '', + name: 'BoardList', component: () => import('@v/board/BoardList.vue') }, { @@ -21,8 +21,14 @@ const routes = [ component: () => import('@v/board/BoardWrite.vue') }, { - path: 'get/:id', + path: ':id', + name: 'BoardDetail', component: () => import('@v/board/BoardView.vue') + }, + { + path: 'edit/:id', + name: 'BoardEdit', + component: () => import('@v/board/BoardEdit.vue') } ] }, diff --git a/src/stores/calendarStore.js b/src/stores/calendarStore.js index 80c8525..aacb07f 100644 --- a/src/stores/calendarStore.js +++ b/src/stores/calendarStore.js @@ -1,15 +1,15 @@ import { ref } from 'vue'; -import axios from 'axios'; +import axios from '@api'; const events = ref([]); const fetchEvents = async () => { - const response = await axios.get('/api/calendar/events'); + const response = await axios.get('/calendar/events'); events.value = response.data; }; const addEvent = async (event) => { - await axios.post('/api/calendar/event', event); + await axios.post('/calendar/event', event); fetchEvents(); }; diff --git a/src/views/board/BoardEdit.vue b/src/views/board/BoardEdit.vue new file mode 100644 index 0000000..3629502 --- /dev/null +++ b/src/views/board/BoardEdit.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/src/views/board/BoardList.vue b/src/views/board/BoardList.vue index 25109bd..ce7873a 100644 --- a/src/views/board/BoardList.vue +++ b/src/views/board/BoardList.vue @@ -1,30 +1,15 @@ - + diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 890e036..080fdc0 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -3,15 +3,32 @@
+
- +
+
- - +
{{ boardTitle }}
+ +
+ + + +
-
@@ -21,16 +38,51 @@ - diff --git a/src/views/board/BoardWrite.vue b/src/views/board/BoardWrite.vue index f522ea4..97249fd 100644 --- a/src/views/board/BoardWrite.vue +++ b/src/views/board/BoardWrite.vue @@ -55,9 +55,10 @@ import FormSelect from '@c/input/FormSelect.vue'; import FormFile from '@c/input/FormFile.vue'; import { ref, watch } from 'vue'; import router from '@/router'; +import axios from '@api'; const categoryList = ['자유', '익명', '공지사항']; -// input 경고문 만들어야함 +// input 경고문 만들어야함!! const title = ref(''); const password = ref(''); const category = ref(0); @@ -76,9 +77,81 @@ const goList = () => { router.push('/board'); }; -const write = () => { - console.log('작성'); +const write = async () => { + // 입력값 유효성 검사 + if (!title.value) { + titleAlert.value = true; + return; + } else { + titleAlert.value = false; + } + + if (category.value === 1 && !password.value) { + passwordAlert.value = true; + return; + } else { + passwordAlert.value = false; + } + + if (!content.value) { + contentAlert.value = true; + return; + } else { + contentAlert.value = false; + } + + try { + // 게시물 작성 데이터 준비 + const boardData = { + LOCBRDTTL: title.value, + LOCBRDCON: content.value, + LOCBRDPWD: category.value === 1 ? password.value : null, + LOCBRDTYP: category.value === 1 ? 'S' : 'F', //공지사항 추가해야함!! + // MEMBERSEQ: 로그인이용자 id(세션) + }; + + // 게시물 작성 API 호출 + const { data: boardResponse } = await axios.post('board', boardData); + const boardId = boardResponse.data.boardId; + + // 첨부파일 처리 + if (attachFiles.value && attachFiles.value.length > 0) { + for (const file of attachFiles.value) { + const realName = file.name.substring(0, file.name.lastIndexOf('.')); + const fileInfo = { + path: "/uploads", // 파일 경로 (수정 필요) + originalName: realName, // 확장자를 제외한 파일명 + extension: file.name.split('.').pop(), // 파일 확장자 + registrantId: 1, // 등록자 ID (수정 필요) + }; + + + const formData = new FormData(); + formData.append("file", file); // 첨부 파일 + formData.append("CMNFLEPAT", fileInfo.path); // 파일 경로 + formData.append("CMNFLENAM", fileInfo.originalName); // 파일 명(확장자제외) + formData.append("CMNFLEORG", fileInfo.originalName); // 원본 파일명(확장자제외) + formData.append("CMNFLEEXT", fileInfo.extension); // 파일 확장자 + formData.append("CMNFLESIZ", file.size); // 파일 크기 + formData.append("CMNFLEREG", fileInfo.registrantId); // 등록자 ID + + const response = await axios.post(`board/${boardId}/attachments`, formData, { + headers: { + "Content-Type": "multipart/form-data", + }, + }); + } + } + + alert("게시물이 작성되었습니다."); + goList(); + } catch (error) { + console.error(error); + alert("게시물 작성 중 오류가 발생했습니다."); + } }; + +