Feat: 레이블링 api 추가 및 약간 수정

This commit is contained in:
정현조 2024-09-13 08:16:53 +09:00
parent 6b53eccd5c
commit e4df9ed847
4 changed files with 53 additions and 12 deletions

View File

@ -3,6 +3,7 @@ import useAuthStore from '@/stores/useAuthStore';
import { BaseResponse, CustomError, SuccessResponse, RefreshTokenResponseDTO } from '@/types';
const baseURL = 'https://j11s002.p.ssafy.io';
// const baseURL = 'http://localhost:5173'; 모킹 테스트
const api = axios.create({
baseURL,
@ -105,8 +106,6 @@ const handleCommonErrors = (error: AxiosError<BaseResponse<CustomError>>) => {
window.location.href = '/';
} else {
console.error('오류 발생:', error.response?.data?.message || '알 수 없는 오류');
useAuthStore.getState().clearAuth();
window.location.href = '/';
}
};

View File

@ -10,7 +10,6 @@ export const fetchFolderApi = async (
try {
const response = await api.get(`/api/projects/${projectId}/folders/${folderId}`, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -32,7 +31,6 @@ export const updateFolderApi = async (
try {
const response = await api.put(`/api/projects/${projectId}/folders/${folderId}`, folderData, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -53,7 +51,6 @@ export const deleteFolderApi = async (
try {
const response = await api.delete(`/api/projects/${projectId}/folders/${folderId}`, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -74,7 +71,6 @@ export const createFolderApi = async (
try {
const response = await api.post(`/api/projects/${projectId}/folders`, folderData, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -95,7 +91,6 @@ export const fetchFolderReviewListApi = async (
try {
const response = await api.get(`/api/projects/${projectId}/folders/${folderId}/review`, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {

View File

@ -11,7 +11,6 @@ export const fetchImageApi = async (
try {
const response = await api.get(`/api/projects/${projectId}/folders/${folderId}/images/${imageId}`, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -34,7 +33,6 @@ export const moveImageApi = async (
try {
const response = await api.put(`/api/projects/${projectId}/folders/${folderId}/images/${imageId}`, moveRequest, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -56,7 +54,6 @@ export const deleteImageApi = async (
try {
const response = await api.delete(`/api/projects/${projectId}/folders/${folderId}/images/${imageId}`, {
params: { memberId },
withCredentials: true,
});
return response.data;
} catch (error) {
@ -82,7 +79,6 @@ export const changeImageStatusApi = async (
statusChangeRequest,
{
params: { memberId },
withCredentials: true,
}
);
return response.data;
@ -108,7 +104,6 @@ export const uploadImageListApi = async (
{ imageList },
{
params: { memberId },
withCredentials: true,
}
);
return response.data;

View File

@ -0,0 +1,52 @@
import api from '@/api/axiosConfig';
import { AxiosError, AxiosResponse } from 'axios';
import { BaseResponse } from '@/types';
import { LabelingRequestDTO } from '@/types';
export const saveImageLabelingApi = async (
projectId: number,
imageId: number,
memberId: number,
data: LabelingRequestDTO
): Promise<BaseResponse<Record<string, never>>> => {
try {
const response: AxiosResponse<BaseResponse<Record<string, never>>> = await api.post(
`/api/projects/${projectId}/label/image/${imageId}`,
data,
{
params: { memberId },
}
);
return response.data;
} catch (error) {
if (error instanceof AxiosError) {
console.error('이미지 레이블링 저장 실패:', error.response?.data?.message || '알 수 없는 오류');
} else {
console.error('알 수 없는 오류가 발생했습니다.');
}
throw error;
}
};
export const autoLabelingApi = async (
projectId: number,
memberId: number
): Promise<BaseResponse<Record<string, never>>> => {
try {
const response: AxiosResponse<BaseResponse<Record<string, never>>> = await api.post(
`/api/projects/${projectId}/label/auto`,
{},
{
params: { memberId },
}
);
return response.data;
} catch (error) {
if (error instanceof AxiosError) {
console.error('오토 레이블링 실패:', error.response?.data?.message || '알 수 없는 오류');
} else {
console.error('알 수 없는 오류가 발생했습니다.');
}
throw error;
}
};