user.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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. 'mobile' => array
  141. (
  142. 'type' => 'varchar-32',
  143. 'name' => '手机号',
  144. 'default' => '',
  145. 'desc' => '请输入用户手机号',
  146. 'match' => $mobile,
  147. 'update' => 'text',
  148. 'search' => 'fulltext,exist',
  149. 'exist' => array
  150. (
  151. 'yes' => '有值',
  152. //'no' => '没有值',
  153. ),
  154. 'list' => true,
  155. ),
  156. 'system_id' => array
  157. (
  158. 'type' => 'int-11',
  159. 'name' => '所属项目',
  160. 'default' => '1',
  161. 'desc' => '所属项目',
  162. 'match' => 'is_numeric',
  163. 'option' => $system,
  164. //'update' => 'select',
  165. //'list' => true,
  166. ),
  167. 'profession' => array
  168. (
  169. 'type' => 'int-11',
  170. 'name' => '职业',
  171. 'default' => '1',
  172. 'desc' => '职业',
  173. 'match' => 'is_numeric',
  174. 'option' => $profession,
  175. //'update' => 'select',
  176. //'list' => true,
  177. ),
  178. 'wechat' => array
  179. (
  180. 'type' => 'varchar-100',
  181. 'name' => '微信号',
  182. 'default' => '',
  183. 'desc' => '微信号',
  184. 'match' => 'is_string',
  185. //'update' => 'select',
  186. //'list' => true,
  187. ),
  188. 'source_type' => array
  189. (
  190. 'type' => 'varchar-100',
  191. 'name' => '用户来源-废弃,用system_source替代,暂时保留',
  192. 'default' => '',
  193. 'desc' => '请选择用户来源',
  194. 'match' => 'is_string',
  195. //'update' => 'select',
  196. 'option' => $source_type,
  197. //'search' => 'select',
  198. //'list' => true,
  199. ),
  200. 'system_source' => array
  201. (
  202. 'type' => 'tinyint-1',
  203. 'name' => '所属平台',
  204. 'default' => '1',
  205. 'desc' => '所属平台',
  206. 'match' => 'is_numeric',
  207. 'option' => $system_source,
  208. 'update' => 'radio',
  209. 'search' => 'select',
  210. 'list' => true,
  211. ),
  212. 'email' => array
  213. (
  214. 'type' => 'varchar-150',
  215. 'name' => '邮箱',
  216. 'default' => '',
  217. 'desc' => '请输入邮箱',
  218. 'match' => $email,
  219. 'update' => 'text',
  220. //'search' => 'fulltext',
  221. //'list' => true,
  222. ),
  223. 'password' => array
  224. (
  225. 'type' => 'varchar-50',
  226. 'name' => '密码',
  227. 'default' => '',
  228. 'desc' => '请输入密码',
  229. 'match' => 'option',
  230. 'update' => 'password',
  231. 'callback' => 'sha1',
  232. ),
  233. //search_exist_avatar=yes
  234. 'avatar' => array
  235. (
  236. 'type' => 'varchar-150',
  237. 'name' => '头像',
  238. 'default' => '',
  239. 'desc' => '请选择头像',
  240. 'match' => 'option',
  241. 'update' => 'image',
  242. 'key' => '1',
  243. 'place' => '150',
  244. 'list_name' => '详细信息',
  245. //'list' => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
  246. 'list' => 'Dever::load("passport/lib/manage.show", {id})',
  247. ),
  248. 'address_contact' => array
  249. (
  250. 'type' => 'varchar-100',
  251. 'name' => '联系人',
  252. 'default' => '',
  253. 'desc' => '联系人',
  254. 'match' => 'option',
  255. //'update' => 'text',
  256. //'list' => true,
  257. ),
  258. 'address_mobile' => array
  259. (
  260. 'type' => 'varchar-100',
  261. 'name' => '联系电话',
  262. 'default' => '',
  263. 'desc' => '联系电话',
  264. 'match' => 'option',
  265. //'update' => 'text',
  266. //'list' => true,
  267. ),
  268. 'country' => array
  269. (
  270. 'type' => 'varchar-100',
  271. 'name' => '国家-来自微信',
  272. 'default' => '',
  273. 'desc' => '国家',
  274. 'match' => 'option',
  275. //'update' => 'text',
  276. ),
  277. 'province' => array
  278. (
  279. 'type' => 'varchar-100',
  280. 'name' => '省份-来自微信',
  281. 'default' => '',
  282. 'desc' => '省份',
  283. 'match' => 'option',
  284. //'update' => 'text',
  285. ),
  286. 'city' => array
  287. (
  288. 'type' => 'varchar-100',
  289. 'name' => '城市-来自微信',
  290. 'default' => '',
  291. 'desc' => '城市',
  292. 'match' => 'option',
  293. //'update' => 'text',
  294. ),
  295. 'county' => array
  296. (
  297. 'type' => 'varchar-100',
  298. 'name' => '区县-来自微信',
  299. 'default' => '',
  300. 'desc' => '区县',
  301. 'match' => 'option',
  302. //'update' => 'text',
  303. ),
  304. 'area' => array
  305. (
  306. 'type' => 'varchar-800',
  307. 'name' => '地区-来自微信',
  308. 'default' => '',
  309. 'desc' => '地区',
  310. 'match' => 'option',
  311. //'update' => 'text',
  312. //'list' => true,
  313. ),
  314. 'area_id' => array
  315. (
  316. 'type' => 'varchar-500',
  317. 'name' => '地区-用户自己选择',
  318. 'default' => '',
  319. 'desc' => '地区',
  320. 'match' => 'is_string',
  321. 'search' => 'linkage',
  322. 'update' => 'linkage',
  323. 'option' => Dever::url('api.get', 'area'),
  324. 'list' => 'Dever::load("area/api.string", "{area_id}")',
  325. ),
  326. 'address' => array
  327. (
  328. 'type' => 'varchar-1000',
  329. 'name' => '详细地址-不带省市区的地址',
  330. 'default' => '',
  331. 'desc' => '详细地址',
  332. 'match' => 'option',
  333. 'update' => 'text',
  334. //'list' => true,
  335. ),
  336. 'info' => array
  337. (
  338. 'type' => 'varchar-255',
  339. 'name' => '介绍-选填,如果想清空该介绍,请输入null。',
  340. 'default' => '',
  341. 'desc' => '请输入介绍',
  342. 'match' => 'option',
  343. 'update' => 'editor',
  344. ),
  345. 'score' => array
  346. (
  347. 'type' => 'varchar-50',
  348. 'name' => '积分',
  349. 'default' => '',
  350. 'desc' => '请输入积分',
  351. 'match' => 'option',
  352. //'update' => 'text',
  353. //'list' => true,
  354. ),
  355. 'sex' => array
  356. (
  357. 'type' => 'tinyint-1',
  358. 'name' => '用户性别',
  359. 'default' => '3',
  360. 'desc' => '用户性别',
  361. 'match' => 'is_numeric',
  362. 'option' => $sex,
  363. 'update' => 'radio',
  364. //'list' => true,
  365. ),
  366. 'level' => array
  367. (
  368. 'type' => 'int-11',
  369. 'name' => '用户等级',
  370. 'default' => '1',
  371. 'desc' => '请选择用户等级',
  372. 'match' => 'is_numeric',
  373. //'option' => $level,
  374. //'update' => 'select',
  375. //'list' => true,
  376. ),
  377. 'temp' => array
  378. (
  379. 'type' => 'tinyint-1',
  380. 'name' => '是否临时用户',
  381. 'default' => '1',
  382. 'desc' => '是否临时用户',
  383. 'match' => 'is_numeric',
  384. //'search' => 'select',
  385. 'option' => $temp,
  386. //'update' => 'select',
  387. //'list' => true,
  388. ),
  389. 'login_date' => array
  390. (
  391. 'type' => 'int-11',
  392. 'name' => '最近登录',
  393. //'match' => array('is_numeric', time()),
  394. 'match' => 'is_numeric',
  395. 'desc' => '',
  396. 'default' => '0',
  397. //'list' => 'date("Y-m-d H:i:s", {login_date})',
  398. ),
  399. 'bind' => array
  400. (
  401. 'type' => 'tinyint-1',
  402. 'name' => '是否绑定手机',
  403. 'default' => '2',
  404. 'desc' => '请选择是否绑定手机',
  405. 'match' => 'is_numeric',
  406. //'option' => $bind,
  407. //'update' => 'radio',
  408. ),
  409. 'state' => array
  410. (
  411. 'type' => 'tinyint-1',
  412. 'name' => '状态',
  413. 'default' => '1',
  414. 'desc' => '请选择状态',
  415. 'match' => 'is_numeric',
  416. 'option' => $option,
  417. 'update' => 'radio',
  418. ),
  419. 'cdate' => array
  420. (
  421. 'type' => 'int-11',
  422. 'name' => '注册时间',
  423. 'match' => array('is_numeric', time()),
  424. 'desc' => '',
  425. # 只有insert时才生效
  426. 'insert' => true,
  427. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  428. ),
  429. ),
  430. 'manage' => array
  431. (
  432. 'excel' => true,
  433. 'button' => $button,
  434. # 列表
  435. 'list_button' => $list_button,
  436. ),
  437. # 更新表结构
  438. /*
  439. 'alter' => array
  440. (
  441. 1 => array
  442. (
  443. array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
  444. ),
  445. 'version' => 1,
  446. ),
  447. */
  448. # 索引
  449. 'index' => array
  450. (
  451. 1 => array
  452. (
  453. 'mobile' => 'mobile',
  454. ),
  455. # 版本号 更改版本号会更新当前表的索引
  456. 'version' => 1,
  457. ),
  458. # request 请求接口定义
  459. 'request' => array
  460. (
  461. # 此处定义是为跳出auth
  462. 'login' => array
  463. (
  464. 'option' => array
  465. (
  466. 'username' => 'yes',
  467. 'mobile' => 'yes',
  468. 'email' => 'yes',
  469. 'password' => 'yes',
  470. ),
  471. 'type' => 'one',
  472. ),
  473. # 验证手机号是否被使用
  474. 'checkMobile' => array
  475. (
  476. # 匹配的正则或函数 选填项
  477. 'where' => array
  478. (
  479. 'mobile' => 'yes',
  480. 'id' => array('yes', '!='),
  481. ),
  482. 'type' => 'one',
  483. ),
  484. # 此处定义是为跳出auth
  485. 'updates' => array
  486. (
  487. 'set' => array
  488. (
  489. 'state' => 'yes',
  490. ),
  491. 'where' => array
  492. (
  493. 'id' => array('yes', 'in'),
  494. ),
  495. 'type' => 'update',
  496. ),
  497. # 后台搜索用到
  498. 'search' => array
  499. (
  500. # 匹配的正则或函数 选填项
  501. 'option' => array
  502. (
  503. 'ids' => array('yes-id', 'in'),
  504. 'username' => array('yes', 'like'),
  505. 'id' => 'yes',
  506. 'state' => 1,
  507. ),
  508. 'type' => 'all',
  509. 'order' => array('id' => 'desc'),
  510. 'limit' => '0,1000',
  511. 'col' => 'username as name, id, id as value, "" as selected, "" as disabled|id',
  512. ),
  513. # 获取基本常用的信息
  514. 'getOne' => array
  515. (
  516. 'option' => array
  517. (
  518. 'id' => 'yes',
  519. ),
  520. 'type' => 'one',
  521. 'col' => 'id,username,avatar,sex,truename,area,mobile,area_id,address,address_contact,address_mobile,info',
  522. ),
  523. ),
  524. );