refactor(document-service): Umbenennung der Methode getDocuments in get für Konsistenz

- Die Methode `getDocuments` in `DocService` wurde in `get` umbenannt, um die Verwendung zu vereinfachen und die Konsistenz der Namensgebung bei allen Abfragemethoden (`getDocumentById`, `getDocumentByName`, `getDocumentByAttributes`) zu verbessern.
 - Keine Änderungen an der Funktionalität oder dem externen Verhalten.
This commit is contained in:
tekh 2025-07-16 14:51:05 +02:00
parent a88238f209
commit 8c7e18637a
3 changed files with 10 additions and 9 deletions

View File

@ -559,5 +559,6 @@ export function _genFile(name: string): Uint8Array | undefined {
case "report.docx": case "report.docx":
return base64ToUint8Array(_base64.report_docx); return base64ToUint8Array(_base64.report_docx);
default: default:
return undefined;
} }
} }

View File

@ -40,7 +40,7 @@ export function DocSearchView() {
const [docs, setDocs] = useState<Doc[]>([]); const [docs, setDocs] = useState<Doc[]>([]);
useEffect(() => { useEffect(() => {
docService.getDocuments({}).then((res) => { docService.get({}).then((res) => {
setDocs(res); setDocs(res);
}); });
}, []); }, []);
@ -49,7 +49,7 @@ export function DocSearchView() {
const [attributes, setAttributes] = useState<Record<string, string>>({}); const [attributes, setAttributes] = useState<Record<string, string>>({});
useEffect(() => { useEffect(() => {
docService.getDocumentByAttributes(attributes).then(setDocs); docService.getByAttribute(attributes).then(setDocs);
}, [attributes]); }, [attributes]);
function setAttribute(name: string, serilizedValue: string) { function setAttribute(name: string, serilizedValue: string) {

View File

@ -78,7 +78,7 @@ export type DocQuery = {
} }
class DocService { class DocService {
getDocuments(query: DocQuery | undefined = undefined): Promise<Doc[]> { get(query: DocQuery | undefined = undefined): Promise<Doc[]> {
let documents = _documents; let documents = _documents;
if (query?.id) if (query?.id)
@ -95,16 +95,16 @@ class DocService {
return Promise.resolve(documents); return Promise.resolve(documents);
} }
getDocumentById(id: number): Promise<Doc[]> { getById(id: number): Promise<Doc[]> {
return this.getDocuments({ id: id }); return this.get({ id: id });
} }
getDocumentByName(name: string): Promise<Doc[]> { getByName(name: string): Promise<Doc[]> {
return this.getDocuments({ name: name }); return this.get({ name: name });
} }
getDocumentByAttributes(attributes: Record<string, string>): Promise<Doc[]> { getByAttribute(attributes: Record<string, string>): Promise<Doc[]> {
return this.getDocuments({ attributes: attributes }); return this.get({ attributes: attributes });
} }
} }