package com.keyware.shandan.mark.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.keyware.shandan.common.util.MD5Util;
import com.keyware.shandan.common.util.StringUtils;
import lombok.Data;

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

/**
 * @author GuoXin
 * @date 2022-05-17
 */
@Data
@TableName("MARK_FORM_CONFIG")
public class FormMark implements Serializable {
    private static final long serialVersionUID = -136858993778660366L;

    @TableId("ID")
    private String id;

    @TableField("FORM_TYPE")
    private String formType;

    @TableField("MARK_TYPE_ID")
    private Integer markTypeId;

    @TableField("MARK_TYPE")
    private String markType;

    @TableField("MARK_DEFAULT")
    private String markDefault;

    @TableField(exist = false)
    private List<MarkType> markTypeList;

    @TableField(exist = false)
    private String[] markDefaultList;

    public String[] getMarkDefaultList() {
        if (StringUtils.hasText(markDefault)) {
            return markDefault.split(",");
        }
        return new String[]{};
    }

    public String md5() {
        return MD5Util.getMD5(formType + markTypeId);
    }
}
