| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 | 
							- <?php
 
- /*
 
- |--------------------------------------------------------------------------
 
- | admin.php 管理员表
 
- |--------------------------------------------------------------------------
 
- */
 
- # 定义几个常用的选项
 
- $status = array
 
- (
 
- 	1 => '普通',
 
- 	2 => '封禁',
 
- );
 
- $cur = Dever::load('manage/auth.data', false);
 
- $desc = '';
 
- if($cur['role'] > 1)
 
- {
 
- 	$desc =  $cur['username'] . ',你好,你可以在此管理你的下属账号';
 
- 	$child = array_keys(Dever::db('manage/role')->all());
 
- 	$admin = Dever::db('manage/admin_role')->list(array
 
- 	(
 
- 		'col' => 'admin_id|admin_id',
 
- 		'option' => array
 
- 		(
 
- 			'role_id' => array('yes', 'in'),
 
- 		),
 
- 		'option_role_id' => implode(',', $child),
 
- 	));
 
- 	# 配置当前列表页的参数 只能查看自己下属的管理员
 
- 	Dever::$global['model']['manage/admin-list'] = array
 
- 	(
 
- 		'option' => array
 
- 		(
 
- 			'id' => array('yes', 'in'),
 
- 		),
 
- 		'option_id' => $admin ? array_keys($admin) : -1,
 
- 	);
 
- }
 
- $role = function()
 
- {
 
- 	return Dever::load('manage/role-all');
 
- };
 
- $group = function()
 
- {
 
- 	return Dever::load('manage/group-all');
 
- };
 
- $config = function()
 
- {
 
- 	return Dever::load('manage/config-all');
 
- };
 
- # 获取头部菜单list 建议这里使用匿名函数
 
- $top = function()
 
- {
 
- 	$data = Dever::load('manage/top.all');
 
- 	$data['state'] = 1;
 
- 	return $data;
 
- };
 
- return array
 
- (
 
- 	# 表名
 
- 	'name' => 'admin',
 
- 	# 显示给用户看的名称
 
- 	'lang' => '管理账户设置',
 
- 	'desc' => $desc,
 
- 	# 这个表不使用cache功能
 
- 	//'cache' => false,
 
- 	/*
 
- 	# 用到哪个后台菜单上,对应项目的key
 
- 	'menu' => 'project_niuyou_main',
 
- 	# 后台菜单排序
 
- 	'order' => 10,
 
- 	# 显示到后台快捷发布中,值为排序
 
- 	'fast' => 1,
 
- 	*/
 
- 	'order' => 9,
 
- 	# 检测email必须唯一
 
- 	'check' => 'email',
 
- 	# 同步更新另外一个或多个表的数据
 
- 	'sync' => array
 
- 	(
 
- 		'manage/admin_role' => array
 
- 		(
 
- 			# 更新另外一个表的字段 => 本表的字段
 
- 			'where' => array('admin_id', 'id'),
 
- 			# 要更新的数据
 
- 			'update' => array('role_id' => 'role'),
 
- 			# 同步更新的类型,delete为先删再插入,update为直接更新
 
- 			'type' => 'delete',
 
- 		)
 
- 	),
 
- 	/*该方法用check替代
 
- 	'start' => array
 
- 	(
 
- 		'update' => 'manage/auth.check',
 
- 		'insert' => 'manage/auth.check',
 
- 	),
 
- 	*/
 
- 	'end' => array
 
- 	(
 
- 		'update' => 'manage/auth.update',
 
- 	),
 
- 	# 数据结构
 
- 	'struct' => array
 
- 	(
 
- 		'id' 		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '管理员ID',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '',
 
- 			'match' 	=> 'is_numeric',
 
- 			'search'	=> 'order',
 
- 			'list'		=> true,
 
- 		),
 
- 		
 
- 		'username'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-24',
 
- 			'name' 		=> '管理员名',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入管理员名',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'text',
 
- 			# 自动完成功能,第一个参数是请求的地址,请自行实现,第二个参数是要使用的字段,共有id和value两个选择,id会特殊处理,value则直接把当前值写入,第三个参数是直接替换当前的值
 
- 			//'autocomplete' => array('auth.role?json=1', 'value', 'manage/role-check#name'),
 
- 			'autocomplete' => array('auth.role?json=1'),
 
- 			'search'	=> 'order,fulltext',
 
- 			'list'		=> true,
 
- 			# 绑定js脚本,更新时使用,第一个参数是执行的方式,第二个参数执行的方法,第三个参数是传值。
 
- 			//'bind'		=> array('onblur', 'loading', array('url' => Dever::url("auth.blur"))),
 
- 		),
 
- 		'email'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-150',
 
- 			'name' 		=> '邮箱-可用于登录,请准确填写,不允许重复',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入邮箱',
 
- 			'match' 	=> Dever::rule('email'),
 
- 			'update'	=> 'text',
 
- 			'search'	=> 'fulltext',
 
- 			'list'		=> true,
 
- 			# 在手机版或者小屏幕下,列表页的表格是否展示,1为展示,2、3、4、5、6均为在一定宽度下展示,详细参考:https://github.com/nadangergeo/RWD-Table-Patterns
 
