refactor(myapp): 重命名查询参数类以统一命名风格

- 将 ApplicationQueryParams 改为 ApplicationQueryParam
- 同步更新相关导入和函数参数类型注解
- 修改 PaginationQueryParams 为 PaginationQueryParam

refactor(demo): 重命名查询参数类以统一命名风格

- 将 DemoQueryParams 改为 DemoQueryParam
- 同步更新相关导入和函数参数类型注解
- 修改 PaginationQueryParams 为 PaginationQueryParam

refactor(gencode): 优化代码生成模块的模型和服务层结构

- 统一模型名称后缀为 Schema,调整相关引用
- 规范 Pydantic schema 的命名和定义
- 删除无用的 Python DAO 模板文件
- 调整导入路径,统一使用 app 目录下的模块路径
- 改进服务层方法签名,添加返回类型注解
- 使用自定义异常 CustomException 替代旧异常
- 统一成功响应格式为 SuccessResponse
- 优化代码生成服务中的数据库操作 DAO 调用参数传递
- 优化代码生成业务表和字段模型的字段定义,添加注释和默认值
- 优化生成代码路径处理逻辑和异常信息提示
- 整合分页查询参数定义,统一分页模型
- 修正多个服务方法的参数类型和返回类型
- 删除无用的导入和多余注释,提升代码整洁度
This commit is contained in:
zhangtao
2025-09-18 01:51:41 +08:00
parent 035efcd796
commit 019bfdf57b
69 changed files with 663 additions and 531 deletions
@@ -6,12 +6,12 @@ from fastapi.responses import JSONResponse, StreamingResponse
from app.common.response import StreamResponse, SuccessResponse
from app.common.request import PaginationService
from app.utils.common_util import bytes2file_response
from app.core.base_params import PaginationQueryParams
from app.core.base_params import PaginationQueryParam
from app.core.dependencies import AuthPermission
from app.core.router_class import OperationLogRoute
from app.core.logger import logger
from app.api.v1.module_system.auth.schema import AuthSchema
from .param import JobQueryParams, JobLogQueryParams
from .param import JobQueryParam, JobLogQueryParam
from .service import JobService, JobLogService
from .schema import (
JobCreateSchema,
@@ -33,8 +33,8 @@ async def get_obj_detail_controller(
@JobRouter.get("/list", summary="查询定时任务", description="查询定时任务")
async def get_obj_list_controller(
page: PaginationQueryParams = Depends(),
search: JobQueryParams = Depends(),
page: PaginationQueryParam = Depends(),
search: JobQueryParam = Depends(),
auth: AuthSchema = Depends(AuthPermission(permissions=["monitor:job:query"]))
) -> JSONResponse:
result_dict_list = await JobService.get_job_list_service(auth=auth, search=search, order_by=page.order_by)
@@ -72,7 +72,7 @@ async def delete_obj_controller(
@JobRouter.post('/export', summary="导出定时任务", description="导出定时任务")
async def export_obj_list_controller(
search: JobQueryParams = Depends(),
search: JobQueryParam = Depends(),
auth: AuthSchema = Depends(AuthPermission(permissions=["monitor:job:export"]))
) -> StreamingResponse:
# 获取全量数据
@@ -143,8 +143,8 @@ async def get_job_log_detail_controller(
@JobRouter.get("/log/list", summary="查询定时任务日志", description="查询定时任务日志")
async def get_job_log_list_controller(
page: PaginationQueryParams = Depends(),
search: JobLogQueryParams = Depends(),
page: PaginationQueryParam = Depends(),
search: JobLogQueryParam = Depends(),
auth: AuthSchema = Depends(AuthPermission(permissions=["monitor:job:query"]))
) -> JSONResponse:
result_dict_list = await JobLogService.get_job_log_list_service(auth=auth, search=search, order_by=page.order_by)
@@ -174,7 +174,7 @@ async def clear_job_log_controller(
@JobRouter.post('/log/export', summary="导出定时任务日志", description="导出定时任务日志")
async def export_job_log_list_controller(
search: JobLogQueryParams = Depends(),
search: JobLogQueryParam = Depends(),
auth: AuthSchema = Depends(AuthPermission(permissions=["monitor:job:export"]))
) -> StreamingResponse:
# 获取全量数据
@@ -7,7 +7,7 @@ from datetime import datetime
from app.core.validator import DateTimeStr
class JobQueryParams:
class JobQueryParam:
"""定时任务查询参数"""
def __init__(
@@ -34,7 +34,7 @@ class JobQueryParams:
self.created_at = ("between", (start_datetime, end_datetime))
class JobLogQueryParams:
class JobLogQueryParam:
"""定时任务查询参数"""
def __init__(
@@ -8,7 +8,7 @@ from app.utils.cron_util import CronUtil
from app.utils.excel_util import ExcelUtil
from app.api.v1.module_system.auth.schema import AuthSchema
from .schema import JobCreateSchema, JobUpdateSchema, JobOutSchema, JobLogOutSchema
from .param import JobQueryParams, JobLogQueryParams
from .param import JobQueryParam, JobLogQueryParam
from .crud import JobCRUD, JobLogCRUD
@@ -23,7 +23,7 @@ class JobService:
return JobOutSchema.model_validate(obj).model_dump()
@classmethod
async def get_job_list_service(cls, auth: AuthSchema, search: JobQueryParams = None, order_by: List[Dict[str, str]] = None) -> List[Dict]:
async def get_job_list_service(cls, auth: AuthSchema, search: JobQueryParam = None, order_by: List[Dict[str, str]] = None) -> List[Dict]:
if order_by:
order_by = eval(order_by)
obj_list = await JobCRUD(auth).get_obj_list_crud(search=search.__dict__, order_by=order_by)
@@ -130,7 +130,7 @@ class JobLogService:
return JobLogOutSchema.model_validate(obj).model_dump()
@classmethod
async def get_job_log_list_service(cls, auth: AuthSchema, search: JobLogQueryParams = None, order_by: List[Dict[str, str]] = None) -> List[Dict]:
async def get_job_log_list_service(cls, auth: AuthSchema, search: JobLogQueryParam = None, order_by: List[Dict[str, str]] = None) -> List[Dict]:
"""获取定时任务日志列表"""
if order_by:
order_by = eval(order_by)
@@ -7,10 +7,10 @@ from redis.asyncio.client import Redis
from app.common.request import PaginationService
from app.common.response import SuccessResponse,ErrorResponse
from app.core.dependencies import AuthPermission, redis_getter
from app.core.base_params import PaginationQueryParams
from app.core.base_params import PaginationQueryParam
from app.core.router_class import OperationLogRoute
from app.core.logger import logger
from .param import OnlineQueryParams
from .param import OnlineQueryParam
from .service import OnlineService
@@ -25,8 +25,8 @@ OnlineRouter = APIRouter(route_class=OperationLogRoute, prefix="/online", tags=[
)
async def get_online_list_controller(
redis: Redis = Depends(redis_getter),
paging_query: PaginationQueryParams = Depends(),
search: OnlineQueryParams = Depends()
paging_query: PaginationQueryParam = Depends(),
search: OnlineQueryParam = Depends()
)->JSONResponse:
# 获取全量数据
result_dict_list = await OnlineService.get_online_list_service(redis=redis, search=search)
@@ -4,7 +4,7 @@ from typing import Optional
from fastapi import Query
class OnlineQueryParams:
class OnlineQueryParam:
"""在线用户查询参数"""
def __init__(
@@ -8,14 +8,14 @@ from app.common.enums import RedisInitKeyConfig
from app.core.redis_crud import RedisCURD
from app.core.security import decode_access_token
from app.core.logger import logger
from .param import OnlineQueryParams
from .param import OnlineQueryParam
from .schema import OnlineOutSchema
class OnlineService:
"""在线用户管理模块服务层"""
@classmethod
async def get_online_list_service(cls, redis: Redis, search: Optional[OnlineQueryParams] = None) -> List[Dict]:
async def get_online_list_service(cls, redis: Redis, search: Optional[OnlineQueryParam] = None) -> List[Dict]:
"""
获取在线用户列表信息(支持分页和搜索)
"""
@@ -64,7 +64,7 @@ class OnlineService:
@staticmethod
def _match_search_conditions(online_info: Dict, search: Optional[OnlineQueryParams]) -> bool:
def _match_search_conditions(online_info: Dict, search: Optional[OnlineQueryParam]) -> bool:
"""检查是否匹配搜索条件"""
if not search:
return True