user.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. //search_exist_avatar=yes
  103. 'avatar' => array
  104. (
  105. 'type' => 'varchar-150',
  106. 'name' => '头像',
  107. 'default' => '',
  108. 'desc' => '请选择头像',
  109. 'match' => 'option',
  110. 'update' => 'image',
  111. 'key' => '1',
  112. 'place' => '150',
  113. 'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  114. ),
  115. 'country' => array
  116. (
  117. 'type' => 'varchar-100',
  118. 'name' => '国家',
  119. 'default' => '',
  120. 'desc' => '国家',
  121. 'match' => 'option',
  122. //'update' => 'text',
  123. ),
  124. 'province' => array
  125. (
  126. 'type' => 'varchar-100',
  127. 'name' => '省份',
  128. 'default' => '',
  129. 'desc' => '省份',
  130. 'match' => 'option',
  131. //'update' => 'text',
  132. ),
  133. 'city' => array
  134. (
  135. 'type' => 'varchar-100',
  136. 'name' => '城市',
  137. 'default' => '',
  138. 'desc' => '城市',
  139. 'match' => 'option',
  140. //'update' => 'text',
  141. ),
  142. 'area' => array
  143. (
  144. 'type' => 'varchar-800',
  145. 'name' => '地区',
  146. 'default' => '',
  147. 'desc' => '地区',
  148. 'match' => 'option',
  149. //'update' => 'text',
  150. 'list' => true,
  151. ),
  152. 'info' => array
  153. (
  154. 'type' => 'varchar-255',
  155. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  156. 'default' => '',
  157. 'desc' => '请输入介绍',
  158. 'match' => 'option',
  159. 'update' => 'editor',
  160. ),
  161. 'score' => array
  162. (
  163. 'type' => 'varchar-50',
  164. 'name' => '积分',
  165. 'default' => '',
  166. 'desc' => '请输入积分',
  167. 'match' => 'option',
  168. //'update' => 'text',
  169. 'list' => true,
  170. ),
  171. 'sex' => array
  172. (
  173. 'type' => 'tinyint-1',
  174. 'name' => '用户性别',
  175. 'default' => '1',
  176. 'desc' => '用户性别',
  177. 'match' => 'is_numeric',
  178. 'option' => $sex,
  179. 'update' => 'radio',
  180. 'list' => true,
  181. ),
  182. 'level' => array
  183. (
  184. 'type' => 'tinyint-1',
  185. 'name' => '用户等级',
  186. 'default' => '1',
  187. 'desc' => '请选择用户等级',
  188. 'match' => 'is_numeric',
  189. 'option' => $level,
  190. 'update' => 'select',
  191. 'list' => true,
  192. ),
  193. 'login_date' => array
  194. (
  195. 'type' => 'int-11',
  196. 'name' => '最近登录',
  197. 'match' => array('is_numeric', time()),
  198. 'desc' => '',
  199. 'default' => '0',
  200. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  201. ),
  202. 'bind' => array
  203. (
  204. 'type' => 'tinyint-1',
  205. 'name' => '是否绑定手机',
  206. 'default' => '2',
  207. 'desc' => '请选择是否绑定手机',
  208. 'match' => 'is_numeric',
  209. //'option' => $bind,
  210. //'update' => 'radio',
  211. ),
  212. 'state' => array
  213. (
  214. 'type' => 'tinyint-1',
  215. 'name' => '状态',
  216. 'default' => '1',
  217. 'desc' => '请选择状态',
  218. 'match' => 'is_numeric',
  219. 'option' => $option,
  220. 'update' => 'radio',
  221. ),
  222. 'cdate' => array
  223. (
  224. 'type' => 'int-11',
  225. 'name' => '注册时间',
  226. 'match' => array('is_numeric', time()),
  227. 'desc' => '',
  228. # 只有insert时才生效
  229. 'insert' => true,
  230. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  231. ),
  232. ),
  233. 'manage' => array
  234. (
  235. 'excel' => true,
  236. ),
  237. # 更新表结构
  238. /*
  239. 'alter' => array
  240. (
  241. 1 => array
  242. (
  243. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  244. ),
  245. 'version' => 1,
  246. ),
  247. */
  248. # request 请求接口定义
  249. 'request' => array
  250. (
  251. # 此处定义是为跳出auth
  252. 'login' => array
  253. (
  254. 'option' => array
  255. (
  256. 'username' => 'yes',
  257. 'mobile' => 'yes',
  258. 'email' => 'yes',
  259. 'password' => 'yes',
  260. ),
  261. 'type' => 'one',
  262. ),
  263. # 验证手机号是否被使用
  264. 'checkMobile' => array
  265. (
  266. # 匹配的正则或函数 选填项
  267. 'where' => array
  268. (
  269. 'mobile' => 'yes',
  270. 'id' => array('yes', '!='),
  271. ),
  272. 'type' => 'one',
  273. ),
  274. ),
  275. );