- 			'level'		=> 1,
 
- 		),
 
- 		'mobile'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-32',
 
- 			'name' 		=> '联系电话',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入用户联系电话',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'text',
 
- 			'search'	=> 'fulltext',
 
- 			'list'		=> true,
 
- 			'level'		=> 1,
 
- 			# 显示在table中
 
- 			//'list_table'=> '111',
 
- 		),
 
- 		
 
- 		'password'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-64',
 
- 			'name' 		=> '管理员密码',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入管理员密码',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'password',
 
- 			'callback'	=> 'hash.sha256',
 
- 		),
 
- 		
 
- 		'config'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '后台配置',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择后台配置',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $config,
 
- 			'update'	=> 'select',
 
- 			'list'		=> true,
 
- 		),
 
- 		
 
- 		'role'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-100',
 
- 			'name' 		=> '角色',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择角色',
 
- 			'match' 	=> 'is_string',
 
- 			'option' 	=> $role,
 
- 			'update'	=> 'checkbox',
 
- 			//'list'		=> true,
 
- 		),
 
- 		'group'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '分组',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择分组',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $group,
 
- 			'update'	=> 'select',
 
- 			//'list'		=> true,
 
- 		),
 
- 		'top'		=> array
 
- 		(
 
- 			'type' 		=> 'text-255',
 
- 			'name' 		=> '头部菜单-这里的头部菜单如果设置,则会覆盖角色中的头部菜单',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请选择头部菜单',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'checkbox',
 
- 			'option'	=> $top,
 
- 		),
 
- 		
 
- 		'state'		=> array
 
- 		(
 
- 			'type' 		=> 'tinyint-1',
 
- 			'name' 		=> '数据状态',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择状态',
 
- 			'match' 	=> 'is_numeric',
 
- 			//'option' 	=> $option,
 
- 			//'update'	=> 'radio',
 
- 			//'list'		=> true,
 
- 		),
 
- 		'status'		=> array
 
- 		(
 
- 			'type' 		=> 'tinyint-1',
 
- 			'name' 		=> '状态',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择状态',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $status,
 
- 			'update'	=> 'radio',
 
- 			'list'		=> true,
 
- 			'edit'		=> true,
 
- 		),
 
- 		
 
- 		'cdate'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '录入时间',
 
- 			'match' 	=> array('is_numeric', DEVER_TIME),
 
- 			'desc' 		=> '',
 
- 			# 只有insert时才生效
 
- 			'insert'	=> true,
 
- 			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 
- 		),
 
- 	),
 
- 	'manage' => array
 
- 	(
 
- 		'delete' => false,
 
- 		// 载入自定义资源
 
- 		'res' => array
 
- 		(
 
- 			'js' => 'demo',
 
- 			'css' => 'demo',
 
- 		),
 
- 	),
 
- 	
 
- 	# 更新表结构
 
- 	'alter' => array
 
- 	(
 
- 		2 => array
 
- 		(
 
- 			//array('update', 'role', 'role', 'varchar-100 1 角色'),
 
- 			//array('add', 'config', 'config', 'int-11 1 配置'),
 
- 		),
 
- 		'version' => 2,
 
- 	),
 
- 	
 
- 	# 默认值
 
- 	/*
 
- 	'default' => array
 
- 	(
 
- 		'col' => 'username,email,password,role,state,cdate',
 
- 		'value' => array
 
- 		(
 
- 			//'"DMC","DMC@dever.cc","'. md5('admin_' . date('Y_m_d_H')) . '",1, 1,' . time(),
 
- 			'"admin","DMC@dever.cc","'. hash('sha256', 'admin_123') . '",1, 1,' . DEVER_TIME,
 
- 		),
 
- 	),
 
- 	*/
 
- 	
 
- 	# 索引
 
- 	'index' => array
 
- 	(
 
- 		# 索引名 => 索引id
 
- 		//'id' => 'id,state',
 
- 	),
 
- 	
 
- 	# request 请求接口定义
 
- 	'request' => array
 
- 	(
 
- 		# one 根据用户名和密码取一条数据
 
- 		'user' => array
 
- 		(
 
- 			# 匹配的正则或函数 必填项
 
- 			'where' => array
 
- 			(
 
- 				//'username' => '/^([A-Za-z0-9])/',
 
- 				//'username' => 'yes',
 
- 				'email' => 'yes',
 
- 				'status' => 1,
 
- 				'state' => 1,
 
- 				//'password' => 'is_string',
 
- 			),
 
- 			'type' => 'one',
 
- 			# 为这个接口独立设置缓存
 
- 			'cache' => true,
 
- 		),
 
- 		
 
- 		# 更新密码
 
- 		'password' => array
 
- 		(
 
- 			'type' => 'update',
 
- 			'where' => array
 
- 			(
 
- 				'id' => 'yes',
 
- 			),
 
- 			'set' => array
 
- 			(
 
- 				'password' => 'yes',
 
- 			),
 
- 		),
 
- 	),
 
- );
 
 
  |