-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat-NoticeController-通知发布的时候可以对外广播消息
- Loading branch information
Showing
4 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
muyun-platform/src/main/java/net/ximatai/muyun/platform/BusChannel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.ximatai.muyun.platform; | ||
|
||
public class BusChannel { | ||
|
||
public static final String ROLE_CHANGED = "role_changed"; | ||
|
||
public static String channelForUser(String userID) { | ||
return "web.user.%s".formatted(userID); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
muyun-platform/src/main/java/net/ximatai/muyun/platform/model/MessageToFrontEnd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.ximatai.muyun.platform.model; | ||
|
||
import io.vertx.core.json.JsonObject; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class MessageToFrontEnd { | ||
private final String title; | ||
private final String content; | ||
private final LocalDateTime createdAt; | ||
private final String url; | ||
|
||
public MessageToFrontEnd(String title, String content, String url) { | ||
this(title, content, url, LocalDateTime.now()); | ||
} | ||
|
||
public MessageToFrontEnd(String title, String content, String url, LocalDateTime createdAt) { | ||
this.title = title; | ||
this.content = content; | ||
this.url = url; | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public JsonObject toJson() { | ||
JsonObject json = new JsonObject(); | ||
json.put("title", title); | ||
json.put("content", content); | ||
json.put("createdAt", createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | ||
return json; | ||
} | ||
} |