<?php


$cate = function()
{
    $array = array();
    $info = Dever::db('content/cate')->state();
    if($info)
    {
        $array += $info;
    }
    return $array;
};

$author = function()
{
    $array = array();
    $info = Dever::db('content/author')->state();
    if($info)
    {
        $array += $info;
    }
    return $array;
};

return array
(
    # 表名
    'name' => 'wechat',
    # 显示给用户看的名称
    'lang' => '公众号管理',
    # 后台菜单排序
    'order' => 10,
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'      => true,
            'order'     => 'desc',
        ),
        
        'name'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '名称-直接输入公众号名称即可,系统会自动抓取该公众号的最新10篇文章',
            'default'   => '',
            'desc'      => '请输入名称',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'wechat'      => array
        (
            'type'      => 'varchar-200',
            'name'      => '微信号',
            'default'   => '',
            'desc'      => '微信号',
            'match'     => 'is_string',
            //'update'    => 'text',
            'search'    => 'fulltext',
            'list'      => true,
        ),

        'cate_id'       => array
        (
            'type'      => 'int-11',
            'name'      => '所属栏目',
            'default'   => '1',
            'desc'      => '所属栏目',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $cate,
            'search'    => 'select',
            'list'      => true,
            'edit'      => true,
        ),

        'author_id'     => array
        (
            'type'      => 'int-11',
            'name'      => '作者',
            'default'   => '1',
            'desc'      => '作者',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $author,
            'search'    => 'select',
            'list'      => true,
            'edit'      => true,
        ),

        'zdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '下次执行时间',
            'match'     => 'is_numeric',
            'desc'      => '请选择执行时间',
            'default'   => '',
            'update'    => 'date',
            'callback'  => 'maketime',
            'list'      => '{zdate} > 0 ? date("Y-m-d H:i:s", {zdate}) : "未知"',
        ),

        'pdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '抓取时间间隔-每个公众号发布的文章时间不同,请设置抓取时间间隔,单位为小时,尽量保证每次抓取都有新数据,也请不要设置间隔时间太短,抓取太频繁会导致抓取失败',
            'match'     => 'is_numeric',
            'default'   => '12',
            'desc'      => '',
            'update'    => 'text',
            'list'      => true,
        ),
        
        'reorder'       => array
        (
            'type'      => 'int-11',
            'name'      => '排序(数值越大越靠前)',
            'default'   => '1',
            'desc'      => '请输入排序',
            'match'     => 'option',
            //'update'    => 'text',
            'search'    => 'order',
            //'list'      => true,
            'order'     => 'desc',
            'edit'      => true,
        ),

        '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,
            //'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    # 默认值
    'default' => array
    (

    ),

    'manage' => array
    (
        
    ),

    # request 请求接口定义
    'request' => array
    (
        # get
        'get' => array
        (
            'where' => array
            (
                'zdate' => array('yes', '<='),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('id', 'desc'),
            'col' => '*',
        ),
    ),
);