You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from app.common.response import ResponseSchema, SuccessResponse
|
|
from app.core.base_schema import AuthSchema
|
|
from app.core.dependencies import AuthPermission
|
|
from app.core.router_class import OperationLogRoute
|
|
|
|
from .schema import TemplateConfigSaveSchema
|
|
from .service import TemplateConfigService
|
|
|
|
TemplateConfigRouter = APIRouter(route_class=OperationLogRoute, prefix="/attachment-template/config", tags=["能源报告模板配置"])
|
|
|
|
|
|
@TemplateConfigRouter.get(
|
|
"/detail",
|
|
summary="查询模板章节规则和变量关联配置",
|
|
response_model=ResponseSchema[dict],
|
|
)
|
|
async def get_template_config_detail_controller(
|
|
template_id: Annotated[int, Query(ge=1, description="模板ID")],
|
|
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_energy:attachment_template:detail"]))],
|
|
) -> JSONResponse:
|
|
result = await TemplateConfigService(auth).detail(template_id=template_id)
|
|
return SuccessResponse(data=result, msg="查询模板配置成功")
|
|
|
|
|
|
@TemplateConfigRouter.post(
|
|
"/save",
|
|
summary="统一保存模板章节规则和变量关联配置",
|
|
response_model=ResponseSchema[dict],
|
|
)
|
|
async def save_template_config_controller(
|
|
data: TemplateConfigSaveSchema,
|
|
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_energy:attachment_template:update"]))],
|
|
) -> JSONResponse:
|
|
result = await TemplateConfigService(auth).save(data=data)
|
|
return SuccessResponse(data=result, msg="保存模板配置成功")
|