controller.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. from typing import Annotated
  2. from fastapi import APIRouter, Depends, Path, Query
  3. from fastapi.responses import JSONResponse
  4. from app.api.v1.module_system.auth.schema import AuthSchema
  5. from app.common.response import ResponseSchema, SuccessResponse
  6. from app.core.dependencies import AuthPermission
  7. from app.core.logger import log
  8. from app.core.router_class import OperationLogRoute
  9. from .schema import (
  10. ExpenseRuleCreateSchema,
  11. # ExpenseRuleDeleteSchema,
  12. # ExpenseRuleModifySchema,
  13. # RuleCreateSchema,
  14. # RuleListOutSchema,
  15. # RuleOperationOutSchema,
  16. # RuleOutSchema,
  17. # RuleUpdateSchema,
  18. )
  19. # from .service import RuleService
  20. RuleRouter = APIRouter(
  21. route_class=OperationLogRoute,
  22. prefix="/rule",
  23. tags=["使用规则"],
  24. )
  25. # @RuleRouter.post(
  26. # "/expense/create",
  27. # summary="创建费控使用规则",
  28. # description="创建费控使用规则 (alipay.ebpp.invoice.institution.expenserule.create)",
  29. # # response_model=ResponseSchema[RuleOperationOutSchema],
  30. # )
  31. # async def create_expense_rule_controller(
  32. # data: ExpenseRuleCreateSchema,
  33. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:expense:create"]))],
  34. # ) -> JSONResponse:
  35. # result = await RuleService.create_expense_rule_service(auth=auth, data=data)
  36. # log.info(f"创建费控使用规则成功: out_biz_no={result.out_biz_no}")
  37. # return SuccessResponse(data=result, msg="创建费控使用规则成功")
  38. # @RuleRouter.post(
  39. # "",
  40. # summary="创建使用规则",
  41. # description="创建使用规则",
  42. # response_model=ResponseSchema[RuleOperationOutSchema],
  43. # )
  44. # async def create_rule_controller(
  45. # data: RuleCreateSchema,
  46. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:create"]))],
  47. # ) -> JSONResponse:
  48. # result = await RuleService.create_rule_service(auth=auth, data=data)
  49. # log.info(f"创建使用规则成功: out_biz_no={result.out_biz_no}")
  50. # return SuccessResponse(data=result, msg="创建使用规则成功")
  51. # @RuleRouter.put(
  52. # "/expense/{out_biz_no}",
  53. # summary="编辑使用规则",
  54. # description="编辑使用规则 (alipay.ebpp.invoice.institution.expenserule.modify)",
  55. # # response_model=ResponseSchema[RuleOperationOutSchema],
  56. # )
  57. # async def modify_expense_rule_controller(
  58. # out_biz_no: Annotated[str, Path(description="外部业务编号")],
  59. # data: ExpenseRuleModifySchema,
  60. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:expense:modify"]))],
  61. # ) -> JSONResponse:
  62. # result = await RuleService.modify_expense_rule_service(auth=auth, out_biz_no=out_biz_no, data=data)
  63. # log.info(f"编辑使用规则成功: {out_biz_no}")
  64. # return SuccessResponse(data=result, msg="编辑使用规则成功")
  65. # @RuleRouter.delete(
  66. # "/expense/{out_biz_no}",
  67. # summary="删除使用规则",
  68. # description="删除使用规则 (alipay.ebpp.invoice.institution.expenserule.delete)",
  69. # # response_model=ResponseSchema[RuleOperationOutSchema],
  70. # )
  71. # async def delete_expense_rule_controller(
  72. # out_biz_no: Annotated[str, Path(description="外部业务编号")],
  73. # data: ExpenseRuleDeleteSchema,
  74. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:expense:delete"]))],
  75. # ) -> JSONResponse:
  76. # result = await RuleService.delete_expense_rule_service(auth=auth, out_biz_no=out_biz_no, data=data)
  77. # log.info(f"删除使用规则成功: {out_biz_no}")
  78. # return SuccessResponse(data=result, msg="删除使用规则成功")
  79. # @RuleRouter.get(
  80. # "",
  81. # summary="查询使用规则列表",
  82. # description="分页查询使用规则列表",
  83. # # response_model=ResponseSchema[RuleListOutSchema],
  84. # )
  85. # async def list_rule_controller(
  86. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:list"]))],
  87. # page_no: Annotated[int, Query(description="页码")] = 1,
  88. # page_size: Annotated[int, Query(description="每页数量")] = 20,
  89. # institution_id: Annotated[str | None, Query(description="制度ID")] = None,
  90. # ) -> JSONResponse:
  91. # search = {}
  92. # if institution_id:
  93. # search["institution_id"] = institution_id
  94. # result = await RuleService.list_service(
  95. # auth=auth, page_no=page_no, page_size=page_size, search=search
  96. # )
  97. # return SuccessResponse(data=result, msg="查询使用规则列表成功")
  98. # @RuleRouter.get(
  99. # "/{out_biz_no}",
  100. # summary="查询使用规则详情",
  101. # # response_model=ResponseSchema[RuleOutSchema],
  102. # )
  103. # async def get_detail_controller(
  104. # out_biz_no: Annotated[str, Path(description="外部业务编号")],
  105. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:detail"]))],
  106. # ) -> JSONResponse:
  107. # result = await RuleService.detail_service(auth=auth, out_biz_no=out_biz_no)
  108. # return SuccessResponse(data=result, msg="查询使用规则详情成功")
  109. # @RuleRouter.put(
  110. # "/{out_biz_no}",
  111. # summary="更新使用规则",
  112. # # response_model=ResponseSchema[RuleOperationOutSchema],
  113. # )
  114. # async def update_controller(
  115. # out_biz_no: Annotated[str, Path(description="外部业务编号")],
  116. # data: RuleUpdateSchema,
  117. # auth: Annotated[AuthSchema, Depends(AuthPermission(["module_payment:expense:rule:update"]))],
  118. # ) -> JSONResponse:
  119. # result = await RuleService.update_service(auth=auth, out_biz_no=out_biz_no, data=data)
  120. # log.info(f"更新使用规则成功: {out_biz_no}")
  121. # return SuccessResponse(data=result, msg="更新使用规则成功")