systemLog.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const { mock } = require('mockjs')
  2. const List = []
  3. const count = 50
  4. for (let i = 0; i < count; i++) {
  5. List.push(
  6. mock({
  7. uuid: '@uuid',
  8. id: '@id',
  9. account: '@account(1, 2)',
  10. 'type|1': ['操作日志', '数据库日志', '系统日志'],
  11. 'account|1': ['admin', 'editor', 'test'],
  12. 'executeResult|1': [
  13. '登录成功',
  14. '登录成功',
  15. '登录失败',
  16. '接口异常',
  17. 'dos攻击',
  18. ],
  19. ip: '@ip',
  20. datetime: '@datetime',
  21. })
  22. )
  23. }
  24. module.exports = [
  25. {
  26. url: '/systemLog/getList',
  27. type: 'get',
  28. response: (config) => {
  29. const { account, pageNo = 1, pageSize = 20 } = config.query
  30. const mockList = List.filter(
  31. (item) => !(account && item.account.indexOf(account) < 0)
  32. )
  33. const list = mockList.filter(
  34. (item, index) =>
  35. index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
  36. )
  37. return {
  38. code: 200,
  39. msg: 'success',
  40. data: { list, ...{ total: mockList.length } },
  41. }
  42. },
  43. },
  44. ]