<?php
$page = 15;
return array
(
	# 表名
	'name' => 'info',
	# 显示给用户看的名称
	'lang' => '小刊管理',
	'order' => 100,
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
		),
		
		'name'		=> array
		(
			'type' 		=> 'varchar-80',
			'name' 		=> '标题',
			'default' 	=> '',
			'desc' 		=> '标题',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'list'		=> true,
		),

		'name'		=> array
		(
			'type' 		=> 'varchar-80',
			'name' 		=> '标题',
			'default' 	=> '',
			'desc' 		=> '标题',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'list'		=> true,
		),

  		'pic_list_cover'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '列表封面图-4:3比例的图片',
			'default' 	=> '',
			'desc' 		=> '列表封面图',
			'match' 	=> 'option',
			'update'	=> 'image',
			'key' 		=> '1',
			'place'		=> '150',
		),

		'pic_cover'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '封面图-1:1比例的图片',
			'default' 	=> '',
			'desc' 		=> '封面图',
			'match' 	=> 'option',
			'update'	=> 'image',
			'key' 		=> '1',
			'place'		=> '150',
		),

		'num_add_ding'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '手动增加订阅数',
			'default' 	=> '0',
			'desc' 		=> '手动增加阅读数',
			'match' 	=> 'option',
			'update'	=> 'text',
		),

		'num_ding'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '订阅数',
			'default' 	=> '0',
			'desc' 		=> '请填写订阅数',
			'match' 	=> 'option',
			'search'	=> 'order',
			//'list'		=> '{num_view}+{num_add_view}',
		),

		'num_add_view'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '手动增加阅读数',
			'default' 	=> '0',
			'desc' 		=> '手动增加阅读数',
			'match' 	=> 'option',
			'update'	=> 'text',
		),

		'num_view'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '阅读数',
			'default' 	=> '0',
			'desc' 		=> '请填写阅读数',
			'match' 	=> 'option',
			'search'	=> 'order',
			//'list'		=> '{num_view}+{num_add_view}',
		),
		
		'num_up'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '喜欢数',
			'default' 	=> '0',
			'desc' 		=> '请填写喜欢数',
			'match' 	=> 'option',
			//'search'	=> 'order',
			'list'		=> '"订阅数:{num_add_ding}+{num_ding}<br />喜欢数:{num_up}<br />阅读数:{num_view}+{num_add_view}<br />评论数:{num_comment}<br />"',
			'list_name'	=> '统计数字',
		),

		'num_comment'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '评论数',
			'default' 	=> '0',
			'desc' 		=> '请填写评论数',
			'search'	=> 'order',
			'match' 	=> 'option',
			//'list'		=> true,
		),

		'state'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '状态',
			'default' 	=> '1',
			'desc' 		=> '请选择状态',
			'match' 	=> 'is_numeric',
		),

		'admin_founder'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '创建人',
			'default' 	=> '1',
			'desc' 		=> '创建人',
			'match' 	=> 'is_numeric',
		),

		'admin_editor'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '操作人',
			'default' 	=> '1',
			'desc' 		=> '操作人',
			'match' 	=> 'is_numeric',
		),

		'pdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '发布时间',
			'match' 	=> 'is_numeric',
			'desc' 		=> '',
			'update'	=> 'date',
			'callback'	=> 'maketime',
			'list'		=> 'date("Y-m-d H:i:s", {pdate})',
		),

		'udate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '更新时间',
			'match' 	=> array('is_numeric', time()),
			'desc' 		=> '',
		),

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

	# 索引
	'index' => array
	(
		'version' => 1,
		
		1 => array
		(
			'i1' => 'uid,cate_id',
		)
	),
	
	# 管理功能
	'manage' => array
	(
		//'insert' => false,
		# 列表
		/*
		'list_button' => array
		(
			'list' => array('评论列表', '"comment&search_option_data_id={id}&oper_parent=article"'),
		),
		*/
	),

	# request 请求接口定义
	'request' => array
	(
		'getAll' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'cate_ids' => array('yes-cate_id', 'in'),
				'id' => 'yes',
			),
			'type' => 'all',
			'order' => array('id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),

		# 获取默认主题,按照置顶和时间排序的
		'default' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),

		# 获取最新主题
		'new' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'name' => array('yes', 'like'),
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('id', 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),
		
		# 获取热门主题
		'hot' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('num_view`+`num_add_view' => 'desc', 'id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),

		# 获取冷门主题
		'cold' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('num_view`+`num_add_view' => 'asc', 'id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),


		
		# 更新浏览量
		'addView' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_view' => array('1', '+='),
			),
		),
		
		# 更新回复数
		'addComment' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_comment' => array('1', '+='),
			),
		),
		
		# 更新点赞数
		'addUp' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_up' => array('1', '+='),
			),
		),
		
		# 更新点赞数
		'desUp' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_up' => array('1', '-='),
			),
		),
	),
);