<?php

$table = Dever::config('base')->type;

return array
(
	# 表名
	'name' => 'invite',
	# 显示给用户看的名称
	'lang' => '邀请排行榜',
	# 是否显示在后台菜单
	'order' => 1,
	'menu' => false,
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
			'order'		=> 'desc',
			//'list'		=> true,
		),
		
		'source_uid'        => array
        (
            'type'      => 'int-11',
            'name'      => '邀请者-填写uid',
            'default'   => '',
            'desc'      => '邀请者',
            'match'     => 'option',
            'update'	=> 'text',
            'search'    => array
            (
                'api' => 'passport/user-all',
                'col' => 'username',
                'result' => 'id',
            ),
            'list'      => '{source_uid} > 0 ? Dever::load("passport/user-one#username", {source_uid}) : "匿名用户"',
        ),

		'type' 		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '邀请类型',
			'default' 	=> '',
			'desc' 		=> '邀请类型',
			'match' 	=> 'option',
			'update'	=> 'select',
			//'search'	=> 'select',
			'option' 	=> $table,
			'list'		=> true,
		),
		
		'data_id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '标题-填写id',
			'default' 	=> '',
			'desc' 		=> '标题',
			'update'	=> 'text',
			'match' 	=> 'option',
			'list'		=> '{type} >0 ? Dever::load("act/lib/manage.load", "{type}", "{data_id}") : "未知"',
		),

		'uid'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '被邀请者-填写uid',
			'default' 	=> '0',
			'desc' 		=> '被邀请者',
			'match' 	=> 'is_numeric',
			'update'	=> 'text',
			//'search'	=> 'select',
			'search'    => array
            (
                'api' => 'passport/user-all',
                'col' => 'username',
                'result' => 'id',
            ),
			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
		),
		
		'state'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '状态',
			'default' 	=> '1',
			'desc' 		=> '请选择状态',
			'match' 	=> 'is_numeric',
		),
		
		'cdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '时间',
			'match' 	=> array('is_numeric', time()),
			'desc' 		=> '',
			# 只有insert时才生效
			'insert'	=> true,
			//'search'	=> 'date',
			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
		),
	),

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

	# request 请求接口定义
	'request' => array
	(
		'getAll' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'source_uid' => 'yes',
				'uid' => 'yes',
				'data_id' => 'yes',
				'type' => 'yes',
				'avatar' => array('yes-t_2.avatar', '!='),
				'state' => 1,
			),
			# 联表
			'join' => array
			(
				array
				(
					'table' => 'passport/user',
					'type' => 'left join',
					'on' => array('uid','id'),
					'col' => 't_2.username,t_2.avatar',
				),
			),
			'type' => 'all',
			'order' => array('t_1.id' => 'desc'),
			'page' => array(50, 'list'),
			'col' => '*',
		),
	)
);
