user.php 10 KB

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