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

import {ModelFieldMU} from './ModelField' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2020-06-30 18:20
 */
interface BmModelCU extends ConditionUtil<BmModelCU>{
    ID:FieldUtil<BmModelCU>;
    BM_PROJECT_ID:FieldUtil<BmModelCU>;
    VERSION_ID:FieldUtil<BmModelCU>;
    VERSION_NO:FieldUtil<BmModelCU>;
    NAME:FieldUtil<BmModelCU>;
    TABLE_NAME:FieldUtil<BmModelCU>;
    DESCRIPTION:FieldUtil<BmModelCU>;
    RELEASED:FieldUtil<BmModelCU>;
    BUILD_METHOD:FieldUtil<BmModelCU>;
    BUILD_SQL:FieldUtil<BmModelCU>;
    DATASOURCE_ID:FieldUtil<BmModelCU>;
    CREATE_USER_ID:FieldUtil<BmModelCU>;
    UPDATE_USER_ID:FieldUtil<BmModelCU>;
    FROM_ID:FieldUtil<BmModelCU>;
    JSON_CONFIG:FieldUtil<BmModelCU>;
    CREATE_TIME:FieldUtil<BmModelCU>;
    UPDATE_TIME:FieldUtil<BmModelCU>;
    STATE:FieldUtil<BmModelCU>;
}

class BmModelCUImpl extends ConditionUtilImpl<BmModelCUImpl> implements BmModelCU{ 
    newInstance(): BmModelCUImpl {
        return new BmModelCUImpl();
    } 
    get ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('ID','id','主键', this);
    }
    get BM_PROJECT_ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('BM_PROJECT_ID','bmProjectId','模型项目ID', this);
    }
    get VERSION_ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('VERSION_ID','versionId','版本ID', this);
    }
    get VERSION_NO(): FieldUtil<BmModelCU>{  
        return new FieldUtil('VERSION_NO','versionNo','版本ID', this);
    }
    get NAME(): FieldUtil<BmModelCU>{  
        return new FieldUtil('NAME','name','模型名称', this);
    }
    get TABLE_NAME(): FieldUtil<BmModelCU>{  
        return new FieldUtil('TABLE_NAME','tableName','表名', this);
    }
    get DESCRIPTION(): FieldUtil<BmModelCU>{  
        return new FieldUtil('DESCRIPTION','description','描述', this);
    }
    get RELEASED(): FieldUtil<BmModelCU>{  
        return new FieldUtil('RELEASED','released','是否已发布的', this);
    }
    get BUILD_METHOD(): FieldUtil<BmModelCU>{  
        return new FieldUtil('BUILD_METHOD','buildMethod','构建方式 0:sql,1:手动创建,2:表名', this);
    }
    get BUILD_SQL(): FieldUtil<BmModelCU>{  
        return new FieldUtil('BUILD_SQL','buildSql','构建SQL', this);
    }
    get DATASOURCE_ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('DATASOURCE_ID','datasourceId','数据源ID', this);
    }
    get CREATE_USER_ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('CREATE_USER_ID','createUserId','创建人ID', this);
    }
    get UPDATE_USER_ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('UPDATE_USER_ID','updateUserId','修改人ID', this);
    }
    get FROM_ID(): FieldUtil<BmModelCU>{  
        return new FieldUtil('FROM_ID','fromId','从哪里COPY', this);
    }
    get JSON_CONFIG(): FieldUtil<BmModelCU>{  
        return new FieldUtil('JSON_CONFIG','jsonConfig','配置信息', this);
    }
    get CREATE_TIME(): FieldUtil<BmModelCU>{  
        return new FieldUtil('CREATE_TIME','createTime','创建时间', this);
    }
    get UPDATE_TIME(): FieldUtil<BmModelCU>{  
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', this);
    }
    get STATE(): FieldUtil<BmModelCU>{  
        return new FieldUtil('STATE','state','state', this);
    }
}

