import {ModelConditionUtil, ModelConditionUtilImpl, FieldUtil, TableUtilImpl, IdType, BasicFieldUtil, JoinTable, SubTable } from 'model-util'
import {Container, Singleton} from 'typescript-ioc' 
import * as Knex from 'knex' 

import {BMViewModelField,BMViewModelFieldMU} from './BMViewModelField' 


/**
 * @author Keytop midend auto generate
 * @version 1.0
 * @date 2020-06-02 09:56
 */
interface BMViewModel{
    /**
    * 模型项目ID
    * @type { string }
    */
    bmProjectId?: string;
    /**
    * 构建方式 0:sql,1:手动创建,2:表名
    * @type { string }
    */
    buildMethod?: string;
    /**
    * 构建SQL
    * @type { string }
    */
    buildSql?: string;
    /**
    * 创建时间
    * @type { Date }
    */
    createTime?: Date;
    /**
    * 创建人ID
    * @type { string }
    */
    createUserId?: string;
    /**
    * 数据源ID
    * @type { string }
    */
    datasourceId?: string;
    /**
    * 描述
    * @type { string }
    */
    description?: string;
    /**
    * 主键
    * @type { string }
    */
    id?: string;
    /**
    * 模型名称
    * @type { string }
    */
    name?: string;
    /**
    * 是否已发布的
    * @type { boolean }
    */
    released?: boolean;
    /**
    * 表名
    * @type { string }
    */
    tableName?: string;
    /**
    * 更新时间
    * @type { Date }
    */
    updateTime?: Date;
    /**
    * 修改人ID
    * @type { string }
    */
    updateUserId?: string;
    /**
    * 版本ID
    * @type { string }
    */
    versionId?: string;
    /**
    * 版本ID
    * @type { string }
    */
    versionNo?: string;
    /**
    * 子表 BMViewModelField 
    * @type { BMViewModelField[] }
    */
    bMViewModelField:BMViewModelField[];
}
interface BMViewModelMCU extends ModelConditionUtil<BMViewModelMCU>{
    BM_PROJECT_ID:FieldUtil<BMViewModelMCU>;
    BUILD_METHOD:FieldUtil<BMViewModelMCU>;
    BUILD_SQL:FieldUtil<BMViewModelMCU>;
    CREATE_TIME:FieldUtil<BMViewModelMCU>;
    CREATE_USER_ID:FieldUtil<BMViewModelMCU>;
    DATASOURCE_ID:FieldUtil<BMViewModelMCU>;
    DESCRIPTION:FieldUtil<BMViewModelMCU>;
    ID:FieldUtil<BMViewModelMCU>;
    NAME:FieldUtil<BMViewModelMCU>;
    RELEASED:FieldUtil<BMViewModelMCU>;
    TABLE_NAME:FieldUtil<BMViewModelMCU>;
    UPDATE_TIME:FieldUtil<BMViewModelMCU>;
    UPDATE_USER_ID:FieldUtil<BMViewModelMCU>;
    VERSION_ID:FieldUtil<BMViewModelMCU>;
    VERSION_NO:FieldUtil<BMViewModelMCU>;
}

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

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

];

    constructor() {
        super(Container.get(Knex));
    }
    createModelConditionUtil(): BMViewModelMCU {
        return new BMViewModelMCUImpl();
    }   

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

    get BM_PROJECT_ID(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.BM_PROJECT_ID;
    }
    get BUILD_METHOD(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.BUILD_METHOD;
    }
    get BUILD_SQL(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.BUILD_SQL;
    }
    get CREATE_TIME(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.CREATE_TIME;
    }
    get CREATE_USER_ID(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.CREATE_USER_ID;
    }
    get DATASOURCE_ID(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.DATASOURCE_ID;
    }
    get DESCRIPTION(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.DESCRIPTION;
    }
    get ID(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.ID;
    }
    get NAME(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.NAME;
    }
    get RELEASED(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.RELEASED;
    }
    get TABLE_NAME(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.TABLE_NAME;
    }
    get UPDATE_TIME(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.UPDATE_TIME;
    }
    get UPDATE_USER_ID(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.UPDATE_USER_ID;
    }
    get VERSION_ID(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.VERSION_ID;
    }
    get VERSION_NO(): FieldUtil<BMViewModelMCU>{ 
        return BMViewModelMU.VERSION_NO;
    }
}
export {BMViewModelMCU, BMViewModelMCUImpl, BMViewModel, BMViewModelMU}
