user.php 10.0 KB

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