api 수정
This commit is contained in:
parent
e87957c88a
commit
a093a1b394
@ -2,7 +2,7 @@ import axios from "axios";
|
|||||||
import router from "@/router/index";
|
import router from "@/router/index";
|
||||||
|
|
||||||
const $api = axios.create({
|
const $api = axios.create({
|
||||||
baseURL: import.meta.env.VITE_API_URL,
|
baseURL: 'http://localhost:10325/api/',
|
||||||
timeout: 300000,
|
timeout: 300000,
|
||||||
withCredentials : true
|
withCredentials : true
|
||||||
})
|
})
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from '@api';
|
||||||
import DeleteButton from '../button/DeleteBtn.vue';
|
import DeleteButton from '../button/DeleteBtn.vue';
|
||||||
import EditButton from '../button/EditBtn.vue';
|
import EditButton from '../button/EditBtn.vue';
|
||||||
import BoardRecommendBtn from '../button/BoardRecommendBtn.vue';
|
import BoardRecommendBtn from '../button/BoardRecommendBtn.vue';
|
||||||
@ -82,7 +82,7 @@ const handleEdit = () => {
|
|||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
if (confirm('정말 이 게시물을 삭제하시겠습니까?')) {
|
if (confirm('정말 이 게시물을 삭제하시겠습니까?')) {
|
||||||
try {
|
try {
|
||||||
await axios.delete(`/board/${boardId}`);
|
await axios.delete(`board/${boardId}`);
|
||||||
alert('게시물이 성공적으로 삭제되었습니다.');
|
alert('게시물이 성공적으로 삭제되었습니다.');
|
||||||
router.push({ name: 'BoardList' });
|
router.push({ name: 'BoardList' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ import dayGridPlugin from '@fullcalendar/daygrid';
|
|||||||
import interactionPlugin from '@fullcalendar/interaction';
|
import interactionPlugin from '@fullcalendar/interaction';
|
||||||
import CenterModal from '@c/modal/CenterModal.vue';
|
import CenterModal from '@c/modal/CenterModal.vue';
|
||||||
import { inject, onMounted, reactive, ref } from 'vue';
|
import { inject, onMounted, reactive, ref } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from '@api';
|
||||||
import { isEmpty } from '@/common/utils';
|
import { isEmpty } from '@/common/utils';
|
||||||
import FormInput from '../input/FormInput.vue';
|
import FormInput from '../input/FormInput.vue';
|
||||||
import FlatPickr from 'vue-flatpickr-component';
|
import FlatPickr from 'vue-flatpickr-component';
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "@api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -57,7 +57,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async fetchPosts() {
|
async fetchPosts() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("/board/general");
|
const response = await axios.get("board/general");
|
||||||
if (response.data && Array.isArray(response.data.data)) {
|
if (response.data && Array.isArray(response.data.data)) {
|
||||||
console.log("API Response:",response.data);
|
console.log("API Response:",response.data);
|
||||||
this.posts = response.data.data.map((post) => ({
|
this.posts = response.data.data.map((post) => ({
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from '@api';
|
||||||
|
|
||||||
const events = ref([]);
|
const events = ref([]);
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ const currentBoardId = ref(Number(route.params.id));
|
|||||||
// 게시물 데이터 로드
|
// 게시물 데이터 로드
|
||||||
const fetchBoardDetails = async () => {
|
const fetchBoardDetails = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/board/${currentBoardId.value}`);
|
const response = await axios.get(`board/${currentBoardId.value}`);
|
||||||
const data = response.data.data.boardDetail;
|
const data = response.data.data.boardDetail;
|
||||||
|
|
||||||
// 데이터 초기화
|
// 데이터 초기화
|
||||||
@ -113,14 +113,14 @@ const updateBoard = async () => {
|
|||||||
LOCBRDCON: content.value,
|
LOCBRDCON: content.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
await axios.put(`/board/${currentBoardId.value}`, boardData);
|
await axios.put(`board/${currentBoardId.value}`, boardData);
|
||||||
|
|
||||||
// 첨부파일 처리
|
// 첨부파일 처리
|
||||||
if (attachFiles.value && attachFiles.value.length > 0) {
|
if (attachFiles.value && attachFiles.value.length > 0) {
|
||||||
for (const file of attachFiles.value) {
|
for (const file of attachFiles.value) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
await axios.post(`/board/${currentBoardId.value}/attachments`, formData, {
|
await axios.post(`board/${currentBoardId.value}/attachments`, formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -57,7 +57,7 @@ const addComment = async (newComment) => {
|
|||||||
const requestData = {
|
const requestData = {
|
||||||
content: newComment,
|
content: newComment,
|
||||||
};
|
};
|
||||||
const response = await axios.post(`/board/${currentBoardId.value}/comment`, requestData);
|
const response = await axios.post(`board/${currentBoardId.value}/comment`, requestData);
|
||||||
comments.value.push(response.data);
|
comments.value.push(response.data);
|
||||||
alert('댓글이 추가되었습니다.');
|
alert('댓글이 추가되었습니다.');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -69,7 +69,7 @@ const addComment = async (newComment) => {
|
|||||||
// 게시물 상세 데이터 불러오기
|
// 게시물 상세 데이터 불러오기
|
||||||
const fetchBoardDetails = async () => {
|
const fetchBoardDetails = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/board/${currentBoardId.value}`);
|
const response = await axios.get(`board/${currentBoardId.value}`);
|
||||||
const data = response.data.data;
|
const data = response.data.data;
|
||||||
|
|
||||||
// API 응답 데이터 반영
|
// API 응답 데이터 반영
|
||||||
|
|||||||
@ -111,7 +111,7 @@ const write = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 게시물 작성 API 호출
|
// 게시물 작성 API 호출
|
||||||
const { data: boardResponse } = await axios.post('/board', boardData);
|
const { data: boardResponse } = await axios.post('board', boardData);
|
||||||
const boardId = boardResponse.data.boardId;
|
const boardId = boardResponse.data.boardId;
|
||||||
|
|
||||||
// 첨부파일 처리
|
// 첨부파일 처리
|
||||||
@ -135,7 +135,7 @@ const write = async () => {
|
|||||||
formData.append("CMNFLESIZ", file.size); // 파일 크기
|
formData.append("CMNFLESIZ", file.size); // 파일 크기
|
||||||
formData.append("CMNFLEREG", fileInfo.registrantId); // 등록자 ID
|
formData.append("CMNFLEREG", fileInfo.registrantId); // 등록자 ID
|
||||||
|
|
||||||
const response = await axios.post(`/board/${boardId}/attachments`, formData, {
|
const response = await axios.post(`board/${boardId}/attachments`, formData, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,14 +5,6 @@ import vueDevTools from 'vite-plugin-vue-devtools'
|
|||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
server: {
|
|
||||||
proxy: {
|
|
||||||
'/api': {
|
|
||||||
target: 'http://localhost:10325/api', // Spring Boot 서버 주소
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
vueDevTools(),
|
vueDevTools(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user