self defined value tables - getters

This commit is contained in:
Julian Krauser 2024-09-04 14:01:22 +02:00
parent c85f23ed73
commit ddb355836a
28 changed files with 1067 additions and 0 deletions

View file

@ -58,4 +58,21 @@ export default abstract class RefreshCommandHandler {
throw new InternalException("failed refresh removal");
});
}
/**
* @description delete expired
* @returns {Promise<any>}
*/
static async deleteExpired(): Promise<any> {
return await dataSource
.createQueryBuilder()
.delete()
.from(refresh)
.where("refresh.expiry < :expiry", { expiry: new Date() })
.execute()
.then((res) => {})
.catch((err) => {
throw new InternalException("failed expired refresh removal");
});
}
}

View file

@ -0,0 +1,77 @@
import { Request, Response } from "express";
import AwardService from "../../service/awardService";
import AwardFactory from "../../factory/admin/award";
/**
* @description get all awards
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAllAwards(req: Request, res: Response): Promise<any> {
let awards = await AwardService.getAll();
res.json(AwardFactory.mapToBase(awards));
}
/**
* @description get award by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAwardById(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
let award = await AwardService.getById(id);
res.json(AwardFactory.mapToSingle(award));
}
/**
* @description get members assigned to award by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAwardAssignedMembers(req: Request, res: Response): Promise<any> {
const awardId = parseInt(req.params.id);
res.json([]);
}
/**
* @description create new award
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function createAward(req: Request, res: Response): Promise<any> {
const award = req.body.award;
res.sendStatus(204);
}
/**
* @description update award
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateAward(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
const award = req.body.award;
res.sendStatus(204);
}
/**
* @description delete award
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function deleteAward(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
res.sendStatus(204);
}

View file

@ -0,0 +1,77 @@
import { Request, Response } from "express";
import CommunicationTypeService from "../../service/communicationTypeService";
import CommunicationTypeFactory from "../../factory/admin/communicationType";
import CommunicationService from "../../service/communicationService";
/**
* @description get all communicationTypes
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAllCommunicationTypes(req: Request, res: Response): Promise<any> {
let types = await CommunicationTypeService.getAll();
res.json(CommunicationTypeFactory.mapToBase(types));
}
/**
* @description get communicationType by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getCommunicationTypeById(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
let type = await CommunicationTypeService.getById(id);
res.json(CommunicationTypeFactory.mapToSingle(type));
}
/**
* @description get columns available to communicationType
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getCommunicationTypeAvailableColumns(req: Request, res: Response): Promise<any> {
let columns = CommunicationService.getAvailableColumnsForCommunication();
res.json(columns);
}
/**
* @description create new communicationType
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function createCommunicationType(req: Request, res: Response): Promise<any> {
const communicationType = req.body.communicationType;
res.sendStatus(204);
}
/**
* @description update communicationType
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateCommunicationType(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
const communicationType = req.body.communicationType;
res.sendStatus(204);
}
/**
* @description delete communicationType
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function deleteCommunicationType(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
res.sendStatus(204);
}

View file

@ -0,0 +1,77 @@
import { Request, Response } from "express";
import ExecutivePositionService from "../../service/executivePositionService";
import ExecutivePositionFactory from "../../factory/admin/executivePosition";
/**
* @description get all executivePositions
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAllExecutivePositions(req: Request, res: Response): Promise<any> {
let positions = await ExecutivePositionService.getAll();
res.json(ExecutivePositionFactory.mapToBase(positions));
}
/**
* @description get executivePosition by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getExecutivePositionById(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
let position = await ExecutivePositionService.getById(id);
res.json(ExecutivePositionFactory.mapToSingle(position));
}
/**
* @description get members assigned to executivePosition by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getExecutivePositionAssignedMembers(req: Request, res: Response): Promise<any> {
const executivePositionId = parseInt(req.params.id);
res.json([]);
}
/**
* @description create new executivePosition
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function createExecutivePosition(req: Request, res: Response): Promise<any> {
const executivePosition = req.body.executivePosition;
res.sendStatus(204);
}
/**
* @description update executivePosition
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateExecutivePosition(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
const executivePosition = req.body.executivePosition;
res.sendStatus(204);
}
/**
* @description delete executivePosition
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function deleteExecutivePosition(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
res.sendStatus(204);
}

View file

@ -0,0 +1,77 @@
import { Request, Response } from "express";
import MembershipStatusService from "../../service/membershipStatusService";
import MembershipStatusFactory from "../../factory/admin/membershipStatus";
/**
* @description get all membershipStatus
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAllMembershipStatus(req: Request, res: Response): Promise<any> {
let status = await MembershipStatusService.getAll();
res.json(MembershipStatusFactory.mapToBase(status));
}
/**
* @description get membershipStatus by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getMembershipStatusById(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
let status = await MembershipStatusService.getById(id);
res.json(MembershipStatusFactory.mapToSingle(status));
}
/**
* @description get members assigned to membershipStatus by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getMembershipStatusAssignedMembers(req: Request, res: Response): Promise<any> {
const membershipStatusId = parseInt(req.params.id);
res.json({});
}
/**
* @description create new membershipStatus
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function createMembershipStatus(req: Request, res: Response): Promise<any> {
const membershipStatus = req.body.membershipStatus;
res.sendStatus(204);
}
/**
* @description update membershipStatus
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateMembershipStatus(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
const membershipStatus = req.body.membershipStatus;
res.sendStatus(204);
}
/**
* @description delete membershipStatus
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function deleteMembershipStatus(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
res.sendStatus(204);
}

View file

@ -0,0 +1,77 @@
import { Request, Response } from "express";
import QualificationService from "../../service/qualification";
import QualificationFactory from "../../factory/admin/qualification";
/**
* @description get all qualifications
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getAllQualifications(req: Request, res: Response): Promise<any> {
let qualifications = await QualificationService.getAll();
res.json(QualificationFactory.mapToBase(qualifications));
}
/**
* @description get qualification by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getQualificationById(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
let qualification = await QualificationService.getById(id);
res.json(QualificationFactory.mapToSingle(qualification));
}
/**
* @description get members assigned to qualification by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getQualificationAssignedMembers(req: Request, res: Response): Promise<any> {
const qualificationId = parseInt(req.params.id);
res.json({});
}
/**
* @description create new qualification
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function createQualification(req: Request, res: Response): Promise<any> {
const qualification = req.body.qualification;
res.sendStatus(204);
}
/**
* @description update qualification
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateQualification(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
const qualification = req.body.qualification;
res.sendStatus(204);
}
/**
* @description delete qualification
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function deleteQualification(req: Request, res: Response): Promise<any> {
const id = parseInt(req.params.id);
res.sendStatus(204);
}

View file

@ -0,0 +1,25 @@
import { award } from "../../entity/award";
import { AwardViewModel } from "../../viewmodel/admin/award.models";
export default abstract class AwardFactory {
/**
* @description map record to award
* @param {award} record
* @returns {AwardViewModel}
*/
public static mapToSingle(record: award): AwardViewModel {
return {
id: record.id,
award: record.award,
};
}
/**
* @description map records to award
* @param {Array<award>} records
* @returns {Array<AwardViewModel>}
*/
public static mapToBase(records: Array<award>): Array<AwardViewModel> {
return records.map((r) => this.mapToSingle(r));
}
}

