cyt-logs.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
  2. const validator = {
  3. "app_status": {
  4. "rules": [
  5. {
  6. "format": "string"
  7. }
  8. ]
  9. },
  10. "user_name": {
  11. "rules": [
  12. {
  13. "format": "string"
  14. }
  15. ]
  16. },
  17. "user_brand": {
  18. "rules": [
  19. {
  20. "format": "string"
  21. }
  22. ]
  23. },
  24. "user_model": {
  25. "rules": [
  26. {
  27. "format": "string"
  28. }
  29. ]
  30. },
  31. "api_src": {
  32. "rules": [
  33. {
  34. "format": "string"
  35. }
  36. ]
  37. },
  38. "request_parameters": {
  39. "rules": [
  40. {
  41. "format": "string"
  42. }
  43. ]
  44. },
  45. "response_parameters": {
  46. "rules": [
  47. {
  48. "format": "string"
  49. }
  50. ]
  51. },
  52. "api_status": {
  53. "rules": [
  54. {
  55. "format": "string"
  56. }
  57. ]
  58. },
  59. "error_info": {
  60. "rules": [
  61. {
  62. "format": "string"
  63. }
  64. ]
  65. }
  66. }
  67. const enumConverter = {}
  68. function filterToWhere(filter, command) {
  69. let where = {}
  70. for (let field in filter) {
  71. let { type, value } = filter[field]
  72. switch (type) {
  73. case "search":
  74. if (typeof value === 'string' && value.length) {
  75. where[field] = new RegExp(value)
  76. }
  77. break;
  78. case "select":
  79. if (value.length) {
  80. let selectValue = []
  81. for (let s of value) {
  82. selectValue.push(command.eq(s))
  83. }
  84. where[field] = command.or(selectValue)
  85. }
  86. break;
  87. case "range":
  88. if (value.length) {
  89. let gt = value[0]
  90. let lt = value[1]
  91. where[field] = command.and([command.gte(gt), command.lte(lt)])
  92. }
  93. break;
  94. case "date":
  95. if (value.length) {
  96. let [s, e] = value
  97. let startDate = new Date(s)
  98. let endDate = new Date(e)
  99. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  100. }
  101. break;
  102. case "timestamp":
  103. if (value.length) {
  104. let [startDate, endDate] = value
  105. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  106. }
  107. break;
  108. }
  109. }
  110. return where
  111. }
  112. export { validator, enumConverter, filterToWhere }