파일 업로드기능 완료

This commit is contained in:
2025-06-03 19:10:07 +09:00
parent e609a8ce52
commit eb0addf4e3
20 changed files with 4501 additions and 27 deletions
+118
View File
@@ -372,4 +372,122 @@ export default {
throw error;
}
},
/**
* 파일 업로드 후 파싱 요청
* @param {Object} data - 파일명과 클럽ID 정보
* @returns {Promise<Object>} 파싱된 데이터
*/
async parseEventFile(data) {
if (!data.filename || !data.clubId) {
throw new Error('파일명과 클럽 ID가 필요합니다.');
}
try {
const response = await apiClient.post('/api/club/events/parse-preview', data);
return response.data;
} catch (error) {
if (error.response && error.response.data && error.response.data.message) {
throw new Error(error.response.data.message);
}
throw error;
}
},
/**
* 파일 업로드 URL 가져오기
* @param {number} clubId - 클럽 ID
* @returns {string} 파일 업로드 URL
*/
getFileUploadUrl(clubId) {
if (!clubId) {
throw new Error('클럽 ID가 필요합니다.');
}
return `/api/club/events/upload?clubId=${clubId}`;
},
/**
* 파일 업로드 함수
* @param {File} file - 업로드할 파일
* @param {number} clubId - 클럽 ID
* @returns {Promise<Object>} 업로드 결과
*/
async uploadFile(file, clubId) {
if (!file || !clubId) {
throw new Error('파일과 클럽 ID가 필요합니다.');
}
const formData = new FormData();
formData.append('file', file);
formData.append('clubId', clubId);
try {
const response = await apiClient.post('/api/club/events/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
});
return response.data;
} catch (error) {
console.error('파일 업로드 오류:', error);
if (error.response && error.response.data && error.response.data.message) {
throw new Error(error.response.data.message);
}
throw error;
}
},
/**
* 이벤트 파일 데이터 저장
* @param {Object} data - 이벤트 데이터, 참가자 데이터, 클럽 ID
* @returns {Promise<Object>} 저장된 이벤트 정보
*/
async saveEventFileData(data) {
if (!data.eventData || !data.participants || !data.clubId) {
throw new Error('이벤트 정보, 참가자 정보, 클럽 ID가 필요합니다.');
}
try {
const response = await apiClient.post('/api/club/events/save-file-data', data);
return response.data;
} catch (error) {
if (error.response && error.response.data && error.response.data.message) {
throw new Error(error.response.data.message);
}
throw error;
}
},
/**
* 업로드된 임시 파일 삭제
* @param {Object} data - 파일명 정보
* @returns {Promise<Object>} 삭제 결과
*/
async deleteUploadedFile(data) {
if (!data.filename) {
throw new Error('파일명이 필요합니다.');
}
try {
const response = await apiClient.post('/api/club/events/delete-file', data);
return response.data;
} catch (error) {
if (error.response && error.response.data && error.response.data.message) {
throw new Error(error.response.data.message);
}
throw error;
}
},
/**
* 이벤트 파일 업로드 URL 생성
* @param {number} clubId - 클럽 ID
* @returns {string} 파일 업로드 URL
*/
getFileUploadUrl(clubId) {
if (!clubId) {
throw new Error('클럽 ID가 필요합니다.');
}
return `/api/club/events/upload`;
}
};