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.TemplateModelV3;
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 TemplateModelV3 templateModel;
    private final List<Todo> todos;

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

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