Compare commits

..

No commits in common. "e5fbe92dc5882918ef2acf578c3a36a32347a8b1" and "7a8ab80a84f2eaf9b43e5fad9008e4f198a46c6e" have entirely different histories.

2 changed files with 1 additions and 69 deletions

View File

@ -1,45 +0,0 @@
import pool from "../../shared/db.ts";
export const getCompanies = async (ctx: any) => {
try {
const [rows] = await pool.query(`SELECT company_id, name FROM companies`);
ctx.response.status = 200;
ctx.response.body = { success: true, data: rows };
} catch (error) {
ctx.response.status = 500;
ctx.response.body = { success: false, error: (error as Error).message };
}
};
export const getBranches = async (ctx: any) => {
try {
const [rows] = await pool.query(`SELECT branch_id, name, company_id FROM branches`);
ctx.response.status = 200;
ctx.response.body = { success: true, data: rows };
} catch (error) {
ctx.response.status = 500;
ctx.response.body = { success: false, error: (error as Error).message };
}
};
export const getDepartments = async (ctx: any) => {
try {
const [rows] = await pool.query(`SELECT department_id, name, parent_id FROM departments`);
ctx.response.status = 200;
ctx.response.body = { success: true, data: rows };
} catch (error) {
ctx.response.status = 500;
ctx.response.body = { success: false, error: (error as Error).message };
}
};
export const getJobs = async (ctx: any) => {
try {
const [rows] = await pool.query(`SELECT job_id, title, department_id FROM job_positions`);
ctx.response.status = 200;
ctx.response.body = { success: true, data: rows };
} catch (error) {
ctx.response.status = 500;
ctx.response.body = { success: false, error: (error as Error).message };
}
};

View File

@ -4,19 +4,10 @@ import {
createEmployee,
getEmployeeById,
updateEmployee,
deleteEmployee
} from "./controllers/employee.controller.ts";
import {
getCompanies,
getBranches,
getDepartments,
getJobs
} from "./controllers/lookup.controller.ts";
deleteEmployee } from "./controllers/employee.controller.ts";
const router = new Router();
// --- Employee Core Endpoints ---
// Retrieve all employees
router.get("/api/v1/employees", getEmployees);
@ -32,18 +23,4 @@ router.put("/api/v1/employees/:id", updateEmployee);
// Deactivate an employee
router.delete("/api/v1/employees/:id", deleteEmployee);
// --- Organizational Lookup Endpoints ---
// Fetch legal entities and parent group structures.
router.get("/api/v1/companies", getCompanies);
//Fetch structural branch offices
router.get("/api/v1/branches", getBranches);
//List corporate departments and organizational chart reporting lines
router.get("/api/v1/departments", getDepartments);
//List company designations and employment titles.
router.get("/api/v1/jobs", getJobs);
export default router;