@Singleton 
class BmModelMU extends TableUtilImpl<BmModelCU,BmModel>{ 
    tableName  = 'bm_view_model';
    tableFields  = ['id','bm_project_id','version_id','version_no','name','table_name','description','released','build_method','build_sql','datasource_id','create_user_id','update_user_id','from_id','json_config','create_time','update_time','state'];
    modelFields  = ['id','bmProjectId','versionId','versionNo','name','tableName','description','released','buildMethod','buildSql','datasourceId','createUserId','updateUserId','fromId','jsonConfig','createTime','updateTime','state'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [];
    subTables = [{
            name: 'modelField',
            parentIdFields: [BmModelMU.ID],
            foreignKeyFields: [ModelFieldMU.BM_VIEW_MODEL_ID],
            getTableUtil: ()=>{
                return Container.get(ModelFieldMU);
            }
        } as SubTable

];

    createConditionUtil(): BmModelCU {
        return new BmModelCUImpl();
    }   

    static get ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('ID','id','主键', new BmModelCUImpl());
    }
    static get BM_PROJECT_ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('BM_PROJECT_ID','bmProjectId','模型项目ID', new BmModelCUImpl());
    }
    static get VERSION_ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('VERSION_ID','versionId','版本ID', new BmModelCUImpl());
    }
    static get VERSION_NO(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('VERSION_NO','versionNo','版本ID', new BmModelCUImpl());
    }
    static get NAME(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('NAME','name','模型名称', new BmModelCUImpl());
    }
    static get TABLE_NAME(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('TABLE_NAME','tableName','表名', new BmModelCUImpl());
    }
    static get DESCRIPTION(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('DESCRIPTION','description','描述', new BmModelCUImpl());
    }
    static get RELEASED(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('RELEASED','released','是否已发布的', new BmModelCUImpl());
    }
    static get BUILD_METHOD(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('BUILD_METHOD','buildMethod','构建方式 0:sql,1:手动创建,2:表名', new BmModelCUImpl());
    }
    static get BUILD_SQL(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('BUILD_SQL','buildSql','构建SQL', new BmModelCUImpl());
    }
    static get DATASOURCE_ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('DATASOURCE_ID','datasourceId','数据源ID', new BmModelCUImpl());
    }
    static get CREATE_USER_ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('CREATE_USER_ID','createUserId','创建人ID', new BmModelCUImpl());
    }
    static get UPDATE_USER_ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('UPDATE_USER_ID','updateUserId','修改人ID', new BmModelCUImpl());
    }
    static get FROM_ID(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('FROM_ID','fromId','从哪里COPY', new BmModelCUImpl());
    }
    static get JSON_CONFIG(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('JSON_CONFIG','jsonConfig','配置信息', new BmModelCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('CREATE_TIME','createTime','创建时间', new BmModelCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', new BmModelCUImpl());
    }
    static get STATE(): FieldUtil<BmModelCU>{ 
        return new FieldUtil('STATE','state','state', new BmModelCUImpl());
    }

    get ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.ID;
    }
    get BM_PROJECT_ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.BM_PROJECT_ID;
    }
    get VERSION_ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.VERSION_ID;
    }
    get VERSION_NO(): FieldUtil<BmModelCU>{ 
        return BmModelMU.VERSION_NO;
    }
    get NAME(): FieldUtil<BmModelCU>{ 
        return BmModelMU.NAME;
    }
    get TABLE_NAME(): FieldUtil<BmModelCU>{ 
        return BmModelMU.TABLE_NAME;
    }
    get DESCRIPTION(): FieldUtil<BmModelCU>{ 
        return BmModelMU.DESCRIPTION;
    }
    get RELEASED(): FieldUtil<BmModelCU>{ 
        return BmModelMU.RELEASED;
    }
    get BUILD_METHOD(): FieldUtil<BmModelCU>{ 
        return BmModelMU.BUILD_METHOD;
    }
    get BUILD_SQL(): FieldUtil<BmModelCU>{ 
        return BmModelMU.BUILD_SQL;
    }
    get DATASOURCE_ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.DATASOURCE_ID;
    }
    get CREATE_USER_ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.CREATE_USER_ID;
    }
    get UPDATE_USER_ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.UPDATE_USER_ID;
    }
    get FROM_ID(): FieldUtil<BmModelCU>{ 
        return BmModelMU.FROM_ID;
    }
    get JSON_CONFIG(): FieldUtil<BmModelCU>{ 
        return BmModelMU.JSON_CONFIG;
    }
    get CREATE_TIME(): FieldUtil<BmModelCU>{ 
        return BmModelMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<BmModelCU>{ 
        return BmModelMU.UPDATE_TIME;
    }
    get STATE(): FieldUtil<BmModelCU>{ 
        return BmModelMU.STATE;
    }
}
export {BmModelMU, BmModelCU}
