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

import {DevopsHostMU} from './DevopsHost' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-05-20 14:10
 */
interface DevopsTemplateHostCU extends ConditionUtil<DevopsTemplateHostCU>{
    ID:FieldUtil<DevopsTemplateHostCU>;
    TEMPLATE_ID:FieldUtil<DevopsTemplateHostCU>;
    ENABLED:FieldUtil<DevopsTemplateHostCU>;
    CREATE_TIME:FieldUtil<DevopsTemplateHostCU>;
    UPDATE_TIME:FieldUtil<DevopsTemplateHostCU>;
    INSTANCE_ID:FieldUtil<DevopsTemplateHostCU>;
}

class DevopsTemplateHostCUImpl extends ConditionUtilImpl<DevopsTemplateHostCUImpl> implements DevopsTemplateHostCU{ 
    newInstance(): DevopsTemplateHostCUImpl {
        return new DevopsTemplateHostCUImpl();
    } 
    get ID(): FieldUtil<DevopsTemplateHostCU>{  
        return new FieldUtil('id','id','主键', this);
    }
    get TEMPLATE_ID(): FieldUtil<DevopsTemplateHostCU>{  
        return new FieldUtil('template_id','templateId','模板id', this);
    }
    get ENABLED(): FieldUtil<DevopsTemplateHostCU>{  
        return new FieldUtil('enabled','enabled','是否选中升级', this);
    }
    get CREATE_TIME(): FieldUtil<DevopsTemplateHostCU>{  
        return new FieldUtil('create_time','createTime','创建时间', this);
    }
    get UPDATE_TIME(): FieldUtil<DevopsTemplateHostCU>{  
        return new FieldUtil('update_time','updateTime','更新时间', this);
    }
    get INSTANCE_ID(): FieldUtil<DevopsTemplateHostCU>{  
        return new FieldUtil('instance_id','instanceId','主机实例id', this);
    }
    get IP(): FieldInfo{  
        return new FieldInfo('ip','主机ip(内网地址)');
    }
    get INSTANCE_NAME(): FieldInfo{  
        return new FieldInfo('instanceName','主机名称');
    }
    get BUSINESS_AREA(): FieldInfo{  
        return new FieldInfo('businessArea','自定义的分区');
    }
}

@Singleton 
class DevopsTemplateHostMU extends TableUtilImpl<DevopsTemplateHostCU,DevopsTemplateHost>{ 
    tableName  = 'devops_template_host';
    tableFields  = ['id','template_id','enabled','create_time','update_time','instance_id'];
    modelFields  = ['id','templateId','enabled','createTime','updateTime','instanceId','ip','instanceName','businessArea'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: false,
            foreignKeyFields: [DevopsTemplateHostMU.INSTANCE_ID],
            joinIdFields: [DevopsHostMU.INSTANCE_ID],
            getTableUtil: ()=>{
                return Container.get(DevopsHostMU);
            },
            fields: [
                {
                    fieldUtil: DevopsHostMU.IP,
                    alias: 'ip'
                }
                ,{
                    fieldUtil: DevopsHostMU.INSTANCE_NAME,
                    alias: 'instanceName'
                }
                ,{
                    fieldUtil: DevopsHostMU.BUSINESS_AREA,
                    alias: 'businessArea'
                }
            ]

        } as JoinTable

];
    subTables = [];

    createConditionUtil(): DevopsTemplateHostCU {
        return new DevopsTemplateHostCUImpl();
    }   

    static get ID(): FieldUtil<DevopsTemplateHostCU>{ 
        return new FieldUtil('id','id','主键', new DevopsTemplateHostCUImpl());
    }
    static get TEMPLATE_ID(): FieldUtil<DevopsTemplateHostCU>{ 
        return new FieldUtil('template_id','templateId','模板id', new DevopsTemplateHostCUImpl());
    }
    static get ENABLED(): FieldUtil<DevopsTemplateHostCU>{ 
        return new FieldUtil('enabled','enabled','是否选中升级', new DevopsTemplateHostCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<DevopsTemplateHostCU>{ 
        return new FieldUtil('create_time','createTime','创建时间', new DevopsTemplateHostCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<DevopsTemplateHostCU>{ 
        return new FieldUtil('update_time','updateTime','更新时间', new DevopsTemplateHostCUImpl());
    }
    static get INSTANCE_ID(): FieldUtil<DevopsTemplateHostCU>{ 
        return new FieldUtil('instance_id','instanceId','主机实例id', new DevopsTemplateHostCUImpl());
    }
    static get IP(): FieldInfo{  
        return new FieldInfo('ip','主机ip(内网地址)');
    }
    static get INSTANCE_NAME(): FieldInfo{  
        return new FieldInfo('instanceName','主机名称');
    }
    static get BUSINESS_AREA(): FieldInfo{  
        return new FieldInfo('businessArea','自定义的分区');
    }

    get ID(): FieldUtil<DevopsTemplateHostCU>{ 
        return DevopsTemplateHostMU.ID;
    }
    get TEMPLATE_ID(): FieldUtil<DevopsTemplateHostCU>{ 
        return DevopsTemplateHostMU.TEMPLATE_ID;
    }
    get ENABLED(): FieldUtil<DevopsTemplateHostCU>{ 
        return DevopsTemplateHostMU.ENABLED;
    }
    get CREATE_TIME(): FieldUtil<DevopsTemplateHostCU>{ 
        return DevopsTemplateHostMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<DevopsTemplateHostCU>{ 
        return DevopsTemplateHostMU.UPDATE_TIME;
    }
    get INSTANCE_ID(): FieldUtil<DevopsTemplateHostCU>{ 
        return DevopsTemplateHostMU.INSTANCE_ID;
    }
    get IP(): FieldInfo{  
        return DevopsTemplateHostMU.IP;
    }
    get INSTANCE_NAME(): FieldInfo{  
        return DevopsTemplateHostMU.INSTANCE_NAME;
    }
    get BUSINESS_AREA(): FieldInfo{  
        return DevopsTemplateHostMU.BUSINESS_AREA;
    }
}
export {DevopsTemplateHostMU, DevopsTemplateHostCU}
