67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import {
|
|
type Organization,
|
|
type OrganizationFormData,
|
|
type OrganizationService,
|
|
type OrganizationTree,
|
|
type OrganizationTreeForDnd,
|
|
} from "../model/organization-interface";
|
|
|
|
export class OrganizationApiService implements OrganizationService {
|
|
public async getOrganizationsTreeList(): Promise<OrganizationTree[]> {
|
|
const response = await client.get<OrganizationTree[]>(
|
|
`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}/tree`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async getOrganizationInfo(ognzSn: number): Promise<Organization> {
|
|
const response = await client.get<Organization>(
|
|
`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}/${ognzSn}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async createOrganization(data: OrganizationFormData): Promise<void> {
|
|
await client.post<void>(`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}`, data);
|
|
}
|
|
|
|
public async deleteOrganization(ognzSn: number): Promise<void> {
|
|
await client.delete<void>(
|
|
`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}/${ognzSn}`,
|
|
);
|
|
}
|
|
|
|
public async updateOrganizationName(
|
|
ognzSn: number,
|
|
name: string,
|
|
): Promise<Organization> {
|
|
const response = await client.put<Organization>(
|
|
`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}/${ognzSn}/${name}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async updateOrganization(
|
|
ognzSn: number,
|
|
data: OrganizationFormData,
|
|
): Promise<void> {
|
|
await client.put<void>(
|
|
`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}/${ognzSn}`,
|
|
data,
|
|
);
|
|
}
|
|
|
|
public async updateOrganizationByDnd(
|
|
data: OrganizationTreeForDnd,
|
|
): Promise<void> {
|
|
await client.put<void>(
|
|
`${ENDPOINT.CMS_SERVICE.ORGANIZATIONS}/dnd/tree`,
|
|
data,
|
|
);
|
|
}
|
|
}
|
|
|
|
export const OrganizationApi = new OrganizationApiService();
|