package com.lqkj.link.message; import io.swagger.v3.oas.annotations.media.Schema; import java.io.Serializable; import java.util.ArrayList; import java.util.List; /** * 服务器多个信息bean * Created by free on 2017/7/27 0027. */ @Schema(description = "多个实体返回对象") public class MessageListBean extends MessageBaseBean implements Serializable { public MessageListBean() { this.setTime(System.currentTimeMillis()); } public MessageListBean(List data) { this.data = data; this.setTime(System.currentTimeMillis()); } /** * 被包含的多个消息实体 */ @Schema(description = "包含的对象") private List data; public List getData() { return data; } public void setData(List data) { this.data = data; } /** * 增加一个数据 * * @param data 数据 */ public void addData(T data) { if (this.data == null) { this.data = new ArrayList(5); } this.data.add(data); } public static MessageListBean ok(List data, String message) { MessageListBean messageListBean = new MessageListBean<>(); messageListBean.setStatus(true); messageListBean.setData(data); messageListBean.setCode(200); messageListBean.setMessage(message); return messageListBean; } public static MessageListBean error(String message) { MessageListBean messageListBean = new MessageListBean<>(); messageListBean.setStatus(false); messageListBean.setCode(-1); messageListBean.setMessage(message); return messageListBean; } }