Compare commits
No commits in common. "e5fbe92dc5882918ef2acf578c3a36a32347a8b1" and "7a8ab80a84f2eaf9b43e5fad9008e4f198a46c6e" have entirely different histories.
e5fbe92dc5
...
7a8ab80a84
@ -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 };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -4,19 +4,10 @@ import {
|
|||||||
createEmployee,
|
createEmployee,
|
||||||
getEmployeeById,
|
getEmployeeById,
|
||||||
updateEmployee,
|
updateEmployee,
|
||||||
deleteEmployee
|
deleteEmployee } from "./controllers/employee.controller.ts";
|
||||||
} from "./controllers/employee.controller.ts";
|
|
||||||
import {
|
|
||||||
getCompanies,
|
|
||||||
getBranches,
|
|
||||||
getDepartments,
|
|
||||||
getJobs
|
|
||||||
} from "./controllers/lookup.controller.ts";
|
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
// --- Employee Core Endpoints ---
|
|
||||||
|
|
||||||
// Retrieve all employees
|
// Retrieve all employees
|
||||||
router.get("/api/v1/employees", getEmployees);
|
router.get("/api/v1/employees", getEmployees);
|
||||||
|
|
||||||
@ -32,18 +23,4 @@ router.put("/api/v1/employees/:id", updateEmployee);
|
|||||||
// Deactivate an employee
|
// Deactivate an employee
|
||||||
router.delete("/api/v1/employees/:id", deleteEmployee);
|
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;
|
export default router;
|
||||||
Loading…
x
Reference in New Issue
Block a user