opendb-app-list.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
  2. const validator = {
  3. "appid": {
  4. "rules": [{
  5. "required": true
  6. },
  7. {
  8. "format": "string"
  9. }
  10. ],
  11. "label": "AppID"
  12. },
  13. "name": {
  14. "rules": [{
  15. "required": true
  16. },
  17. {
  18. "format": "string"
  19. }
  20. ],
  21. "label": "应用名称"
  22. },
  23. "icon_url": {
  24. "rules": [{
  25. "format": "string"
  26. }],
  27. "label": "应用图标"
  28. },
  29. "introduction": {
  30. "rules": [{
  31. "format": "string"
  32. }],
  33. "label": "应用简介"
  34. },
  35. "description": {
  36. "rules": [{
  37. "format": "string"
  38. }],
  39. "label": "应用描述"
  40. },
  41. "screenshot": {
  42. "rules": [{
  43. "format": "array"
  44. }],
  45. "label": "应用截图"
  46. },
  47. "create_date": {
  48. "rules": [{
  49. "format": "timestamp"
  50. }],
  51. "label": "发行时间"
  52. }
  53. }
  54. function filterToWhere(filter, command) {
  55. let where = {}
  56. for (let field in filter) {
  57. let {
  58. type,
  59. value
  60. } = filter[field]
  61. switch (type) {
  62. case "search":
  63. if (typeof value === 'string' && value.length) {
  64. where[field] = new RegExp(value)
  65. }
  66. break;
  67. case "select":
  68. if (value.length) {
  69. let selectValue = []
  70. for (let s of value) {
  71. selectValue.push(command.eq(s))
  72. }
  73. where[field] = command.or(selectValue)
  74. }
  75. break;
  76. case "range":
  77. if (value.length) {
  78. let gt = value[0]
  79. let lt = value[1]
  80. where[field] = command.and([command.gte(gt), command.lte(lt)])
  81. }
  82. break;
  83. case "date":
  84. if (value.length) {
  85. let [s, e] = value
  86. let startDate = new Date(s)
  87. let endDate = new Date(e)
  88. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  89. }
  90. break;
  91. case "timestamp":
  92. if (value.length) {
  93. let [startDate, endDate] = value
  94. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  95. }
  96. break;
  97. }
  98. }
  99. return where
  100. }
  101. const enumConverter = {}
  102. const mpPlatform = {
  103. 'mp_weixin': '微信小程序',
  104. 'mp_alipay': '支付宝小程序',
  105. 'mp_baidu': '百度小程序',
  106. 'mp_toutiao': '字节小程序',
  107. 'mp_qq': 'QQ小程序',
  108. 'mp_dingtalk': '钉钉小程序',
  109. 'mp_kuaishou': '快手小程序',
  110. 'mp_lark': '飞书小程序',
  111. 'mp_jd': '京东小程序',
  112. 'quickapp': '快应用'
  113. }
  114. export {
  115. enumConverter,
  116. validator,
  117. filterToWhere,
  118. mpPlatform
  119. }