package com.zsc.edu.gateway.modules.message.entity;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 消息内容
 *
 * @author harry_yao
 */
public abstract class NoticePayload {

    public NoticeType type;
    public String content;
    public Boolean html;

    public static class Other extends NoticePayload {
        public Other(String content) {
            this.content = content;
            this.type = NoticeType.MESSAGE;
        }
    }

    public static class ResetPassword extends NoticePayload {
        public String username;
        public String password;
        public LocalDateTime resetTime;

        public ResetPassword(String username, String password, LocalDateTime resetTime) {
            this.username = username;
            this.password = password;
            this.resetTime = resetTime;
            this.type = NoticeType.NOTICE;
            this.content = String.format("尊敬的用户%s，您的密码已于%s被管理员重置，新密码为%s，" +
                "请及时登录系统修改密码！", username, resetTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), password);
        }
    }

}