View file

@ -0,0 +1,26 @@
import { communicationType } from "../../entity/communicationType";
import { CommunicationTypeViewModel } from "../../viewmodel/admin/communicationType.models";
export default abstract class CommunicationTypeFactory {
/**
* @description map record to communicationType
* @param {communicationType} record
* @returns {CommunicationTypeViewModel}
*/
public static mapToSingle(record: communicationType): CommunicationTypeViewModel {
return {
id: record.id,
type: record.type,
useColumns: record.useColumns,
};
}
/**
* @description map records to communicationType
* @param {Array<communicationType>} records
* @returns {Array<CommunicationTypeViewModel>}
*/
public static mapToBase(records: Array<communicationType>): Array<CommunicationTypeViewModel> {
return records.map((r) => this.mapToSingle(r));
}
}

View file

@ -0,0 +1,25 @@
import { executivePosition } from "../../entity/executivePosition";
import { ExecutivePositionViewModel } from "../../viewmodel/admin/executivePosition.models";
export default abstract class ExecutivePositionFactory {
/**
* @description map record to executivePosition
* @param {executivePosition} record
* @returns {ExecutivePositionViewModel}
*/
public static mapToSingle(record: executivePosition): ExecutivePositionViewModel {
return {
id: record.id,
position: record.position,
};
}
/**
* @description map records to executivePosition
* @param {Array<executivePosition>} records
* @returns {Array<ExecutivePositionViewModel>}
*/
public static mapToBase(records: Array<executivePosition>): Array<ExecutivePositionViewModel> {
return records.map((r) => this.mapToSingle(r));
}
}

