change folder structure
This commit is contained in:
parent
a332e4d779
commit
a09c75a998
167 changed files with 262 additions and 246 deletions
42
src/service/configuration/salutationService.ts
Normal file
42
src/service/configuration/salutationService.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import { dataSource } from "../../data-source";
|
||||
import { salutation } from "../../entity/configuration/salutation";
|
||||
import DatabaseActionException from "../../exceptions/databaseActionException";
|
||||
import InternalException from "../../exceptions/internalException";
|
||||
|
||||
export default abstract class SalutationService {
|
||||
/**
|
||||
* @description get all salutations
|
||||
* @returns {Promise<Array<salutation>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<salutation>> {
|
||||
return await dataSource
|
||||
.getRepository(salutation)
|
||||
.createQueryBuilder("salutation")
|
||||
.orderBy("salutation", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "salutation", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get salutation by id
|
||||
* @returns {Promise<salutation>}
|
||||
*/
|
||||
static async getById(id: number): Promise<salutation> {
|
||||
return await dataSource
|
||||
.getRepository(salutation)
|
||||
.createQueryBuilder("salutation")
|
||||
.where("salutation.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "salutation", err);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue