package com.friday.custody.service.trustService.guosen.context;

import com.friday.custody.service.trustService.guosen.dto.InvokeGuosenRecordDto;
import com.friday.custody.service.trustService.guosen.service.ProcessGuosenDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 */
@Slf4j
@Service
public class ProcessGuosenDataServiceContext {
    private final Map<String, ProcessGuosenDataService> outsourceStrategyMap = new ConcurrentHashMap<>();

    @Autowired
    public void dpStrategyContext(Map<String, ProcessGuosenDataService> strategyMap) {
        strategyMap.forEach(this.outsourceStrategyMap::put);
    }

    public void processData(InvokeGuosenRecordDto dto) {
        log.info("ProcessGuosenDataServiceContext  processData,the type is {} ",dto.getUrl());
        outsourceStrategyMap.get(dto.getUrl()).processData(dto);
    }
}
