78 lines
2 KiB
TypeScript
78 lines
2 KiB
TypeScript
|
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);
|
||
|
}
|