user.php 4.3 KB

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