admin.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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-getData');
  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. // 可以自定义表头 参考layui table表头自定义
  178. //'list_header' => array('width' => '60%'),
  179. # 绑定js脚本,更新时使用,第一个参数是执行的方式,第二个参数执行的方法,第三个参数是传值。
  180. //'bind' => array('onblur', 'loading', array('url' => Dever::url("auth.blur"))),
  181. ),
  182. #多级联动
  183. //'update' => 'linkage',//多级联动 option参数:请求地址(返回参数为level_num当前联动级数,level_id当前选择的id),参考area组件:dever package area
  184. //'option' => Dever::url('api.get', 'area'),
  185. 'email' => array
  186. (
  187. 'type' => 'varchar-150',
  188. 'name' => '邮箱-可用于登录,请准确填写,不允许重复',
  189. 'default' => '',
  190. 'desc' => '请输入邮箱',
  191. 'match' => Dever::rule('email'),
  192. 'update' => 'text',
  193. /*
  194. * 列表页搜索选项,这里的search或者update的值为
  195. * fulltext:全文检索,模糊匹配
  196. * text:精确匹配
  197. * exp:大小判断,仅能选择一项
  198. * select:选择器,需要option项
  199. * group:组选择器,需要option项
  200. * linkage:多级联动选择器,需要option项,值为联动数据接口地址,参考area组件 'option' => Dever::url('api.get', 'area'), 'list' => 'Dever::load("area/api.string", "{area}")',
  201. * exist:是否存在,需要exist项,基本配置为
  202. $source_id = array
  203. (
  204. 'yes' => '有值',
  205. 'no' => '没有值',
  206. 'no|2832' => '没有值或者有值为2832',
  207. 'yes|2832' => '有值并且过滤值为2829',
  208. '2832' => '查找',
  209. );
  210. * 如果search的值为数组,则认为是接口,需要从接口获取数据后再进行查找
  211. * 如'search' => array
  212. (
  213. 'api' => 'passport/user-all',//接口地址,最好是获取多条数据的地址
  214. 'col' => 'name',//要查询的字段
  215. 'result' => 'id',//返回的字段
  216. 'search' => 'uid',//本表的字段,默认为当前的字段
  217. //'option' => $option, //选择模式
  218. ),
  219. * 就是将本字段email当做passport/user-one的name字段来查找id
  220. */
  221. 'search' => 'fulltext',
  222. 'list' => true,
  223. # 在手机版或者小屏幕下,列表页的表格是否展示,1为展示,2、3、4、5、6均为在一定宽度下展示,详细参考:https://github.com/nadangergeo/RWD-Table-Patterns
  224. 'level' => 1,
  225. //直接上传到云端
  226. //'upload' => 'qiniu',
  227. //上传大数据
  228. //'large' => true,
  229. ),
  230. # 比较特殊的一些设置,不断添加中:
  231. /*
  232. //启用复制其他字段的值
  233. 'testname' => array
  234. (
  235. 'type' => 'varchar-24',
  236. 'name' => '角色名',
  237. 'default' => '',
  238. 'desc' => '请输入角色名',
  239. 'match' => 'is_string',
  240. 'update' => 'copy.name',//直接复制name的值
  241. 'search' => 'order,fulltext',
  242. 'list' => true,
  243. ),
  244. //当前的字段属于另外一个表,主要不要有type
  245. 'manage-role_test-name'=> array
  246. (
  247. 'name' => '测试名',
  248. 'default' => '',
  249. 'desc' => '请输入角色名',
  250. 'match' => 'option',
  251. 'update' => 'text',//直接复制name的值
  252. # 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
  253. 'sync' => array('id', 'role_id'),
  254. 'list' => true,
  255. ),
  256. */
  257. #设置分割条
  258. /*
  259. 'hr1' => array
  260. (
  261. 'name' => '基本信息',
  262. 'class' => '',//本项必须填写
  263. 'attr' => '',
  264. ),
  265. */
  266. /*
  267. 'cate' => array
  268. (
  269. 'type' => 'varchar-300',
  270. 'name' => '标签分类',
  271. 'default' => '1',
  272. 'desc' => '标签分类',
  273. 'match' => 'is_string',
  274. 'update' => 'select',
  275. 'option' => $cate,
  276. 'search' => 'fulltext',
  277. //'list' => true,
  278. 'control' => 'cate',
  279. ),
  280. # 标签,根据分类变化的标签
  281. 'tag' => array
  282. (
  283. 'type' => 'varchar-300',
  284. 'name' => '标签',
  285. 'default' => '',
  286. 'desc' => '标签',
  287. 'match' => 'is_string',
  288. 'update' => 'checkbox',
  289. # 新增接口 暂未实现
  290. 'adding' => 'tag/manage.getByCate?cate=',
  291. # 开启这个,需要将update更换为text类型,输入文字即可选择标签
  292. //'autocomplete' => array('tag/manage.getByName', 'id', 'tag/info-one#name'),
  293. 'search' => 'fulltext',
  294. //'list' => true,
  295. # 与上边的cate联动(ajax)
  296. 'show' => 'cate=tag/manage.getByCate?cate=',
  297. # 或者加入可选项 待实现
  298. 'option' => $cate,
  299. ),
  300. # 标签,根据分类变化的标签
  301. 'tag' => array
  302. (
  303. 'type' => 'text-255',
  304. 'name' => '标签',
  305. 'default' => '',
  306. 'desc' => '标签',
  307. 'match' => 'is_string',
  308. // 多级联动+多选
  309. 'update' => 'linkage_checkbox',
  310. 'option' => array(Dever::url('api.get', 'area'), '', Dever::url('api.get', 'area')),//先选择多级联动,再选择多选
  311. ),
  312. # 加载地图
  313. 'map' => array
  314. (
  315. 'type' => 'varchar-300',
  316. 'name' => '地理位置',
  317. 'default' => '',
  318. 'desc' => '地理位置',
  319. 'match' => 'is_string',
  320. # 如果是map,必须在config的base.php中设置map信息
  321. //'update' => 'map',
  322. 'search' => 'fulltext',
  323. //'list' => true,
  324. //自定义编辑器右侧按钮
  325. 'editor' => array
  326. (
  327. 'name' => '选择插入模块',
  328. 'button' => array
  329. (
  330. array
  331. (
  332. # 名称
  333. 'name' => '图片',
  334. # 资源库id
  335. 'key' => 1,
  336. # 类型
  337. 'type' => 'image',
  338. ),
  339. array
  340. (
  341. 'name' => '音频',
  342. 'key' => 2,
  343. 'type' => 'media',
  344. ),
  345. array
  346. (
  347. 'name' => '视频',
  348. 'key' => 'video/lib/core.vod',
  349. ),
  350. array
  351. (
  352. 'name' => '直播',
  353. 'key' => 'video/lib/core.live',
  354. ),
  355. ),
  356. ),
  357. ),
  358. # 三级地区联动
  359. 'area' => array
  360. (
  361. 'type' => 'varchar-100',
  362. 'name' => '地区',
  363. 'default' => '',
  364. 'desc' => '地区',
  365. 'match' => 'is_string',
  366. 'search' => 'linkage',
  367. 'update' => 'linkage',//多级联动 option参数:请求地址(参数为level_num当前联动级数,level_id当前选择的id)
  368. 'option' => Dever::url('api.get', 'area'),
  369. 'list' => 'Dever::load("area/api.string", "{area}")',
  370. ),
  371. # 无限级联动
  372. 'category' => array
  373. (
  374. 'type' => 'varchar-500',
  375. 'name' => '分类',
  376. 'default' => '',
  377. 'desc' => '分类',
  378. 'match' => 'is_string',
  379. 'search' => 'linkage',
  380. //'update' => 'linkage',
  381. 'option' => Dever::url('api.get', 'category'),
  382. 'list' => 'Dever::load("category/api.string", "{category}")',
  383. ),
  384. # 属性管理
  385. 'attr' => array
  386. (
  387. 'type' => 'varchar-800',
  388. 'name' => '属性设置',
  389. 'default' => '',
  390. 'desc' => '属性设置',
  391. 'match' => 'option',
  392. 'update' => 'checkbox',
  393. 'option' => $attr,
  394. 'update_input' => '',
  395. 'update_input_default' => '',
  396. 'update_parent' => 'checkbox',
  397. ),
  398. # 属性管理 需要用这个来设置值
  399. 'attr_input' => array
  400. (
  401. 'type' => 'text-255',
  402. 'name' => '属性值设置',
  403. 'default' => '',
  404. 'desc' => '属性值设置',
  405. 'match' => 'option',
  406. ),
  407. */
  408. 'mobile' => array
  409. (
  410. 'type' => 'varchar-32',
  411. 'name' => '手机号',
  412. 'default' => '',
  413. 'desc' => '请输入手机号',
  414. 'match' => Dever::rule('mobile'),
  415. 'update' => 'text',
  416. 'search' => 'fulltext',
  417. 'list' => true,
  418. 'level' => 1,
  419. # 显示在table中
  420. //'list_table'=> '111',
  421. ),
  422. 'password' => array
  423. (
  424. 'type' => 'varchar-64',
  425. 'name' => '管理员密码',
  426. 'default' => '',
  427. 'desc' => '请输入管理员密码',
  428. 'match' => 'option',
  429. 'update' => 'password',
  430. 'callback' => 'hash.sha256',
  431. ),
  432. 'config' => array
  433. (
  434. 'type' => 'int-11',
  435. 'name' => '人性化配置',
  436. 'default' => '1',
  437. 'desc' => '个性化配置',
  438. 'match' => 'is_numeric',
  439. 'option' => $config,
  440. 'update' => 'select',
  441. //'list' => true,
  442. ),
  443. 'role' => array
  444. (
  445. 'type' => 'varchar-100',
  446. 'name' => '角色名称',
  447. 'default' => '1',
  448. 'desc' => '请选择角色',
  449. 'match' => 'is_string',
  450. 'option' => $role,
  451. 'update' => 'checkbox',
  452. 'list' => true,
  453. ),
  454. 'group' => array
  455. (
  456. 'type' => 'int-11',
  457. 'name' => '分组',
  458. 'default' => '1',
  459. 'desc' => '请选择分组',
  460. 'match' => 'is_numeric',
  461. 'option' => $group,
  462. 'update' => 'select',
  463. //'list' => true,
  464. # 取代option,从接口里读取选项
  465. //'update_search' => 'goods/lib/manage.search_sku',
  466. ),
  467. 'top' => array
  468. (
  469. 'type' => 'text-255',
  470. 'name' => '头部菜单-这里的头部菜单如果设置,则会覆盖角色中的头部菜单',
  471. 'default' => '',
  472. 'desc' => '请选择头部菜单',
  473. 'match' => 'option',
  474. //'update' => 'checkbox',
  475. 'option' => $top,
  476. ),
  477. 'state' => array
  478. (
  479. 'type' => 'tinyint-1',
  480. 'name' => '数据状态',
  481. 'default' => '1',
  482. 'desc' => '请选择状态',
  483. 'match' => 'is_numeric',
  484. //'option' => $option,
  485. //'update' => 'radio',
  486. //'list' => true,
  487. //'extend' => true,//扩展功能,该字段为虚拟字段,只在数据库中建立extend字段来保存 后续实现
  488. ),
  489. /*
  490. 提供冲突检测机制(乐观锁),保证高并发下的数据安全
  491. 这是模仿自 php 的 Memcached 扩展 后续实现
  492. 'token' => array
  493. (
  494. 'type' => 'int-11',
  495. 'name' => 'token',
  496. 'default' => '1',
  497. 'desc' => 'token',
  498. 'match' => 'is_numeric',
  499. ),
  500. */
  501. 'status' => array
  502. (
  503. 'type' => 'tinyint-1',
  504. 'name' => '状态',
  505. 'default' => '1',
  506. 'desc' => '请选择状态',
  507. 'match' => 'is_numeric',
  508. 'option' => $status,
  509. 'update' => 'radio',
  510. 'list' => true,
  511. 'edit' => true,
  512. ),
  513. 'cdate' => array
  514. (
  515. 'type' => 'int-11',
  516. 'name' => '录入时间',
  517. 'match' => array('is_numeric', DEVER_TIME),
  518. 'desc' => '',
  519. # 只有insert时才生效
  520. 'insert' => true,
  521. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  522. ),
  523. ),
  524. 'manage' => array
  525. (
  526. # 表格使用html模式,默认是js渲染模式
  527. //'list_table' => 'html',
  528. 'delete' => false,
  529. // 载入自定义资源
  530. 'res' => array
  531. (
  532. 'js' => 'demo',
  533. 'css' => 'demo',
  534. ),
  535. # 快捷更新
  536. /*
  537. 'list_button' => array
  538. (
  539. 'edit' => array('审核', 'name'),
  540. ),
  541. */
  542. /*
  543. 'insert' => false,
  544. 'edit' => false,
  545. //'delete' => false,
  546. # 自定义快捷新增和编辑
  547. 'button' => array
  548. (
  549. '新增' => array('fast', 'name,reorder'),
  550. ),
  551. # 快捷更新
  552. 'list_button' => array
  553. (
  554. 'edit' => array('编辑', 'name,reorder'),
  555. ),
  556. */
  557. ),
  558. # 更新表结构
  559. 'alter' => array
  560. (
  561. 2 => array
  562. (
  563. //array('update', 'role', 'role', 'varchar-100 1 角色'),
  564. //array('add', 'config', 'config', 'int-11 1 配置'),
  565. ),
  566. 'version' => 2,
  567. ),
  568. # 默认值
  569. /*
  570. 'default' => array
  571. (
  572. 'col' => 'username,email,password,role,state,cdate',
  573. 'value' => array
  574. (
  575. //'"DMC","DMC@dever.cc","'. md5('admin_' . date('Y_m_d_H')) . '",1, 1,' . time(),
  576. '"admin","DMC@dever.cc","'. hash('sha256', 'admin_123') . '",1, 1,' . DEVER_TIME,
  577. ),
  578. ),
  579. */
  580. # 索引
  581. 'index' => array
  582. (
  583. # 索引名 => 索引id
  584. //'id' => 'id,state',
  585. ),
  586. # request 请求接口定义
  587. 'request' => array
  588. (
  589. # one 根据用户名和密码取一条数据
  590. 'user' => array
  591. (
  592. # 匹配的正则或函数 必填项
  593. 'where' => array
  594. (
  595. //'username' => '/^([A-Za-z0-9])/',
  596. //'username' => 'yes',
  597. 'email' => 'yes',
  598. 'status' => 1,
  599. 'state' => 1,
  600. //'password' => 'is_string',
  601. ),
  602. 'type' => 'one',
  603. # 为这个接口独立设置缓存
  604. 'cache' => true,
  605. ),
  606. # one 根据用户名和密码取一条数据
  607. 'email' => array
  608. (
  609. # 匹配的正则或函数 必填项
  610. 'where' => array
  611. (
  612. //'username' => '/^([A-Za-z0-9])/',
  613. //'username' => 'yes',
  614. 'email' => 'yes',
  615. 'status' => 1,
  616. 'state' => 1,
  617. //'password' => 'is_string',
  618. ),
  619. 'type' => 'one',
  620. # 为这个接口独立设置缓存
  621. 'cache' => true,
  622. ),
  623. # one 根据用户名和密码取一条数据
  624. 'mobile' => array
  625. (
  626. # 匹配的正则或函数 必填项
  627. 'where' => array
  628. (
  629. //'username' => '/^([A-Za-z0-9])/',
  630. //'username' => 'yes',
  631. 'mobile' => 'yes',
  632. 'status' => 1,
  633. 'state' => 1,
  634. //'password' => 'is_string',
  635. ),
  636. 'type' => 'one',
  637. # 为这个接口独立设置缓存
  638. 'cache' => true,
  639. ),
  640. # 更新密码
  641. 'password' => array
  642. (
  643. 'type' => 'update',
  644. 'where' => array
  645. (
  646. 'id' => 'yes',
  647. ),
  648. 'set' => array
  649. (
  650. 'password' => 'yes',
  651. ),
  652. ),
  653. 'getSearch' => array
  654. (
  655. # 匹配的正则或函数 选填项
  656. 'option' => array
  657. (
  658. 'col' => array('yes-mobile,username,email', 'like'),
  659. ),
  660. 'type' => 'all',
  661. 'col' => '*|id',
  662. ),
  663. ),
  664. );