user.php 4.5 KB

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