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 FormSelectFormat 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.getDictName(formItem, originValue.toString());
        }

        return FormFormatUtil.getDictNameListString(formItem, originValue);
    }

}
