5e682b79e0843567f9f6fc36f95a66b7ad834dc2.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | admin.php 管理员表
  5. |--------------------------------------------------------------------------
  6. */
  7. # 定义几个常用的选项
  8. $option = array
  9. (
  10. 1 => '普通',
  11. 2 => '封禁',
  12. );
  13. $role = function()
  14. {
  15. return Maze::load('/role-all');
  16. };
  17. $config = function()
  18. {
  19. return Maze::load('/config-all');
  20. };
  21. return array
  22. (
  23. # 表名
  24. 'name' => 'admin',
  25. # 显示给用户看的名称
  26. 'lang' => '管理账户设置',
  27. /*
  28. # 用到哪个后台菜单上,对应项目的key
  29. 'menu' => 'project_niuyou_main',
  30. # 后台菜单排序
  31. 'order' => 10,
  32. # 显示到后台快捷发布中,值为排序
  33. 'fast' => 1,
  34. */
  35. 'order' => 9,
  36. # 数据结构
  37. 'struct' => array
  38. (
  39. 'id' => array
  40. (
  41. 'type' => 'int-11',
  42. 'name' => '管理员ID',
  43. 'default' => '',
  44. 'desc' => '',
  45. 'match' => 'is_numeric',
  46. 'search' => 'order',
  47. 'list' => true,
  48. ),
  49. 'username' => array
  50. (
  51. 'type' => 'varchar-24',
  52. 'name' => '管理员名',
  53. 'default' => '',
  54. 'desc' => '请输入管理员名',
  55. 'match' => 'is_string',
  56. 'update' => 'text',
  57. //'autocomplete' => 'auth.role?json=1',
  58. 'search' => 'order,fulltext',
  59. 'list' => true,
  60. ),
  61. 'password' => array
  62. (
  63. 'type' => 'varchar-32',
  64. 'name' => '管理员密码',
  65. 'default' => '',
  66. 'desc' => '请输入管理员密码',
  67. 'match' => 'option',
  68. 'update' => 'password',
  69. 'callback' => 'md5',
  70. ),
  71. 'config' => array
  72. (
  73. 'type' => 'int-11',
  74. 'name' => '后台配置',
  75. 'default' => '1',
  76. 'desc' => '请选择后台配置',
  77. 'match' => 'is_numeric',
  78. 'option' => $config,
  79. 'update' => 'select',
  80. 'list' => true,
  81. ),
  82. 'role' => array
  83. (
  84. 'type' => 'varchar-100',
  85. 'name' => '角色',
  86. 'default' => '1',
  87. 'desc' => '请选择角色',
  88. 'match' => 'is_string',
  89. 'option' => $role,
  90. 'update' => 'checkbox',
  91. //'list' => true,
  92. ),
  93. 'state' => array
  94. (
  95. 'type' => 'tinyint-1',
  96. 'name' => '状态',
  97. 'default' => '1',
  98. 'desc' => '请选择状态',
  99. 'match' => 'is_numeric',
  100. 'option' => $option,
  101. 'update' => 'radio',
  102. 'list' => true,
  103. ),
  104. 'cdate' => array
  105. (
  106. 'type' => 'int-11',
  107. 'name' => '录入时间',
  108. 'match' => array('is_numeric', time()),
  109. 'desc' => '',
  110. # 只有insert时才生效
  111. 'insert' => true,
  112. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  113. ),
  114. ),
  115. # 更新表结构
  116. 'alter' => array
  117. (
  118. 2 => array
  119. (
  120. array('update', 'role', 'role', 'varchar-100 1 角色'),
  121. array('add', 'config', 'config', 'int-11 1 配置'),
  122. ),
  123. 'version' => 2,
  124. ),
  125. # 默认值
  126. 'default' => array
  127. (
  128. 'col' => 'username,password,role,state,cdate',
  129. 'value' => array
  130. (
  131. '"admin","'. md5('admin123') . '",1, 1,' . time(),
  132. ),
  133. ),
  134. # 索引
  135. 'index' => array
  136. (
  137. # 索引名 => 索引id
  138. //'id' => 'id,state',
  139. ),
  140. # request 请求接口定义
  141. 'request' => array
  142. (
  143. # one 根据用户名和密码取一条数据
  144. 'user' => array
  145. (
  146. # 匹配的正则或函数 必填项
  147. 'where' => array
  148. (
  149. //'username' => '/^([A-Za-z0-9])/',
  150. 'username' => 'is_string',
  151. //'password' => 'is_string',
  152. ),
  153. 'type' => 'one',
  154. ),
  155. # 更新密码
  156. 'password' => array
  157. (
  158. 'type' => 'update',
  159. 'where' => array
  160. (
  161. 'id' => 'yes',
  162. ),
  163. 'set' => array
  164. (
  165. 'password' => 'yes',
  166. ),
  167. ),
  168. ),
  169. );