user.php 9.5 KB

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