operlog.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # -*- coding: utf-8 -*-
  2. # @Author : YY
  3. from typing import List
  4. from pydantic import BeforeValidator
  5. from typing_extensions import Annotated
  6. from ruoyi_common.base.transformer import ids_to_list
  7. from ruoyi_common.base.model import AjaxResponse, TableResponse
  8. from ruoyi_common.descriptor.validator import QueryValidator, PathValidator
  9. from ruoyi_common.descriptor.serializer import BaseSerializer, JsonSerializer
  10. from ruoyi_common.domain.enum import BusinessType
  11. from ruoyi_system.domain.entity import SysOperLog
  12. from ruoyi_system.service.sys_oper_log import SysOperLogService
  13. from ruoyi_framework.descriptor.log import Log
  14. from ruoyi_framework.descriptor.permission import HasPerm, PreAuthorize
  15. from ... import reg
  16. @reg.api.route('/monitor/operlog/list',methods=['GET'])
  17. @QueryValidator(is_page=True)
  18. @PreAuthorize(HasPerm("monitor:operlog:list"))
  19. @JsonSerializer()
  20. def monitor_operlog_list(dto:SysOperLog):
  21. '''
  22. 查询登录日志列表
  23. '''
  24. rows = SysOperLogService.select_operlog_list(dto)
  25. return TableResponse(rows=rows)
  26. @reg.api.route('/monitor/operlog/export',methods=['POST'])
  27. @PreAuthorize(HasPerm("monitor:operlog:EXPORT"))
  28. @Log(title = "操作日志", business_type = BusinessType.EXPORT)
  29. @BaseSerializer()
  30. def monitor_operlog_export():
  31. '''
  32. 导出登录日志
  33. '''
  34. # todo
  35. return AjaxResponse.from_success()
  36. @reg.api.route('/monitor/operlog/<ids>',methods=['DELETE'])
  37. @PathValidator()
  38. @PreAuthorize(HasPerm("monitor:operlog:remove"))
  39. @Log(title = "操作日志", business_type = BusinessType.DELETE)
  40. @JsonSerializer()
  41. def monitor_operlog_delete(
  42. ids: Annotated[List[int],BeforeValidator(ids_to_list)]
  43. ):
  44. '''
  45. 批量删除登录日志
  46. '''
  47. SysOperLogService.delete_operlog_by_ids(ids)
  48. return AjaxResponse.from_success()
  49. @reg.api.route('/monitor/operlog/clean',methods=['DELETE'])
  50. @PreAuthorize(HasPerm("monitor:operlog:remove"))
  51. @Log(title = "操作日志", business_type = BusinessType.CLEAN)
  52. @JsonSerializer()
  53. def monitor_operlog_clean():
  54. '''
  55. 清空登录日志
  56. '''
  57. SysOperLogService.clean_operlog()
  58. return AjaxResponse.from_success()