package cn.ey.biz.module.system.convert.permission;

import cn.ey.biz.module.system.api.permission.dto.CodeBlockAreaConfigDataRespDTO;
import cn.ey.biz.module.system.api.permission.dto.CodeBlockServiceLineConfigDataRespDTO;
import cn.hutool.core.collection.CollectionUtil;

import java.util.ArrayList;
import java.util.List;

public class DataRoleConverter {

    public static List<CodeBlockAreaConfigDataRespDTO> stringToAreaObject(List<List<String>> list) {
        if (CollectionUtil.isEmpty(list)) return null;
        //area:[ [ "MNG", "N01", "N0351", "CN730" ] ]
        List<CodeBlockAreaConfigDataRespDTO> lastList = new ArrayList<>();
        for (List<String> stringList : list) {
            CodeBlockAreaConfigDataRespDTO configDataRespDTO = new CodeBlockAreaConfigDataRespDTO();
            for (int i = 0; i < stringList.size(); i++) {
                switch (i) {
                    case 0:
                        configDataRespDTO.setCountryRegionCode(stringList.get(i));
                        continue;
                    case 1:
                        configDataRespDTO.setMarketSegmentCode(stringList.get(i));
                        continue;
                    case 2:
                        configDataRespDTO.setCityCode(stringList.get(i));
                        continue;
                    case 3:
                        configDataRespDTO.setBuCode(stringList.get(i));
                        continue;
                    default:
                        break;
                }
            }
            lastList.add(configDataRespDTO);
        }
        return lastList;
    }

    public static List<CodeBlockServiceLineConfigDataRespDTO> stringToServiceLineObject(List<List<String>> list) {
        if (CollectionUtil.isEmpty(list)) return null;
        //serviceLine: [ [ "Eygs", "09", "0922", "0922C036", "0922102" ], [ "Eygs", "09", "0921", "0921C035", "0921103" ] ]
        List<CodeBlockServiceLineConfigDataRespDTO> lastList = new ArrayList<>();
        for (List<String> stringList : list) {
            CodeBlockServiceLineConfigDataRespDTO configDataRespDTO = new CodeBlockServiceLineConfigDataRespDTO();
            for (int i = 0; i < stringList.size(); i++) {
                switch (i) {
                    case 0:
                        configDataRespDTO.setSlCode(stringList.get(i));
                        continue;
                    case 1:
                        configDataRespDTO.setSslCode(stringList.get(i));
                        continue;
                    case 2:
                        configDataRespDTO.setCompetencyCode(stringList.get(i));
                        continue;
                    case 3:
                        configDataRespDTO.setSmuCode(stringList.get(i));
                        continue;
                    default:
                        break;
                }
            }
            lastList.add(configDataRespDTO);
        }
        return lastList;
    }
}
