package cn.axzo.msg.center.domain.entity;

import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
import cn.axzo.msg.center.service.domain.GroupConfig;
import cn.axzo.msg.center.service.enums.GroupType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;

/**
 * @author yanglin
 */
@Setter
@Getter
@TableName(value = "message_template_group_v3", autoResultMap = true)
public class MessageTemplateGroupV3 extends BaseEntityWithOperator<MessageTemplateGroupV3> {

    /**
     * 分组名称, 公共组件时为空
     */
    private String name;

    /**
     * 模板code
     */
    private String templateCode;

    /**
     * 分组类型. KV_VALUES: 键值信息; COMPONENT_WORKER:工人卡片
     */
    private GroupType groupType;

    /**
     * 排列顺序
     */
    private Integer sortOrder;

    /**
     * 分组配置
     */
    @TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
    private GroupConfig groupConfig;

    @TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
    private RecordExt recordExt;

    public RecordExt getOrCreateRecordExt() {
        if (recordExt == null) recordExt = new RecordExt();
        return recordExt;
    }

    public GroupConfig getOrCreateGroupConfig() {
        if (groupConfig == null)
            groupConfig = new GroupConfig();
        return groupConfig;
    }

    @Setter
    @Getter
    public static class RecordExt {
        private Boolean isMigrated;
        private Boolean isSyncedForTest;
    }
}