<?php

return array
(
    # 表名
    'name' => 'collection',
    # 显示给用户看的名称
    'lang' => '用户拥有合集记录',
    'menu' => false,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

        'uid'       => array
        (
            'type'      => 'int-11',
            'name'      => '用户名',
            '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}) : "匿名用户"',
        ),

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

        'cate_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '合集分类',
            'default'   => '',
            'desc'      => '合集分类',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        'info_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '合集',
            'default'   => '',
            'desc'      => '合集',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        'ticket_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '门票id',
            'default'   => '',
            'desc'      => '门票id',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        'num'      => array
        (
            'type'      => 'int-11',
            'name'      => '数量',
            'default'   => '0',
            'desc'      => '数量',
            'match'     => 'is_numeric',
            'update'    => 'text',
        ),

        '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
    (
        
    ),

    'request' => array
    (
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'info_id' => 'yes',
                'cate_id' => 'yes',
                'state' => 1,
            ),
            # 联表
            'join' => array
            (
                array
                (
                    'table' => 'collection/info',
                    'type' => 'left join',
                    'on' => array('info_id','id'),
                    'col' => 't_2.id,t_2.name,t_2.desc,t_2.pic_cover',
                ),
            ),
            'type' => 'all',
            'order' => array('t_2.reorder' => 'desc', 't_2.pdate' => 'desc', 't_2.id' => 'desc'),
            'page' => array(10, 'list'),
            'col' => 'info_id,num',
        ),

        'getCateAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'cate_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('id' => 'desc'),
            'group' => 'cate_id',
            'col' => 'info_id,cate_id,num|cate_id',
        ),

        'num' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'uid' => 'yes',
                'info_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(num) as num',
        ),
    ),
);