✨ Compatible with pydantic 2.0 using the pydantic compatibility layer provided by nonebot

This commit is contained in:
HibiKier
2025-01-10 12:19:11 +08:00
committed by BalconyJH
parent 23ef00d01f
commit e814469b75
69 changed files with 178 additions and 147 deletions
@@ -14,7 +14,13 @@ from zhenxun.utils.platform import PlatformUtils
from ....base_model import BaseResultModel, QueryModel
from ..main.data_source import bot_live
from .model import AllChatAndCallCount, BotInfo, ChatCallMonthCount, QueryChatCallCount
from .model import (
AllChatAndCallCount,
BotConnectLogInfo,
BotInfo,
ChatCallMonthCount,
QueryChatCallCount,
)
driver: Driver = nonebot.get_driver()
@@ -235,6 +241,12 @@ class ApiDataSource:
.offset((query.index - 1) * query.size)
.limit(query.size)
)
result_list = []
for v in data:
v.connect_time = v.connect_time.replace(tzinfo=None).replace(microsecond=0)
return BaseResultModel(total=total, data=data)
result_list.append(
BotConnectLogInfo(
bot_id=v.bot_id, connect_time=v.connect_time, type=v.type
)
)
return BaseResultModel(total=total, data=result_list)
@@ -1,6 +1,17 @@
from datetime import datetime
from pydantic import BaseModel
class BotConnectLogInfo(BaseModel):
bot_id: str
"""机器人ID"""
connect_time: datetime
"""连接日期"""
type: int
"""连接类型"""
class BotInfo(BaseModel):
self_id: str
"""SELF ID"""