v0.8.1测试
This commit is contained in:
@@ -12,6 +12,19 @@
|
|||||||
import aiomysql
|
import aiomysql
|
||||||
from typing import Optional, Dict, Any, List
|
from typing import Optional, Dict, Any, List
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
from datetime import datetime, date
|
||||||
|
|
||||||
|
def _convert_datetime(obj: Any) -> Any:
|
||||||
|
'''递归转换datetime对象为字符串'''
|
||||||
|
if isinstance(obj, datetime):
|
||||||
|
return obj.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
elif isinstance(obj, date):
|
||||||
|
return obj.strftime('%Y-%m-%d')
|
||||||
|
elif isinstance(obj, dict):
|
||||||
|
return {k: _convert_datetime(v) for k, v in obj.items()}
|
||||||
|
elif isinstance(obj, list):
|
||||||
|
return [_convert_datetime(item) for item in obj]
|
||||||
|
return obj
|
||||||
|
|
||||||
from config import settings
|
from config import settings
|
||||||
from utils.logger import get_logger
|
from utils.logger import get_logger
|
||||||
@@ -88,14 +101,16 @@ async def execute_query(sql: str, params: tuple = None) -> List[Dict[str, Any]]:
|
|||||||
"""执行查询SQL"""
|
"""执行查询SQL"""
|
||||||
async with get_connection() as cursor:
|
async with get_connection() as cursor:
|
||||||
await cursor.execute(sql, params)
|
await cursor.execute(sql, params)
|
||||||
return await cursor.fetchall()
|
result = await cursor.fetchall()
|
||||||
|
return _convert_datetime(result)
|
||||||
|
|
||||||
|
|
||||||
async def execute_one(sql: str, params: tuple = None) -> Optional[Dict[str, Any]]:
|
async def execute_one(sql: str, params: tuple = None) -> Optional[Dict[str, Any]]:
|
||||||
"""执行查询SQL(单条)"""
|
"""执行查询SQL(单条)"""
|
||||||
async with get_connection() as cursor:
|
async with get_connection() as cursor:
|
||||||
await cursor.execute(sql, params)
|
await cursor.execute(sql, params)
|
||||||
return await cursor.fetchone()
|
result = await cursor.fetchone()
|
||||||
|
return _convert_datetime(result)
|
||||||
|
|
||||||
|
|
||||||
async def execute_insert(sql: str, params: tuple = None) -> int:
|
async def execute_insert(sql: str, params: tuple = None) -> int:
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ if (isset($_SESSION['user_id']) && isset($_SESSION['user_type'])) {
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="login-footer">
|
<div class="login-footer">
|
||||||
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?> | <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a><?php endif; ?></p>
|
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio</p>
|
||||||
|
<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?>
|
||||||
|
<p><a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a></p>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user