
- Set up project structure with FastAPI application - Implement SQLAlchemy models for users, services, projects, team members, contacts - Create API endpoints for website functionality - Implement JWT authentication system with user roles - Add file upload functionality for media - Configure CORS and health check endpoints - Add database migrations with Alembic - Create comprehensive README with setup instructions
25 lines
756 B
Python
25 lines
756 B
Python
from typing import List, Optional
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.service import Service
|
|
from app.schemas.service import ServiceCreate, ServiceUpdate
|
|
|
|
|
|
class CRUDService(CRUDBase[Service, ServiceCreate, ServiceUpdate]):
|
|
def get_by_slug(self, db: Session, *, slug: str) -> Optional[Service]:
|
|
return db.query(Service).filter(Service.slug == slug).first()
|
|
|
|
def get_active(self, db: Session, *, skip: int = 0, limit: int = 100) -> List[Service]:
|
|
return (
|
|
db.query(Service)
|
|
.filter(Service.is_active)
|
|
.order_by(Service.order.asc())
|
|
.offset(skip)
|
|
.limit(limit)
|
|
.all()
|
|
)
|
|
|
|
|
|
service = CRUDService(Service) |