package org.dromara.common.batch.processer;

import java.util.Map;

public class GameAthleteProcessor implements ItemProcessor<GameAthlete, GameAthlete> {

    private Map<String, Long> codeToIdMap;
    private boolean codesLoaded = false;

    @Override
    public GameAthlete process(GameAthlete item) throws Exception {
        if (!codesLoaded) {
            loadExistingCodes(item);
            codesLoaded = true;
        }

        if (item.getAthleteCode() != null && codeToIdMap.containsKey(item.getAthleteCode())) {
            item.setAthleteId(codeToIdMap.get(item.getAthleteCode()));
        }
        return item;
    }

    private void loadExistingCodes(GameAthlete sampleItem) {
        // 获取所有需要检查的code
        // 这里需要从上下文中获取完整的列表，可能需要调整设计
        // 或者改为在writer中处理
    }
}
