user.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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 (!$list_button) {
  11. $list_button = array();
  12. }
  13. if (Dever::project('account')) {
  14. $list_button += array
  15. (
  16. 'list99' => array('钱包', '"info&project=account&config_key=qianbao&search_option_uid={id}&oper_parent=user&oper_project=passport"'),
  17. );
  18. }
  19. if (Dever::project('score')) {
  20. $list_button += array
  21. (
  22. 'list100' => array('积分', '"user&project=score&search_option_uid={id}&oper_parent=user&oper_project=passport"'),
  23. 'list101' => array('等级', '"user_level&project=score&search_option_uid={id}&oper_parent=user&oper_project=passport"'),
  24. );
  25. }
  26. /*
  27. $level = function()
  28. {
  29. return Dever::db('passport/level')->state();
  30. };
  31. */
  32. $system = function()
  33. {
  34. $array = array();
  35. $info = Dever::db('passport/system')->state();
  36. if ($info) {
  37. $array += $info;
  38. }
  39. return $array;
  40. };
  41. $profession = function()
  42. {
  43. $array = array();
  44. $info = Dever::db('passport/profession')->state();
  45. if ($info) {
  46. $array += $info;
  47. }
  48. return $array;
  49. };
  50. $sex = array
  51. (
  52. 1 => '男',
  53. 2 => '女',
  54. 3 => '未知',
  55. );
  56. $weixin = array
  57. (
  58. 1 => '已关注',
  59. 2 => '未关注',
  60. );
  61. $temp = array
  62. (
  63. 1 => '临时用户',
  64. 2 => '正式用户',
  65. );
  66. $bind = array
  67. (
  68. 1 => '已绑定',
  69. 2 => '未绑定',
  70. );
  71. # 即将废弃 暂时做兼容
  72. $source_type = array (
  73. 'ios' => 'ios',
  74. 'android' => 'android',
  75. 'h5' => 'h5',
  76. 'applet' => '小程序',
  77. 'pc' => '网站',
  78. 'service' => '公众号',
  79. );
  80. $system_source = Dever::config('base')->system_source;
  81. $email = Dever::rule('email');
  82. $email = 'option';
  83. $mobile = Dever::rule('mobile');
  84. $mobile = 'option';
  85. return array
  86. (
  87. 'email' => $email,
  88. 'mobile' => $mobile,
  89. 'source_type' => $source_type,
  90. 'system_source' => $system_source,
  91. 'sex' => $sex,
  92. # 表名
  93. 'name' => 'user',
  94. # 显示给用户看的名称
  95. 'lang' => '用户管理',
  96. 'order' => 10,
  97. /*
  98. 'end' => array
  99. (
  100. 'insert' => '',
  101. ),
  102. */
  103. # 数据结构
  104. 'struct' => array
  105. (
  106. 'id' => array
  107. (
  108. 'type' => 'int-11',
  109. 'name' => '用户ID',
  110. 'default' => '',
  111. 'desc' => '',
  112. 'match' => 'is_numeric',
  113. 'search' => 'order,fulltext',
  114. 'list' => true,
  115. ),
  116. 'username' => array
  117. (
  118. 'type' => 'varchar-50',
  119. 'name' => '用户名',
  120. 'default' => '',
  121. 'desc' => '请输入用户名',
  122. 'match' => 'is_string',
  123. 'update' => 'text',
  124. 'search' => 'fulltext',
  125. 'list' => true,
  126. ),
  127. 'truename' => array
  128. (
  129. 'type' => 'varchar-50',
  130. 'name' => '姓名',
  131. 'default' => '',
  132. 'desc' => '请输入姓名',
  133. 'match' => 'option',
  134. 'update' => 'text',
  135. 'search' => 'fulltext',
  136. //'list' => '"{truename}" ? "{truename}" : "点此编辑"',
  137. //'edit' => true,
  138. ),
  139. 'title' => array
  140. (
  141. 'type' => 'varchar-800',
  142. 'name' => '头衔',
  143. 'default' => '',
  144. 'desc' => '请输入头衔',
  145. 'match' => 'option',
  146. 'update' => 'text',
  147. 'search' => 'fulltext',
  148. ),
  149. 'mobile' => array
  150. (
  151. 'type' => 'varchar-32',
  152. 'name' => '手机号',
  153. 'default' => '',
  154. 'desc' => '请输入用户手机号',
  155. 'match' => $mobile,
  156. 'update' => 'text',
  157. 'search' => 'fulltext,exist',
  158. 'exist' => array
  159. (
  160. 'yes' => '有值',
  161. //'no' => '没有值',
  162. ),
  163. 'list' => true,
  164. ),
  165. 'system_id' => array
  166. (
  167. 'type' => 'int-11',
  168. 'name' => '所属项目',
  169. 'default' => '1',
  170. 'desc' => '所属项目',
  171. 'match' => 'is_numeric',
  172. 'option' => $system,
  173. //'update' => 'select',
  174. //'list' => true,
  175. ),
  176. 'profession' => array
  177. (
  178. 'type' => 'int-11',
  179. 'name' => '职业',
  180. 'default' => '1',
  181. 'desc' => '职业',
  182. 'match' => 'is_numeric',
  183. 'option' => $profession,
  184. //'update' => 'select',
  185. //'list' => true,
  186. ),
  187. 'wechat' => array
  188. (
  189. 'type' => 'varchar-100',
  190. 'name' => '微信号',
  191. 'default' => '',
  192. 'desc' => '微信号',
  193. 'match' => 'is_string',
  194. //'update' => 'select',
  195. //'list' => true,
  196. ),
  197. 'source_type' => array
  198. (
  199. 'type' => 'varchar-100',
  200. 'name' => '用户来源-废弃,用system_source替代,暂时保留',
  201. 'default' => '',
  202. 'desc' => '请选择用户来源',
  203. 'match' => 'is_string',
  204. //'update' => 'select',
  205. 'option' => $source_type,
  206. //'search' => 'select',
  207. //'list' => true,
  208. ),
  209. 'system_source' => array
  210. (
  211. 'type' => 'tinyint-1',
  212. 'name' => '所属平台',
  213. 'default' => '1',
  214. 'desc' => '所属平台',
  215. 'match' => 'is_numeric',
  216. 'option' => $system_source,
  217. 'update' => 'radio',
  218. 'search' => 'select',
  219. 'list' => true,
  220. ),
  221. 'email' => array
  222. (
  223. 'type' => 'varchar-150',
  224. 'name' => '邮箱',
  225. 'default' => '',
  226. 'desc' => '请输入邮箱',
  227. 'match' => $email,
  228. 'update' => 'text',
  229. //'search' => 'fulltext',
  230. //'list' => true,
  231. ),
  232. 'password' => array
  233. (
  234. 'type' => 'varchar-50',
  235. 'name' => '密码',
  236. 'default' => '',
  237. 'desc' => '请输入密码',
  238. 'match' => 'option',
  239. 'update' => 'password',
  240. 'callback' => 'sha1',
  241. ),
  242. 'avatar_id' => array
  243. (
  244. 'type' => 'int-11',
  245. 'name' => '默认头像',
  246. 'default' => '1',
  247. 'desc' => '默认头像',
  248. 'match' => 'is_numeric',
  249. ),
  250. //search_exist_avatar=yes
  251. 'avatar' => array
  252. (
  253. 'type' => 'varchar-150',
  254. 'name' => '头像',
  255. 'default' => '',
  256. 'desc' => '请选择头像',
  257. 'match' => 'option',
  258. 'update' => 'image',
  259. 'key' => '1',
  260. 'place' => '150',
  261. 'list_name' => '详细信息',
  262. //'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  263. 'list' => 'Dever::load("passport/lib/manage.show", {id})',
  264. ),
  265. 'address_contact' => array
  266. (
  267. 'type' => 'varchar-100',
  268. 'name' => '联系人',
  269. 'default' => '',
  270. 'desc' => '联系人',
  271. 'match' => 'option',
  272. //'update' => 'text',
  273. //'list' => true,
  274. ),
  275. 'address_mobile' => array
  276. (
  277. 'type' => 'varchar-100',
  278. 'name' => '联系电话',
  279. 'default' => '',
  280. 'desc' => '联系电话',
  281. 'match' => 'option',
  282. //'update' => 'text',
  283. //'list' => true,
  284. ),
  285. 'country' => array
  286. (
  287. 'type' => 'varchar-100',
  288. 'name' => '国家-来自微信',
  289. 'default' => '',
  290. 'desc' => '国家',
  291. 'match' => 'option',
  292. //'update' => 'text',
  293. ),
  294. 'province' => array
  295. (
  296. 'type' => 'varchar-100',
  297. 'name' => '省份-来自微信',
  298. 'default' => '',
  299. 'desc' => '省份',
  300. 'match' => 'option',
  301. //'update' => 'text',
  302. ),
  303. 'city' => array
  304. (
  305. 'type' => 'varchar-100',
  306. 'name' => '城市-来自微信',
  307. 'default' => '',
  308. 'desc' => '城市',
  309. 'match' => 'option',
  310. //'update' => 'text',
  311. ),
  312. 'county' => array
  313. (
  314. 'type' => 'varchar-100',
  315. 'name' => '区县-来自微信',
  316. 'default' => '',
  317. 'desc' => '区县',
  318. 'match' => 'option',
  319. //'update' => 'text',
  320. ),
  321. 'area' => array
  322. (
  323. 'type' => 'varchar-800',
  324. 'name' => '地区-来自微信',
  325. 'default' => '',
  326. 'desc' => '地区',
  327. 'match' => 'option',
  328. //'update' => 'text',
  329. //'list' => true,
  330. ),
  331. 'area_id' => array
  332. (
  333. 'type' => 'varchar-500',
  334. 'name' => '地区-用户自己选择',
  335. 'default' => '',
  336. 'desc' => '地区',
  337. 'match' => 'option',
  338. 'search' => 'linkage',
  339. 'update' => 'linkage',
  340. 'option' => Dever::url('api.get', 'area'),
  341. 'list' => 'Dever::load("area/api.string", "{area_id}")',
  342. ),
  343. 'address' => array
  344. (
  345. 'type' => 'varchar-1000',
  346. 'name' => '详细地址-不带省市区的地址',
  347. 'default' => '',
  348. 'desc' => '详细地址',
  349. 'match' => 'option',
  350. 'update' => 'text',
  351. //'list' => true,
  352. ),
  353. 'info' => array
  354. (
  355. 'type' => 'varchar-255',
  356. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  357. 'default' => '',
  358. 'desc' => '请输入介绍',
  359. 'match' => 'option',
  360. 'update' => 'textarea',
  361. ),
  362. 'cash' => array
  363. (
  364. 'type' => 'decimal-11,2',
  365. 'name' => '钱包余额',
  366. 'default' => '0',
  367. 'desc' => '钱包余额',
  368. 'match' => 'is_string',
  369. //'update' => 'text',
  370. //'list' => true,
  371. ),
  372. 'score' => array
  373. (
  374. 'type' => 'varchar-50',
  375. 'name' => '积分',
  376. 'default' => '',
  377. 'desc' => '请输入积分',
  378. 'match' => 'option',
  379. //'update' => 'text',
  380. //'list' => true,
  381. ),
  382. 'sex' => array
  383. (
  384. 'type' => 'tinyint-1',
  385. 'name' => '用户性别',
  386. 'default' => '3',
  387. 'desc' => '用户性别',
  388. 'match' => 'is_numeric',
  389. 'option' => $sex,
  390. 'update' => 'radio',
  391. //'list' => true,
  392. ),
  393. 'level' => array
  394. (
  395. 'type' => 'int-11',
  396. 'name' => '用户等级',
  397. 'default' => '1',
  398. 'desc' => '请选择用户等级',
  399. 'match' => 'is_numeric',
  400. //'option' => $level,
  401. //'update' => 'select',
  402. //'list' => true,
  403. ),
  404. 'temp' => array
  405. (
  406. 'type' => 'tinyint-1',
  407. 'name' => '是否临时用户',
  408. 'default' => '1',
  409. 'desc' => '是否临时用户',
  410. 'match' => 'is_numeric',
  411. //'search' => 'select',
  412. 'option' => $temp,
  413. //'update' => 'select',
  414. //'list' => true,
  415. ),
  416. 'birthday' => array
  417. (
  418. 'type' => 'int-11',
  419. 'name' => '生日',
  420. 'default' => '',
  421. 'match' => 'option',
  422. 'desc' => '生日',
  423. 'update' => 'time',
  424. 'callback' => 'maketime',
  425. ),
  426. 'login_date' => array
  427. (
  428. 'type' => 'int-11',
  429. 'name' => '最近登录',
  430. //'match' => array('is_numeric', time()),
  431. 'match' => 'is_numeric',
  432. 'desc' => '',
  433. 'default' => '0',
  434. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  435. ),
  436. 'bind' => array
  437. (
  438. 'type' => 'tinyint-1',
  439. 'name' => '是否绑定手机',
  440. 'default' => '2',
  441. 'desc' => '请选择是否绑定手机',
  442. 'match' => 'is_numeric',
  443. //'option' => $bind,
  444. //'update' => 'radio',
  445. ),
  446. 'state' => array
  447. (
  448. 'type' => 'tinyint-1',
  449. 'name' => '状态',
  450. 'default' => '1',
  451. 'desc' => '请选择状态',
  452. 'match' => 'is_numeric',
  453. //'option' => $option,
  454. //'update' => 'radio',
  455. ),
  456. 'cdate' => array
  457. (
  458. 'type' => 'int-11',
  459. 'name' => '注册时间',
  460. 'match' => array('is_numeric', time()),
  461. 'desc' => '',
  462. # 只有insert时才生效
  463. 'insert' => true,
  464. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  465. ),
  466. ),
  467. 'manage' => array
  468. (
  469. 'excel' => true,
  470. 'button' => $button,
  471. # 列表
  472. 'list_button' => $list_button,
  473. ),
  474. # 更新表结构
  475. /*
  476. 'alter' => array
  477. (
  478. 1 => array
  479. (
  480. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  481. ),
  482. 'version' => 1,
  483. ),
  484. */
  485. # 索引
  486. 'index' => array
  487. (
  488. 1 => array
  489. (
  490. 'mobile' => 'mobile',
  491. ),
  492. # 版本号 更改版本号会更新当前表的索引
  493. 'version' => 1,
  494. ),
  495. # request 请求接口定义
  496. 'request' => array
  497. (
  498. # 此处定义是为跳出auth
  499. 'login' => array
  500. (
  501. 'option' => array
  502. (
  503. 'username' => 'yes',
  504. 'mobile' => 'yes',
  505. 'email' => 'yes',
  506. 'password' => 'yes',
  507. ),
  508. 'type' => 'one',
  509. ),
  510. # 验证手机号是否被使用
  511. 'checkMobile' => array
  512. (
  513. # 匹配的正则或函数 选填项
  514. 'where' => array
  515. (
  516. 'mobile' => 'yes',
  517. 'id' => array('yes', '!='),
  518. ),
  519. 'type' => 'one',
  520. ),
  521. # 此处定义是为跳出auth
  522. 'updates' => array
  523. (
  524. 'set' => array
  525. (
  526. 'state' => 'yes',
  527. ),
  528. 'where' => array
  529. (
  530. 'id' => array('yes', 'in'),
  531. ),
  532. 'type' => 'update',
  533. ),
  534. # 后台搜索用到
  535. 'search' => array
  536. (
  537. # 匹配的正则或函数 选填项
  538. 'option' => array
  539. (
  540. 'ids' => array('yes-id', 'in'),
  541. 'username' => array('yes', 'like'),
  542. 'id' => 'yes',
  543. 'state' => 1,
  544. ),
  545. 'type' => 'all',
  546. 'order' => array('id' => 'desc'),
  547. 'limit' => '0,1000',
  548. 'col' => 'username as name, id, id as value, "" as selected, "" as disabled|id',
  549. ),
  550. # 获取基本常用的信息
  551. 'getOne' => array
  552. (
  553. 'option' => array
  554. (
  555. 'id' => 'yes',
  556. ),
  557. 'type' => 'one',
  558. 'col' => 'id,username,avatar,sex,truename,area,mobile,area_id,address,address_contact,address_mobile,info,title,birthday,avatar_id,cash',
  559. ),
  560. 'getNum' => array
  561. (
  562. # 匹配的正则或函数 选填项
  563. 'option' => array
  564. (
  565. 'start' => array('yes-cdate', '>='),
  566. 'end' => array('yes-cdate', '<='),
  567. 'state' => 1,
  568. ),
  569. 'type' => 'count',
  570. 'col' => '*',
  571. ),
  572. 'like' => array
  573. (
  574. # 匹配的正则或函数 选填项
  575. 'option' => array
  576. (
  577. 'search' => array('yes-mobile,username', 'like'),
  578. 'mobile' => array('yes', 'like'),
  579. 'username' => array('yes', 'like'),
  580. 'id' => 'yes',
  581. 'state' => 1,
  582. ),
  583. 'type' => 'all',
  584. 'order' => array('id' => 'desc'),
  585. 'col' => '*|id',
  586. ),
  587. 'upCash' => array
  588. (
  589. 'type' => 'update',
  590. 'where' => array
  591. (
  592. 'id' => 'yes',
  593. ),
  594. 'set' => array
  595. (
  596. 'cash' => array('yes', '+='),
  597. ),
  598. ),
  599. ),
  600. );