2025-01-05 14:14:00 +01:00
|
|
|
import { dataSource } from "../../data-source";
|
2025-02-15 10:59:54 +01:00
|
|
|
import { template } from "../../entity/configuration/template";
|
2025-01-05 14:14:00 +01:00
|
|
|
import { member } from "../../entity/club/member/member";
|
|
|
|
import InternalException from "../../exceptions/internalException";
|
2025-01-29 09:42:22 +01:00
|
|
|
import DatabaseActionException from "../../exceptions/databaseActionException";
|
2024-12-22 10:29:42 +01:00
|
|
|
|
|
|
|
export default abstract class TemplateService {
|
|
|
|
/**
|
|
|
|
* @description get all templates
|
|
|
|
* @returns {Promise<Array<template>>}
|
|
|
|
*/
|
|
|
|
static async getAll(): Promise<Array<template>> {
|
|
|
|
return await dataSource
|
|
|
|
.getRepository(template)
|
|
|
|
.createQueryBuilder("template")
|
2025-01-12 18:17:54 +01:00
|
|
|
.orderBy("template", "ASC")
|
2024-12-22 10:29:42 +01:00
|
|
|
.getMany()
|
|
|
|
.then((res) => {
|
|
|
|
return res;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2025-01-29 09:42:22 +01:00
|
|
|
throw new DatabaseActionException("SELECT", "template", err);
|
2024-12-22 10:29:42 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description get template by id
|
|
|
|
* @returns {Promise<template>}
|
|
|
|
*/
|
|
|
|
static async getById(id: number): Promise<template> {
|
|
|
|
return await dataSource
|
|
|
|
.getRepository(template)
|
|
|
|
.createQueryBuilder("template")
|
|
|
|
.where("template.id = :id", { id: id })
|
|
|
|
.getOneOrFail()
|
|
|
|
.then((res) => {
|
|
|
|
return res;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2025-01-29 09:42:22 +01:00
|
|
|
throw new DatabaseActionException("SELECT", "template", err);
|
2024-12-22 10:29:42 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|