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

import {AdMaterialMU} from './AdMaterial' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-05-28 10:30
 */
interface AdInfoMaterialCU extends ConditionUtil<AdInfoMaterialCU>{
    AD_INFO_ID:FieldUtil<AdInfoMaterialCU>;
    AD_MATERIAL_ID:FieldUtil<AdInfoMaterialCU>;
    DEL_FLAG:FieldUtil<AdInfoMaterialCU>;
}

class AdInfoMaterialCUImpl extends ConditionUtilImpl<AdInfoMaterialCUImpl> implements AdInfoMaterialCU{ 
    newInstance(): AdInfoMaterialCUImpl {
        return new AdInfoMaterialCUImpl();
    } 
    get AD_INFO_ID(): FieldUtil<AdInfoMaterialCU>{  
        return new FieldUtil('ad_info_id','adInfoId','广告信息id', this);
    }
    get AD_MATERIAL_ID(): FieldUtil<AdInfoMaterialCU>{  
        return new FieldUtil('ad_material_id','adMaterialId','素材id', this);
    }
    get DEL_FLAG(): FieldUtil<AdInfoMaterialCU>{  
        return new FieldUtil('del_flag','delFlag','是否删除：0，否；1，是', this);
    }
    get ID(): FieldInfo{  
        return new FieldInfo('id','素材id');
    }
    get AD_STYLE_ID(): FieldInfo{  
        return new FieldInfo('adStyleId','广告样式id');
    }
    get NAME(): FieldInfo{  
        return new FieldInfo('name','素材名称');
    }
    get STATUS(): FieldInfo{  
        return new FieldInfo('status','状态：0，启用；1，删除');
    }
    get CREATE_TIME(): FieldInfo{  
        return new FieldInfo('createTime','');
    }
    get CREATOR(): FieldInfo{  
        return new FieldInfo('creator','');
    }
    get UPDATE_TIME(): FieldInfo{  
        return new FieldInfo('updateTime','');
    }
    get UPDATOR(): FieldInfo{  
        return new FieldInfo('updator','');
    }
}

@Singleton 
class AdInfoMaterialMU extends TableUtilImpl<AdInfoMaterialCU,AdInfoMaterial>{ 
    tableName  = 'ad_info_material';
    tableFields  = ['ad_info_id','ad_material_id','del_flag'];
    modelFields  = ['adInfoId','adMaterialId','delFlag','id','adStyleId','name','status','createTime','creator','updateTime','updator'];
    modelIdFields  = ['adInfoId','adMaterialId'];
    tableIdFields  = ['ad_info_id','ad_material_id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: false,
            foreignKeyFields: [AdInfoMaterialMU.AD_MATERIAL_ID],
            joinIdFields: [AdMaterialMU.ID],
            getTableUtil: ()=>{
                return Container.get(AdMaterialMU);
            },
            fields: [
                {
                    fieldUtil: AdMaterialMU.ID,
                    alias: 'id'
                }
                ,{
                    fieldUtil: AdMaterialMU.AD_STYLE_ID,
                    alias: 'adStyleId'
                }
                ,{
                    fieldUtil: AdMaterialMU.NAME,
                    alias: 'name'
                }
                ,{
                    fieldUtil: AdMaterialMU.STATUS,
                    alias: 'status'
                }
                ,{
                    fieldUtil: AdMaterialMU.CREATE_TIME,
                    alias: 'createTime'
                }
                ,{
                    fieldUtil: AdMaterialMU.CREATOR,
                    alias: 'creator'
                }
                ,{
                    fieldUtil: AdMaterialMU.UPDATE_TIME,
                    alias: 'updateTime'
                }
                ,{
                    fieldUtil: AdMaterialMU.UPDATOR,
                    alias: 'updator'
                }
            ]

        } as JoinTable

];
    subTables = [];

    createConditionUtil(): AdInfoMaterialCU {
        return new AdInfoMaterialCUImpl();
    }   

    static get AD_INFO_ID(): FieldUtil<AdInfoMaterialCU>{ 
        return new FieldUtil('ad_info_id','adInfoId','广告信息id', new AdInfoMaterialCUImpl());
    }
    static get AD_MATERIAL_ID(): FieldUtil<AdInfoMaterialCU>{ 
        return new FieldUtil('ad_material_id','adMaterialId','素材id', new AdInfoMaterialCUImpl());
    }
    static get DEL_FLAG(): FieldUtil<AdInfoMaterialCU>{ 
        return new FieldUtil('del_flag','delFlag','是否删除：0，否；1，是', new AdInfoMaterialCUImpl());
    }
    static get ID(): FieldInfo{  
        return new FieldInfo('id','素材id');
    }
    static get AD_STYLE_ID(): FieldInfo{  
        return new FieldInfo('adStyleId','广告样式id');
    }
    static get NAME(): FieldInfo{  
        return new FieldInfo('name','素材名称');
    }
    static get STATUS(): FieldInfo{  
        return new FieldInfo('status','状态：0，启用；1，删除');
    }
    static get CREATE_TIME(): FieldInfo{  
        return new FieldInfo('createTime','');
    }
    static get CREATOR(): FieldInfo{  
        return new FieldInfo('creator','');
    }
    static get UPDATE_TIME(): FieldInfo{  
        return new FieldInfo('updateTime','');
    }
    static get UPDATOR(): FieldInfo{  
        return new FieldInfo('updator','');
    }

    get AD_INFO_ID(): FieldUtil<AdInfoMaterialCU>{ 
        return AdInfoMaterialMU.AD_INFO_ID;
    }
    get AD_MATERIAL_ID(): FieldUtil<AdInfoMaterialCU>{ 
        return AdInfoMaterialMU.AD_MATERIAL_ID;
    }
    get DEL_FLAG(): FieldUtil<AdInfoMaterialCU>{ 
        return AdInfoMaterialMU.DEL_FLAG;
    }
    get ID(): FieldInfo{  
        return AdInfoMaterialMU.ID;
    }
    get AD_STYLE_ID(): FieldInfo{  
        return AdInfoMaterialMU.AD_STYLE_ID;
    }
    get NAME(): FieldInfo{  
        return AdInfoMaterialMU.NAME;
    }
    get STATUS(): FieldInfo{  
        return AdInfoMaterialMU.STATUS;
    }
    get CREATE_TIME(): FieldInfo{  
        return AdInfoMaterialMU.CREATE_TIME;
    }
    get CREATOR(): FieldInfo{  
        return AdInfoMaterialMU.CREATOR;
    }
    get UPDATE_TIME(): FieldInfo{  
        return AdInfoMaterialMU.UPDATE_TIME;
    }
    get UPDATOR(): FieldInfo{  
        return AdInfoMaterialMU.UPDATOR;
    }
}
export {AdInfoMaterialMU, AdInfoMaterialCU}
