user.php 13 KB

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