V2.0.0-alpha1

This commit is contained in:
2025-04-22 03:22:17 +08:00
parent 2a217c4b8c
commit 39bbc94d07
53 changed files with 5019 additions and 1203 deletions

View File

@@ -15,6 +15,7 @@ import tool
import logging
from typing import Optional
# 数据库类
class Database:
def __init__(self, db_path: str = "data.db"):
self.db_path = db_path
@@ -103,7 +104,8 @@ class Database:
logging.info("数据库初始化完成并提交更改")
async def add_object(self, key: str, name: str, icon: str = None, phone: str = None):
"""添加新对象
"""
添加新对象
:param key: 序列号
:param name: 名称
@@ -134,7 +136,8 @@ class Database:
lost_description: Optional[str] = None,
find_ip: Optional[str] = None,
lost_time: Optional[str] = None):
"""更新对象信息
"""
更新对象信息
:param id: 对象ID
:param key: 序列号
@@ -171,7 +174,8 @@ class Database:
await db.commit()
async def get_object(self, id: int = None, key: str = None):
"""获取对象
"""
获取对象
:param id: 对象ID
:param key: 序列号
@@ -187,7 +191,8 @@ class Database:
return await cursor.fetchall()
async def delete_object(self, id: int):
"""删除对象
"""
删除对象
:param id: 对象ID
"""
@@ -196,7 +201,8 @@ class Database:
await db.commit()
async def set_setting(self, name: str, value: str):
"""设置配置项
"""
设置配置项
:param name: 配置项名称
:param value: 配置项值
@@ -209,7 +215,8 @@ class Database:
await db.commit()
async def get_setting(self, name: str):
"""获取配置项
"""
获取配置项
:param name: 配置项名称
"""

View File

@@ -1,6 +1,16 @@
from pydantic import BaseModel
from typing import Literal, Optional
class DefaultResponse(BaseModel):
code: int = 0
data: dict | list | None = None
msg: str = ""
msg: str = ""
class ObjectData(BaseModel):
id: int
key: str
name: str
icon: str
status: Literal['ok', 'lost']
phone: str
context: Optional[str] = None