-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
214 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@host = 127.0.0.1 | ||
@port = 9090 | ||
|
||
### | ||
|
||
GET http://{{host}}:{{port}}/docs HTTP/1.1 | ||
|
||
### | ||
|
||
POST http://{{host}}:{{port}}/api/organisation HTTP/1.1 | ||
Content-Type: application/json | ||
|
||
{ | ||
"kennung": "NI-HK-KGS", | ||
"name": "Kooperative Gesamtschule Schwarmstedt", | ||
"namensergaenzung": "string", | ||
"kuerzel": "KGS", | ||
"typ": "SCHULE" | ||
} | ||
|
||
### | ||
|
||
@orgId = 78d9ae41-a101-4947-82cc-b0545d2b2e85 | ||
|
||
GET http://{{host}}:{{port}}/api/organisation/{{orgId}} HTTP/1.1 | ||
|
||
### | ||
|
||
GET http://localhost:8080/metrics HTTP/1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,28 @@ | ||
/* eslint-disable @typescript-eslint/explicit-member-accessibility */ | ||
|
||
// TODO should Refactor with german | ||
import { Scope } from '../../../shared/repo/scope.js'; | ||
import { EntityName } from '@mikro-orm/core'; | ||
import { ScopeBase, ScopeOperator } from '../../../shared/persistence/index.js'; | ||
import { PersonEntity } from './person.entity.js'; | ||
export class PersonScope extends Scope<PersonEntity> { | ||
byFirstName(firstName: string | undefined): this { | ||
if (firstName) { | ||
this.addQuery({ firstName: { $re: firstName } }); | ||
} | ||
return this; | ||
} | ||
|
||
byLastName(lastName: string | undefined): this { | ||
if (lastName) { | ||
this.addQuery({ lastName: { $re: lastName } }); | ||
} | ||
return this; | ||
} | ||
type SearchProps = { | ||
firstName?: string; | ||
lastName?: string; | ||
birthDate?: Date; | ||
}; | ||
|
||
byBirthDate(birthDate: Date | undefined): this { | ||
if (birthDate) { | ||
this.addQuery({ birthDate }); | ||
} | ||
return this; | ||
export class PersonScope extends ScopeBase<PersonEntity> { | ||
public override get entityName(): EntityName<PersonEntity> { | ||
return PersonEntity; | ||
} | ||
|
||
/* byBirthPlace(birthPlace: string | undefined): this { | ||
if (birthPlace) { | ||
this.addQuery({ birthPlace }); | ||
} | ||
public searchBy(searchProps: SearchProps): this { | ||
this.findBy( | ||
{ | ||
firstName: searchProps.firstName, | ||
lastName: searchProps.lastName, | ||
birthDate: searchProps.birthDate, | ||
}, | ||
ScopeOperator.AND, | ||
); | ||
|
||
return this; | ||
} */ | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface Paged<T> { | ||
/** | ||
* The number off items skipped from the start. | ||
*/ | ||
offset: number; | ||
|
||
/** | ||
* The maximal amount of items that can be fetched with one request. | ||
*/ | ||
limit: number; | ||
|
||
/** | ||
* The total amount of items tha can be fetched. | ||
*/ | ||
total: number; | ||
|
||
/** | ||
* The requested items. | ||
*/ | ||
items: T[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './repo-base.js'; | ||
export * from './scope-base.js'; | ||
export * from './scope.enums.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { AnyEntity, EntityName } from '@mikro-orm/core'; | ||
import { EntityManager } from '@mikro-orm/postgresql'; | ||
|
||
export abstract class RepoBase<T extends AnyEntity> { | ||
protected constructor(protected readonly em: EntityManager) {} | ||
|
||
public abstract get entityName(): EntityName<T>; | ||
|
||
public async findById(id: string): Promise<Option<PersonDo<true>>> { | ||
const person: Option<PersonEntity> = await this.em.findOne(this.entityName, { id }); | ||
if (person) { | ||
return this.mapper.map(person, PersonEntity, PersonDo); | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.