ff-admin-server/src/service/membershipStatusService.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-09-04 12:01:22 +00:00
import { dataSource } from "../data-source";
import { membershipStatus } from "../entity/membershipStatus";
import InternalException from "../exceptions/internalException";
2024-09-15 12:03:15 +00:00
import { membership } from "../entity/membership";
2024-09-04 12:01:22 +00:00
export default abstract class MembershipStatusService {
/**
* @description get all membershipStatuss
* @returns {Promise<Array<membershipStatus>>}
*/
static async getAll(): Promise<Array<membershipStatus>> {
return await dataSource
.getRepository(membershipStatus)
.createQueryBuilder("membershipStatus")
.getMany()
.then((res) => {
return res;
})
2024-09-06 08:08:19 +00:00
.catch((err) => {
throw new InternalException("membershipStatuss not found", err);
2024-09-04 12:01:22 +00:00
});
}
/**
* @description get membershipStatus by id
* @returns {Promise<membershipStatus>}
*/
static async getById(id: number): Promise<membershipStatus> {
return await dataSource
.getRepository(membershipStatus)
.createQueryBuilder("membershipStatus")
2024-09-15 12:03:15 +00:00
.where("membershipStatus.id = :id", { id: id })
2024-09-04 12:01:22 +00:00
.getOneOrFail()
.then((res) => {
return res;
})
2024-09-06 08:08:19 +00:00
.catch((err) => {
throw new InternalException("membershipStatus not found by id", err);
2024-09-04 12:01:22 +00:00
});
}
}