View file

@ -0,0 +1,25 @@
import { membershipStatus } from "../../entity/membershipStatus";
import { MembershipStatusViewModel } from "../../viewmodel/admin/membershipStatus.models";
export default abstract class MembershipStatusFactory {
/**
* @description map record to membershipStatus
* @param {membershipStatus} record
* @returns {MembershipStatusViewModel}
*/
public static mapToSingle(record: membershipStatus): MembershipStatusViewModel {
return {
id: record.id,
status: record.status,
};
}
/**
* @description map records to membershipStatus
* @param {Array<membershipStatus>} records
* @returns {Array<MembershipStatusViewModel>}
*/
public static mapToBase(records: Array<membershipStatus>): Array<MembershipStatusViewModel> {
return records.map((r) => this.mapToSingle(r));
}
}

View file

@ -0,0 +1,26 @@
import { qualification } from "../../entity/qualification";
import { QualificationViewModel } from "../../viewmodel/admin/qualification.models";
export default abstract class QualificationFactory {
/**
* @description map record to qualification
* @param {qualification} record
* @returns {AwardViewModel}
*/
public static mapToSingle(record: qualification): QualificationViewModel {
return {
id: record.id,
qualification: record.qualification,
description: record.description,
};
}
/**
* @description map records to qualification
* @param {Array<qualification>} records
* @returns {Array<AwardViewModel>}
*/
public static mapToBase(records: Array<qualification>): Array<QualificationViewModel> {
return records.map((r) => this.mapToSingle(r));
}
}

View file

@ -25,3 +25,10 @@ router(app);
app.listen(SERVER_PORT, () => {
console.log(`listening on *:${SERVER_PORT}`);
});
import schedule from "node-schedule";
import RefreshCommandHandler from "./command/refreshCommandHandler";
const job = schedule.scheduleJob("0 0 * * *", async () => {
console.log(`running Cron at ${new Date()}`);
await RefreshCommandHandler.deleteExpired();
});

35
src/routes/admin/award.ts Normal file
View file

@ -0,0 +1,35 @@
import express, { Request, Response } from "express";
import {
createAward,
deleteAward,
getAllAwards,
getAwardAssignedMembers,
getAwardById,
updateAward,
} from "../../controller/admin/awardController";
var router = express.Router({ mergeParams: true });
router.get("/", async (req: Request, res: Response) => {
await getAllAwards(req, res);
});
router.get("/:id", async (req: Request, res: Response) => {
await getAwardById(req, res);
});
router.get("/:id/assigned", async (req: Request, res: Response) => {
await getAwardAssignedMembers(req, res);
});
router.post("/", async (req: Request, res: Response) => {
await createAward(req, res);
});
router.patch("/:id", async (req: Request, res: Response) => {
await updateAward(req, res);
});
router.delete("/:id", async (req: Request, res: Response) => {
await deleteAward(req, res);
});

