2023-02-16 15:28:15 +08:00

114 lines
2.6 KiB
Java

package com.zhgd.mqtt.bean;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
/**
* mqtt 消息推送实体
*
* @author
* @date 2019/11/14$ 15:52$
*/
@Slf4j
@Setter
@Getter
public class PushPayload {
//推送类型
private String type;
//推送子类型
private String itemType;
//推送对象
private String accountId;
//标题
private String title;
//内容
private String content;
//数量
private Integer badge = 1;
//铃声
private String sound = "default";
public PushPayload(String type, String accountId, String title, String content, Integer badge , String sound,String itemType){
this.type = type;
this.accountId = accountId;
this.title = title;
this.content = content;
this.badge = badge;
this.sound = sound;
this.itemType = itemType;
}
public static class Builder{
//推送类型
private String type;
//推送子类型
private String itemType;
//推送对象
private String accountId;
//标题
private String title;
//内容
private String content;
//数量
private Integer badge = 1;
//铃声
private String sound = "default";
public Builder setType(String type) {
this.type = type;
return this;
}
public Builder setItemType(String itemType) {
this.itemType = itemType;
return this;
}
public Builder setAccountId(String accountId) {
this.accountId = accountId;
return this;
}
public Builder setTitle(String title) {
this.title = title;
return this;
}
public Builder setContent(String content) {
this.content = content;
return this;
}
public Builder setBadge(Integer badge) {
this.badge = badge;
return this;
}
public Builder setSound(String sound) {
this.sound = sound;
return this;
}
public PushPayload bulid(){
return new PushPayload(type,accountId,title,content,badge,sound,itemType);
}
}
public static Builder getPushPayloadBuider(){
return new Builder();
}
@Override
public String toString() {
return JSON.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect);
}
}