feat: 重构代码生成模块并优化定时任务功能

refactor(backend): 清理冗余模板文件并统一模板结构
fix(backend): 修复定时任务状态显示与操作逻辑
perf(backend): 优化数据库连接日志和初始化流程
style(frontend): 调整应用列表空状态显示样式
docs: 更新README中的命令说明和环境配置
chore: 添加banner.txt和统一环境变量格式
This commit is contained in:
zhangtao
2025-11-02 18:01:05 +08:00
parent 0f1916e544
commit 2c7174db32
46 changed files with 1286 additions and 1786 deletions
@@ -103,9 +103,8 @@ async def gen_table_detail_controller(
返回:
- JSONResponse: 包含业务表详细信息的JSON响应
"""
gen_table = await GenTableService.get_gen_table_by_id_service(auth, table_id)
gen_tables = await GenTableService.get_gen_table_all_service(auth)
gen_table_detail_result = dict(info=gen_table.model_dump(), rows=gen_table.model_dump()['columns'], tables=[gen_table.model_dump() for gen_table in gen_tables])
# 统一走服务层的聚合逻辑,避免控制器拼装重复代码
gen_table_detail_result = await GenTableService.get_gen_table_detail_service(auth, table_id)
logger.info(f'获取table_id为{table_id}的信息成功')
return SuccessResponse(data=gen_table_detail_result, msg="获取业务表详细信息成功")
@@ -188,18 +187,8 @@ async def batch_gen_code_controller(
返回:
- StreamResponse: 包含批量生成代码的ZIP文件流响应
"""
# 检查table_names是否为空
if not table_names:
logger.error('表名列表不能为空')
# 返回一个空的StreamResponse,包含错误信息
error_content = bytes(f'{RET.ERROR.msg}: 表名列表不能为空', 'utf-8')
return StreamResponse(
data=bytes2file_response(error_content),
media_type='text/plain',
headers={'Content-Disposition': 'attachment; filename=error.txt'}
)
batch_gen_code_result = await GenTableService.batch_gen_code_service(auth, table_names)
logger.info('批量生成代码成功')
logger.info(f'批量生成代码成功,表名列表:{table_names}')
return StreamResponse(
data=bytes2file_response(batch_gen_code_result),
media_type='application/zip',
@@ -223,7 +212,7 @@ async def gen_code_local_controller(
- JSONResponse: 包含生成结果的JSON响应
"""
result = await GenTableService.generate_code_service(auth, table_name)
logger.info('生成代码到指定路径成功')
logger.info(f'生成代码,表名:{table_name},到指定路径成功')
return SuccessResponse(msg="生成代码到指定路径成功", data=result)
@@ -243,7 +232,7 @@ async def preview_code_controller(
- JSONResponse: 包含预览代码的JSON响应
"""
preview_code_result = await GenTableService.preview_code_service(auth, table_id)
logger.info('预览代码成功')
logger.info(f'预览代码,表id{table_id},成功')
return SuccessResponse(data=preview_code_result, msg="预览代码成功")
@@ -263,5 +252,5 @@ async def sync_db_controller(
- JSONResponse: 包含同步数据库结果的JSON响应
"""
result = await GenTableService.sync_db_service(auth, table_name)
logger.info('同步数据库成功')
logger.info(f'同步数据库,表名:{table_name},成功')
return SuccessResponse(msg="同步数据库成功", data=result)