View file

@ -0,0 +1,35 @@
import express, { Request, Response } from "express";
import {
createCommunicationType,
deleteCommunicationType,
getAllCommunicationTypes,
getCommunicationTypeAvailableColumns,
getCommunicationTypeById,
updateCommunicationType,
} from "../../controller/admin/communicationTypeController";
var router = express.Router({ mergeParams: true });
router.get("/", async (req: Request, res: Response) => {
await getAllCommunicationTypes(req, res);
});
router.get("/:id", async (req: Request, res: Response) => {
await getCommunicationTypeById(req, res);
});
router.get("/fields", async (req: Request, res: Response) => {
await getCommunicationTypeAvailableColumns(req, res);
});
router.post("/", async (req: Request, res: Response) => {
await createCommunicationType(req, res);
});
router.patch("/:id", async (req: Request, res: Response) => {
await updateCommunicationType(req, res);
});
router.delete("/:id", async (req: Request, res: Response) => {
await deleteCommunicationType(req, res);
});

View file

@ -0,0 +1,35 @@
import express, { Request, Response } from "express";
import {
createExecutivePosition,
deleteExecutivePosition,
getAllExecutivePositions,
getExecutivePositionAssignedMembers,
getExecutivePositionById,
updateExecutivePosition,
} from "../../controller/admin/executivePositionController";
var router = express.Router({ mergeParams: true });
router.get("/", async (req: Request, res: Response) => {
await getAllExecutivePositions(req, res);
});
router.get("/:id", async (req: Request, res: Response) => {
await getExecutivePositionById(req, res);
});
router.get("/:id/assigned", async (req: Request, res: Response) => {
await getExecutivePositionAssignedMembers(req, res);
});
router.post("/", async (req: Request, res: Response) => {
await createExecutivePosition(req, res);
});
router.patch("/:id", async (req: Request, res: Response) => {
await updateExecutivePosition(req, res);
});
router.delete("/:id", async (req: Request, res: Response) => {
await deleteExecutivePosition(req, res);
});

View file

@ -0,0 +1,35 @@
import express, { Request, Response } from "express";
import {
createMembershipStatus,
deleteMembershipStatus,
getAllMembershipStatus,
getMembershipStatusAssignedMembers,
getMembershipStatusById,
updateMembershipStatus,
} from "../../controller/admin/membershipStatusController";
var router = express.Router({ mergeParams: true });
router.get("/", async (req: Request, res: Response) => {
await getAllMembershipStatus(req, res);
});
router.get("/:id", async (req: Request, res: Response) => {
await getMembershipStatusById(req, res);
});
router.get("/:id/assigned", async (req: Request, res: Response) => {
await getMembershipStatusAssignedMembers(req, res);
});
router.post("/", async (req: Request, res: Response) => {
await createMembershipStatus(req, res);
});
router.patch("/:id", async (req: Request, res: Response) => {
await updateMembershipStatus(req, res);
});
router.delete("/:id", async (req: Request, res: Response) => {
await deleteMembershipStatus(req, res);
});

View file

@ -0,0 +1,35 @@
import express, { Request, Response } from "express";
import {
createQualification,
deleteQualification,
getAllQualifications,
getQualificationAssignedMembers,
getQualificationById,
updateQualification,
} from "../../controller/admin/qualificationController";
var router = express.Router({ mergeParams: true });
router.get("/", async (req: Request, res: Response) => {
await getAllQualifications(req, res);
});
router.get("/:id", async (req: Request, res: Response) => {
await getQualificationById(req, res);
});
router.get("/:id/assigned", async (req: Request, res: Response) => {
await getQualificationAssignedMembers(req, res);
});
router.post("/", async (req: Request, res: Response) => {
await createQualification(req, res);
});
router.patch("/:id", async (req: Request, res: Response) => {
await updateQualification(req, res);
});
router.delete("/:id", async (req: Request, res: Response) => {
await deleteQualification(req, res);
});

