109 lines
3.5 KiB
Protocol Buffer
109 lines
3.5 KiB
Protocol Buffer
syntax = "proto3";
|
|
package topfans.notification;
|
|
|
|
option go_package = "github.com/topfans/backend/pkg/proto/notification;notification";
|
|
|
|
import "proto/common.proto";
|
|
import "google/api/annotations.proto";
|
|
import "google/protobuf/struct.proto";
|
|
|
|
service NotificationService {
|
|
rpc CreateNotification(CreateNotificationRequest) returns (CreateNotificationResponse) {
|
|
option (google.api.http) = {
|
|
post: "/internal/v1/notifications"
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc GetNotifications(GetNotificationsRequest) returns (GetNotificationsResponse) {
|
|
option (google.api.http) = { get: "/api/v1/notifications" };
|
|
}
|
|
rpc GetUnreadCount(GetUnreadCountRequest) returns (GetUnreadCountResponse) {
|
|
option (google.api.http) = { get: "/api/v1/notifications/unread-count" };
|
|
}
|
|
rpc MarkAsRead(MarkAsReadRequest) returns (MarkAsReadResponse) {
|
|
option (google.api.http) = { post: "/api/v1/notifications/{id}/read" };
|
|
}
|
|
rpc MarkAsReadByTarget(MarkAsReadByTargetRequest) returns (MarkAsReadByTargetResponse) {
|
|
option (google.api.http) = { post: "/api/v1/notifications/targets/{target_id}/read" };
|
|
}
|
|
rpc MarkAllAsRead(MarkAllAsReadRequest) returns (MarkAllAsReadResponse) {
|
|
option (google.api.http) = { post: "/api/v1/notifications/read-all" };
|
|
}
|
|
rpc DeleteNotification(DeleteNotificationRequest) returns (DeleteNotificationResponse) {
|
|
option (google.api.http) = { delete: "/api/v1/notifications/{id}" };
|
|
}
|
|
rpc DeleteByTarget(DeleteByTargetRequest) returns (DeleteByTargetResponse) {
|
|
option (google.api.http) = { delete: "/api/v1/notifications/targets/{target_id}" };
|
|
}
|
|
}
|
|
|
|
message Notification {
|
|
int64 id = 1; int64 user_id = 2; int64 star_id = 3;
|
|
string type = 4; string title = 5; string content = 6;
|
|
google.protobuf.Struct data = 7;
|
|
bool is_read = 8; int64 created_at = 9; int64 read_at = 10;
|
|
|
|
// 列表层聚合:仅 type=like 且按 target_id 聚合时返回
|
|
bool aggregated = 11;
|
|
int32 total_count = 12;
|
|
repeated ActorPreview actors = 13;
|
|
int64 target_id = 14;
|
|
}
|
|
|
|
message ActorPreview {
|
|
int64 user_id = 1; string nickname = 2; string avatar = 3;
|
|
int64 liked_at = 4;
|
|
}
|
|
|
|
message CreateNotificationRequest {
|
|
int64 user_id = 1; int64 star_id = 2;
|
|
string type = 3; string title = 4; string content = 5;
|
|
google.protobuf.Struct data = 6;
|
|
}
|
|
message CreateNotificationResponse {
|
|
topfans.common.BaseResponse base = 1;
|
|
int64 id = 2;
|
|
}
|
|
|
|
message GetNotificationsRequest {
|
|
string type = 1;
|
|
string tab = 2;
|
|
int32 page = 3; int32 page_size = 4;
|
|
}
|
|
message GetNotificationsResponse {
|
|
topfans.common.BaseResponse base = 1;
|
|
repeated Notification items = 2;
|
|
int64 total = 3;
|
|
int32 page = 4; int32 page_size = 5;
|
|
}
|
|
|
|
message GetUnreadCountRequest {}
|
|
message UnreadCount {
|
|
int32 like = 1; int32 system = 2; int32 activity = 3; int32 total = 4;
|
|
}
|
|
message GetUnreadCountResponse {
|
|
topfans.common.BaseResponse base = 1;
|
|
UnreadCount counts = 2;
|
|
}
|
|
|
|
message MarkAsReadRequest { int64 id = 1; }
|
|
message MarkAsReadResponse { topfans.common.BaseResponse base = 1; }
|
|
|
|
message MarkAsReadByTargetRequest { int64 target_id = 1; }
|
|
message MarkAsReadByTargetResponse {
|
|
topfans.common.BaseResponse base = 1; int32 affected = 2;
|
|
}
|
|
|
|
message MarkAllAsReadRequest { string type = 1; }
|
|
message MarkAllAsReadResponse {
|
|
topfans.common.BaseResponse base = 1; int32 affected = 2;
|
|
}
|
|
|
|
message DeleteNotificationRequest { int64 id = 1; }
|
|
message DeleteNotificationResponse { topfans.common.BaseResponse base = 1; }
|
|
|
|
message DeleteByTargetRequest { int64 target_id = 1; }
|
|
message DeleteByTargetResponse {
|
|
topfans.common.BaseResponse base = 1; int32 affected = 2;
|
|
}
|