user.php 9.1 KB

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