64 lines
1.9 KiB
Protocol Buffer
64 lines
1.9 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
package notes.v1;
|
||
|
||
option go_package = "backend/gen/notes/v1;notesv1";
|
||
|
||
import "google/protobuf/timestamp.proto";
|
||
import "google/protobuf/empty.proto";
|
||
|
||
// ─── Модели ───────────────────────────────────────────────
|
||
|
||
message Note {
|
||
string id = 1;
|
||
string title = 2;
|
||
string content = 3;
|
||
google.protobuf.Timestamp created_at = 4;
|
||
google.protobuf.Timestamp updated_at = 5;
|
||
}
|
||
|
||
// ─── Запросы и ответы ─────────────────────────────────────
|
||
|
||
message CreateNoteRequest {
|
||
string title = 1;
|
||
string content = 2;
|
||
}
|
||
|
||
message GetNoteRequest {
|
||
string id = 1;
|
||
}
|
||
|
||
message UpdateNoteRequest {
|
||
string id = 1;
|
||
string title = 2;
|
||
string content = 3;
|
||
}
|
||
|
||
message DeleteNoteRequest {
|
||
string id = 1;
|
||
}
|
||
|
||
message ListNotesRequest {
|
||
int32 page = 1;
|
||
int32 page_size = 2;
|
||
}
|
||
|
||
message ListNotesResponse {
|
||
repeated Note notes = 1;
|
||
int32 total_count = 2;
|
||
}
|
||
|
||
// ─── Сервис ───────────────────────────────────────────────
|
||
// Один этот файл определяет ВСЕ типы и ВСЕ эндпоинты.
|
||
// Из него генерируется типизированный код для Go и Dart.
|
||
// Изменил proto → перегенерировал → ошибки компиляции
|
||
// на обеих сторонах, если контракт нарушен.
|
||
|
||
service NoteService {
|
||
rpc CreateNote(CreateNoteRequest) returns (Note);
|
||
rpc GetNote(GetNoteRequest) returns (Note);
|
||
rpc UpdateNote(UpdateNoteRequest) returns (Note);
|
||
rpc DeleteNote(DeleteNoteRequest) returns (google.protobuf.Empty);
|
||
rpc ListNotes(ListNotesRequest) returns (ListNotesResponse);
|
||
}
|