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

import {PayAccountMU} from './PayAccount' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2020-10-16 11:27
 */
interface PayConfigAccountCU extends ConditionUtil<PayConfigAccountCU>{
    ID:FieldUtil<PayConfigAccountCU>;
    ACCOUNT_ID:FieldUtil<PayConfigAccountCU>;
    PAY_CONFIG_ID:FieldUtil<PayConfigAccountCU>;
    STATE:FieldUtil<PayConfigAccountCU>;
    CREATE_TIME:FieldUtil<PayConfigAccountCU>;
    UPDATE_TIME:FieldUtil<PayConfigAccountCU>;
}

class PayConfigAccountCUImpl extends ConditionUtilImpl<PayConfigAccountCUImpl> implements PayConfigAccountCU{ 
    newInstance(): PayConfigAccountCUImpl {
        return new PayConfigAccountCUImpl();
    } 
    get ID(): FieldUtil<PayConfigAccountCU>{  
        return new FieldUtil('ID','id','', this);
    }
    get ACCOUNT_ID(): FieldUtil<PayConfigAccountCU>{  
        return new FieldUtil('ACCOUNT_ID','accountId','支付账户ID', this);
    }
    get PAY_CONFIG_ID(): FieldUtil<PayConfigAccountCU>{  
        return new FieldUtil('PAY_CONFIG_ID','payConfigId','支付配置ID', this);
    }
    get STATE(): FieldUtil<PayConfigAccountCU>{  
        return new FieldUtil('STATE','state','状态：0-正常，1-删除', this);
    }
    get CREATE_TIME(): FieldUtil<PayConfigAccountCU>{  
        return new FieldUtil('CREATE_TIME','createTime','创建时间', this);
    }
    get UPDATE_TIME(): FieldUtil<PayConfigAccountCU>{  
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', this);
    }
    get ACCOUNT_CODE(): FieldInfo{  
        return new FieldInfo('accountCode','账户代码');
    }
    get ACCOUNT_NAME(): FieldInfo{  
        return new FieldInfo('accountName','账户名称');
    }
}

@Singleton 
class PayConfigAccountMU extends TableUtilImpl<PayConfigAccountCU,PayConfigAccount>{ 
    tableName  = 'pay_config_account';
    tableFields  = ['id','account_id','pay_config_id','state','create_time','update_time'];
    modelFields  = ['id','accountId','payConfigId','state','createTime','updateTime','accountCode','accountName'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [PayConfigAccountMU.ACCOUNT_ID],
            joinIdFields: [PayAccountMU.ID],
            getTableUtil: ()=>{
                return Container.get(PayAccountMU);
            },
            fields: [
                {
                    fieldUtil: PayAccountMU.CODE,
                    alias: 'accountCode'
                }
                ,{
                    fieldUtil: PayAccountMU.NAME,
                    alias: 'accountName'
                }
            ]

        } as JoinTable

];
    subTables = [{
            name: 'payAccount',
            parentIdFields: [PayConfigAccountMU.ACCOUNT_ID],
            foreignKeyFields: [PayAccountMU.ID],
            getTableUtil: ()=>{
                return Container.get(PayAccountMU);
            }
        } as SubTable

];

    createConditionUtil(): PayConfigAccountCU {
        return new PayConfigAccountCUImpl();
    }   

    static get ID(): FieldUtil<PayConfigAccountCU>{ 
        return new FieldUtil('ID','id','', new PayConfigAccountCUImpl());
    }
    static get ACCOUNT_ID(): FieldUtil<PayConfigAccountCU>{ 
        return new FieldUtil('ACCOUNT_ID','accountId','支付账户ID', new PayConfigAccountCUImpl());
    }
    static get PAY_CONFIG_ID(): FieldUtil<PayConfigAccountCU>{ 
        return new FieldUtil('PAY_CONFIG_ID','payConfigId','支付配置ID', new PayConfigAccountCUImpl());
    }
    static get STATE(): FieldUtil<PayConfigAccountCU>{ 
        return new FieldUtil('STATE','state','状态：0-正常，1-删除', new PayConfigAccountCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<PayConfigAccountCU>{ 
        return new FieldUtil('CREATE_TIME','createTime','创建时间', new PayConfigAccountCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<PayConfigAccountCU>{ 
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', new PayConfigAccountCUImpl());
    }
    static get ACCOUNT_CODE(): FieldInfo{  
        return new FieldInfo('accountCode','账户代码');
    }
    static get ACCOUNT_NAME(): FieldInfo{  
        return new FieldInfo('accountName','账户名称');
    }

    get ID(): FieldUtil<PayConfigAccountCU>{ 
        return PayConfigAccountMU.ID;
    }
    get ACCOUNT_ID(): FieldUtil<PayConfigAccountCU>{ 
        return PayConfigAccountMU.ACCOUNT_ID;
    }
    get PAY_CONFIG_ID(): FieldUtil<PayConfigAccountCU>{ 
        return PayConfigAccountMU.PAY_CONFIG_ID;
    }
    get STATE(): FieldUtil<PayConfigAccountCU>{ 
        return PayConfigAccountMU.STATE;
    }
    get CREATE_TIME(): FieldUtil<PayConfigAccountCU>{ 
        return PayConfigAccountMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<PayConfigAccountCU>{ 
        return PayConfigAccountMU.UPDATE_TIME;
    }
    get ACCOUNT_CODE(): FieldInfo{  
        return PayConfigAccountMU.ACCOUNT_CODE;
    }
    get ACCOUNT_NAME(): FieldInfo{  
        return PayConfigAccountMU.ACCOUNT_NAME;
    }
}
export {PayConfigAccountMU, PayConfigAccountCU}
