admin.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | admin.php 管理员表
  5. |--------------------------------------------------------------------------
  6. */
  7. # 定义几个常用的选项
  8. $status = array
  9. (
  10. 1 => '普通',
  11. 2 => '封禁',
  12. );
  13. $cur = Dever::load('manage/auth.data', false);
  14. $desc = '';
  15. if($cur && $cur['role'] > 1)
  16. {
  17. $desc = $cur['username'] . ',你好,你可以在此管理你的下属账号';
  18. $child = array_keys(Dever::db('manage/role')->all());
  19. $admin = Dever::db('manage/admin_role')->getData(array
  20. (
  21. 'role_id' => implode(',', $child),
  22. ));
  23. # 配置当前列表页的参数 只能查看自己下属的管理员
  24. Dever::$global['model']['manage/admin-list'] = array
  25. (
  26. 'option' => array
  27. (
  28. 'id' => array('yes', 'in'),
  29. ),
  30. 'option_id' => $admin ? array_keys($admin) : -1,
  31. );
  32. }
  33. $role = function()
  34. {
  35. return Dever::load('manage/role-all');
  36. };
  37. $group = function()
  38. {
  39. return Dever::load('manage/group-all');
  40. };
  41. $config = function()
  42. {
  43. return Dever::load('manage/config-all');
  44. };
  45. # 获取头部菜单list 建议这里使用匿名函数
  46. $top = function()
  47. {
  48. $data = Dever::load('manage/top.all');
  49. $data['state'] = 1;
  50. return $data;
  51. };
  52. return array
  53. (
  54. # 表名
  55. 'name' => 'admin',
  56. # 显示给用户看的名称
  57. 'lang' => '管理账户设置',
  58. 'desc' => $desc,
  59. # 表类型 值为\innodb\myisam\,默认为innodb,仅在mysql类型有效
  60. 'type' => 'innodb',
  61. # 分区设置,现在仅支持mysql
  62. /*
  63. 'partition' => array
  64. (
  65. 'type' => 'range',//分区类型
  66. 'col' => 'year(cdate)',//分区字段,可以使用mysql内置函数
  67. 'exp' => 'LESS THAN',
  68. //设置分区的值
  69. 'value' => array
  70. (
  71. '1996',
  72. '1997',
  73. '1998',
  74. ),
  75. ),
  76. */
  77. /* 设置上级菜单,当config里设置menu后,这里将失效
  78. 'parent' => array
  79. (
  80. 'key' => 'kefu',
  81. 'order' => 1,
  82. 'name' => '客服设置',
  83. ),
  84. */
  85. # 这个表不使用cache功能
  86. //'cache' => false,
  87. /*
  88. # 用到哪个后台菜单上,对应项目的key
  89. 'menu' => 'project_niuyou_main',
  90. # 后台菜单排序
  91. 'order' => 10,
  92. # 显示到后台快捷发布中,值为排序
  93. 'fast' => 1,
  94. */
  95. 'order' => 9,
  96. # 检测email必须唯一
  97. 'check' => 'email',
  98. # 同步更新另外一个或多个表的多条关联数据,以逗号隔开
  99. 'sync' => array
  100. (
  101. 'manage/admin_role' => array
  102. (
  103. # 更新时的条件,另外一个表的字段 => 本表的字段
  104. 'where' => array('admin_id', 'id'),
  105. # 要更新的数据
  106. 'update' => array('role_id' => 'role'),
  107. # 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
  108. 'type' => 'delete',
  109. )
  110. ),
  111. /*
  112. # 查询出数据时,填充默认数据
  113. 'fill' => array
  114. (
  115. # 从哪个表填充
  116. 'cover/hot_service' => array
  117. (
  118. # 条件,另外一个表的字段 => 本表的字段
  119. 'where' => array('id' => 'service_id', 'seller_id' => '-1'),
  120. # 要填充的数据,另外一个表的字段 => 本表的字段,如果不填写就是所有的
  121. //'update' => array('name', 'title', 'desc', 'desc', 'back_color', 'pic', 'min_pic1', 'min_pic2', 'top', 'top_name', 'top_cover', 'hot_pic', 'case_pic', 'gradient', 'share_name', 'share_desc', 'share_pic', 'content', 'reorder'),
  122. # 不需要填充的字段 与update互斥
  123. 'no' => array('id', 'seller_id', 'service_id', 'chose', 'state', 'cdate')
  124. )
  125. ),
  126. */
  127. # 同步更新另外一个或多个表的一条关联数据
  128. /*
  129. 'syncone' => array
  130. (
  131. 'manage/admin_role' => array
  132. (
  133. # 更新另外一个表的字段 => 本表的字段
  134. 'where' => array('admin_id' => 'id'),
  135. # 要更新的数据
  136. 'update' => array('role_id' => 'role'),
  137. )
  138. ),
  139. */
  140. /*该方法用check替代
  141. 'start' => array
  142. (
  143. 'update' => 'manage/auth.check',
  144. 'insert' => 'manage/auth.check',
  145. ),
  146. */
  147. 'end' => array
  148. (
  149. 'update' => 'manage/auth.update',
  150. ),
  151. # 数据结构
  152. 'struct' => array
  153. (
  154. 'id' => array
  155. (
  156. 'type' => 'int-11',
  157. 'name' => '管理员ID',
  158. 'default' => '',
  159. 'desc' => '',
  160. 'match' => 'is_numeric',
  161. 'search' => 'order',
  162. 'list' => true,
  163. ),
  164. 'username' => array
  165. (
  166. 'type' => 'varchar-24',
  167. 'name' => '管理员名',
  168. 'default' => '',
  169. 'desc' => '请输入管理员名',
  170. 'match' => 'is_string',
  171. 'update' => 'text',
  172. # 自动完成功能,第一个参数是请求的地址,请自行实现,第二个参数是要使用的字段,共有id和value两个选择,id会特殊处理,value则直接把当前值写入,第三个参数是直接替换当前的值,第四个参数是当前表里的字段名,一般为分类的id
  173. //'autocomplete' => array('auth.role?json=1', 'value', 'manage/role-check#name', 'cate_id'),
  174. //'autocomplete' => array('auth.role?json=1'),
  175. 'search' => 'order,fulltext',
  176. 'list' => true,
  177. # 绑定js脚本,更新时使用,第一个参数是执行的方式,第二个参数执行的方法,第三个参数是传值。
  178. //'bind' => array('onblur', 'loading', array('url' => Dever::url("auth.blur"))),
  179. ),
  180. #多级联动
  181. //'update' => 'linkage',//多级联动 option参数:请求地址(返回参数为level_num当前联动级数,level_id当前选择的id),参考area组件:dever package area
  182. //'option' => Dever::url('api.get', 'area'),
  183. 'email' => array
  184. (
  185. 'type' => 'varchar-150',
  186. 'name' => '邮箱-可用于登录,请准确填写,不允许重复',
  187. 'default' => '',
  188. 'desc' => '请输入邮箱',
  189. 'match' => Dever::rule('email'),
  190. 'update' => 'text',
  191. /*
  192. * 列表页搜索选项,这里的search或者update的值为
  193. * fulltext:全文检索,模糊匹配
  194. * text:精确匹配
  195. * exp:大小判断,仅能选择一项
  196. * select:选择器,需要option项
  197. * group:组选择器,需要option项
  198. * linkage:多级联动选择器,需要option项,值为联动数据接口地址,参考area组件 'option' => Dever::url('api.get', 'area'), 'list' => 'Dever::load("area/api.string", "{area}")',
  199. * exist:是否存在,需要exist项,基本配置为
  200. $source_id = array
  201. (
  202. 'yes' => '有值',
  203. 'no' => '没有值',
  204. 'no|2832' => '没有值或者有值为2832',
  205. 'yes|2832' => '有值并且过滤值为2829',
  206. '2832' => '查找',
  207. );
  208. * 如果search的值为数组,则认为是接口,需要从接口获取数据后再进行查找
  209. * 如'search' => array
  210. (
  211. 'api' => 'passport/user-all',//接口地址,最好是获取多条数据的地址
  212. 'col' => 'name',//要查询的字段
  213. 'result' => 'id',//返回的字段
  214. 'search' => 'uid',//本表的字段,默认为当前的字段
  215. //'option' => $option, //选择模式
  216. ),
  217. * 就是将本字段email当做passport/user-one的name字段来查找id
  218. */
  219. 'search' => 'fulltext',
  220. 'list' => true,
  221. # 在手机版或者小屏幕下,列表页的表格是否展示,1为展示,2、3、4、5、6均为在一定宽度下展示,详细参考:https://github.com/nadangergeo/RWD-Table-Patterns
  222. 'level' => 1,
  223. //直接上传到云端
  224. //'upload' => 'qiniu',
  225. //上传大数据
  226. //'large' => true,
  227. ),
  228. # 比较特殊的一些设置,不断添加中:
  229. /*
  230. //启用复制其他字段的值
  231. 'testname' => array
  232. (
  233. 'type' => 'varchar-24',
  234. 'name' => '角色名',
  235. 'default' => '',
  236. 'desc' => '请输入角色名',
  237. 'match' => 'is_string',
  238. 'update' => 'copy.name',//直接复制name的值
  239. 'search' => 'order,fulltext',
  240. 'list' => true,
  241. ),
  242. //当前的字段属于另外一个表,主要不要有type
  243. 'manage-role_test-name'=> array
  244. (
  245. 'name' => '测试名',
  246. 'default' => '',
  247. 'desc' => '请输入角色名',
  248. 'match' => 'option',
  249. 'update' => 'text',//直接复制name的值
  250. # 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
  251. 'sync' => array('id', 'role_id'),
  252. 'list' => true,
  253. ),
  254. */
  255. #设置分割条
  256. /*
  257. 'hr1' => array
  258. (
  259. 'name' => '基本信息',
  260. 'class' => '',//本项必须填写
  261. 'attr' => '',
  262. ),
  263. */
  264. /*
  265. 'cate' => array
  266. (
  267. 'type' => 'varchar-300',
  268. 'name' => '标签分类',
  269. 'default' => '1',
  270. 'desc' => '标签分类',
  271. 'match' => 'is_string',
  272. 'update' => 'select',
  273. 'option' => $cate,
  274. 'search' => 'fulltext',
  275. //'list' => true,
  276. 'control' => 'cate',
  277. ),
  278. # 标签,根据分类变化的标签
  279. 'tag' => array
  280. (
  281. 'type' => 'varchar-300',
  282. 'name' => '标签',
  283. 'default' => '',
  284. 'desc' => '标签',
  285. 'match' => 'is_string',
  286. 'update' => 'checkbox',
  287. # 新增接口 暂未实现
  288. 'adding' => 'tag/manage.getByCate?cate=',
  289. # 开启这个,需要将update更换为text类型,输入文字即可选择标签
  290. //'autocomplete' => array('tag/manage.getByName', 'id', 'tag/info-one#name'),
  291. 'search' => 'fulltext',
  292. //'list' => true,
  293. # 与上边的cate联动(ajax)
  294. 'show' => 'cate=tag/manage.getByCate?cate=',
  295. # 或者加入可选项 待实现
  296. 'option' => $cate,
  297. ),
  298. # 标签,根据分类变化的标签
  299. 'tag' => array
  300. (
  301. 'type' => 'text-255',
  302. 'name' => '标签',
  303. 'default' => '',
  304. 'desc' => '标签',
  305. 'match' => 'is_string',
  306. // 多级联动+多选
  307. 'update' => 'linkage_checkbox',
  308. 'option' => array(Dever::url('api.get', 'area'), '', Dever::url('api.get', 'area')),//先选择多级联动,再选择多选
  309. ),
  310. # 加载地图
  311. 'map' => array
  312. (
  313. 'type' => 'varchar-300',
  314. 'name' => '地理位置',
  315. 'default' => '',
  316. 'desc' => '地理位置',
  317. 'match' => 'is_string',
  318. # 如果是map,必须在config的base.php中设置map信息
  319. //'update' => 'map',
  320. 'search' => 'fulltext',
  321. //'list' => true,
  322. //自定义编辑器右侧按钮
  323. 'editor' => array
  324. (
  325. 'name' => '选择插入模块',
  326. 'button' => array
  327. (
  328. array
  329. (
  330. # 名称
  331. 'name' => '图片',
  332. # 资源库id
  333. 'key' => 1,
  334. # 类型
  335. 'type' => 'image',
  336. ),
  337. array
  338. (
  339. 'name' => '音频',
  340. 'key' => 2,
  341. 'type' => 'media',
  342. ),
  343. array
  344. (
  345. 'name' => '视频',
  346. 'key' => 'video/lib/core.vod',
  347. ),
  348. array
  349. (
  350. 'name' => '直播',
  351. 'key' => 'video/lib/core.live',
  352. ),
  353. ),
  354. ),
  355. ),
  356. # 三级地区联动
  357. 'area' => array
  358. (
  359. 'type' => 'varchar-100',
  360. 'name' => '地区',
  361. 'default' => '',
  362. 'desc' => '地区',
  363. 'match' => 'is_string',
  364. 'search' => 'linkage',
  365. 'update' => 'linkage',//多级联动 option参数:请求地址(参数为level_num当前联动级数,level_id当前选择的id)
  366. 'option' => Dever::url('api.get', 'area'),
  367. 'list' => 'Dever::load("area/api.string", "{area}")',
  368. ),
  369. # 无限级联动
  370. 'category' => array
  371. (
  372. 'type' => 'varchar-500',
  373. 'name' => '分类',
  374. 'default' => '',
  375. 'desc' => '分类',
  376. 'match' => 'is_string',
  377. 'search' => 'linkage',
  378. //'update' => 'linkage',
  379. 'option' => Dever::url('api.get', 'category'),
  380. 'list' => 'Dever::load("category/api.string", "{category}")',
  381. ),
  382. # 属性管理
  383. 'attr' => array
  384. (
  385. 'type' => 'varchar-800',
  386. 'name' => '属性设置',
  387. 'default' => '',
  388. 'desc' => '属性设置',
  389. 'match' => 'option',
  390. 'update' => 'checkbox',
  391. 'option' => $attr,
  392. 'update_input' => '',
  393. 'update_input_default' => '',
  394. 'update_parent' => 'checkbox',
  395. ),
  396. # 属性管理 需要用这个来设置值
  397. 'attr_input' => array
  398. (
  399. 'type' => 'text-255',
  400. 'name' => '属性值设置',
  401. 'default' => '',
  402. 'desc' => '属性值设置',
  403. 'match' => 'option',
  404. ),
  405. */
  406. 'mobile' => array
  407. (
  408. 'type' => 'varchar-32',
  409. 'name' => '手机号',
  410. 'default' => '',
  411. 'desc' => '请输入手机号',
  412. 'match' => Dever::rule('mobile'),
  413. 'update' => 'text',
  414. 'search' => 'fulltext',
  415. 'list' => true,
  416. 'level' => 1,
  417. # 显示在table中
  418. //'list_table'=> '111',
  419. ),
  420. 'password' => array
  421. (
  422. 'type' => 'varchar-64',
  423. 'name' => '管理员密码',
  424. 'default' => '',
  425. 'desc' => '请输入管理员密码',
  426. 'match' => 'option',
  427. 'update' => 'password',
  428. 'callback' => 'hash.sha256',
  429. ),
  430. 'config' => array
  431. (
  432. 'type' => 'int-11',
  433. 'name' => '人性化配置',
  434. 'default' => '1',
  435. 'desc' => '个性化配置',
  436. 'match' => 'is_numeric',
  437. 'option' => $config,
  438. 'update' => 'select',
  439. //'list' => true,
  440. ),
  441. 'role' => array
  442. (
  443. 'type' => 'varchar-100',
  444. 'name' => '角色名称',
  445. 'default' => '1',
  446. 'desc' => '请选择角色',
  447. 'match' => 'is_string',
  448. 'option' => $role,
  449. 'update' => 'checkbox',
  450. 'list' => true,
  451. ),
  452. 'group' => array
  453. (
  454. 'type' => 'int-11',
  455. 'name' => '分组',
  456. 'default' => '1',
  457. 'desc' => '请选择分组',
  458. 'match' => 'is_numeric',
  459. 'option' => $group,
  460. 'update' => 'select',
  461. //'list' => true,
  462. # 取代option,从接口里读取选项
  463. //'update_search' => 'goods/lib/manage.search_sku',
  464. ),
  465. 'top' => array
  466. (
  467. 'type' => 'text-255',
  468. 'name' => '头部菜单-这里的头部菜单如果设置,则会覆盖角色中的头部菜单',
  469. 'default' => '',
  470. 'desc' => '请选择头部菜单',
  471. 'match' => 'option',
  472. //'update' => 'checkbox',
  473. 'option' => $top,
  474. ),
  475. 'state' => array
  476. (
  477. 'type' => 'tinyint-1',
  478. 'name' => '数据状态',
  479. 'default' => '1',
  480. 'desc' => '请选择状态',
  481. 'match' => 'is_numeric',
  482. //'option' => $option,
  483. //'update' => 'radio',
  484. //'list' => true,
  485. //'extend' => true,//扩展功能,该字段为虚拟字段,只在数据库中建立extend字段来保存 后续实现
  486. ),
  487. /*
  488. 提供冲突检测机制(乐观锁),保证高并发下的数据安全
  489. 这是模仿自 php 的 Memcached 扩展 后续实现
  490. 'token' => array
  491. (
  492. 'type' => 'int-11',
  493. 'name' => 'token',
  494. 'default' => '1',
  495. 'desc' => 'token',
  496. 'match' => 'is_numeric',
  497. ),
  498. */
  499. 'status' => array
  500. (
  501. 'type' => 'tinyint-1',
  502. 'name' => '状态',
  503. 'default' => '1',
  504. 'desc' => '请选择状态',
  505. 'match' => 'is_numeric',
  506. 'option' => $status,
  507. 'update' => 'radio',
  508. 'list' => true,
  509. 'edit' => true,
  510. ),
  511. 'cdate' => array
  512. (
  513. 'type' => 'int-11',
  514. 'name' => '录入时间',
  515. 'match' => array('is_numeric', DEVER_TIME),
  516. 'desc' => '',
  517. # 只有insert时才生效
  518. 'insert' => true,
  519. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  520. ),
  521. ),
  522. 'manage' => array
  523. (
  524. 'delete' => false,
  525. // 载入自定义资源
  526. 'res' => array
  527. (
  528. 'js' => 'demo',
  529. 'css' => 'demo',
  530. ),
  531. # 快捷更新
  532. /*
  533. 'list_button' => array
  534. (
  535. 'edit' => array('审核', 'name'),
  536. ),
  537. */
  538. /*
  539. 'insert' => false,
  540. 'edit' => false,
  541. //'delete' => false,
  542. # 自定义快捷新增和编辑
  543. 'button' => array
  544. (
  545. '新增' => array('fast', 'name,reorder'),
  546. ),
  547. # 快捷更新
  548. 'list_button' => array
  549. (
  550. 'edit' => array('编辑', 'name,reorder'),
  551. ),
  552. */
  553. ),
  554. # 更新表结构
  555. 'alter' => array
  556. (
  557. 2 => array
  558. (
  559. //array('update', 'role', 'role', 'varchar-100 1 角色'),
  560. //array('add', 'config', 'config', 'int-11 1 配置'),
  561. ),
  562. 'version' => 2,
  563. ),
  564. # 默认值
  565. /*
  566. 'default' => array
  567. (
  568. 'col' => 'username,email,password,role,state,cdate',
  569. 'value' => array
  570. (
  571. //'"DMC","DMC@dever.cc","'. md5('admin_' . date('Y_m_d_H')) . '",1, 1,' . time(),
  572. '"admin","DMC@dever.cc","'. hash('sha256', 'admin_123') . '",1, 1,' . DEVER_TIME,
  573. ),
  574. ),
  575. */
  576. # 索引
  577. 'index' => array
  578. (
  579. # 索引名 => 索引id
  580. //'id' => 'id,state',
  581. ),
  582. # request 请求接口定义
  583. 'request' => array
  584. (
  585. # one 根据用户名和密码取一条数据
  586. 'user' => array
  587. (
  588. # 匹配的正则或函数 必填项
  589. 'where' => array
  590. (
  591. //'username' => '/^([A-Za-z0-9])/',
  592. //'username' => 'yes',
  593. 'email' => 'yes',
  594. 'status' => 1,
  595. 'state' => 1,
  596. //'password' => 'is_string',
  597. ),
  598. 'type' => 'one',
  599. # 为这个接口独立设置缓存
  600. 'cache' => true,
  601. ),
  602. # one 根据用户名和密码取一条数据
  603. 'email' => array
  604. (
  605. # 匹配的正则或函数 必填项
  606. 'where' => array
  607. (
  608. //'username' => '/^([A-Za-z0-9])/',
  609. //'username' => 'yes',
  610. 'email' => 'yes',
  611. 'status' => 1,
  612. 'state' => 1,
  613. //'password' => 'is_string',
  614. ),
  615. 'type' => 'one',
  616. # 为这个接口独立设置缓存
  617. 'cache' => true,
  618. ),
  619. # one 根据用户名和密码取一条数据
  620. 'mobile' => array
  621. (
  622. # 匹配的正则或函数 必填项
  623. 'where' => array
  624. (
  625. //'username' => '/^([A-Za-z0-9])/',
  626. //'username' => 'yes',
  627. 'mobile' => 'yes',
  628. 'status' => 1,
  629. 'state' => 1,
  630. //'password' => 'is_string',
  631. ),
  632. 'type' => 'one',
  633. # 为这个接口独立设置缓存
  634. 'cache' => true,
  635. ),
  636. # 更新密码
  637. 'password' => array
  638. (
  639. 'type' => 'update',
  640. 'where' => array
  641. (
  642. 'id' => 'yes',
  643. ),
  644. 'set' => array
  645. (
  646. 'password' => 'yes',
  647. ),
  648. ),
  649. ),
  650. );