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

import {CnLabelMU} from './CnLabel' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-06-09 09:11
 */
interface CnLabelRefCU extends ConditionUtil<CnLabelRefCU>{
    ID:FieldUtil<CnLabelRefCU>;
    LABEL_ID:FieldUtil<CnLabelRefCU>;
    BUSSINESS_ID:FieldUtil<CnLabelRefCU>;
    DELETED:FieldUtil<CnLabelRefCU>;
    CREATE_USER_ID:FieldUtil<CnLabelRefCU>;
    CREATE_TIME:FieldUtil<CnLabelRefCU>;
}

class CnLabelRefCUImpl extends ConditionUtilImpl<CnLabelRefCUImpl> implements CnLabelRefCU{ 
    newInstance(): CnLabelRefCUImpl {
        return new CnLabelRefCUImpl();
    } 
    get ID(): FieldUtil<CnLabelRefCU>{  
        return new FieldUtil('id','id','主键', this);
    }
    get LABEL_ID(): FieldUtil<CnLabelRefCU>{  
        return new FieldUtil('label_id','labelId','标签主键', this);
    }
    get BUSSINESS_ID(): FieldUtil<CnLabelRefCU>{  
        return new FieldUtil('bussiness_id','bussinessId','业务关联主键', this);
    }
    get DELETED(): FieldUtil<CnLabelRefCU>{  
        return new FieldUtil('deleted','deleted','删除标记', this);
    }
    get CREATE_USER_ID(): FieldUtil<CnLabelRefCU>{  
        return new FieldUtil('create_user_id','createUserId','创建人', this);
    }
    get CREATE_TIME(): FieldUtil<CnLabelRefCU>{  
        return new FieldUtil('create_time','createTime','创建时间', this);
    }
    get LABEL_NAME(): FieldInfo{  
        return new FieldInfo('labelName','名称');
    }
}

@Singleton 
class CnLabelRefMU extends TableUtilImpl<CnLabelRefCU,CnLabelRef>{ 
    tableName  = 'cn_label_ref';
    tableFields  = ['id','label_id','bussiness_id','deleted','create_user_id','create_time'];
    modelFields  = ['id','labelId','bussinessId','deleted','createUserId','createTime','labelName'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [CnLabelRefMU.LABEL_ID],
            joinIdFields: [CnLabelMU.ID],
            getTableUtil: ()=>{
                return Container.get(CnLabelMU);
            },
            fields: [
                {
                    fieldUtil: CnLabelMU.NAME,
                    alias: 'labelName'
                }
            ]

        } as JoinTable

];
    subTables = [];

    createConditionUtil(): CnLabelRefCU {
        return new CnLabelRefCUImpl();
    }   

    static get ID(): FieldUtil<CnLabelRefCU>{ 
        return new FieldUtil('id','id','主键', new CnLabelRefCUImpl());
    }
    static get LABEL_ID(): FieldUtil<CnLabelRefCU>{ 
        return new FieldUtil('label_id','labelId','标签主键', new CnLabelRefCUImpl());
    }
    static get BUSSINESS_ID(): FieldUtil<CnLabelRefCU>{ 
        return new FieldUtil('bussiness_id','bussinessId','业务关联主键', new CnLabelRefCUImpl());
    }
    static get DELETED(): FieldUtil<CnLabelRefCU>{ 
        return new FieldUtil('deleted','deleted','删除标记', new CnLabelRefCUImpl());
    }
    static get CREATE_USER_ID(): FieldUtil<CnLabelRefCU>{ 
        return new FieldUtil('create_user_id','createUserId','创建人', new CnLabelRefCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<CnLabelRefCU>{ 
        return new FieldUtil('create_time','createTime','创建时间', new CnLabelRefCUImpl());
    }
    static get LABEL_NAME(): FieldInfo{  
        return new FieldInfo('labelName','名称');
    }

    get ID(): FieldUtil<CnLabelRefCU>{ 
        return CnLabelRefMU.ID;
    }
    get LABEL_ID(): FieldUtil<CnLabelRefCU>{ 
        return CnLabelRefMU.LABEL_ID;
    }
    get BUSSINESS_ID(): FieldUtil<CnLabelRefCU>{ 
        return CnLabelRefMU.BUSSINESS_ID;
    }
    get DELETED(): FieldUtil<CnLabelRefCU>{ 
        return CnLabelRefMU.DELETED;
    }
    get CREATE_USER_ID(): FieldUtil<CnLabelRefCU>{ 
        return CnLabelRefMU.CREATE_USER_ID;
    }
    get CREATE_TIME(): FieldUtil<CnLabelRefCU>{ 
        return CnLabelRefMU.CREATE_TIME;
    }
    get LABEL_NAME(): FieldInfo{  
        return CnLabelRefMU.LABEL_NAME;
    }
}
export {CnLabelRefMU, CnLabelRefCU}
