modify: auth 插件
This commit is contained in:
@@ -16,6 +16,8 @@ from .pydantic import MultiplyGetResponse
|
||||
from .pydantic import SubtractGetRequest
|
||||
from .pydantic import SubtractGetResponse
|
||||
|
||||
from .counter import Counter
|
||||
|
||||
__all__ = [
|
||||
"AddGetRequest",
|
||||
"AddGetResponse",
|
||||
@@ -29,4 +31,5 @@ __all__ = [
|
||||
"MultiplyGetResponse",
|
||||
"SubtractGetRequest",
|
||||
"SubtractGetResponse",
|
||||
"Counter"
|
||||
]
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
# src/plugins/example/models/counter.py
|
||||
from pydantic import BaseModel
|
||||
import modelvault
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
class Counter(BaseModel):
|
||||
# 主键字段
|
||||
__modelvault_primary_key__ = "name"
|
||||
# 唯一索引
|
||||
__modelvault_indexes__ = [
|
||||
modelvault.models.unique("name"),
|
||||
]
|
||||
|
||||
name: str # 计数器名称(例如 "visits")
|
||||
value: int = 0
|
||||
class Counter(SQLModel, table=True):
|
||||
__tablename__ = "counter" # type: ignore
|
||||
name: str = Field(primary_key=True, index=True)
|
||||
value: int = Field(default=0)
|
||||
|
||||
Reference in New Issue
Block a user