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

import {SysUserMU} from './SysUser' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-09-15 13:46
 */
interface MonitorContactGroupRelCU extends ConditionUtil<MonitorContactGroupRelCU>{
    ID:FieldUtil<MonitorContactGroupRelCU>;
    CONTACT_ID:FieldUtil<MonitorContactGroupRelCU>;
    GROUP_ID:FieldUtil<MonitorContactGroupRelCU>;
    DELETED:FieldUtil<MonitorContactGroupRelCU>;
    CREATE_TIME:FieldUtil<MonitorContactGroupRelCU>;
    UPDATE_TIME:FieldUtil<MonitorContactGroupRelCU>;
}

class MonitorContactGroupRelCUImpl extends ConditionUtilImpl<MonitorContactGroupRelCUImpl> implements MonitorContactGroupRelCU{ 
    newInstance(): MonitorContactGroupRelCUImpl {
        return new MonitorContactGroupRelCUImpl();
    } 
    get ID(): FieldUtil<MonitorContactGroupRelCU>{  
        return new FieldUtil('id','id','主键', this);
    }
    get CONTACT_ID(): FieldUtil<MonitorContactGroupRelCU>{  
        return new FieldUtil('contact_id','contactId','联系人id', this);
    }
    get GROUP_ID(): FieldUtil<MonitorContactGroupRelCU>{  
        return new FieldUtil('group_id','groupId','联系组id', this);
    }
    get DELETED(): FieldUtil<MonitorContactGroupRelCU>{  
        return new FieldUtil('deleted','deleted','deleted', this);
    }
    get CREATE_TIME(): FieldUtil<MonitorContactGroupRelCU>{  
        return new FieldUtil('create_time','createTime','create_time', this);
    }
    get UPDATE_TIME(): FieldUtil<MonitorContactGroupRelCU>{  
        return new FieldUtil('update_time','updateTime','update_time', this);
    }
    get CONTACT_PHONE(): FieldInfo{  
        return new FieldInfo('contactPhone','电话');
    }
}

@Singleton 
class MonitorContactGroupRelMU extends TableUtilImpl<MonitorContactGroupRelCU,MonitorContactGroupRel>{ 
    tableName  = 'monitor_contact_group_rel';
    tableFields  = ['id','contact_id','group_id','deleted','create_time','update_time'];
    modelFields  = ['id','contactId','groupId','deleted','createTime','updateTime','contactPhone'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [MonitorContactGroupRelMU.CONTACT_ID],
            joinIdFields: [SysUserMU.ID],
            getTableUtil: ()=>{
                return Container.get(SysUserMU);
            },
            fields: [
                {
                    fieldUtil: SysUserMU.PHONE,
                    alias: 'contactPhone'
                }
            ]

        } as JoinTable

];
    subTables = [];

    createConditionUtil(): MonitorContactGroupRelCU {
        return new MonitorContactGroupRelCUImpl();
    }   

    static get ID(): FieldUtil<MonitorContactGroupRelCU>{ 
        return new FieldUtil('id','id','主键', new MonitorContactGroupRelCUImpl());
    }
    static get CONTACT_ID(): FieldUtil<MonitorContactGroupRelCU>{ 
        return new FieldUtil('contact_id','contactId','联系人id', new MonitorContactGroupRelCUImpl());
    }
    static get GROUP_ID(): FieldUtil<MonitorContactGroupRelCU>{ 
        return new FieldUtil('group_id','groupId','联系组id', new MonitorContactGroupRelCUImpl());
    }
    static get DELETED(): FieldUtil<MonitorContactGroupRelCU>{ 
        return new FieldUtil('deleted','deleted','deleted', new MonitorContactGroupRelCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<MonitorContactGroupRelCU>{ 
        return new FieldUtil('create_time','createTime','create_time', new MonitorContactGroupRelCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<MonitorContactGroupRelCU>{ 
        return new FieldUtil('update_time','updateTime','update_time', new MonitorContactGroupRelCUImpl());
    }
    static get CONTACT_PHONE(): FieldInfo{  
        return new FieldInfo('contactPhone','电话');
    }

    get ID(): FieldUtil<MonitorContactGroupRelCU>{ 
        return MonitorContactGroupRelMU.ID;
    }
    get CONTACT_ID(): FieldUtil<MonitorContactGroupRelCU>{ 
        return MonitorContactGroupRelMU.CONTACT_ID;
    }
    get GROUP_ID(): FieldUtil<MonitorContactGroupRelCU>{ 
        return MonitorContactGroupRelMU.GROUP_ID;
    }
    get DELETED(): FieldUtil<MonitorContactGroupRelCU>{ 
        return MonitorContactGroupRelMU.DELETED;
    }
    get CREATE_TIME(): FieldUtil<MonitorContactGroupRelCU>{ 
        return MonitorContactGroupRelMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<MonitorContactGroupRelCU>{ 
        return MonitorContactGroupRelMU.UPDATE_TIME;
    }
    get CONTACT_PHONE(): FieldInfo{  
        return MonitorContactGroupRelMU.CONTACT_PHONE;
    }
}
export {MonitorContactGroupRelMU, MonitorContactGroupRelCU}
