package com.zd.system.api.alarm.domain;

import cn.hutool.json.JSONUtil;
import com.zd.common.core.constant.Constants;

import javax.validation.constraints.NotNull;
import java.util.Arrays;

public class AlarmEntrty {

    private Routes route;

    /**
     * 手机号码
     * Type 对象为 SMS、Call、All 时，To 为电话号码，字符串数组
     */
    @NotNull(message = "手机号码不能为空")
    private String[] To;

    /**
     * 告警通知类型
     * 目前只做出电话语音和短信（不选邮件和音频）
     */
    private String Type;

    /**
     * 编码方式 默认UTF-8
     */
    private String Encoding = Constants.UTF8;

    /**
     * 邮件主题
     * Type 对象为 Email 时，Sub 必须添加邮件主题
     * 可选
     */
    private String Sub;

    /**
     * 通知内容
     */
    @NotNull(message = "通知内容不能为空！")
    private String Text;

    public AlarmEntrty() {
    }

    /**
     * 默认 电话语音播报
     */
    public AlarmEntrty(@NotNull Routes route, @NotNull String[] to, @NotNull String text) {
        this.route = route;
        this.Type = SendTypes.All+"";
        this.setTo(to);
        this.Text = text;
    }

    public AlarmEntrty(@NotNull Routes route, @NotNull String[] to, @NotNull String type, @NotNull String text) {
        this.route = route;
        this.To = to;
        this.Type = type;
        this.Text = text;
    }

    public String[] getTo() {
        return To;
    }

    public void setTo(String[] to) {
        To = to;
    }

    public String getType() {
        return Type;
    }

    public void setType(String type) {
        Type = type;
    }

    public String getEncoding() {
        return Encoding;
    }

    public void setEncoding(String encoding) {
        Encoding = encoding;
    }

    public String getSub() {
        return Sub;
    }

    public void setSub(String sub) {
        Sub = sub;
    }

    public String getText() {
        return Text;
    }

    public void setText(String text) {
        Text = text;
    }

    public Routes getRoute() {
        return route;
    }

    public void setRoute(Routes route) {
        this.route = route;
    }

    @Override
    public String toString() {
        return JSONUtil.toJsonStr(this);
    }
}
