user.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '正常',
  6. 2 => '冻结',
  7. );
  8. $level = array
  9. (
  10. 1 => '普通',
  11. 2 => '元老',
  12. 3 => '小编',
  13. 10 => '管理员',
  14. );
  15. $weixin = array
  16. (
  17. 1 => '已关注',
  18. 2 => '未关注',
  19. );
  20. $bind = array
  21. (
  22. 1 => '已绑定',
  23. 2 => '未绑定',
  24. );
  25. $email = Dever::rule('email');
  26. $mobile = Dever::rule('mobile');
  27. return array
  28. (
  29. 'email' => $email,
  30. 'mobile' => $mobile,
  31. # 表名
  32. 'name' => 'user',
  33. # 显示给用户看的名称
  34. 'lang' => '用户管理',
  35. 'order' => 10,
  36. # 数据结构
  37. 'struct' => array
  38. (
  39. 'id' => array
  40. (
  41. 'type' => 'int-11',
  42. 'name' => '用户ID',
  43. 'default' => '',
  44. 'desc' => '',
  45. 'match' => 'is_numeric',
  46. 'search' => 'order',
  47. 'list' => true,
  48. ),
  49. 'email' => array
  50. (
  51. 'type' => 'varchar-150',
  52. 'name' => '邮箱',
  53. 'default' => '',
  54. 'desc' => '请输入邮箱',
  55. 'match' => $email,
  56. 'update' => 'text',
  57. 'search' => 'fulltext',
  58. 'list' => true,
  59. ),
  60. 'username' => array
  61. (
  62. 'type' => 'varchar-50',
  63. 'name' => '用户名',
  64. 'default' => '',
  65. 'desc' => '请输入用户名',
  66. 'match' => 'is_string',
  67. 'update' => 'text',
  68. 'search' => 'fulltext',
  69. 'list' => true,
  70. ),
  71. 'mobile' => array
  72. (
  73. 'type' => 'varchar-32',
  74. 'name' => '手机号',
  75. 'default' => '',
  76. 'desc' => '请输入用户手机号',
  77. 'match' => $mobile,
  78. 'update' => 'text',
  79. 'search' => 'fulltext',
  80. 'list' => true,
  81. ),
  82. 'password' => array
  83. (
  84. 'type' => 'varchar-50',
  85. 'name' => '密码',
  86. 'default' => '',
  87. 'desc' => '请输入密码',
  88. 'match' => 'option',
  89. 'update' => 'password',
  90. 'callback' => 'md5',
  91. ),
  92. 'avatar' => array
  93. (
  94. 'type' => 'varchar-150',
  95. 'name' => '头像',
  96. 'default' => '',
  97. 'desc' => '请选择头像',
  98. 'match' => 'option',
  99. 'update' => 'image',
  100. 'key' => '1',
  101. 'place' => '150',
  102. ),
  103. 'info' => array
  104. (
  105. 'type' => 'varchar-255',
  106. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  107. 'default' => '',
  108. 'desc' => '请输入介绍',
  109. 'match' => 'option',
  110. 'update' => 'editor',
  111. ),
  112. 'level' => array
  113. (
  114. 'type' => 'tinyint-1',
  115. 'name' => '用户等级',
  116. 'default' => '1',
  117. 'desc' => '请选择用户等级',
  118. 'match' => 'is_numeric',
  119. //'option' => $level,
  120. //'update' => 'radio',
  121. //'list' => true,
  122. ),
  123. 'login_date' => array
  124. (
  125. 'type' => 'int-11',
  126. 'name' => '最近登录',
  127. 'match' => array('is_numeric', time()),
  128. 'desc' => '',
  129. 'default' => '0',
  130. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  131. ),
  132. 'reg_date' => array
  133. (
  134. 'type' => 'int-11',
  135. 'name' => '注册时间',
  136. 'match' => array('is_numeric', time()),
  137. 'desc' => '',
  138. 'default' => '0',
  139. ),
  140. 'bind' => array
  141. (
  142. 'type' => 'tinyint-1',
  143. 'name' => '是否绑定手机',
  144. 'default' => '2',
  145. 'desc' => '请选择是否绑定手机',
  146. 'match' => 'is_numeric',
  147. //'option' => $bind,
  148. //'update' => 'radio',
  149. ),
  150. 'state' => array
  151. (
  152. 'type' => 'tinyint-1',
  153. 'name' => '状态',
  154. 'default' => '1',
  155. 'desc' => '请选择状态',
  156. 'match' => 'is_numeric',
  157. 'option' => $option,
  158. 'update' => 'radio',
  159. ),
  160. 'cdate' => array
  161. (
  162. 'type' => 'int-11',
  163. 'name' => '注册时间',
  164. 'match' => array('is_numeric', time()),
  165. 'desc' => '',
  166. # 只有insert时才生效
  167. 'insert' => true,
  168. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  169. ),
  170. ),
  171. # 更新表结构
  172. /*
  173. 'alter' => array
  174. (
  175. 1 => array
  176. (
  177. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  178. ),
  179. 'version' => 1,
  180. ),
  181. */
  182. # request 请求接口定义
  183. 'request' => array
  184. (
  185. # 此处定义是为跳出auth
  186. 'login' => array
  187. (
  188. 'option' => array
  189. (
  190. 'username' => 'yes',
  191. 'mobile' => 'yes',
  192. 'email' => 'yes',
  193. 'password' => 'yes',
  194. ),
  195. 'type' => 'one',
  196. ),
  197. # 验证手机号是否被使用
  198. 'checkMobile' => array
  199. (
  200. # 匹配的正则或函数 选填项
  201. 'where' => array
  202. (
  203. 'mobile' => 'yes',
  204. 'id' => array('yes', '!='),
  205. ),
  206. 'type' => 'one',
  207. ),
  208. ),
  209. );