refactor: 그룹 서비스 및 인터페이스 엔티티 폴더로 이동

This commit is contained in:
2025-06-19 10:33:50 +09:00
parent 3b7f8bcca7
commit cb38462164
7 changed files with 22 additions and 13 deletions
@@ -0,0 +1,59 @@
import { client } from "@/shared/api";
import { ENDPOINT } from "@/shared/config";
import type {
GroupService,
GroupSearchParams,
GroupList,
GroupResponseDto,
GroupFormData,
} from "../model/group-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 GroupApi = new GroupsApiService();
+6
View File
@@ -0,0 +1,6 @@
export { GroupApi } from "./api/group-service";
export {
groupFormSchema,
type GroupFormData,
type GroupListResponseDto,
} from "./model/group-interface";
@@ -0,0 +1,87 @@
import { z } from "zod";
import type { PageableList, PageableParams } from "@/shared/model";
// 그룹 검색 파라미터 인터페이스
export interface GroupSearchParams extends PageableParams {
keywordType?: string;
keyword?: string;
groupId?: string;
groupNm?: string;
groupSeCd?: string;
delYn?: string;
authrtId?: string;
siteId?: string;
groupExpln?: string;
roleId?: string;
mngrYn?: string;
}
// 그룹 목록 응답 인터페이스
export interface GroupListResponseDto {
groupId: string;
groupNm: string;
groupSeCd: string;
groupSeNm: string;
delYn: string;
authrtId: string;
groupExpln: string;
siteId: string;
mngrYn: string;
roleId: string;
roleNm: string;
mdfcnDt: string;
mdfrNm: string;
}
// 그룹 상세 응답 인터페이스
export interface GroupResponseDto {
groupId: string;
groupNm: string;
groupSeCd: string;
groupSeNm: string;
groupExpln: string;
delYn: string;
regDt: string;
rgtr: string;
mdfcnDt: string;
mdfr: string;
authrtId: string;
siteId: string;
mngrYn: string;
}
// 그룹 저장 데이터 스키마
export const groupFormSchema = z.object({
groupId: z.string().min(1, { message: "그룹 ID를 입력해주세요." }),
groupNm: z.string().min(1, { message: "그룹명을 입력해주세요." }),
groupSeCd: z.string().min(1, { message: "그룹구분을 선택해주세요." }),
groupExpln: z.string().optional(),
delYn: z.string().default("N"),
authrtId: z.string().min(1, { message: "권한ID를 선택해주세요." }),
siteId: z.string().optional(),
mngrYn: z.string().default("N"),
});
export type GroupList = PageableList<GroupListResponseDto>;
export type GroupFormData = z.infer<typeof groupFormSchema>;
// 그룹 서비스 인터페이스
export interface GroupService {
// 그룹 목록 조회
findPageGroup: (params: GroupSearchParams) => Promise<GroupList>;
// 그룹 단건 조회
findGroupById: (groupId: string) => Promise<GroupResponseDto>;
// 그룹 저장
saveGroup: (data: GroupFormData) => Promise<GroupResponseDto>;
// 그룹 수정
updateGroup: (
groupId: string,
data: GroupFormData,
) => Promise<GroupResponseDto>;
// 그룹 삭제
deleteGroup: (groupId: string) => Promise<boolean>;
}