View file

@ -0,0 +1,60 @@
import { dataSource } from "../data-source";
import { award } from "../entity/award";
import { user } from "../entity/user";
import InternalException from "../exceptions/internalException";
export default abstract class AwardService {
/**
* @description get all awards
* @returns {Promise<Array<award>>}
*/
static async getAll(): Promise<Array<award>> {
return await dataSource
.getRepository(award)
.createQueryBuilder("award")
.getMany()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("awards not found");
});
}
/**
* @description get award by id
* @returns {Promise<award>}
*/
static async getById(id: number): Promise<award> {
return await dataSource
.getRepository(award)
.createQueryBuilder("award")
.andWhere("award.id = :id", { id: id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("award not found by id");
});
}
// /**
// * @description get members assigned to award
// * @returns {Promise<Array<member>>}
// */
// static async getMembersByAwardId(id: number): Promise<Array<member>> {
// return await dataSource
// .getRepository(award)
// .createQueryBuilder("award")
// .leftJoinAndSelect("award.members", "members")
// .andWhere("award.id = :id", { id: id })
// .getOneOrFail()
// .then((res) => {
// return [];
// })
// .catch(() => {
// throw new InternalException("award assigned members not found by id");
// });
// }
}

View file

@ -0,0 +1,33 @@
import { dataSource } from "../data-source";
import { communication } from "../entity/communication";
import InternalException from "../exceptions/internalException";
export default abstract class CommunicationService {
/**
* @description get communications by user
* @returns {Promise<Array<communication>>}
*/
static async getById(userId: number): Promise<communication> {
return await dataSource
.getRepository(communication)
.createQueryBuilder("communication")
.leftJoin("communication.user", "user")
.andWhere("user.id = :id", { id: userId })
.getOneOrFail()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("communications not found by userid");
});
}
/**
* @description get available columns for self made com type
* @returns {Array<string>}
*/
static getAvailableColumnsForCommunication(): Array<string> {
let metadata = dataSource.getMetadata(communication);
return metadata.columns.map((c) => c.propertyName);
}
}

View file

@ -0,0 +1,61 @@
import { dataSource } from "../data-source";
import { communication } from "../entity/communication";
import { communicationType } from "../entity/communicationType";
import { user } from "../entity/user";
import InternalException from "../exceptions/internalException";
export default abstract class CommunicationTypeService {
/**
* @description get all communicationTypes
* @returns {Promise<Array<communicationType>>}
*/
static async getAll(): Promise<Array<communicationType>> {
return await dataSource
.getRepository(communicationType)
.createQueryBuilder("communicationType")
.getMany()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("communicationTypes not found");
});
}
/**
* @description get communicationType by id
* @returns {Promise<communicationType>}
*/
static async getById(id: number): Promise<communicationType> {
return await dataSource
.getRepository(communicationType)
.createQueryBuilder("communicationType")
.andWhere("communicationType.id = :id", { id: id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("communicationType not found by id");
});
}
// /**
// * @description get members assigned to communicationType
// * @returns {Promise<Array<member>>}
// */
// static async getMembersBycommunicationTypeId(id: number): Promise<Array<member>> {
// return await dataSource
// .getRepository(communicationType)
// .createQueryBuilder("communicationType")
// .leftJoinAndSelect("communicationType.members", "members")
// .andWhere("communicationType.id = :id", { id: id })
// .getOneOrFail()
// .then((res) => {
// return [];
// })
// .catch(() => {
// throw new InternalException("communicationType assigned members not found by id");
// });
// }
}

View file

