From 8c7e18637a4eb99c638d4ef5230f19c00fb90ccf Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 16 Jul 2025 14:51:05 +0200 Subject: [PATCH] =?UTF-8?q?refactor(document-service):=20Umbenennung=20der?= =?UTF-8?q?=20Methode=20`getDocuments`=20in=20`get`=20f=C3=BCr=20Konsisten?= =?UTF-8?q?z=20=20-=20Die=20Methode=20`getDocuments`=20in=20`DocService`?= =?UTF-8?q?=20wurde=20in=20`get`=20umbenannt,=20um=20die=20Verwendung=20zu?= =?UTF-8?q?=20vereinfachen=20und=20die=20Konsistenz=20der=20Namensgebung?= =?UTF-8?q?=20bei=20allen=20Abfragemethoden=20(`getDocumentById`,=20`getDo?= =?UTF-8?q?cumentByName`,=20`getDocumentByAttributes`)=20zu=20verbessern.?= =?UTF-8?q?=20=20-=20Keine=20=C3=84nderungen=20an=20der=20Funktionalit?= =?UTF-8?q?=C3=A4t=20oder=20dem=20externen=20Verhalten.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/dd-hub-react/src/_mock/_data.ts | 1 + .../src/sections/document/view/doc-search-view.tsx | 4 ++-- .../dd-hub-react/src/services/document-service.ts | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/client/dd-hub-react/src/_mock/_data.ts b/src/client/dd-hub-react/src/_mock/_data.ts index c37fc23..99b29c5 100644 --- a/src/client/dd-hub-react/src/_mock/_data.ts +++ b/src/client/dd-hub-react/src/_mock/_data.ts @@ -559,5 +559,6 @@ export function _genFile(name: string): Uint8Array | undefined { case "report.docx": return base64ToUint8Array(_base64.report_docx); default: + return undefined; } } \ No newline at end of file diff --git a/src/client/dd-hub-react/src/sections/document/view/doc-search-view.tsx b/src/client/dd-hub-react/src/sections/document/view/doc-search-view.tsx index fa1a779..915d1b1 100644 --- a/src/client/dd-hub-react/src/sections/document/view/doc-search-view.tsx +++ b/src/client/dd-hub-react/src/sections/document/view/doc-search-view.tsx @@ -40,7 +40,7 @@ export function DocSearchView() { const [docs, setDocs] = useState([]); useEffect(() => { - docService.getDocuments({}).then((res) => { + docService.get({}).then((res) => { setDocs(res); }); }, []); @@ -49,7 +49,7 @@ export function DocSearchView() { const [attributes, setAttributes] = useState>({}); useEffect(() => { - docService.getDocumentByAttributes(attributes).then(setDocs); + docService.getByAttribute(attributes).then(setDocs); }, [attributes]); function setAttribute(name: string, serilizedValue: string) { diff --git a/src/client/dd-hub-react/src/services/document-service.ts b/src/client/dd-hub-react/src/services/document-service.ts index 7487369..1aa9c38 100644 --- a/src/client/dd-hub-react/src/services/document-service.ts +++ b/src/client/dd-hub-react/src/services/document-service.ts @@ -78,7 +78,7 @@ export type DocQuery = { } class DocService { - getDocuments(query: DocQuery | undefined = undefined): Promise { + get(query: DocQuery | undefined = undefined): Promise { let documents = _documents; if (query?.id) @@ -95,16 +95,16 @@ class DocService { return Promise.resolve(documents); } - getDocumentById(id: number): Promise { - return this.getDocuments({ id: id }); + getById(id: number): Promise { + return this.get({ id: id }); } - getDocumentByName(name: string): Promise { - return this.getDocuments({ name: name }); + getByName(name: string): Promise { + return this.get({ name: name }); } - getDocumentByAttributes(attributes: Record): Promise { - return this.getDocuments({ attributes: attributes }); + getByAttribute(attributes: Record): Promise { + return this.get({ attributes: attributes }); } }