diff --git a/kinit-api/application/settings.py b/kinit-api/application/settings.py index 0092cda..b6aa9c0 100644 --- a/kinit-api/application/settings.py +++ b/kinit-api/application/settings.py @@ -11,7 +11,7 @@ from fastapi.security import OAuth2PasswordBearer """ 系统版本 """ -VERSION = "3.4.0" +VERSION = "3.4.1" """安全警告: 不要在生产中打开调试运行!""" DEBUG = False diff --git a/kinit-api/apps/vadmin/system/crud.py b/kinit-api/apps/vadmin/system/crud.py index f8a2f6e..f4f0257 100644 --- a/kinit-api/apps/vadmin/system/crud.py +++ b/kinit-api/apps/vadmin/system/crud.py @@ -108,7 +108,7 @@ class SettingsDal(DalBase): if ico.config_value == web_ico: continue # 将上传的ico路径替换到static/system/favicon.ico文件 - await FileManage.async_copy(value, os.path.join(STATIC_ROOT, "system/favicon.ico")) + await FileManage.async_copy_file(value, os.path.join(STATIC_ROOT, "system/favicon.ico")) sql = update(self.model).where(self.model.config_key == "web_ico").values(config_value=web_ico) await self.db.execute(sql) else: diff --git a/kinit-api/core/mongo_manage.py b/kinit-api/core/mongo_manage.py index a0d6549..b418d6f 100644 --- a/kinit-api/core/mongo_manage.py +++ b/kinit-api/core/mongo_manage.py @@ -37,7 +37,7 @@ class MongoManage: :param is_object_id: _id 列是否为 ObjectId 格式 """ self.db = db - self.collection = db[collection] + self.collection = db[collection] if collection else None self.schema = schema self.is_object_id = is_object_id diff --git a/kinit-api/utils/cache.py b/kinit-api/utils/cache.py index b75b518..385136f 100644 --- a/kinit-api/utils/cache.py +++ b/kinit-api/utils/cache.py @@ -7,6 +7,8 @@ # @desc : 缓存 from typing import List + +from sqlalchemy import false from sqlalchemy.future import select from sqlalchemy.orm import joinedload from core.logger import logger # 注意:报错就在这里,如果只写 core.logger 会写入日志报错,很难排查 @@ -34,9 +36,9 @@ class Cache: model = VadminSystemSettingsTab v_options = [joinedload(model.settings)] sql = select(model).where( - model.is_delete == False, + model.is_delete == false(), model.tab_name.in_(tab_names), - model.disabled == False + model.disabled == false() ).options(*[load for load in v_options]) queryset = await session.execute(sql) datas = queryset.scalars().unique().all() @@ -74,7 +76,7 @@ class Cache: """ 获取系统配置 :param tab_name: 配置表标签名称 - :param retry_num: 重试次数 + :param retry: 重试次数 """ result = await self.rd.get(tab_name) if not result and retry > 0: diff --git a/kinit-api/utils/file/aliyun_oss.py b/kinit-api/utils/file/aliyun_oss.py index 8c62ba4..8e73de4 100644 --- a/kinit-api/utils/file/aliyun_oss.py +++ b/kinit-api/utils/file/aliyun_oss.py @@ -60,10 +60,10 @@ class AliyunOSS(FileBase): # 验证图片类型 await self.validate_file(file, max_size, self.IMAGE_ACCEPT) # 生成文件路径 - path = self.generate_path(path, file.filename) + path = self.generate_static_file_path(path, file.filename) if compress: # 压缩图片 - file_path = await FileManage.save_tmp_file(file) + file_path = await FileManage.async_save_temp_file(file) new_file = compress_jpg_png(file_path, originpath=os.path.abspath(file_path)) with open(new_file, "rb") as f: file_data = f.read() @@ -83,7 +83,7 @@ class AliyunOSS(FileBase): # 验证图片类型 await self.validate_file(file, max_size, self.VIDEO_ACCEPT) # 生成文件路径 - path = self.generate_path(path, file.filename) + path = self.generate_static_file_path(path, file.filename) file_data = await file.read() return await self.__upload_file_to_oss(path, file_data) @@ -95,7 +95,7 @@ class AliyunOSS(FileBase): :param file: 文件对象 :return: 上传后的文件oss链接 """ - path = self.generate_path(path, file.filename) + path = self.generate_static_file_path(path, file.filename) file_data = await file.read() return await self.__upload_file_to_oss(path, file_data)