260316:1117 20260316:1100 Refactor UUID
Build and Deploy / deploy (push) Successful in 9m24s

This commit is contained in:
admin
2026-03-16 11:17:15 +07:00
parent b93cd91325
commit c5c3ed9016
92 changed files with 1726 additions and 620 deletions
+3
View File
@@ -3,6 +3,7 @@ import { NotificationResponse } from "@/types/notification";
// Mock Data
let mockNotifications = [
{
uuid: "019575a0-0001-7000-8000-000000000001",
notificationId: 1,
title: "RFA Approved",
message: "RFA-001 has been approved by the Project Manager.",
@@ -12,6 +13,7 @@ let mockNotifications = [
link: "/rfas/1",
},
{
uuid: "019575a0-0002-7000-8000-000000000002",
notificationId: 2,
title: "New Correspondence",
message: "You have received a new correspondence from Contractor A.",
@@ -21,6 +23,7 @@ let mockNotifications = [
link: "/correspondences/3",
},
{
uuid: "019575a0-0003-7000-8000-000000000003",
notificationId: 3,
title: "Drawing Revision Required",
message: "Drawing S-201 requires revision based on recent comments.",
@@ -18,8 +18,8 @@ export const asBuiltDrawingService = {
/**
* Get details by ID
*/
getById: async (id: string | number) => {
const response = await apiClient.get(`/drawings/asbuilt/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/drawings/asbuilt/${uuid}`);
return response.data;
},
@@ -34,8 +34,8 @@ export const asBuiltDrawingService = {
/**
* Create New Revision
*/
createRevision: async (id: string | number, data: CreateAsBuiltDrawingRevisionDto) => {
const response = await apiClient.post(`/drawings/asbuilt/${id}/revisions`, data);
createRevision: async (uuid: string, data: CreateAsBuiltDrawingRevisionDto) => {
const response = await apiClient.post(`/drawings/asbuilt/${uuid}/revisions`, data);
return response.data;
},
};
+6 -6
View File
@@ -19,9 +19,9 @@ export const circulationService = {
/**
* ดึงรายละเอียดใบเวียนตาม ID
*/
getById: async (id: string | number) => {
// GET /circulations/:id
const response = await apiClient.get(`/circulations/${id}`);
getByUuid: async (uuid: string) => {
// GET /circulations/:uuid
const response = await apiClient.get(`/circulations/${uuid}`);
return response.data;
},
@@ -47,8 +47,8 @@ export const circulationService = {
/**
* ลบ/ยกเลิกใบเวียน
*/
delete: async (id: string | number) => {
const response = await apiClient.delete(`/circulations/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/circulations/${uuid}`);
return response.data;
}
};
};
@@ -17,8 +17,8 @@ export const contractDrawingService = {
/**
* ดึงรายละเอียดตาม ID
*/
getById: async (id: string | number) => {
const response = await apiClient.get(`/drawings/contract/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/drawings/contract/${uuid}`);
return response.data;
},
@@ -33,16 +33,16 @@ export const contractDrawingService = {
/**
* แก้ไขข้อมูลแบบสัญญา
*/
update: async (id: string | number, data: UpdateContractDrawingDto) => {
const response = await apiClient.put(`/drawings/contract/${id}`, data);
update: async (uuid: string, data: UpdateContractDrawingDto) => {
const response = await apiClient.put(`/drawings/contract/${uuid}`, data);
return response.data;
},
/**
* ลบแบบสัญญา (Soft Delete)
*/
delete: async (id: string | number) => {
const response = await apiClient.delete(`/drawings/contract/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/drawings/contract/${uuid}`);
return response.data;
},
};
+10 -10
View File
@@ -19,11 +19,11 @@ export const contractService = {
},
/**
* Get contract by ID
* GET /contracts/:id
* Get contract by UUID
* GET /contracts/:uuid
*/
getById: async (id: number) => {
const response = await apiClient.get(`/contracts/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/contracts/${uuid}`);
return response.data;
},
@@ -38,19 +38,19 @@ export const contractService = {
/**
* Update contract
* PATCH /contracts/:id
* PATCH /contracts/:uuid
*/
update: async (id: number, data: UpdateContractDto) => {
const response = await apiClient.patch(`/contracts/${id}`, data);
update: async (uuid: string, data: UpdateContractDto) => {
const response = await apiClient.patch(`/contracts/${uuid}`, data);
return response.data;
},
/**
* Delete contract
* DELETE /contracts/:id
* DELETE /contracts/:uuid
*/
delete: async (id: number) => {
const response = await apiClient.delete(`/contracts/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/contracts/${uuid}`);
return response.data;
},
};
+14 -14
View File
@@ -15,8 +15,8 @@ export const correspondenceService = {
return response.data;
},
getById: async (id: string | number) => {
const response = await apiClient.get(`/correspondences/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/correspondences/${uuid}`);
return response.data.data; // Unwrap NestJS Interceptor 'data' wrapper
},
@@ -25,13 +25,13 @@ export const correspondenceService = {
return response.data;
},
update: async (id: string | number, data: Partial<CreateCorrespondenceDto>) => {
const response = await apiClient.put(`/correspondences/${id}`, data);
update: async (uuid: string, data: Partial<CreateCorrespondenceDto>) => {
const response = await apiClient.put(`/correspondences/${uuid}`, data);
return response.data;
},
delete: async (id: string | number) => {
const response = await apiClient.delete(`/correspondences/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/correspondences/${uuid}`);
return response.data;
},
@@ -40,33 +40,33 @@ export const correspondenceService = {
/**
* ส่งเอกสาร (Submit) เพื่อเริ่ม Workflow
*/
submit: async (id: string | number, data: SubmitCorrespondenceDto) => {
const response = await apiClient.post(`/correspondences/${id}/submit`, data);
submit: async (uuid: string, data: SubmitCorrespondenceDto) => {
const response = await apiClient.post(`/correspondences/${uuid}/submit`, data);
return response.data;
},
/**
* ดำเนินการ Workflow (เช่น Approve, Reject) ในขั้นตอนปัจจุบัน
*/
processWorkflow: async (id: string | number, data: WorkflowActionDto) => {
const response = await apiClient.post(`/correspondences/${id}/workflow`, data);
processWorkflow: async (uuid: string, data: WorkflowActionDto) => {
const response = await apiClient.post(`/correspondences/${uuid}/workflow`, data);
return response.data;
},
/**
* เพิ่มเอกสารอ้างอิง
*/
addReference: async (id: string | number, data: AddReferenceDto) => {
const response = await apiClient.post(`/correspondences/${id}/references`, data);
addReference: async (uuid: string, data: AddReferenceDto) => {
const response = await apiClient.post(`/correspondences/${uuid}/references`, data);
return response.data;
},
/**
* ลบเอกสารอ้างอิง
*/
removeReference: async (id: string | number, data: RemoveReferenceDto) => {
removeReference: async (uuid: string, data: RemoveReferenceDto) => {
// ใช้ DELETE method โดยส่ง body ไปด้วย (axios รองรับผ่าน config.data)
const response = await apiClient.delete(`/correspondences/${id}/references`, {
const response = await apiClient.delete(`/correspondences/${uuid}/references`, {
data: data
});
return response.data;
+4 -4
View File
@@ -78,14 +78,14 @@ export const masterDataService = {
},
/** แก้ไของค์กร */
updateOrganization: async (id: number, data: UpdateOrganizationDto) => {
const response = await apiClient.put(`/organizations/${id}`, data);
updateOrganization: async (uuid: string, data: UpdateOrganizationDto) => {
const response = await apiClient.put(`/organizations/${uuid}`, data);
return response.data;
},
/** ลบองค์กร */
deleteOrganization: async (id: number) => {
const response = await apiClient.delete(`/organizations/${id}`);
deleteOrganization: async (uuid: string) => {
const response = await apiClient.delete(`/organizations/${uuid}`);
return response.data;
},
@@ -9,8 +9,8 @@ export const notificationService = {
return response.data;
},
markAsRead: async (id: number) => {
const response = await apiClient.patch(`/notifications/${id}/read`);
markAsRead: async (uuid: string) => {
const response = await apiClient.put(`/notifications/${uuid}/read`);
return response.data;
},
+10 -10
View File
@@ -20,11 +20,11 @@ export const organizationService = {
},
/**
* Get organization by ID
* GET /organizations/:id
* Get organization by UUID
* GET /organizations/:uuid
*/
getById: async (id: number) => {
const response = await apiClient.get(`/organizations/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/organizations/${uuid}`);
return response.data;
},
@@ -39,19 +39,19 @@ export const organizationService = {
/**
* Update organization
* PATCH /organizations/:id
* PATCH /organizations/:uuid
*/
update: async (id: number, data: UpdateOrganizationDto) => {
const response = await apiClient.patch(`/organizations/${id}`, data);
update: async (uuid: string, data: UpdateOrganizationDto) => {
const response = await apiClient.patch(`/organizations/${uuid}`, data);
return response.data;
},
/**
* Delete organization
* DELETE /organizations/:id
* DELETE /organizations/:uuid
*/
delete: async (id: number) => {
const response = await apiClient.delete(`/organizations/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/organizations/${uuid}`);
return response.data;
},
};
+7 -7
View File
@@ -23,9 +23,9 @@ export const projectService = {
return response.data;
},
/** ดึงรายละเอียดโครงการตาม ID */
getById: async (id: string | number) => {
const response = await apiClient.get(`/projects/${id}`);
/** ดึงรายละเอียดโครงการตาม UUID */
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/projects/${uuid}`);
return response.data;
},
@@ -36,14 +36,14 @@ export const projectService = {
},
/** แก้ไขโครงการ */
update: async (id: string | number, data: UpdateProjectDto) => {
const response = await apiClient.put(`/projects/${id}`, data);
update: async (uuid: string, data: UpdateProjectDto) => {
const response = await apiClient.put(`/projects/${uuid}`, data);
return response.data;
},
/** ลบโครงการ (Soft Delete) */
delete: async (id: string | number) => {
const response = await apiClient.delete(`/projects/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/projects/${uuid}`);
return response.data;
},
@@ -18,8 +18,8 @@ export const shopDrawingService = {
/**
* ดึงรายละเอียดตาม ID (ควรได้ Revision History มาด้วย)
*/
getById: async (id: string | number) => {
const response = await apiClient.get(`/drawings/shop/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get(`/drawings/shop/${uuid}`);
return response.data;
},
@@ -34,8 +34,8 @@ export const shopDrawingService = {
/**
* สร้าง Revision ใหม่สำหรับ Shop Drawing เดิม
*/
createRevision: async (id: string | number, data: CreateShopDrawingRevisionDto) => {
const response = await apiClient.post(`/drawings/shop/${id}/revisions`, data);
createRevision: async (uuid: string, data: CreateShopDrawingRevisionDto) => {
const response = await apiClient.post(`/drawings/shop/${uuid}/revisions`, data);
return response.data;
},
};
+8 -7
View File
@@ -12,7 +12,8 @@ interface RawUser {
const transformUser = (user: RawUser): User => {
return {
...(user as unknown as User),
userId: (user.user_id ?? user.userId) as number,
uuid: (user.uuid as string) ?? '',
userId: (user.user_id ?? user.userId) as number | undefined,
roles: (user.assignments?.map((a) => a.role) ?? []) as User['roles'],
};
};
@@ -45,8 +46,8 @@ export const userService = {
return response.data;
},
getById: async (id: number) => {
const response = await apiClient.get<RawUser>(`/users/${id}`);
getByUuid: async (uuid: string) => {
const response = await apiClient.get<RawUser>(`/users/${uuid}`);
return transformUser(response.data);
},
@@ -55,13 +56,13 @@ export const userService = {
return transformUser(response.data);
},
update: async (id: number, data: UpdateUserDto) => {
const response = await apiClient.put<RawUser>(`/users/${id}`, data);
update: async (uuid: string, data: UpdateUserDto) => {
const response = await apiClient.put<RawUser>(`/users/${uuid}`, data);
return transformUser(response.data);
},
delete: async (id: number) => {
const response = await apiClient.delete(`/users/${id}`);
delete: async (uuid: string) => {
const response = await apiClient.delete(`/users/${uuid}`);
return response.data;
},