60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type {
|
|
GroupService,
|
|
GroupSearchParams,
|
|
GroupList,
|
|
GroupResponseDto,
|
|
GroupFormData,
|
|
} from "../model/groups-interface";
|
|
|
|
export class GroupsApiService implements GroupService {
|
|
// 그룹 목록 조회
|
|
public async findPageGroup(params: GroupSearchParams): Promise<GroupList> {
|
|
const response = await client.get<GroupList>(
|
|
`${ENDPOINT.CMS_SERVICE.GROUPS}`,
|
|
{ params },
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 그룹 단건 조회
|
|
public async findGroupById(groupId: string): Promise<GroupResponseDto> {
|
|
const response = await client.get<GroupResponseDto>(
|
|
`${ENDPOINT.CMS_SERVICE.GROUPS}/${groupId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 그룹 저장
|
|
public async saveGroup(data: GroupFormData): Promise<GroupResponseDto> {
|
|
const response = await client.post<GroupResponseDto>(
|
|
`${ENDPOINT.CMS_SERVICE.GROUPS}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 그룹 수정
|
|
public async updateGroup(
|
|
groupId: string,
|
|
data: GroupFormData,
|
|
): Promise<GroupResponseDto> {
|
|
const response = await client.put<GroupResponseDto>(
|
|
`${ENDPOINT.CMS_SERVICE.GROUPS}/${groupId}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
// 그룹 삭제
|
|
public async deleteGroup(groupId: string): Promise<boolean> {
|
|
const response = await client.delete<boolean>(
|
|
`${ENDPOINT.CMS_SERVICE.GROUPS}/${groupId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
}
|
|
|
|
export const GroupsApi = new GroupsApiService();
|