user.php 4.2 KB

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