package com.ningdatech.pmapi.expert.utils;


import com.ningdatech.basic.exception.BizException;
import com.ningdatech.pmapi.expert.model.DictionaryFieldInfo;
import com.ningdatech.pmapi.expert.model.SensitiveModifySegment;
import com.ningdatech.pmapi.expert.model.TagFieldInfo;
import com.ningdatech.yxt.utils.JSONUtils;

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

/**
 * @author liuxinxin
 * @date 2022/8/24 下午3:36
 */

public class SensitiveModifySegmentUtils {

    private SensitiveModifySegmentUtils() {
    }

    public static List<TagFieldInfo> getTagFieldInfoListApply(SensitiveModifySegment segment) {
        switch (segment.getFieldName()) {
            case good_at:
            case technical_expertise:
            case industry_sector:
            case other:
                if (Objects.nonNull(segment.getApply())) {
                    return JSONUtils.parseArray(segment.getApply().toString(), TagFieldInfo.class);
                }
                return new ArrayList<>();
            default:
                throw new BizException("非法格式");
        }

    }

    public static List<DictionaryFieldInfo> getDictionaryFieldInfoListApply(SensitiveModifySegment segment) {
        switch (segment.getFieldName()) {
            case administrative_rank:
            case title_level: {
                if (Objects.nonNull(segment.getApply())) {
                    return JSONUtils.parseArray(segment.getApply().toString(), DictionaryFieldInfo.class);
                }
                return new ArrayList<>();
            }
            default:
                throw new BizException("非法格式");
        }
    }
}
