education controller, service, command
This commit is contained in:
parent
5368a96d0f
commit
fded8a663a
29 changed files with 884 additions and 5 deletions
49
src/service/club/member/memberEducationService.ts
Normal file
49
src/service/club/member/memberEducationService.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberEducations } from "../../../entity/club/member/memberEducations";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
|
||||
export default abstract class MemberEducationService {
|
||||
/**
|
||||
* @description get all by member id
|
||||
* @param {string} memberId
|
||||
* @returns {Promise<Array<memberEducations>>}
|
||||
*/
|
||||
static async getAll(memberId: string): Promise<Array<memberEducations>> {
|
||||
return await dataSource
|
||||
.getRepository(memberEducations)
|
||||
.createQueryBuilder("memberEducations")
|
||||
.leftJoinAndSelect("memberEducations.education", "education")
|
||||
.where("memberEducations.memberId = :memberId", { memberId: memberId })
|
||||
.orderBy("education.education", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "memberEducations", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get by memberId and recordId
|
||||
* @param {string} memberId
|
||||
* @param {number} recordId
|
||||
* @returns {Promise<Array<member>>}
|
||||
*/
|
||||
static async getById(memberId: string, recordId: number): Promise<memberEducations> {
|
||||
return await dataSource
|
||||
.getRepository(memberEducations)
|
||||
.createQueryBuilder("memberEducations")
|
||||
.leftJoinAndSelect("memberEducations.education", "education")
|
||||
.where("memberEducations.memberId = :memberId", { memberId: memberId })
|
||||
.andWhere("memberEducations.id = :recordId", { recordId: recordId })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "memberEducations", err);
|
||||
});
|
||||
}
|
||||
}
|
41
src/service/configuration/education.ts
Normal file
41
src/service/configuration/education.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { dataSource } from "../../data-source";
|
||||
import { education } from "../../entity/configuration/education";
|
||||
import DatabaseActionException from "../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class EducationService {
|
||||
/**
|
||||
* @description get all educations
|
||||
* @returns {Promise<Array<education>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<education>> {
|
||||
return await dataSource
|
||||
.getRepository(education)
|
||||
.createQueryBuilder("education")
|
||||
.orderBy("education", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "education", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get education by id
|
||||
* @returns {Promise<education>}
|
||||
*/
|
||||
static async getById(id: number): Promise<education> {
|
||||
return await dataSource
|
||||
.getRepository(education)
|
||||
.createQueryBuilder("education")
|
||||
.where("education.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "education", err);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue