user.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. $config = function()
  3. {
  4. $array = array();
  5. $info = Dever::db('score/config')->state();
  6. if($info)
  7. {
  8. $array += $info;
  9. }
  10. return $array;
  11. };
  12. return array
  13. (
  14. # 表名
  15. 'name' => 'user',
  16. # 显示给用户看的名称
  17. 'lang' => '用户积分列表',
  18. 'order' => 100,
  19. 'menu' => 'passport',
  20. 'menu' => false,
  21. # 数据结构
  22. 'struct' => array
  23. (
  24. 'id' => array
  25. (
  26. 'type' => 'int-11',
  27. 'name' => 'ID',
  28. 'default' => '',
  29. 'desc' => '',
  30. 'match' => 'is_numeric',
  31. //'list' => true,
  32. ),
  33. 'uid' => array
  34. (
  35. 'type' => 'int-11',
  36. 'name' => '用户名',
  37. 'default' => '0',
  38. 'desc' => '请选择用户',
  39. 'match' => 'is_numeric',
  40. //'update' => 'select',
  41. //'search' => 'select',
  42. 'search' => array
  43. (
  44. 'api' => 'passport/user-all',
  45. 'col' => 'username',
  46. 'result' => 'id',
  47. ),
  48. 'list' => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
  49. ),
  50. 'config_id' => array
  51. (
  52. 'type' => 'int-11',
  53. 'name' => '积分名称',
  54. 'default' => '1',
  55. 'desc' => '积分名称',
  56. 'match' => 'is_numeric',
  57. 'update' => 'select',
  58. 'option' => $config,
  59. 'search' => 'select',
  60. 'list' => true,
  61. ),
  62. 'score' => array
  63. (
  64. 'type' => 'varchar-80',
  65. 'name' => '可用数量',
  66. 'default' => '0',
  67. 'desc' => '可用数量',
  68. 'match' => 'option',
  69. 'update' => 'text',
  70. 'search' => 'order',
  71. 'list' => true,
  72. ),
  73. 'no_score' => array
  74. (
  75. 'type' => 'varchar-80',
  76. 'name' => '冻结数量',
  77. 'default' => '0',
  78. 'desc' => '冻结数量',
  79. 'match' => 'option',
  80. 'update' => 'text',
  81. 'search' => 'order',
  82. 'list' => true,
  83. ),
  84. 'cdate' => array
  85. (
  86. 'type' => 'int-11',
  87. 'name' => '录入时间',
  88. 'match' => array('is_numeric', time()),
  89. 'desc' => '',
  90. # 只有insert时才生效
  91. 'insert' => true,
  92. ),
  93. ),
  94. # 索引
  95. 'index' => array
  96. (
  97. 1 => array
  98. (
  99. 'search' => 'uid,config_id',
  100. ),
  101. # 版本号 更改版本号会更新当前表的索引
  102. 'version' => 1,
  103. ),
  104. 'manage' => array
  105. (
  106. 'delete' => false,
  107. 'edit' => false,
  108. 'insert' => false,
  109. # 列表
  110. 'list_button' => array
  111. (
  112. 'list' => array('积分日志', '"user_log&&project=score&search_option_uid={uid}&oper_parent=user&oper_project=score&top_project=passport&top_parent=user"'),
  113. ),
  114. ),
  115. # request 请求接口定义
  116. 'request' => array
  117. (
  118. 'getScoreByConfig' => array
  119. (
  120. # 匹配的正则或函数 选填项
  121. 'option' => array
  122. (
  123. 'uid' => 'yes',
  124. ),
  125. 'type' => 'all',
  126. 'order' => array('id' => 'desc'),
  127. 'col' => 'id,uid,config_id,score|config_id',
  128. ),
  129. # 更新积分
  130. 'inc' => array
  131. (
  132. 'type' => 'update',
  133. 'where' => array
  134. (
  135. 'id' => 'yes',
  136. ),
  137. 'set' => array
  138. (
  139. 'score' => array('yes', '+='),
  140. ),
  141. ),
  142. )
  143. );