Initial commit: Angular frontend and Expressjs backend

This commit is contained in:
chamikaJ
2024-05-17 09:32:30 +05:30
parent eb0a0d77d6
commit 298ca6beeb
3548 changed files with 193558 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
import {IWorkLenzRequest} from "../interfaces/worklenz-request";
import {IWorkLenzResponse} from "../interfaces/worklenz-response";
import db from "../config/db";
import {ServerResponse} from "../models/server-response";
import WorklenzControllerBase from "./worklenz-controller-base";
import HandleExceptions from "../decorators/handle-exceptions";
import {PriorityColorCodes} from "../shared/constants";
export default class TaskPrioritiesController extends WorklenzControllerBase {
@HandleExceptions()
public static async get(_req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
const q = `SELECT id, name, value From task_priorities ORDER BY value;`;
const result = await db.query(q, []);
for (const item of result.rows)
item.color_code = PriorityColorCodes[item.value] || PriorityColorCodes["0"];
return res.status(200).send(new ServerResponse(true, result.rows));
}
@HandleExceptions()
public static async getById(_req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
const q = `SELECT id, name From priorities WHERE id=$1;`;
const result = await db.query(q, [_req.params.id]);
const data = result.rows;
return res.status(200).send(new ServerResponse(true, data));
}
}