Add employees management module with database schema and validation

- Introduced `EmployeesModule` to manage employee data, including read and write controllers.
- Created database migrations for the `employees` table, including constraints and unique indexes.
- Implemented validation for employee fields such as name, code, and position with corresponding utility functions.
- Developed service and repository layers for handling employee data operations.
- Added unit tests for the employees service, repository, and controllers to ensure functionality and correctness.
- Updated application module to include the new `EmployeesModule` for better organization.
This commit is contained in:
shancheas
2026-08-24 15:15:52 +07:00
parent cdcc508947
commit ddbe8a9ef8
20 changed files with 3355 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
import { pgTable, text, uniqueIndex, uuid, varchar } from 'drizzle-orm/pg-core';
import { primaryEntityColumns } from './primary-entity-columns';
import { users } from './schema';
/**
* Employees (primary aggregate).
* Kept in a separate module so Drizzle's table type stays resolvable.
*/
export const employees = pgTable(
'employees',
{
id: uuid('id').defaultRandom().notNull().primaryKey(),
code: varchar('code', { length: 16 }).notNull(),
name: varchar('name', { length: 64 }).notNull(),
phone: text('phone').notNull(),
position: text('position').notNull(),
...primaryEntityColumns(users),
},
(t) => [uniqueIndex('employees_code_unique').on(t.code)],
);
export type EmployeeRow = typeof employees.$inferSelect;
export type NewEmployeeRow = typeof employees.$inferInsert;