user.php 6.1 KB

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