package com.ruoyi.business.state.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * 调查问卷模版题目对象 t_state_model_form
 * 
 * @author Duke_yzl
 * @date 2023-06-26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_state_model_form")
public class StateModelForm
{
    private static final long serialVersionUID = 1L;

    /** 题目ID */
    @TableId
    private Long stateId;
    /** 问题 */
    @Excel(name = "问题")
    private String stateName;
    /** 答案 */
    @Excel(name = "答案")
    private String stateValue;

    @TableField(exist = false)
    private List<String> stateValues;
    /** 类型input输入radio单选checkbox多选 */
    @Excel(name = "类型input输入radio单选checkbox多选")
    private String stateType;
    /** 输入框提示语 */
    @Excel(name = "输入框提示语")
    private String statePlaceholder;
    /** 异常提示语 */
    @Excel(name = "异常提示语")
    private String stateVerify;
    /** 模板主键 */
    private Long modelId;
    /** 排序 */
    @Excel(name = "排序")
    private Long orderNum;

    @TableField(exist = false)
    private List<StateModelFormItem> items;

    public List<String> getStateValues(){
        if (StringUtils.isNotBlank(this.stateValue)){
            return Arrays.asList(this.stateValue.split(","));
        }
        return new ArrayList<>();
    }

}
