package cn.stylefeng.team.form.api.parser;

import cn.stylefeng.team.form.api.entity.FormItem;
import cn.stylefeng.team.form.api.parser.base.BaseFormFormat;
import cn.stylefeng.team.form.api.parser.common.FormFormatUtil;

public class FormSelectPositionFormat implements BaseFormFormat {

    @Override
    public Object formatProcess(FormItem formItem, Object originValue) {

        if (formItem == null || originValue == null) {
            return null;
        }

        Boolean itemMultipleChoiceFlag = formItem.getItemMultipleChoiceFlag();
        if (itemMultipleChoiceFlag == null) {
            return null;
        }

        if (!itemMultipleChoiceFlag) {
            return FormFormatUtil.getSinglePositionName(Long.valueOf(originValue.toString()));
        }

        return FormFormatUtil.getSimpleDictListStringReadable(originValue.toString());
    }

}
