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

61 lines
1.9 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 { user } from "../entity/user";
import InternalException from "../exceptions/internalException";
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")
.andWhere("membershipStatus.id = :id", { id: id })
.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
});
}
// /**
// * @description get members assigned to membershipStatus
// * @returns {Promise<Array<members>>}
// */
// static async getMembersBymembershipStatusId(id: number): Promise<Array<members>> {
// return await dataSource
// .getRepository(membershipStatus)
// .createQueryBuilder("membershipStatus")
// .leftJoinAndSelect("membershipStatus.members", "members")
// .andWhere("membershipStatus.id = :id", { id: id })
// .getOneOrFail()
// .then((res) => {
// return [];
// })
2024-09-06 08:08:19 +00:00
// .catch((err) => {
// throw new InternalException("membershipStatus assigned members not found by id", err);
2024-09-04 12:01:22 +00:00
// });
// }
}