40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Text, DateTime
|
|
from sqlalchemy.sql import func
|
|
from pydantic import BaseModel, Field
|
|
from datetime import datetime
|
|
from .database import Base
|
|
from typing import Optional
|
|
class ConfigDB(Base):
|
|
__tablename__ = "configs"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
key = Column(String(100), unique=True, nullable=False)
|
|
value = Column(String(200), nullable=False)
|
|
description = Column(String(200), nullable=True)
|
|
create_time = Column(DateTime(timezone=True), server_default=func.now())
|
|
update_time = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
|
|
class ConfigInfo(BaseModel):
|
|
id: int
|
|
key: str
|
|
value: str
|
|
description: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class ConfigCreate(BaseModel):
|
|
key: str
|
|
value: str
|
|
description: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class ConfigUpdate(BaseModel):
|
|
value: str
|
|
description: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True |