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

import {DevopsHostMU} from './DevopsHost' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-02-20 18:04
 */
interface DevopsTemplateNginxCU extends ConditionUtil<DevopsTemplateNginxCU>{
    ID:FieldUtil<DevopsTemplateNginxCU>;
    TEMPLATE_ID:FieldUtil<DevopsTemplateNginxCU>;
    ENABLED:FieldUtil<DevopsTemplateNginxCU>;
    CREATE_TIME:FieldUtil<DevopsTemplateNginxCU>;
    UPDATE_TIME:FieldUtil<DevopsTemplateNginxCU>;
    INSTANCE_ID:FieldUtil<DevopsTemplateNginxCU>;
}

class DevopsTemplateNginxCUImpl extends ConditionUtilImpl<DevopsTemplateNginxCUImpl> implements DevopsTemplateNginxCU{ 
    newInstance(): DevopsTemplateNginxCUImpl {
        return new DevopsTemplateNginxCUImpl();
    } 
    get ID(): FieldUtil<DevopsTemplateNginxCU>{  
        return new FieldUtil('ID','id','主键', this);
    }
    get TEMPLATE_ID(): FieldUtil<DevopsTemplateNginxCU>{  
        return new FieldUtil('TEMPLATE_ID','templateId','模板id', this);
    }
    get ENABLED(): FieldUtil<DevopsTemplateNginxCU>{  
        return new FieldUtil('ENABLED','enabled','是否切换流量', this);
    }
    get CREATE_TIME(): FieldUtil<DevopsTemplateNginxCU>{  
        return new FieldUtil('CREATE_TIME','createTime','创建时间', this);
    }
    get UPDATE_TIME(): FieldUtil<DevopsTemplateNginxCU>{  
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', this);
    }
    get INSTANCE_ID(): FieldUtil<DevopsTemplateNginxCU>{  
        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 DevopsTemplateNginxMU extends TableUtilImpl<DevopsTemplateNginxCU,DevopsTemplateNginx>{ 
    tableName  = 'devops_template_nginx';
    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: [DevopsTemplateNginxMU.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(): DevopsTemplateNginxCU {
        return new DevopsTemplateNginxCUImpl();
    }   

    static get ID(): FieldUtil<DevopsTemplateNginxCU>{ 
        return new FieldUtil('ID','id','主键', new DevopsTemplateNginxCUImpl());
    }
    static get TEMPLATE_ID(): FieldUtil<DevopsTemplateNginxCU>{ 
        return new FieldUtil('TEMPLATE_ID','templateId','模板id', new DevopsTemplateNginxCUImpl());
    }
    static get ENABLED(): FieldUtil<DevopsTemplateNginxCU>{ 
        return new FieldUtil('ENABLED','enabled','是否切换流量', new DevopsTemplateNginxCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<DevopsTemplateNginxCU>{ 
        return new FieldUtil('CREATE_TIME','createTime','创建时间', new DevopsTemplateNginxCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<DevopsTemplateNginxCU>{ 
        return new FieldUtil('UPDATE_TIME','updateTime','更新时间', new DevopsTemplateNginxCUImpl());
    }
    static get INSTANCE_ID(): FieldUtil<DevopsTemplateNginxCU>{ 
        return new FieldUtil('INSTANCE_ID','instanceId','主机实例id', new DevopsTemplateNginxCUImpl());
    }
    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<DevopsTemplateNginxCU>{ 
        return DevopsTemplateNginxMU.ID;
    }
    get TEMPLATE_ID(): FieldUtil<DevopsTemplateNginxCU>{ 
        return DevopsTemplateNginxMU.TEMPLATE_ID;
    }
    get ENABLED(): FieldUtil<DevopsTemplateNginxCU>{ 
        return DevopsTemplateNginxMU.ENABLED;
    }
    get CREATE_TIME(): FieldUtil<DevopsTemplateNginxCU>{ 
        return DevopsTemplateNginxMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<DevopsTemplateNginxCU>{ 
        return DevopsTemplateNginxMU.UPDATE_TIME;
    }
    get INSTANCE_ID(): FieldUtil<DevopsTemplateNginxCU>{ 
        return DevopsTemplateNginxMU.INSTANCE_ID;
    }
    get IP(): FieldInfo{  
        return DevopsTemplateNginxMU.IP;
    }
    get INSTANCE_NAME(): FieldInfo{  
        return DevopsTemplateNginxMU.INSTANCE_NAME;
    }
    get BUSINESS_AREA(): FieldInfo{  
        return DevopsTemplateNginxMU.BUSINESS_AREA;
    }
}
export {DevopsTemplateNginxMU, DevopsTemplateNginxCU}
