package cn.axzo.msg.center.message.service.todo.manage.event;

import cn.axzo.msg.center.domain.entity.Todo;
import cn.axzo.msg.center.message.domain.dto.MessageTemplateDTO;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;

import java.util.HashMap;
import java.util.List;

/**
 * @author yanglin
 */
@Getter
public class NewTodoEvent extends ApplicationEvent {
    private final MessageTemplateDTO template;
    private final List<Todo> todos;

    public NewTodoEvent(Object source, MessageTemplateDTO template, List<Todo> todos) {
        super(source);
        this.template = template;
        this.todos = todos;
    }

    @Override
    public String toString() {
        HashMap<String, Object> fields = new HashMap<>();
        fields.put("template", template);
        fields.put("todos", todos);
        return JSON.toJSONString(fields);
    }
}