
- FastAPI application with JWT authentication and role-based access control - Complete employee management with CRUD operations - Department management with manager assignments - Leave management system with approval workflow - Payroll processing with overtime and deductions calculation - Attendance tracking with clock in/out functionality - SQLite database with proper migrations using Alembic - Role-based permissions (Admin, HR Manager, Manager, Employee) - Comprehensive API documentation and health checks - CORS enabled for cross-origin requests Environment Variables Required: - SECRET_KEY: JWT secret key for token signing Features implemented: - User registration and authentication - Employee profile management - Department hierarchy management - Leave request creation and approval - Payroll record processing - Daily attendance tracking - Hours calculation for attendance - Proper error handling and validation
22 lines
800 B
Python
22 lines
800 B
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Enum
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
import enum
|
|
|
|
class UserRole(enum.Enum):
|
|
ADMIN = "admin"
|
|
HR_MANAGER = "hr_manager"
|
|
MANAGER = "manager"
|
|
EMPLOYEE = "employee"
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String, nullable=False)
|
|
role = Column(Enum(UserRole), default=UserRole.EMPLOYEE)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now()) |