user.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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. //search_exist_avatar=yes
  244. 'avatar' => array
  245. (
  246. 'type' => 'varchar-150',
  247. 'name' => '头像',
  248. 'default' => '',
  249. 'desc' => '请选择头像',
  250. 'match' => 'option',
  251. 'update' => 'image',
  252. 'key' => '1',
  253. 'place' => '150',
  254. 'list_name' => '详细信息',
  255. //'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  256. 'list' => 'Dever::load("passport/lib/manage.show", {id})',
  257. ),
  258. 'address_contact' => array
  259. (
  260. 'type' => 'varchar-100',
  261. 'name' => '联系人',
  262. 'default' => '',
  263. 'desc' => '联系人',
  264. 'match' => 'option',
  265. //'update' => 'text',
  266. //'list' => true,
  267. ),
  268. 'address_mobile' => array
  269. (
  270. 'type' => 'varchar-100',
  271. 'name' => '联系电话',
  272. 'default' => '',
  273. 'desc' => '联系电话',
  274. 'match' => 'option',
  275. //'update' => 'text',
  276. //'list' => true,
  277. ),
  278. 'country' => array
  279. (
  280. 'type' => 'varchar-100',
  281. 'name' => '国家-来自微信',
  282. 'default' => '',
  283. 'desc' => '国家',
  284. 'match' => 'option',
  285. //'update' => 'text',
  286. ),
  287. 'province' => array
  288. (
  289. 'type' => 'varchar-100',
  290. 'name' => '省份-来自微信',
  291. 'default' => '',
  292. 'desc' => '省份',
  293. 'match' => 'option',
  294. //'update' => 'text',
  295. ),
  296. 'city' => array
  297. (
  298. 'type' => 'varchar-100',
  299. 'name' => '城市-来自微信',
  300. 'default' => '',
  301. 'desc' => '城市',
  302. 'match' => 'option',
  303. //'update' => 'text',
  304. ),
  305. 'county' => array
  306. (
  307. 'type' => 'varchar-100',
  308. 'name' => '区县-来自微信',
  309. 'default' => '',
  310. 'desc' => '区县',
  311. 'match' => 'option',
  312. //'update' => 'text',
  313. ),
  314. 'area' => array
  315. (
  316. 'type' => 'varchar-800',
  317. 'name' => '地区-来自微信',
  318. 'default' => '',
  319. 'desc' => '地区',
  320. 'match' => 'option',
  321. //'update' => 'text',
  322. //'list' => true,
  323. ),
  324. 'area_id' => array
  325. (
  326. 'type' => 'varchar-500',
  327. 'name' => '地区-用户自己选择',
  328. 'default' => '',
  329. 'desc' => '地区',
  330. 'match' => 'option',
  331. 'search' => 'linkage',
  332. 'update' => 'linkage',
  333. 'option' => Dever::url('api.get', 'area'),
  334. 'list' => 'Dever::load("area/api.string", "{area_id}")',
  335. ),
  336. 'address' => array
  337. (
  338. 'type' => 'varchar-1000',
  339. 'name' => '详细地址-不带省市区的地址',
  340. 'default' => '',
  341. 'desc' => '详细地址',
  342. 'match' => 'option',
  343. 'update' => 'text',
  344. //'list' => true,
  345. ),
  346. 'info' => array
  347. (
  348. 'type' => 'varchar-255',
  349. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  350. 'default' => '',
  351. 'desc' => '请输入介绍',
  352. 'match' => 'option',
  353. 'update' => 'textarea',
  354. ),
  355. 'score' => array
  356. (
  357. 'type' => 'varchar-50',
  358. 'name' => '积分',
  359. 'default' => '',
  360. 'desc' => '请输入积分',
  361. 'match' => 'option',
  362. //'update' => 'text',
  363. //'list' => true,
  364. ),
  365. 'sex' => array
  366. (
  367. 'type' => 'tinyint-1',
  368. 'name' => '用户性别',
  369. 'default' => '3',
  370. 'desc' => '用户性别',
  371. 'match' => 'is_numeric',
  372. 'option' => $sex,
  373. 'update' => 'radio',
  374. //'list' => true,
  375. ),
  376. 'level' => array
  377. (
  378. 'type' => 'int-11',
  379. 'name' => '用户等级',
  380. 'default' => '1',
  381. 'desc' => '请选择用户等级',
  382. 'match' => 'is_numeric',
  383. //'option' => $level,
  384. //'update' => 'select',
  385. //'list' => true,
  386. ),
  387. 'temp' => array
  388. (
  389. 'type' => 'tinyint-1',
  390. 'name' => '是否临时用户',
  391. 'default' => '1',
  392. 'desc' => '是否临时用户',
  393. 'match' => 'is_numeric',
  394. //'search' => 'select',
  395. 'option' => $temp,
  396. //'update' => 'select',
  397. //'list' => true,
  398. ),
  399. 'birthday' => array
  400. (
  401. 'type' => 'int-11',
  402. 'name' => '生日',
  403. 'default' => '',
  404. 'match' => 'option',
  405. 'desc' => '生日',
  406. 'update' => 'time',
  407. 'callback' => 'maketime',
  408. ),
  409. 'login_date' => array
  410. (
  411. 'type' => 'int-11',
  412. 'name' => '最近登录',
  413. //'match' => array('is_numeric', time()),
  414. 'match' => 'is_numeric',
  415. 'desc' => '',
  416. 'default' => '0',
  417. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  418. ),
  419. 'bind' => array
  420. (
  421. 'type' => 'tinyint-1',
  422. 'name' => '是否绑定手机',
  423. 'default' => '2',
  424. 'desc' => '请选择是否绑定手机',
  425. 'match' => 'is_numeric',
  426. //'option' => $bind,
  427. //'update' => 'radio',
  428. ),
  429. 'state' => array
  430. (
  431. 'type' => 'tinyint-1',
  432. 'name' => '状态',
  433. 'default' => '1',
  434. 'desc' => '请选择状态',
  435. 'match' => 'is_numeric',
  436. 'option' => $option,
  437. 'update' => 'radio',
  438. ),
  439. 'cdate' => array
  440. (
  441. 'type' => 'int-11',
  442. 'name' => '注册时间',
  443. 'match' => array('is_numeric', time()),
  444. 'desc' => '',
  445. # 只有insert时才生效
  446. 'insert' => true,
  447. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  448. ),
  449. ),
  450. 'manage' => array
  451. (
  452. 'excel' => true,
  453. 'button' => $button,
  454. # 列表
  455. 'list_button' => $list_button,
  456. ),
  457. # 更新表结构
  458. /*
  459. 'alter' => array
  460. (
  461. 1 => array
  462. (
  463. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  464. ),
  465. 'version' => 1,
  466. ),
  467. */
  468. # 索引
  469. 'index' => array
  470. (
  471. 1 => array
  472. (
  473. 'mobile' => 'mobile',
  474. ),
  475. # 版本号 更改版本号会更新当前表的索引
  476. 'version' => 1,
  477. ),
  478. # request 请求接口定义
  479. 'request' => array
  480. (
  481. # 此处定义是为跳出auth
  482. 'login' => array
  483. (
  484. 'option' => array
  485. (
  486. 'username' => 'yes',
  487. 'mobile' => 'yes',
  488. 'email' => 'yes',
  489. 'password' => 'yes',
  490. ),
  491. 'type' => 'one',
  492. ),
  493. # 验证手机号是否被使用
  494. 'checkMobile' => array
  495. (
  496. # 匹配的正则或函数 选填项
  497. 'where' => array
  498. (
  499. 'mobile' => 'yes',
  500. 'id' => array('yes', '!='),
  501. ),
  502. 'type' => 'one',
  503. ),
  504. # 此处定义是为跳出auth
  505. 'updates' => array
  506. (
  507. 'set' => array
  508. (
  509. 'state' => 'yes',
  510. ),
  511. 'where' => array
  512. (
  513. 'id' => array('yes', 'in'),
  514. ),
  515. 'type' => 'update',
  516. ),
  517. # 后台搜索用到
  518. 'search' => array
  519. (
  520. # 匹配的正则或函数 选填项
  521. 'option' => array
  522. (
  523. 'ids' => array('yes-id', 'in'),
  524. 'username' => array('yes', 'like'),
  525. 'id' => 'yes',
  526. 'state' => 1,
  527. ),
  528. 'type' => 'all',
  529. 'order' => array('id' => 'desc'),
  530. 'limit' => '0,1000',
  531. 'col' => 'username as name, id, id as value, "" as selected, "" as disabled|id',
  532. ),
  533. # 获取基本常用的信息
  534. 'getOne' => array
  535. (
  536. 'option' => array
  537. (
  538. 'id' => 'yes',
  539. ),
  540. 'type' => 'one',
  541. 'col' => 'id,username,avatar,sex,truename,area,mobile,area_id,address,address_contact,address_mobile,info,title,birthday',
  542. ),
  543. ),
  544. );