<?php
$config = function()
{
	$array = array();
	$info = Dever::db('score/config')->state();
	if($info)
	{
		$array += $info;
	}
	return $array;
};

return array
(
	# 表名
	'name' => 'user',
	# 显示给用户看的名称
	'lang' => '用户积分列表',
	'order' => 100,
	'menu' => 'passport',
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
			'list'		=> true,
		),

		'uid'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '用户名',
			'default' 	=> '0',
			'desc' 		=> '请选择用户',
			'match' 	=> 'is_numeric',
			//'update'	=> 'select',
			//'search'	=> 'select',
			'search'    => array
            (
                'api' => 'passport/user-all',
                'col' => 'username',
                'result' => 'id',
            ),
			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
		),

		'config_id'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '积分名称',
			'default' 	=> '1',
			'desc' 		=> '积分名称',
			'match' 	=> 'is_numeric',
			'update'	=> 'select',
			'option'	=> $config,
			'search'	=> 'select',
			'list'		=> true,
		),

		'score'		=> array
		(
			'type' 		=> 'varchar-80',
			'name' 		=> '可用数量',
			'default' 	=> '0',
			'desc' 		=> '可用数量',
			'match' 	=> 'option',
			'update'	=> 'text',
			'search'	=> 'order',
			'list'		=> true,
		),

		'no_score'		=> array
		(
			'type' 		=> 'varchar-80',
			'name' 		=> '冻结数量',
			'default' 	=> '0',
			'desc' 		=> '冻结数量',
			'match' 	=> 'option',
			'update'	=> 'text',
			'search'	=> 'order',
			'list'		=> true,
		),

		'cdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '录入时间',
			'match' 	=> array('is_numeric', time()),
			'desc' 		=> '',
			# 只有insert时才生效
			'insert'	=> true,
		),
	),

	'manage' => array
	(
		'delete' => false,
		'edit' => false,
		'insert' => false,

		# 列表
		'list_button' => array
		(
			'list' => array('积分日志', '"user_log&search_option_uid={uid}&oper_parent=user"'),
		),
	),

	# request 请求接口定义
	'request' => array
	(
		'getScoreByConfig' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('id' => 'desc'),
			'col' => 'uid,config_id,score|config_id',
		),
	)
);
