Commit 58b10b85 authored by xuwencheng's avatar xuwencheng

consume

parent 38ae9e7e
......@@ -17,6 +17,19 @@ impl PublishMessage {
pub fn new(id: i64, ty: i32, qos: Qos, data: Option<String>) -> Self {
Self { id, ty, qos, data }
}
pub fn to_push(&self, seller_id: i64, store_id: i64, c_types: &[i32], key: Option<impl AsRef<str>>) -> PushMessage {
PushMessage {
seller_id,
store_id,
client_types: c_types.iter().map(|v| *v).collect::<Vec<i32>>(),
business_type: self.ty,
message_id: self.id,
key: key.map(|s| s.as_ref().to_string()),
qos: self.qos,
payload: self.data.clone(),
}
}
}
#[derive(Debug, Serialize, Deserialize)]
......@@ -30,4 +43,4 @@ pub struct PushMessage {
key: Option<String>,
qos: Qos,
payload: Option<String>,
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment