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

import {BmVersion,BmVersionMU} from './BmVersion' 
import {SysUserDemo,SysUserDemoMU} from './SysUserDemo' 


/**
 * @author Keytop midend auto generate
 * @version 1.0
 * @date 2020-06-13 11:02
 */
interface BmModelProject{
    /**
    * 应用ID
    * @type { string }
    */
    appId?: string;
    /**
    * 代码
    * @type { string }
    */
    code?: string;
    /**
    * 创建时间
    * @type { Date }
    */
    createTime?: Date;
    /**
    * 创建人ID
    * @type { string }
    */
    createUserId?: string;
    /**
    * 描述
    * @type { string }
    */
    description?: string;
    /**
    * 主键
    * @type { string }
    */
    id?: string;
    /**
    * 包名
    * @type { string }
    */
    packageName?: string;
    /**
    * 微服务项目ID
    * @type { string }
    */
    pid?: string;
    /**
    * 服务中心ID
    * @type { string }
    */
    serviceCenterId?: string;
    /**
    * 更新时间
    * @type { Date }
    */
    updateTime?: Date;
    /**
    * 修改人ID
    * @type { string }
    */
    updateUserId?: string;
    /**
    * 子表 BmVersion 
    * @type { BmVersion[] }
    */
    bmVersion:BmVersion[];
    /**
    * extend field in SysUserDemo
    * 姓名
    * @type { string }
    */
    createUserName?: string;

    /**
    * 数据状态 
    * @type { DataState }
    */
    _state: DataState;
}
interface BmModelProjectMCU extends ModelConditionUtil<BmModelProjectMCU>{
    APP_ID:FieldUtil<BmModelProjectMCU>;
    CODE:FieldUtil<BmModelProjectMCU>;
    CREATE_TIME:FieldUtil<BmModelProjectMCU>;
    CREATE_USER_ID:FieldUtil<BmModelProjectMCU>;
    DESCRIPTION:FieldUtil<BmModelProjectMCU>;
    ID:FieldUtil<BmModelProjectMCU>;
    PACKAGE_NAME:FieldUtil<BmModelProjectMCU>;
    PID:FieldUtil<BmModelProjectMCU>;
    SERVICE_CENTER_ID:FieldUtil<BmModelProjectMCU>;
    UPDATE_TIME:FieldUtil<BmModelProjectMCU>;
    UPDATE_USER_ID:FieldUtil<BmModelProjectMCU>;
}

class BmModelProjectMCUImpl extends ModelConditionUtilImpl<BmModelProjectMCUImpl> implements BmModelProjectMCU{ 
    newInstance(): BmModelProjectMCUImpl {
        return new BmModelProjectMCUImpl();
    } 
    get APP_ID(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('APP_ID','appId','应用ID', this);
    }
    get CODE(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('CODE','code','代码', this);
    }
    get CREATE_TIME(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('CREATE_TIME','createTime','创建时间', this);
    }
    get CREATE_USER_ID(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('CREATE_USER_ID','createUserId','创建人ID', this);
    }
    get DESCRIPTION(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('DESCRIPTION','description','描述', this);
    }
    get ID(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('ID','id','主键', this);
    }
    get PACKAGE_NAME(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('PACKAGE_NAME','packageName','包名', this);
    }
    get PID(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('PID','pid','微服务项目ID', this);
    }
    get SERVICE_CENTER_ID(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('SERVICE_CENTER_ID','serviceCenterId','服务中心ID', this);
    }
    get UPDATE_TIME(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', this);
    }
    get UPDATE_USER_ID(): FieldUtil<BmModelProjectMCU>{  
        return new FieldUtil('UPDATE_USER_ID','updateUserId','修改人ID', this);
    }
    get CREATE_USER_NAME(): BasicFieldUtil{  
        return new BasicFieldUtil('createUserName','姓名');
    }
}

@Singleton 
class BmModelProjectMU extends TableUtilImpl<BmModelProjectMCU,BmModelProject>{ 
    tableName  = 'bm_model_project';
    tableFields  = ['app_id','code','create_time','create_user_id','description','id','package_name','pid','service_center_id','update_time','update_user_id'];
    modelFields  = ['appId','code','createTime','createUserId','description','id','packageName','pid','serviceCenterId','updateTime','updateUserId','createUserName'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.UUID;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [BmModelProjectMU.CREATE_USER_ID],
            joinIdFields: [SysUserDemoMU.ID],
            getTableUtil: ()=>{
                return Container.get(SysUserDemoMU);
            },
            fields: [
                {
                    fieldUtil: SysUserDemoMU.NAME,
                    alias: 'createUserName'
                }
            ]

        } as JoinTable

];
    subTables = [{
            name: 'bmVersion',
            parentIdFields: [BmModelProjectMU.ID],
            foreignKeyFields: [BmVersionMU.BM_PROJECT_ID],
            getTableUtil: ()=>{
                return Container.get(BmVersionMU);
            }
        } as SubTable

];

    createModelConditionUtil(): BmModelProjectMCU {
        return new BmModelProjectMCUImpl();
    }   

    static get APP_ID(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('APP_ID','appId','应用ID', new BmModelProjectMCUImpl());
    }
    static get CODE(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('CODE','code','代码', new BmModelProjectMCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('CREATE_TIME','createTime','创建时间', new BmModelProjectMCUImpl());
    }
    static get CREATE_USER_ID(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('CREATE_USER_ID','createUserId','创建人ID', new BmModelProjectMCUImpl());
    }
    static get DESCRIPTION(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('DESCRIPTION','description','描述', new BmModelProjectMCUImpl());
    }
    static get ID(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('ID','id','主键', new BmModelProjectMCUImpl());
    }
    static get PACKAGE_NAME(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('PACKAGE_NAME','packageName','包名', new BmModelProjectMCUImpl());
    }
    static get PID(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('PID','pid','微服务项目ID', new BmModelProjectMCUImpl());
    }
    static get SERVICE_CENTER_ID(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('SERVICE_CENTER_ID','serviceCenterId','服务中心ID', new BmModelProjectMCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', new BmModelProjectMCUImpl());
    }
    static get UPDATE_USER_ID(): FieldUtil<BmModelProjectMCU>{ 
        return new FieldUtil('UPDATE_USER_ID','updateUserId','修改人ID', new BmModelProjectMCUImpl());
    }
    static get CREATE_USER_NAME(): BasicFieldUtil{  
        return new BasicFieldUtil('createUserName','姓名');
    }

    get APP_ID(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.APP_ID;
    }
    get CODE(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.CODE;
    }
    get CREATE_TIME(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.CREATE_TIME;
    }
    get CREATE_USER_ID(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.CREATE_USER_ID;
    }
    get DESCRIPTION(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.DESCRIPTION;
    }
    get ID(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.ID;
    }
    get PACKAGE_NAME(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.PACKAGE_NAME;
    }
    get PID(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.PID;
    }
    get SERVICE_CENTER_ID(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.SERVICE_CENTER_ID;
    }
    get UPDATE_TIME(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.UPDATE_TIME;
    }
    get UPDATE_USER_ID(): FieldUtil<BmModelProjectMCU>{ 
        return BmModelProjectMU.UPDATE_USER_ID;
    }
    get CREATE_USER_NAME(): BasicFieldUtil{  
        return BmModelProjectMU.CREATE_USER_NAME;
    }
}
export {BmModelProject, BmModelProjectMU}
