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:
parent
a88238f209
commit
8c7e18637a
@ -559,5 +559,6 @@ export function _genFile(name: string): Uint8Array | undefined {
|
||||
case "report.docx":
|
||||
return base64ToUint8Array(_base64.report_docx);
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,7 @@ export function DocSearchView() {
|
||||
const [docs, setDocs] = useState<Doc[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
docService.getDocuments({}).then((res) => {
|
||||
docService.get({}).then((res) => {
|
||||
setDocs(res);
|
||||
});
|
||||
}, []);
|
||||
@ -49,7 +49,7 @@ export function DocSearchView() {
|
||||
const [attributes, setAttributes] = useState<Record<string, string>>({});
|
||||
|
||||
useEffect(() => {
|
||||
docService.getDocumentByAttributes(attributes).then(setDocs);
|
||||
docService.getByAttribute(attributes).then(setDocs);
|
||||
}, [attributes]);
|
||||
|
||||
function setAttribute(name: string, serilizedValue: string) {
|
||||
|
||||
@ -78,7 +78,7 @@ export type DocQuery = {
|
||||
}
|
||||
|
||||
class DocService {
|
||||
getDocuments(query: DocQuery | undefined = undefined): Promise<Doc[]> {
|
||||
get(query: DocQuery | undefined = undefined): Promise<Doc[]> {
|
||||
let documents = _documents;
|
||||
|
||||
if (query?.id)
|
||||
@ -95,16 +95,16 @@ class DocService {
|
||||
return Promise.resolve(documents);
|
||||
}
|
||||
|
||||
getDocumentById(id: number): Promise<Doc[]> {
|
||||
return this.getDocuments({ id: id });
|
||||
getById(id: number): Promise<Doc[]> {
|
||||
return this.get({ id: id });
|
||||
}
|
||||
|
||||
getDocumentByName(name: string): Promise<Doc[]> {
|
||||
return this.getDocuments({ name: name });
|
||||
getByName(name: string): Promise<Doc[]> {
|
||||
return this.get({ name: name });
|
||||
}
|
||||
|
||||
getDocumentByAttributes(attributes: Record<string, string>): Promise<Doc[]> {
|
||||
return this.getDocuments({ attributes: attributes });
|
||||
getByAttribute(attributes: Record<string, string>): Promise<Doc[]> {
|
||||
return this.get({ attributes: attributes });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user