package com.arms.api.report.weekly.model.vo;

import lombok.Builder;
import lombok.Getter;

import java.util.Map;

@Getter
@Builder
public class StateMappingInfo {

    private Map<String, Category> categoryMap;
    private Map<String, State> stateMap;
    private Map<String, AlmIssueStatus> almIssueStatusMap;

    public String resolveCategory(String almIssueStatusKey) {
        AlmIssueStatus almIssueStatus = almIssueStatusMap.get(almIssueStatusKey);
        if (almIssueStatus == null) {
            return "기타";
        }

        State state = stateMap.get(almIssueStatus.getArmsStateMappingId());
        if (state == null) {
            return "기타";
        }

        Category category = categoryMap.get(state.getCategoryMappingId());
        if (category == null) {
            return "기타";
        }

        return category.getName();
    }

    @Getter
    @Builder
    public static class Category {
        private String id;
        private String name;
    }

    @Getter
    @Builder
    public static class State {
        private String id;
        private String name;
        private String categoryMappingId;
    }

    @Getter
    @Builder
    public static class AlmIssueStatus {
        private String id;
        private String name;
        private String armsStateMappingId;
    }
}