@ -0,0 +1,60 @@
import { dataSource } from "../data-source";
import { executivePosition } from "../entity/executivePosition";
import { user } from "../entity/user";
import InternalException from "../exceptions/internalException";
export default abstract class ExecutivePositionService {
/**
* @description get all executivePositions
* @returns {Promise<Array<executivePosition>>}
*/
static async getAll(): Promise<Array<executivePosition>> {
return await dataSource
.getRepository(executivePosition)
.createQueryBuilder("executivePosition")
.getMany()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("executivePositions not found");
});
}
/**
* @description get executivePosition by id
* @returns {Promise<executivePosition>}
*/
static async getById(id: number): Promise<executivePosition> {
return await dataSource
.getRepository(executivePosition)
.createQueryBuilder("executivePosition")
.andWhere("executivePosition.id = :id", { id: id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("executivePosition not found by id");
});
}
// /**
// * @description get members assigned to executivePosition
// * @returns {Promise<Array<user>>}
// */
// static async getMembersByexecutivePositionId(id: number): Promise<Array<member>> {
// return await dataSource
// .getRepository(executivePosition)
// .createQueryBuilder("executivePosition")
// .leftJoinAndSelect("executivePosition.members", "members")
// .andWhere("executivePosition.id = :id", { id: id })
// .getOneOrFail()
// .then((res) => {
// return [];
// })
// .catch(() => {
// throw new InternalException("executivePosition assigned members not found by id");
// });
// }
}

View file

@ -0,0 +1,60 @@
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;
})
.catch(() => {
throw new InternalException("membershipStatuss not found");
});
}
/**
* @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;
})
.catch(() => {
throw new InternalException("membershipStatus not found by id");
});
}
// /**
// * @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 [];
// })
// .catch(() => {
// throw new InternalException("membershipStatus assigned members not found by id");
// });
// }
}

View file

@ -0,0 +1,60 @@
import { dataSource } from "../data-source";
import { qualification } from "../entity/qualification";
import { user } from "../entity/user";
import InternalException from "../exceptions/internalException";
export default abstract class QualificationService {
/**
* @description get all qualifications
* @returns {Promise<Array<qualification>>}
*/
static async getAll(): Promise<Array<qualification>> {
return await dataSource
.getRepository(qualification)
.createQueryBuilder("qualification")
.getMany()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("qualifications not found");
});
}
/**
* @description get qualification by id
* @returns {Promise<qualification>}
*/
static async getById(id: number): Promise<qualification> {
return await dataSource
.getRepository(qualification)
.createQueryBuilder("qualification")
.andWhere("qualification.id = :id", { id: id })
.getOneOrFail()
.then((res) => {
return res;
})
.catch(() => {
throw new InternalException("qualification not found by id");
});
}
// /**
// * @description get members assigned to qualification
// * @returns {Promise<Array<member>>}
// */
// static async getMembersByqualificationId(id: number): Promise<Array<member>> {
// return await dataSource
// .getRepository(qualification)
// .createQueryBuilder("qualification")
// .leftJoinAndSelect("qualification.members", "members")
// .andWhere("qualification.id = :id", { id: id })
// .getOneOrFail()
// .then((res) => {
// return [];
// })
// .catch(() => {
// throw new InternalException("qualification assigned members not found by id");
// });
// }
}

View file

@ -0,0 +1,4 @@
export interface AwardViewModel {
id: number;
award: string;
}

View file

@ -0,0 +1,5 @@
export interface CommunicationTypeViewModel {
id: number;
type: string;
useColumns: Array<string>;
}

View file

@ -0,0 +1,4 @@
export interface ExecutivePositionViewModel {
id: number;
position: string;
}

View file

@ -0,0 +1,4 @@
export interface MembershipStatusViewModel {
id: number;
status: string;
}

View file

@ -0,0 +1,5 @@
export interface QualificationViewModel {
id: number;
qualification: string;
description: string | null;
}