user.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. $system = function()
  15. {
  16. $array = array();
  17. $info = Dever::db('passport/system')->state();
  18. if($info)
  19. {
  20. $array += $info;
  21. }
  22. return $array;
  23. };
  24. $profession = function()
  25. {
  26. $array = array();
  27. $info = Dever::db('passport/profession')->state();
  28. if($info)
  29. {
  30. $array += $info;
  31. }
  32. return $array;
  33. };
  34. $sex = array
  35. (
  36. 1 => '男',
  37. 2 => '女',
  38. 3 => '未知',
  39. );
  40. $weixin = array
  41. (
  42. 1 => '已关注',
  43. 2 => '未关注',
  44. );
  45. $temp = array
  46. (
  47. 1 => '临时用户',
  48. 2 => '正式用户',
  49. );
  50. $bind = array
  51. (
  52. 1 => '已绑定',
  53. 2 => '未绑定',
  54. );
  55. $source_type = array (
  56. 'ios' => 'ios',
  57. 'android' => 'android',
  58. 'h5' => 'h5',
  59. 'applet' => '小程序',
  60. 'pc' => '网站',
  61. 'service' => '公众号',
  62. );
  63. $email = Dever::rule('email');
  64. $email = 'option';
  65. $mobile = Dever::rule('mobile');
  66. $mobile = 'option';
  67. return array
  68. (
  69. 'email' => $email,
  70. 'mobile' => $mobile,
  71. 'source_type' => $source_type,
  72. 'sex' => $sex,
  73. # 表名
  74. 'name' => 'user',
  75. # 显示给用户看的名称
  76. 'lang' => '用户管理',
  77. 'order' => 10,
  78. # 数据结构
  79. 'struct' => array
  80. (
  81. 'id' => array
  82. (
  83. 'type' => 'int-11',
  84. 'name' => '用户ID',
  85. 'default' => '',
  86. 'desc' => '',
  87. 'match' => 'is_numeric',
  88. 'search' => 'order,fulltext',
  89. 'list' => true,
  90. ),
  91. 'username' => array
  92. (
  93. 'type' => 'varchar-50',
  94. 'name' => '用户名',
  95. 'default' => '',
  96. 'desc' => '请输入用户名',
  97. 'match' => 'is_string',
  98. 'update' => 'text',
  99. 'search' => 'fulltext',
  100. 'list' => true,
  101. ),
  102. 'truename' => array
  103. (
  104. 'type' => 'varchar-50',
  105. 'name' => '姓名',
  106. 'default' => '',
  107. 'desc' => '请输入姓名',
  108. 'match' => 'option',
  109. 'update' => 'text',
  110. 'search' => 'fulltext',
  111. 'list' => '"{truename}" ? "{truename}" : "点此编辑"',
  112. 'edit' => true,
  113. ),
  114. 'mobile' => array
  115. (
  116. 'type' => 'varchar-32',
  117. 'name' => '手机号',
  118. 'default' => '',
  119. 'desc' => '请输入用户手机号',
  120. 'match' => $mobile,
  121. 'update' => 'text',
  122. 'search' => 'fulltext,exist',
  123. 'exist' => array
  124. (
  125. 'yes' => '有值',
  126. //'no' => '没有值',
  127. ),
  128. 'list' => true,
  129. ),
  130. 'system_id' => array
  131. (
  132. 'type' => 'int-11',
  133. 'name' => '所属项目',
  134. 'default' => '1',
  135. 'desc' => '所属项目',
  136. 'match' => 'is_numeric',
  137. 'option' => $system,
  138. //'update' => 'select',
  139. //'list' => true,
  140. ),
  141. 'profession' => array
  142. (
  143. 'type' => 'int-11',
  144. 'name' => '职业',
  145. 'default' => '1',
  146. 'desc' => '职业',
  147. 'match' => 'is_numeric',
  148. 'option' => $profession,
  149. //'update' => 'select',
  150. //'list' => true,
  151. ),
  152. 'wechat' => array
  153. (
  154. 'type' => 'varchar-100',
  155. 'name' => '微信号',
  156. 'default' => '',
  157. 'desc' => '微信号',
  158. 'match' => 'is_string',
  159. //'update' => 'select',
  160. //'list' => true,
  161. ),
  162. 'source_type' => array
  163. (
  164. 'type' => 'varchar-100',
  165. 'name' => '用户来源',
  166. 'default' => '',
  167. 'desc' => '请选择用户来源',
  168. 'match' => 'is_string',
  169. 'update' => 'select',
  170. 'option' => $source_type,
  171. 'search' => 'select',
  172. //'list' => true,
  173. ),
  174. 'email' => array
  175. (
  176. 'type' => 'varchar-150',
  177. 'name' => '邮箱',
  178. 'default' => '',
  179. 'desc' => '请输入邮箱',
  180. 'match' => $email,
  181. 'update' => 'text',
  182. //'search' => 'fulltext',
  183. //'list' => true,
  184. ),
  185. 'password' => array
  186. (
  187. 'type' => 'varchar-50',
  188. 'name' => '密码',
  189. 'default' => '',
  190. 'desc' => '请输入密码',
  191. 'match' => 'option',
  192. 'update' => 'password',
  193. 'callback' => 'sha1',
  194. ),
  195. //search_exist_avatar=yes
  196. 'avatar' => array
  197. (
  198. 'type' => 'varchar-150',
  199. 'name' => '头像',
  200. 'default' => '',
  201. 'desc' => '请选择头像',
  202. 'match' => 'option',
  203. 'update' => 'image',
  204. 'key' => '1',
  205. 'place' => '150',
  206. 'list_name' => '详细信息',
  207. //'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  208. 'list' => 'Dever::load("passport/lib/manage.show", {id})',
  209. ),
  210. 'country' => array
  211. (
  212. 'type' => 'varchar-100',
  213. 'name' => '国家',
  214. 'default' => '',
  215. 'desc' => '国家',
  216. 'match' => 'option',
  217. //'update' => 'text',
  218. ),
  219. 'province' => array
  220. (
  221. 'type' => 'varchar-100',
  222. 'name' => '省份',
  223. 'default' => '',
  224. 'desc' => '省份',
  225. 'match' => 'option',
  226. //'update' => 'text',
  227. ),
  228. 'city' => array
  229. (
  230. 'type' => 'varchar-100',
  231. 'name' => '城市',
  232. 'default' => '',
  233. 'desc' => '城市',
  234. 'match' => 'option',
  235. //'update' => 'text',
  236. ),
  237. 'area' => array
  238. (
  239. 'type' => 'varchar-800',
  240. 'name' => '地区',
  241. 'default' => '',
  242. 'desc' => '地区',
  243. 'match' => 'option',
  244. //'update' => 'text',
  245. //'list' => true,
  246. ),
  247. 'area_id' => array
  248. (
  249. 'type' => 'varchar-800',
  250. 'name' => '地区',
  251. 'default' => '',
  252. 'desc' => '地区',
  253. 'match' => 'option',
  254. //'update' => 'text',
  255. //'list' => true,
  256. ),
  257. 'address' => array
  258. (
  259. 'type' => 'varchar-1000',
  260. 'name' => '详细地址',
  261. 'default' => '',
  262. 'desc' => '详细地址',
  263. 'match' => 'option',
  264. //'update' => 'text',
  265. //'list' => true,
  266. ),
  267. 'info' => array
  268. (
  269. 'type' => 'varchar-255',
  270. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  271. 'default' => '',
  272. 'desc' => '请输入介绍',
  273. 'match' => 'option',
  274. 'update' => 'editor',
  275. ),
  276. 'score' => array
  277. (
  278. 'type' => 'varchar-50',
  279. 'name' => '积分',
  280. 'default' => '',
  281. 'desc' => '请输入积分',
  282. 'match' => 'option',
  283. //'update' => 'text',
  284. //'list' => true,
  285. ),
  286. 'sex' => array
  287. (
  288. 'type' => 'tinyint-1',
  289. 'name' => '用户性别',
  290. 'default' => '3',
  291. 'desc' => '用户性别',
  292. 'match' => 'is_numeric',
  293. 'option' => $sex,
  294. 'update' => 'radio',
  295. //'list' => true,
  296. ),
  297. 'level' => array
  298. (
  299. 'type' => 'int-11',
  300. 'name' => '用户等级',
  301. 'default' => '1',
  302. 'desc' => '请选择用户等级',
  303. 'match' => 'is_numeric',
  304. //'option' => $level,
  305. //'update' => 'select',
  306. //'list' => true,
  307. ),
  308. 'temp' => array
  309. (
  310. 'type' => 'tinyint-1',
  311. 'name' => '是否临时用户',
  312. 'default' => '1',
  313. 'desc' => '是否临时用户',
  314. 'match' => 'is_numeric',
  315. //'search' => 'select',
  316. 'option' => $temp,
  317. //'update' => 'select',
  318. //'list' => true,
  319. ),
  320. 'login_date' => array
  321. (
  322. 'type' => 'int-11',
  323. 'name' => '最近登录',
  324. //'match' => array('is_numeric', time()),
  325. 'match' => 'is_numeric',
  326. 'desc' => '',
  327. 'default' => '0',
  328. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  329. ),
  330. 'bind' => array
  331. (
  332. 'type' => 'tinyint-1',
  333. 'name' => '是否绑定手机',
  334. 'default' => '2',
  335. 'desc' => '请选择是否绑定手机',
  336. 'match' => 'is_numeric',
  337. //'option' => $bind,
  338. //'update' => 'radio',
  339. ),
  340. 'state' => array
  341. (
  342. 'type' => 'tinyint-1',
  343. 'name' => '状态',
  344. 'default' => '1',
  345. 'desc' => '请选择状态',
  346. 'match' => 'is_numeric',
  347. 'option' => $option,
  348. 'update' => 'radio',
  349. ),
  350. 'cdate' => array
  351. (
  352. 'type' => 'int-11',
  353. 'name' => '注册时间',
  354. 'match' => array('is_numeric', time()),
  355. 'desc' => '',
  356. # 只有insert时才生效
  357. 'insert' => true,
  358. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  359. ),
  360. ),
  361. 'manage' => array
  362. (
  363. 'excel' => true,
  364. # 列表
  365. 'list_button' => Dever::config('base', 'project')->passport_list_button,
  366. ),
  367. # 更新表结构
  368. /*
  369. 'alter' => array
  370. (
  371. 1 => array
  372. (
  373. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  374. ),
  375. 'version' => 1,
  376. ),
  377. */
  378. # 索引
  379. 'index' => array
  380. (
  381. 1 => array
  382. (
  383. 'mobile' => 'mobile',
  384. ),
  385. # 版本号 更改版本号会更新当前表的索引
  386. 'version' => 1,
  387. ),
  388. # request 请求接口定义
  389. 'request' => array
  390. (
  391. # 此处定义是为跳出auth
  392. 'login' => array
  393. (
  394. 'option' => array
  395. (
  396. 'username' => 'yes',
  397. 'mobile' => 'yes',
  398. 'email' => 'yes',
  399. 'password' => 'yes',
  400. ),
  401. 'type' => 'one',
  402. ),
  403. # 验证手机号是否被使用
  404. 'checkMobile' => array
  405. (
  406. # 匹配的正则或函数 选填项
  407. 'where' => array
  408. (
  409. 'mobile' => 'yes',
  410. 'id' => array('yes', '!='),
  411. ),
  412. 'type' => 'one',
  413. ),
  414. # 此处定义是为跳出auth
  415. 'updates' => array
  416. (
  417. 'set' => array
  418. (
  419. 'state' => 'yes',
  420. ),
  421. 'where' => array
  422. (
  423. 'id' => array('yes', 'in'),
  424. ),
  425. 'type' => 'update',
  426. ),
  427. ),
  428. );