req_log.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { AdminRoute } from '../../../decorator/router_register';
  2. import { SearchLogDto } from '../../../dto/admin/sys/log';
  3. import BaseController from '../../base';
  4. import { PageGetDto } from '../../../dto/comm';
  5. /**
  6. * 请求追踪控制器
  7. */
  8. export default class SysReqLogController extends BaseController {
  9. /**
  10. * @api {get} /admin/sys/req-log/page 获取请求追踪列表
  11. * @apiGroup 请求追踪
  12. * @apiUse Auth
  13. * @apiUse BaseRes
  14. * @apiUse Page
  15. * @apiSuccess {SysReqLog[]} data.list 请求追踪列表
  16. */
  17. @AdminRoute('/sys/req-log/page', 'get')
  18. async page() {
  19. const dto = await this.ctx.validate<PageGetDto>(PageGetDto, this.getQuery());
  20. this.res({
  21. data: {
  22. list: await this.service.admin.sys.reqLog.page(dto.current - 1, dto.pageSize),
  23. pagination: {
  24. page: dto.current,
  25. size: dto.pageSize,
  26. total: await this.service.admin.sys.reqLog.count(),
  27. },
  28. },
  29. });
  30. }
  31. /**
  32. * @api {get} /admin/sys/req-log/search 请求追踪搜索
  33. * @apiGroup 请求追踪
  34. * @apiUse Auth
  35. * @apiUse BaseRes
  36. * @apiParam {String} q 条件
  37. */
  38. @AdminRoute('/sys/req-log/search', 'get')
  39. async search() {
  40. const dto = await this.ctx.validate<SearchLogDto>(SearchLogDto, this.getQuery());
  41. this.res({
  42. data: await this.service.admin.sys.reqLog.search(dto.current - 1, dto.pageSize, dto.q),
  43. });
  44. }
  45. }