<?php

$type = array
(
	1 => '获取',
	2 => '更新',
	3 => '删除',
);

$doc = 'token：<br />' . Dever\Http\Api::token() . '<br /><br />加密步骤：<br />a、将所有参数（包括公共请求参数和token）进行字符串字典序排序<br />b、将所有参数字符串拼接成一个字符串进行sha1加密，得到signature<br />c、将所有参数（不包括token）和signature一起传输过来即可';

$request = array
(
	'time' => '时间戳（登录加密请忽略此参数）',
	'nonce' => '唯一值（登录加密请忽略此参数）',
	'signature' => '加密字符串',
	'json' => '1（返回json格式数据）',
	'dever_api_test' => 'test_yes（测试参数，请忽略）',
);

$html = '<br  />公共请求参数：<br />'.Dever::table($request).'<br />';

$response = array
(
	'status' => '1请求成功2请求失败',
	'msg' => '提示信息',
	'data' => '数据，详见下述输出参数',
	'code' => '状态码，一般不定义',
);

$html .= '公共返回参数：<br />'.Dever::table($response).'<br />';

return array
(
	# 表名
	'name' => 'api',
	# 显示给用户看的名称
	'lang' => '接口列表',
	'menu' => false,
	'html' => $html,
	'doc' => $doc,
	'gettype' => $type,
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
			'order'		=> 'desc',
		),

		'name'		=> array
		(
			'type' 		=> 'varchar-30',
			'name' 		=> '接口名称',
			'default' 	=> '',
			'desc' 		=> '请输入接口名称',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'search'	=> 'order,fulltext',
			'list'		=> true,
		),

		'type'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '接口类型',
			'default' 	=> '1',
			'desc' 		=> '请选择接口类型',
			'match' 	=> 'is_numeric',
			'option' 	=> $type,
			//'update'	=> 'radio',
			'search'	=> 'select',
			'list'		=> true,
		),


		'project'		=> array
		(
			'type' 		=> 'varchar-30',
			'name' 		=> '所属项目',
			'default' 	=> '',
			'desc' 		=> '请输入所属项目',
			'match' 	=> 'is_string',
		),
		
		'site'		=> array
		(
			'type' 		=> 'varchar-500',
			'name' 		=> '接口地址',
			'default' 	=> '',
			'desc' 		=> '请输入接口地址',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'search'	=> 'fulltext',
			'list'		=> 'Dever::load("manage/api.getHtml", "{name}", "{site}", "'.$html.'", {id}, "{project}")',
			'modal'		=> '点此查看',
			//'bind'		=> array('onclick', 'checking', array('url' => Dever::url("manage/api.load?json=1"))),
		),

		'reorder'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '排序',
			'default' 	=> '1',
			'desc' 		=> '请输入排序',
			'match' 	=> 'option',
			'update'	=> 'text',
			//'search'	=> 'order',
			//'list'		=> true,
			'order'		=> 'desc',
		),
		
		'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})',
		),
	),
	
	# 更新表结构
	/*
	'alter' => array
	(
		1 => array
		(
			array('update', 'request', 'request', 'text-255  请求'),
			array('update', 'response', 'response', 'text-255  返回参数'),
		),
		'version' => 1,
	),
	*/
	
	'manage' => array
	(
		# 后台banner
		'banner' => array
		(
			'img' => '"http://css.selfimg.com.cn/vogue/mobile-v2/vip/images/index-logo.png"',
			'name' => '"项目名称"',
		),
		'button' => array
		(
			'更新接口' => 'manage/api.update',
			'加密说明' => 'modal|' . $doc,
			'生成接口文档' => Dever::url('doc/view?type=api', 'manage'),
		),
		'delete' => false,
		//'insert' => false,
		'edit' => false,
	),
	
	# request 请求接口定义
	'request' => array
	(
		'site' => array
		(
			'where' => array
			(
				'site' => 'yes',
			),
			'type' => 'one',
		),
		
		# 取所有
		'all' => array
		(
			'type' => 'all',
			'order' => array('reorder` desc,`id', 'desc'),
			'col' => '*|id',
		),

		# 取所有
		'getAll' => array
		(
			'type' => 'all',
			'order' => array('reorder` desc,`id', 'desc'),
			'col' => '*|project|id|',
		),
	),
);
