[as] feat: 체크리스트 엔티티 생성
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { PageResponse } from "@/shared/model";
|
||||
|
||||
import type {
|
||||
CklstArtcl,
|
||||
CklstArtclId,
|
||||
CklstArtclSaveRequest,
|
||||
CklstArtclSearchParams,
|
||||
CklstArtclService,
|
||||
CklstArtclUpdateRequest,
|
||||
} from "../model/cklst-artcl-interface";
|
||||
|
||||
async function findPage(params: CklstArtclSearchParams): Promise<PageResponse<CklstArtcl>> {
|
||||
const response = await client.get<PageResponse<CklstArtcl>>(
|
||||
ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function findByCklstSn(cklstSn: number): Promise<CklstArtcl[]> {
|
||||
const response = await client.get<CklstArtcl[]>(
|
||||
`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL}/by-cklst/${cklstSn}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function findById(cklstArtclSn: number, cklstSn: number): Promise<CklstArtcl> {
|
||||
const response = await client.get<CklstArtcl>(
|
||||
`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL}/${cklstArtclSn}/${cklstSn}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function create(body: CklstArtclSaveRequest): Promise<CklstArtclId> {
|
||||
const response = await client.post<CklstArtclId>(
|
||||
ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL,
|
||||
body,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function update(
|
||||
cklstArtclSn: number,
|
||||
cklstSn: number,
|
||||
body: CklstArtclUpdateRequest,
|
||||
): Promise<CklstArtclId> {
|
||||
const response = await client.put<CklstArtclId>(
|
||||
`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL}/${cklstArtclSn}/${cklstSn}`,
|
||||
body,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function remove(cklstArtclSn: number, cklstSn: number): Promise<CklstArtclId> {
|
||||
const response = await client.delete<CklstArtclId>(
|
||||
`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL}/${cklstArtclSn}/${cklstSn}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const cklstArtclService = {
|
||||
findPage,
|
||||
findByCklstSn,
|
||||
findById,
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
} satisfies CklstArtclService;
|
||||
@@ -0,0 +1,48 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { PageResponse } from "@/shared/model";
|
||||
|
||||
import type {
|
||||
CklstMng,
|
||||
CklstMngSaveRequest,
|
||||
CklstMngSearchParams,
|
||||
CklstMngService,
|
||||
} from "../model/cklst-mng-interface";
|
||||
|
||||
async function findPage(params: CklstMngSearchParams): Promise<PageResponse<CklstMng>> {
|
||||
const response = await client.get<PageResponse<CklstMng>>(ENDPOINT.AS_CHECKLIST_SERVICE.CKLST, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function findById(cklstSn: number): Promise<CklstMng> {
|
||||
const response = await client.get<CklstMng>(`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST}/${cklstSn}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function create(body: CklstMngSaveRequest): Promise<number> {
|
||||
const response = await client.post<number>(ENDPOINT.AS_CHECKLIST_SERVICE.CKLST, body);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function update(cklstSn: number, body: CklstMngSaveRequest): Promise<number> {
|
||||
const response = await client.put<number>(
|
||||
`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST}/${cklstSn}`,
|
||||
body,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function remove(cklstSn: number): Promise<number> {
|
||||
const response = await client.delete<number>(`${ENDPOINT.AS_CHECKLIST_SERVICE.CKLST}/${cklstSn}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const cklstMngService = {
|
||||
findPage,
|
||||
findById,
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
} satisfies CklstMngService;
|
||||
@@ -0,0 +1,167 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
CklstArtclSaveRequest,
|
||||
CklstArtclSearchParams,
|
||||
CklstArtclUpdateRequest,
|
||||
} from "../model/cklst-artcl-interface";
|
||||
import type { CklstMngSaveRequest, CklstMngSearchParams } from "../model/cklst-mng-interface";
|
||||
|
||||
import { cklstArtclService } from "./cklst-artcl-service";
|
||||
import { cklstMngService } from "./cklst-mng-service";
|
||||
|
||||
const cklstMngBaseKey = [ENDPOINT.AS_CHECKLIST_SERVICE.CKLST] as const;
|
||||
const cklstArtclBaseKey = [ENDPOINT.AS_CHECKLIST_SERVICE.CKLST_ARTCL] as const;
|
||||
|
||||
export function useCklstMngPage(params: CklstMngSearchParams) {
|
||||
return useQuery({
|
||||
queryKey: [...cklstMngBaseKey, "page", params],
|
||||
queryFn: () => cklstMngService.findPage(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useCklstMng(cklstSn: number | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: [...cklstMngBaseKey, cklstSn],
|
||||
queryFn: () => cklstMngService.findById(cklstSn!),
|
||||
enabled: cklstSn != null,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateCklstMng() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (body: CklstMngSaveRequest) => cklstMngService.create(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: cklstMngBaseKey });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateCklstMng() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ cklstSn, body }: { cklstSn: number; body: CklstMngSaveRequest }) =>
|
||||
cklstMngService.update(cklstSn, body),
|
||||
onSuccess: (_data, { cklstSn }) => {
|
||||
queryClient.invalidateQueries({ queryKey: cklstMngBaseKey });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstMngBaseKey, cklstSn],
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteCklstMng() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (cklstSn: number) => cklstMngService.remove(cklstSn),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: cklstMngBaseKey });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useCklstArtclPage(params: CklstArtclSearchParams) {
|
||||
const { cklstSn } = params;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [...cklstArtclBaseKey, "page", params],
|
||||
queryFn: () => cklstArtclService.findPage(params),
|
||||
enabled: cklstSn != null,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCklstArtclList(cklstSn: number | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: [...cklstArtclBaseKey, "by-cklst", cklstSn],
|
||||
queryFn: () => cklstArtclService.findByCklstSn(cklstSn!),
|
||||
enabled: cklstSn != null,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCklstArtcl(params: {
|
||||
cklstArtclSn: number | null | undefined;
|
||||
cklstSn: number | null | undefined;
|
||||
}) {
|
||||
const { cklstArtclSn, cklstSn } = params;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [...cklstArtclBaseKey, cklstArtclSn, cklstSn],
|
||||
queryFn: () => cklstArtclService.findById(cklstArtclSn!, cklstSn!),
|
||||
enabled: cklstArtclSn != null && cklstSn != null,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateCklstArtcl() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (body: CklstArtclSaveRequest) => cklstArtclService.create(body),
|
||||
onSuccess: (_data, { cklstSn }) => {
|
||||
queryClient.invalidateQueries({ queryKey: cklstArtclBaseKey });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, "page", { cklstSn }],
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, "by-cklst", cklstSn],
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateCklstArtcl() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
cklstArtclSn,
|
||||
cklstSn,
|
||||
body,
|
||||
}: {
|
||||
cklstArtclSn: number;
|
||||
cklstSn: number;
|
||||
body: CklstArtclUpdateRequest;
|
||||
}) => cklstArtclService.update(cklstArtclSn, cklstSn, body),
|
||||
onSuccess: (_data, { cklstArtclSn, cklstSn }) => {
|
||||
queryClient.invalidateQueries({ queryKey: cklstArtclBaseKey });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, cklstArtclSn, cklstSn],
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, "page", { cklstSn }],
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, "by-cklst", cklstSn],
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteCklstArtcl() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
cklstArtclSn,
|
||||
cklstSn,
|
||||
}: {
|
||||
cklstArtclSn: number;
|
||||
cklstSn: number;
|
||||
}) => cklstArtclService.remove(cklstArtclSn, cklstSn),
|
||||
onSuccess: (_data, { cklstSn }) => {
|
||||
queryClient.invalidateQueries({ queryKey: cklstArtclBaseKey });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, "page", { cklstSn }],
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...cklstArtclBaseKey, "by-cklst", cklstSn],
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
export { cklstArtclService } from "./api/cklst-artcl-service";
|
||||
export { cklstMngService } from "./api/cklst-mng-service";
|
||||
export {
|
||||
useCklstArtcl,
|
||||
useCklstArtclList,
|
||||
useCklstArtclPage,
|
||||
useCklstMng,
|
||||
useCklstMngPage,
|
||||
useCreateCklstArtcl,
|
||||
useCreateCklstMng,
|
||||
useDeleteCklstArtcl,
|
||||
useDeleteCklstMng,
|
||||
useUpdateCklstArtcl,
|
||||
useUpdateCklstMng,
|
||||
} from "./api/queries";
|
||||
export type {
|
||||
CklstArtcl,
|
||||
CklstArtclId,
|
||||
CklstArtclSaveRequest,
|
||||
CklstArtclSearchParams,
|
||||
CklstArtclService,
|
||||
CklstArtclUpdateRequest,
|
||||
} from "./model/cklst-artcl-interface";
|
||||
export type {
|
||||
CklstMng,
|
||||
CklstMngSaveRequest,
|
||||
CklstMngSearchParams,
|
||||
CklstMngService,
|
||||
} from "./model/cklst-mng-interface";
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { PageableParams, PageResponse } from "@/shared/model";
|
||||
|
||||
export interface CklstArtclId {
|
||||
cklstArtclSn: number;
|
||||
cklstSn: number;
|
||||
}
|
||||
|
||||
export interface CklstArtcl {
|
||||
cklstArtclSn: number;
|
||||
cklstSn: number;
|
||||
cklstArtclNm?: string;
|
||||
useYn?: "Y" | "N";
|
||||
rgtr?: string;
|
||||
rgtrNm?: string;
|
||||
mdfr?: string;
|
||||
regDt?: string;
|
||||
mdfcnDt?: string;
|
||||
}
|
||||
|
||||
export interface CklstArtclSearchParams extends PageableParams {
|
||||
cklstSn?: number;
|
||||
cklstArtclNm?: string;
|
||||
useYn?: "Y" | "N";
|
||||
}
|
||||
|
||||
export interface CklstArtclSaveRequest {
|
||||
cklstSn: number;
|
||||
cklstArtclNm?: string;
|
||||
useYn?: "Y" | "N";
|
||||
}
|
||||
|
||||
export interface CklstArtclUpdateRequest {
|
||||
cklstArtclNm?: string;
|
||||
useYn?: "Y" | "N";
|
||||
}
|
||||
|
||||
export interface CklstArtclService {
|
||||
findPage(params: CklstArtclSearchParams): Promise<PageResponse<CklstArtcl>>;
|
||||
findByCklstSn(cklstSn: number): Promise<CklstArtcl[]>;
|
||||
findById(cklstArtclSn: number, cklstSn: number): Promise<CklstArtcl>;
|
||||
create(body: CklstArtclSaveRequest): Promise<CklstArtclId>;
|
||||
update(
|
||||
cklstArtclSn: number,
|
||||
cklstSn: number,
|
||||
body: CklstArtclUpdateRequest,
|
||||
): Promise<CklstArtclId>;
|
||||
remove(cklstArtclSn: number, cklstSn: number): Promise<CklstArtclId>;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { PageableParams, PageResponse } from "@/shared/model";
|
||||
|
||||
export interface CklstMng {
|
||||
cklstSn: number;
|
||||
cklstNm: string;
|
||||
taskSeComCd: string;
|
||||
useYn?: "Y" | "N";
|
||||
docSeComCd?: string;
|
||||
rgtr?: string;
|
||||
rgtrNm?: string;
|
||||
mdfr?: string;
|
||||
regDt?: string;
|
||||
mdfcnDt?: string;
|
||||
}
|
||||
|
||||
export interface CklstMngSearchParams extends PageableParams {
|
||||
cklstNm?: string;
|
||||
taskSeComCd?: string;
|
||||
useYn?: "Y" | "N";
|
||||
docSeComCd?: string;
|
||||
}
|
||||
|
||||
export interface CklstMngSaveRequest {
|
||||
cklstNm: string;
|
||||
taskSeComCd: string;
|
||||
useYn?: "Y" | "N";
|
||||
docSeComCd?: string;
|
||||
}
|
||||
|
||||
export interface CklstMngService {
|
||||
findPage(params: CklstMngSearchParams): Promise<PageResponse<CklstMng>>;
|
||||
findById(cklstSn: number): Promise<CklstMng>;
|
||||
create(body: CklstMngSaveRequest): Promise<number>;
|
||||
update(cklstSn: number, body: CklstMngSaveRequest): Promise<number>;
|
||||
remove(cklstSn: number): Promise<number>;
|
||||
}
|
||||
@@ -11,6 +11,10 @@ export const ENDPOINT = {
|
||||
ELAPR_TMPLT: "/as-elapr-service/api/v1/elapr-tmplt",
|
||||
ELAPR_APLN: "/as-elapr-service/api/v1/elapr-apln",
|
||||
},
|
||||
AS_CHECKLIST_SERVICE: {
|
||||
CKLST: "/as-checklist-service/api/v1/cklst",
|
||||
CKLST_ARTCL: "/as-checklist-service/api/v1/cklst-artcl",
|
||||
},
|
||||
CMS_SERVICE: {
|
||||
CODE: "/cms-service/api/v1/code/cache",
|
||||
MENU_ROLES: "/cms-service/api/v1/menu-roles",
|
||||
|
||||
Reference in New Issue
Block a user