user.php 12 KB

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