feat: 更新接口默认就是按照字段更新
This commit is contained in:
+3
-2
@@ -37,5 +37,6 @@ JWT_REFRESH_TOKEN_EXPIRE_SECONDS = 604800 # JWT刷新令牌默认
|
|||||||
JWT_GLOBAL_ENABLE = false # 是否开启全局JWT认证
|
JWT_GLOBAL_ENABLE = false # 是否开启全局JWT认证
|
||||||
JWT_WHITE_LIST = ["/token", "/login", "/refresh", "/registry", "/verify", "/async_delay", "/", "/redoc", "/docs", "/static/swagger-ui.min.css", "/static/swagger-ui-bundle.min.js", "/openapi.json", "/static/redoc.standalone.js"] # JWT认证白名单接口,不需要认证的接口
|
JWT_WHITE_LIST = ["/token", "/login", "/refresh", "/registry", "/verify", "/async_delay", "/", "/redoc", "/docs", "/static/swagger-ui.min.css", "/static/swagger-ui-bundle.min.js", "/openapi.json", "/static/redoc.standalone.js"] # JWT认证白名单接口,不需要认证的接口
|
||||||
|
|
||||||
FILE_SAVE_PATH=/www/wwwroot/web/web/upload_file/
|
FILE_SAVE_PATH=/www/wwwroot/web/web/upload_file/ # 文件保存在服务器上的路径
|
||||||
FILE_PUBLIC_PATH=/web/upload_file/
|
FILE_PUBLIC_PATH=/web/upload_file/ # 文件在浏览器上的访问路径
|
||||||
|
DEFAULT_UPDATE_BY_FIELDS=true # 更新接口是否默认按字段更新(按需更新字段值)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
file_save_path: str = Field(..., env='FILE_SAVE_PATH')
|
file_save_path: str = Field(..., env='FILE_SAVE_PATH')
|
||||||
file_public_path: str = Field(..., env='FILE_PUBLIC_PATH')
|
file_public_path: str = Field(..., env='FILE_PUBLIC_PATH')
|
||||||
|
default_update_by_fields: bool = Field(..., env='DEFAULT_UPDATE_BY_FIELDS')
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_file = ".env"
|
env_file = ".env"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from app.config.env import env
|
||||||
from app.general.general_utils.build_delete_sql import build_delete_sql
|
from app.general.general_utils.build_delete_sql import build_delete_sql
|
||||||
from app.general.general_utils.build_insert_sql import build_insert_sql
|
from app.general.general_utils.build_insert_sql import build_insert_sql
|
||||||
from app.general.general_utils.build_query_sql import build_query_sql
|
from app.general.general_utils.build_query_sql import build_query_sql
|
||||||
@@ -201,6 +202,7 @@ async def update(session: AsyncSessionDep, query_config, module_config, debug_da
|
|||||||
conn = await session.connection()
|
conn = await session.connection()
|
||||||
|
|
||||||
row = get_value(query_config, 'row', None)
|
row = get_value(query_config, 'row', None)
|
||||||
|
update_by_fields = get_value(query_config, 'updateByFields', env.default_update_by_fields)
|
||||||
update_fields = get_value(query_config, 'updateFields', None)
|
update_fields = get_value(query_config, 'updateFields', None)
|
||||||
|
|
||||||
if row is None:
|
if row is None:
|
||||||
@@ -208,6 +210,9 @@ async def update(session: AsyncSessionDep, query_config, module_config, debug_da
|
|||||||
"error": "row parameter is missing",
|
"error": "row parameter is missing",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if update_by_fields:
|
||||||
|
update_fields = row.keys()
|
||||||
|
|
||||||
row_id = get_value(row, 'id', None)
|
row_id = get_value(row, 'id', None)
|
||||||
|
|
||||||
if row_id is None:
|
if row_id is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user