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

import {SysUserMU} from './SysUser' 
import {BmVersionMU} from './BmVersion' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2020-07-31 17:08
 */
interface BmModelProjectCU extends ConditionUtil<BmModelProjectCU>{
    ID:FieldUtil<BmModelProjectCU>;
    SERVICE_CENTER_ID:FieldUtil<BmModelProjectCU>;
    APP_ID:FieldUtil<BmModelProjectCU>;
    PACKAGE_NAME:FieldUtil<BmModelProjectCU>;
    PID:FieldUtil<BmModelProjectCU>;
    CODE:FieldUtil<BmModelProjectCU>;
    DESCRIPTION:FieldUtil<BmModelProjectCU>;
    UPDATE_USER_ID:FieldUtil<BmModelProjectCU>;
    CREATE_USER_ID:FieldUtil<BmModelProjectCU>;
    CREATE_TIME:FieldUtil<BmModelProjectCU>;
    UPDATE_TIME:FieldUtil<BmModelProjectCU>;
}

class BmModelProjectCUImpl extends ConditionUtilImpl<BmModelProjectCUImpl> implements BmModelProjectCU{ 
    newInstance(): BmModelProjectCUImpl {
        return new BmModelProjectCUImpl();
    } 
    get ID(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('ID','id','', this);
    }
    get SERVICE_CENTER_ID(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('SERVICE_CENTER_ID','serviceCenterId','', this);
    }
    get APP_ID(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('APP_ID','appId','', this);
    }
    get PACKAGE_NAME(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('PACKAGE_NAME','packageName','', this);
    }
    get PID(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('PID','pid','PID', this);
    }
    get CODE(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('CODE','code','项目代码', this);
    }
    get DESCRIPTION(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('DESCRIPTION','description','描述', this);
    }
    get UPDATE_USER_ID(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('UPDATE_USER_ID','updateUserId','', this);
    }
    get CREATE_USER_ID(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('CREATE_USER_ID','createUserId','', this);
    }
    get CREATE_TIME(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('CREATE_TIME','createTime','创建时间', this);
    }
    get UPDATE_TIME(): FieldUtil<BmModelProjectCU>{  
        return new FieldUtil('UPDATE_TIME','updateTime','', this);
    }
    get CREATE_USER_NAME(): FieldInfo{  
        return new FieldInfo('createUserName','');
    }
}

@Singleton 
class BmModelProjectMU extends TableUtilImpl<BmModelProjectCU,BmModelProject>{ 
    tableName  = 'bm_model_project';
    tableFields  = ['ID','SERVICE_CENTER_ID','APP_ID','PACKAGE_NAME','PID','CODE','DESCRIPTION','UPDATE_USER_ID','CREATE_USER_ID','CREATE_TIME','UPDATE_TIME'];
    modelFields  = ['id','serviceCenterId','appId','packageName','pid','code','description','updateUserId','createUserId','createTime','updateTime','createUserName'];
    modelIdFields  = ['id'];
    tableIdFields  = ['ID'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [BmModelProjectMU.CREATE_USER_ID],
            joinIdFields: [SysUserMU.ID],
            getTableUtil: ()=>{
                return Container.get(SysUserMU);
            },
            fields: [
                {
                    fieldUtil: SysUserMU.NAME,
                    alias: 'createUserName'
                }
            ]

        } as JoinTable

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

];

    createConditionUtil(): BmModelProjectCU {
        return new BmModelProjectCUImpl();
    }   

    static get ID(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('ID','id','', new BmModelProjectCUImpl());
    }
    static get SERVICE_CENTER_ID(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('SERVICE_CENTER_ID','serviceCenterId','', new BmModelProjectCUImpl());
    }
    static get APP_ID(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('APP_ID','appId','', new BmModelProjectCUImpl());
    }
    static get PACKAGE_NAME(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('PACKAGE_NAME','packageName','', new BmModelProjectCUImpl());
    }
    static get PID(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('PID','pid','PID', new BmModelProjectCUImpl());
    }
    static get CODE(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('CODE','code','项目代码', new BmModelProjectCUImpl());
    }
    static get DESCRIPTION(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('DESCRIPTION','description','描述', new BmModelProjectCUImpl());
    }
    static get UPDATE_USER_ID(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('UPDATE_USER_ID','updateUserId','', new BmModelProjectCUImpl());
    }
    static get CREATE_USER_ID(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('CREATE_USER_ID','createUserId','', new BmModelProjectCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('CREATE_TIME','createTime','创建时间', new BmModelProjectCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<BmModelProjectCU>{ 
        return new FieldUtil('UPDATE_TIME','updateTime','', new BmModelProjectCUImpl());
    }
    static get CREATE_USER_NAME(): FieldInfo{  
        return new FieldInfo('createUserName','');
    }

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