package com.ruoyi.xq.notice.data;

import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

@Data
public class ExtNoticeData {
    private Integer action = 1;
    private String title = "";
    private String date;
    private String txt1 = "";
    private List<MessageExtDataList> fields = new ArrayList<>();
    private String txt2 = "";
    private Integer link_type = 0;
    private String link_url = "";

    @Data
    public static class MessageExtDataList {
        private String n;
        private String v;

        public MessageExtDataList(String n, String v) {
            this.n = n;
            this.v = v;
        }

        public MessageExtDataList() {
        }
    }

    public void setCurrentDate(){
        this.date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public void addFields(String n,String v){
        fields.add(new MessageExtDataList(n,v));
    }
}
