import { FieldInfo } from 'model-util-base'
import { ConditionUtil, ConditionUtilImpl, FieldUtil, TableUtilImpl, IdType, JoinTable, SubTable } from 'model-util'
import { Container, Singleton } from 'typescript-ioc' 
import { BusCouponInfo } from '../models/index' 

import {BusCouponUserMU} from './BusCouponUser' 
import {BusCouponConfigMU} from './BusCouponConfig' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2020-10-19 17:45
 */
interface BusCouponInfoCU extends ConditionUtil<BusCouponInfoCU>{
    ID:FieldUtil<BusCouponInfoCU>;
    COUPON_CONFIG_ID:FieldUtil<BusCouponInfoCU>;
    USER_ID:FieldUtil<BusCouponInfoCU>;
    SHARE_TIME:FieldUtil<BusCouponInfoCU>;
    CREATE_TIME:FieldUtil<BusCouponInfoCU>;
    UPDATE_TIME:FieldUtil<BusCouponInfoCU>;
    ORDER_NO:FieldUtil<BusCouponInfoCU>;
    LOT_ID:FieldUtil<BusCouponInfoCU>;
}

class BusCouponInfoCUImpl extends ConditionUtilImpl<BusCouponInfoCUImpl> implements BusCouponInfoCU{ 
    newInstance(): BusCouponInfoCUImpl {
        return new BusCouponInfoCUImpl();
    } 
    get ID(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('ID','id','', this);
    }
    get COUPON_CONFIG_ID(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('COUPON_CONFIG_ID','couponConfigId','', this);
    }
    get USER_ID(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('USER_ID','userId','', this);
    }
    get SHARE_TIME(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('SHARE_TIME','shareTime','', this);
    }
    get CREATE_TIME(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('CREATE_TIME','createTime','创建时间', this);
    }
    get UPDATE_TIME(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', this);
    }
    get ORDER_NO(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('ORDER_NO','orderNo','', this);
    }
    get LOT_ID(): FieldUtil<BusCouponInfoCU>{  
        return new FieldUtil('LOT_ID','lotId','', this);
    }
    get U_USER_ID(): FieldInfo{  
        return new FieldInfo('u_userId','');
    }
    get U_STATUS(): FieldInfo{  
        return new FieldInfo('u_status','00:未领取,01:已使用,02:未使用:03::已过期,04:已失效');
    }
    get C_BEGIN_DATE(): FieldInfo{  
        return new FieldInfo('c_beginDate','');
    }
    get C_END_DATE(): FieldInfo{  
        return new FieldInfo('c_endDate','');
    }
    get C_STATUS(): FieldInfo{  
        return new FieldInfo('c_status','');
    }
}

@Singleton 
class BusCouponInfoMU extends TableUtilImpl<BusCouponInfoCU,BusCouponInfo>{ 
    tableName  = 'bus_coupon_info';
    tableFields  = ['ID','COUPON_CONFIG_ID','USER_ID','SHARE_TIME','CREATE_TIME','UPDATE_TIME','ORDER_NO','LOT_ID'];
    modelFields  = ['id','couponConfigId','userId','shareTime','createTime','updateTime','orderNo','lotId','u_userId','u_status','c_beginDate','c_endDate','c_status'];
    modelIdFields  = ['id'];
    tableIdFields  = ['ID'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: false,
            foreignKeyFields: [BusCouponInfoMU.ID],
            joinIdFields: [BusCouponUserMU.COUPON_INFO_ID],
            getTableUtil: ()=>{
                return Container.get(BusCouponUserMU);
            },
            fields: [
                {
                    fieldUtil: BusCouponUserMU.USER_ID,
                    alias: 'u_userId'
                }
                ,{
                    fieldUtil: BusCouponUserMU.STATUS,
                    alias: 'u_status'
                }
            ]

        } as JoinTable

        ,{
            joinByDefault: false,
            foreignKeyFields: [BusCouponInfoMU.COUPON_CONFIG_ID],
            joinIdFields: [BusCouponConfigMU.ID],
            getTableUtil: ()=>{
                return Container.get(BusCouponConfigMU);
            },
            fields: [
                {
                    fieldUtil: BusCouponConfigMU.BEGIN_DATE,
                    alias: 'c_beginDate'
                }
                ,{
                    fieldUtil: BusCouponConfigMU.END_DATE,
                    alias: 'c_endDate'
                }
                ,{
                    fieldUtil: BusCouponConfigMU.STATUS,
                    alias: 'c_status'
                }
            ]

        } as JoinTable

];
    subTables = [];

    createConditionUtil(): BusCouponInfoCU {
        return new BusCouponInfoCUImpl();
    }   

    static get ID(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('ID','id','', new BusCouponInfoCUImpl());
    }
    static get COUPON_CONFIG_ID(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('COUPON_CONFIG_ID','couponConfigId','', new BusCouponInfoCUImpl());
    }
    static get USER_ID(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('USER_ID','userId','', new BusCouponInfoCUImpl());
    }
    static get SHARE_TIME(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('SHARE_TIME','shareTime','', new BusCouponInfoCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('CREATE_TIME','createTime','创建时间', new BusCouponInfoCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', new BusCouponInfoCUImpl());
    }
    static get ORDER_NO(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('ORDER_NO','orderNo','', new BusCouponInfoCUImpl());
    }
    static get LOT_ID(): FieldUtil<BusCouponInfoCU>{ 
        return new FieldUtil('LOT_ID','lotId','', new BusCouponInfoCUImpl());
    }
    static get U_USER_ID(): FieldInfo{  
        return new FieldInfo('u_userId','');
    }
    static get U_STATUS(): FieldInfo{  
        return new FieldInfo('u_status','00:未领取,01:已使用,02:未使用:03::已过期,04:已失效');
    }
    static get C_BEGIN_DATE(): FieldInfo{  
        return new FieldInfo('c_beginDate','');
    }
    static get C_END_DATE(): FieldInfo{  
        return new FieldInfo('c_endDate','');
    }
    static get C_STATUS(): FieldInfo{  
        return new FieldInfo('c_status','');
    }

    get ID(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.ID;
    }
    get COUPON_CONFIG_ID(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.COUPON_CONFIG_ID;
    }
    get USER_ID(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.USER_ID;
    }
    get SHARE_TIME(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.SHARE_TIME;
    }
    get CREATE_TIME(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.UPDATE_TIME;
    }
    get ORDER_NO(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.ORDER_NO;
    }
    get LOT_ID(): FieldUtil<BusCouponInfoCU>{ 
        return BusCouponInfoMU.LOT_ID;
    }
    get U_USER_ID(): FieldInfo{  
        return BusCouponInfoMU.U_USER_ID;
    }
    get U_STATUS(): FieldInfo{  
        return BusCouponInfoMU.U_STATUS;
    }
    get C_BEGIN_DATE(): FieldInfo{  
        return BusCouponInfoMU.C_BEGIN_DATE;
    }
    get C_END_DATE(): FieldInfo{  
        return BusCouponInfoMU.C_END_DATE;
    }
    get C_STATUS(): FieldInfo{  
        return BusCouponInfoMU.C_STATUS;
    }
}
export {BusCouponInfoMU, BusCouponInfoCU}
