From fcfaf56021b029922952f1d8381992c3418a659d Mon Sep 17 00:00:00 2001 From: HibiKier <45528451+HibiKier@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:17:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=95=86?= =?UTF-8?q?=E5=BA=97=E5=95=86=E5=93=81=E4=B8=BA=E7=A9=BA=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99=20(#1634)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/builtin_plugins/shop/_data_source.py | 2 +- .../web_ui/api/tabs/database/__init__.py | 24 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/zhenxun/builtin_plugins/shop/_data_source.py b/zhenxun/builtin_plugins/shop/_data_source.py index fe93e093..31afe157 100644 --- a/zhenxun/builtin_plugins/shop/_data_source.py +++ b/zhenxun/builtin_plugins/shop/_data_source.py @@ -633,7 +633,7 @@ class ShopManage: # await A.apaste(bk, (0, current_h), True) # current_h += 90 current_h = 0 - h = sum(img.height + 10 for img in image_list) + h = sum(img.height + 10 for img in image_list) or 400 A = BuildImage(1100, h, color="#f9f6f2") for img in image_list: await A.paste(img, (0, current_h)) diff --git a/zhenxun/builtin_plugins/web_ui/api/tabs/database/__init__.py b/zhenxun/builtin_plugins/web_ui/api/tabs/database/__init__.py index d334c08c..93c9f31f 100644 --- a/zhenxun/builtin_plugins/web_ui/api/tabs/database/__init__.py +++ b/zhenxun/builtin_plugins/web_ui/api/tabs/database/__init__.py @@ -1,16 +1,16 @@ import nonebot -from fastapi import APIRouter, Request -from nonebot.drivers import Driver from tortoise import Tortoise +from nonebot.drivers import Driver +from fastapi import Request, APIRouter from tortoise.exceptions import OperationalError -from zhenxun.models.plugin_info import PluginInfo from zhenxun.models.task_info import TaskInfo +from zhenxun.models.plugin_info import PluginInfo -from ....base_model import BaseResultModel, QueryModel, Result -from ....utils import authentication -from .models.model import SqlModel, SqlText from .models.sql_log import SqlLog +from ....utils import authentication +from .models.model import SqlText, SqlModel +from ....base_model import Result, QueryModel, BaseResultModel router = APIRouter(prefix="/database") @@ -24,7 +24,8 @@ SQL_DICT = {} SELECT_TABLE_SQL = """ select a.tablename as name,d.description as desc from pg_tables a left join pg_class c on relname=tablename - left join pg_description d on oid=objoid and objsubid=0 where a.schemaname = 'public' + left join pg_description d on oid=objoid + and objsubid=0 where a.schemaname = 'public' """ SELECT_TABLE_COLUMN_SQL = """ @@ -57,10 +58,7 @@ async def _(): module2name = {r[0]: r[1] for r in result} for s in SQL_DICT: module = SQL_DICT[s].module - if module in module2name: - SQL_DICT[s].name = module2name[module] - else: - SQL_DICT[s].name = module + SQL_DICT[s].name = module2name.get(module, module) @router.get( @@ -77,7 +75,7 @@ async def _() -> Result: ) async def _(table_name: str) -> Result: db = Tortoise.get_connection("default") - print(SELECT_TABLE_COLUMN_SQL.format(table_name)) + # print(SELECT_TABLE_COLUMN_SQL.format(table_name)) query = await db.execute_query_dict(SELECT_TABLE_COLUMN_SQL.format(table_name)) return Result.ok(query) @@ -92,7 +90,7 @@ async def _(sql: SqlText, request: Request) -> Result: await SqlLog.add(ip or "0.0.0.0", sql.sql, "") return Result.ok(res, "执行成功啦!") else: - result = await TestSQL.raw(sql.sql) + result = await TaskInfo.raw(sql.sql) await SqlLog.add(ip or "0.0.0.0", sql.sql, str(result)) return Result.ok(info="执行成功啦!") except OperationalError as e: