user.php 6.1 KB

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