user.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. $source_type = array (
  29. 'ios' => 'ios',
  30. 'android' => 'android',
  31. 'h5' => 'h5',
  32. 'applet' => '小程序',
  33. 'pc' => '网站',
  34. );
  35. $email = Dever::rule('email');
  36. $email = 'option';
  37. $mobile = Dever::rule('mobile');
  38. $mobile = 'option';
  39. return array
  40. (
  41. 'email' => $email,
  42. 'mobile' => $mobile,
  43. # 表名
  44. 'name' => 'user',
  45. # 显示给用户看的名称
  46. 'lang' => '用户管理',
  47. 'order' => 10,
  48. # 数据结构
  49. 'struct' => array
  50. (
  51. 'id' => array
  52. (
  53. 'type' => 'int-11',
  54. 'name' => '用户ID',
  55. 'default' => '',
  56. 'desc' => '',
  57. 'match' => 'is_numeric',
  58. 'search' => 'order',
  59. 'list' => true,
  60. ),
  61. 'username' => array
  62. (
  63. 'type' => 'varchar-50',
  64. 'name' => '用户名',
  65. 'default' => '',
  66. 'desc' => '请输入用户名',
  67. 'match' => 'is_string',
  68. 'update' => 'text',
  69. 'search' => 'fulltext',
  70. 'list' => true,
  71. ),
  72. 'mobile' => array
  73. (
  74. 'type' => 'varchar-32',
  75. 'name' => '手机号',
  76. 'default' => '',
  77. 'desc' => '请输入用户手机号',
  78. 'match' => $mobile,
  79. 'update' => 'text',
  80. 'search' => 'fulltext,exist',
  81. 'exist' => array
  82. (
  83. 'yes' => '有值',
  84. //'no' => '没有值',
  85. ),
  86. 'list' => true,
  87. ),
  88. 'source_type' => array
  89. (
  90. 'type' => 'varchar-100',
  91. 'name' => '用户来源',
  92. 'default' => '',
  93. 'desc' => '请选择用户来源',
  94. 'match' => 'is_string',
  95. 'update' => 'select',
  96. 'option' => $source_type,
  97. 'search' => 'select',
  98. 'list' => true,
  99. ),
  100. 'email' => array
  101. (
  102. 'type' => 'varchar-150',
  103. 'name' => '邮箱',
  104. 'default' => '',
  105. 'desc' => '请输入邮箱',
  106. 'match' => $email,
  107. 'update' => 'text',
  108. //'search' => 'fulltext',
  109. //'list' => true,
  110. ),
  111. 'password' => array
  112. (
  113. 'type' => 'varchar-50',
  114. 'name' => '密码',
  115. 'default' => '',
  116. 'desc' => '请输入密码',
  117. 'match' => 'option',
  118. 'update' => 'password',
  119. 'callback' => 'sha1',
  120. ),
  121. //search_exist_avatar=yes
  122. 'avatar' => array
  123. (
  124. 'type' => 'varchar-150',
  125. 'name' => '头像',
  126. 'default' => '',
  127. 'desc' => '请选择头像',
  128. 'match' => 'option',
  129. 'update' => 'image',
  130. 'key' => '1',
  131. 'place' => '150',
  132. 'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  133. ),
  134. 'country' => array
  135. (
  136. 'type' => 'varchar-100',
  137. 'name' => '国家',
  138. 'default' => '',
  139. 'desc' => '国家',
  140. 'match' => 'option',
  141. //'update' => 'text',
  142. ),
  143. 'province' => array
  144. (
  145. 'type' => 'varchar-100',
  146. 'name' => '省份',
  147. 'default' => '',
  148. 'desc' => '省份',
  149. 'match' => 'option',
  150. //'update' => 'text',
  151. ),
  152. 'city' => array
  153. (
  154. 'type' => 'varchar-100',
  155. 'name' => '城市',
  156. 'default' => '',
  157. 'desc' => '城市',
  158. 'match' => 'option',
  159. //'update' => 'text',
  160. ),
  161. 'area' => array
  162. (
  163. 'type' => 'varchar-800',
  164. 'name' => '地区',
  165. 'default' => '',
  166. 'desc' => '地区',
  167. 'match' => 'option',
  168. //'update' => 'text',
  169. 'list' => true,
  170. ),
  171. 'info' => array
  172. (
  173. 'type' => 'varchar-255',
  174. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  175. 'default' => '',
  176. 'desc' => '请输入介绍',
  177. 'match' => 'option',
  178. 'update' => 'editor',
  179. ),
  180. 'score' => array
  181. (
  182. 'type' => 'varchar-50',
  183. 'name' => '积分',
  184. 'default' => '',
  185. 'desc' => '请输入积分',
  186. 'match' => 'option',
  187. //'update' => 'text',
  188. 'list' => true,
  189. ),
  190. 'sex' => array
  191. (
  192. 'type' => 'tinyint-1',
  193. 'name' => '用户性别',
  194. 'default' => '1',
  195. 'desc' => '用户性别',
  196. 'match' => 'is_numeric',
  197. 'option' => $sex,
  198. 'update' => 'radio',
  199. 'list' => true,
  200. ),
  201. 'level' => array
  202. (
  203. 'type' => 'tinyint-1',
  204. 'name' => '用户等级',
  205. 'default' => '1',
  206. 'desc' => '请选择用户等级',
  207. 'match' => 'is_numeric',
  208. 'option' => $level,
  209. 'update' => 'select',
  210. 'list' => true,
  211. ),
  212. 'login_date' => array
  213. (
  214. 'type' => 'int-11',
  215. 'name' => '最近登录',
  216. 'match' => array('is_numeric', time()),
  217. 'desc' => '',
  218. 'default' => '0',
  219. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  220. ),
  221. 'bind' => array
  222. (
  223. 'type' => 'tinyint-1',
  224. 'name' => '是否绑定手机',
  225. 'default' => '2',
  226. 'desc' => '请选择是否绑定手机',
  227. 'match' => 'is_numeric',
  228. //'option' => $bind,
  229. //'update' => 'radio',
  230. ),
  231. 'state' => array
  232. (
  233. 'type' => 'tinyint-1',
  234. 'name' => '状态',
  235. 'default' => '1',
  236. 'desc' => '请选择状态',
  237. 'match' => 'is_numeric',
  238. 'option' => $option,
  239. 'update' => 'radio',
  240. ),
  241. 'cdate' => array
  242. (
  243. 'type' => 'int-11',
  244. 'name' => '注册时间',
  245. 'match' => array('is_numeric', time()),
  246. 'desc' => '',
  247. # 只有insert时才生效
  248. 'insert' => true,
  249. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  250. ),
  251. ),
  252. 'manage' => array
  253. (
  254. 'excel' => true,
  255. ),
  256. # 更新表结构
  257. /*
  258. 'alter' => array
  259. (
  260. 1 => array
  261. (
  262. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  263. ),
  264. 'version' => 1,
  265. ),
  266. */
  267. # request 请求接口定义
  268. 'request' => array
  269. (
  270. # 此处定义是为跳出auth
  271. 'login' => array
  272. (
  273. 'option' => array
  274. (
  275. 'username' => 'yes',
  276. 'mobile' => 'yes',
  277. 'email' => 'yes',
  278. 'password' => 'yes',
  279. ),
  280. 'type' => 'one',
  281. ),
  282. # 验证手机号是否被使用
  283. 'checkMobile' => array
  284. (
  285. # 匹配的正则或函数 选填项
  286. 'where' => array
  287. (
  288. 'mobile' => 'yes',
  289. 'id' => array('yes', '!='),
  290. ),
  291. 'type' => 'one',
  292. ),
  293. ),
  294. );