root 656f596d7e feat: implement AI legal assistant system MVP
Core modules:
- Laws: CRUD, search, AI-powered QA
- Analysis: legal research and case management
- Contracts: lifecycle management with templates
- Signatures: electronic signature workflow

Infrastructure:
- FastAPI + SQLite + async SQLAlchemy
- Docker deployment support
- 54 unit tests passing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 03:34:44 +08:00

108 lines
2.5 KiB
Python

"""Schemas for Law module."""
from datetime import date, datetime
from typing import List, Optional
from enum import Enum
from pydantic import BaseModel, Field
class LawTypeEnum(str, Enum):
LAW = "law"
REGULATION = "regulation"
RULE = "rule"
JUDICIAL_INTERPRETATION = "judicial_interpretation"
class LawStatusEnum(str, Enum):
EFFECTIVE = "effective"
REVOKED = "revoked"
AMENDED = "amended"
class LawBase(BaseModel):
"""Base schema for Law."""
title: str = Field(..., max_length=200)
law_type: LawTypeEnum
promulgation_date: date
effective_date: date
issuing_authority: str = Field(..., max_length=100)
content: str
status: LawStatusEnum = LawStatusEnum.EFFECTIVE
document_number: Optional[str] = Field(None, max_length=50)
class LawCreate(LawBase):
"""Schema for creating a law."""
pass
class LawUpdate(BaseModel):
"""Schema for updating a law."""
title: Optional[str] = Field(None, max_length=200)
law_type: Optional[LawTypeEnum] = None
promulgation_date: Optional[date] = None
effective_date: Optional[date] = None
status: Optional[LawStatusEnum] = None
issuing_authority: Optional[str] = Field(None, max_length=100)
content: Optional[str] = None
document_number: Optional[str] = Field(None, max_length=50)
class LawArticleBase(BaseModel):
"""Base schema for LawArticle."""
article_number: str = Field(..., max_length=20)
content: str
class LawArticleCreate(LawArticleBase):
"""Schema for creating a law article."""
law_id: int
class LawArticleResponse(LawArticleBase):
"""Schema for law article response."""
id: int
law_id: int
created_at: datetime
class Config:
from_attributes = True
class LawResponse(LawBase):
"""Schema for law response."""
id: int
created_at: datetime
updated_at: datetime
articles: List[LawArticleResponse] = []
class Config:
from_attributes = True
class LawListResponse(BaseModel):
"""Schema for law list response."""
items: List[LawResponse]
total: int
skip: int
limit: int
class LawSearchRequest(BaseModel):
"""Schema for law search request."""
keyword: str = Field(..., min_length=1)
limit: int = Field(10, ge=1, le=50)
class LegalQARequest(BaseModel):
"""Schema for legal QA request."""
question: str = Field(..., min_length=1)
context: Optional[str] = None
class LegalQAResponse(BaseModel):
"""Schema for legal QA response."""
question: str
answer: str
references: List[str] = []