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

import cn.ey.biz.module.system.controller.admin.abac.vo.AbacVo;
import cn.ey.biz.module.system.controller.admin.abac.vo.ServiceLineAbAcVo;
import cn.hutool.core.collection.CollectionUtil;

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

public class ServiceLineAbacConverter {

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