All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nebula.boxes.mould.fetcher.FirmStaffDataFetcher Maven / Gradle / Ivy

The newest version!
package com.nebula.boxes.mould.fetcher;

import java.util.List;
import java.util.concurrent.CompletableFuture;

import com.nebula.boxes.mould.fetcher.loader.FirmStaffDataLoader;
import org.dataloader.DataLoader;
import org.springframework.context.annotation.Lazy;
import org.springframework.beans.factory.annotation.Autowired;
import com.nebula.boxes.mould.entity.FirmStaff;
import com.nebula.boxes.mould.service.IFirmStaffService;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsData;
import com.netflix.graphql.dgs.DgsDataFetchingEnvironment;
import com.spring.boxes.dollar.support.ContextAwarePoolExecutor;
import graphql.schema.DataFetchingEnvironment;
import lombok.extern.slf4j.Slf4j;

/**
* 企业基础信息 Fetcher
*/
@Lazy
@Slf4j
@DgsComponent
public class FirmStaffDataFetcher {

    @Autowired
    private IFirmStaffService firmStaffService;

    @Autowired
    private ContextAwarePoolExecutor contextAwarePoolExecutor;

    @DgsData(parentType = "Query", field = "getFirmStaffById")
    public CompletableFuture getFirmStaffById(DataFetchingEnvironment dfe) {
        DgsDataFetchingEnvironment environment = (DgsDataFetchingEnvironment) dfe;
        long id = environment.getArgument("id");
        DataLoader dataLoader = environment.getDataLoader(FirmStaffDataLoader.class);
        return dataLoader.load(id);
    }

    @DgsData(parentType = "Query", field = "getFirmStaffByIds")
    public CompletableFuture> getFirmStaffByIds(DataFetchingEnvironment dfe) {
        DgsDataFetchingEnvironment environment = (DgsDataFetchingEnvironment) dfe;
        List ids = environment.getArgument("ids");
        DataLoader dataLoader = environment.getDataLoader(FirmStaffDataLoader.class);
        return dataLoader.loadMany(ids);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy