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

41 lines
1.2 KiB
TypeScript

import { dataSource } from "../data-source";
import { membershipStatus } from "../entity/membershipStatus";
import InternalException from "../exceptions/internalException";
import { membership } from "../entity/membership";
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;
})
.catch((err) => {
throw new InternalException("membershipStatuss not found", err);
});
}
/**
* @description get membershipStatus by id
* @returns {Promise<membershipStatus>}
*/
static async getById(id: number): Promise<membershipStatus> {
return await dataSource
.getRepository(membershipStatus)
.createQueryBuilder("membershipStatus")
.where("membershipStatus.id = :id", { id: id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch((err) => {
throw new InternalException("membershipStatus not found by id", err);
});
}
}