Skip to content

Commit 23ef84c

Browse files
committed
add a enum
1 parent 5dd67ec commit 23ef84c

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

news.proto

+20-19
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ import "google/protobuf/empty.proto";
44

55
package news;
66

7+
enum Status {
8+
PUBLISHED = 0;
9+
DRAFT = 1;
10+
DELETED = 2;
11+
}
12+
713
message News {
8-
int32 id = 1;
9-
string title = 2;
10-
string body = 3;
11-
string postImage = 4;
14+
int32 id = 1;
15+
string title = 2;
16+
string body = 3;
17+
string postImage = 4;
18+
Status status = 5;
1219
}
1320

1421
service NewsService {
15-
rpc GetAllNews (google.protobuf.Empty) returns (NewsList) {}
16-
rpc GetNews (NewsId) returns (News) {}
17-
rpc GetMultipleNews (MultipleNewsId) returns (NewsList) {}
18-
rpc DeleteNews (NewsId) returns (google.protobuf.Empty) {}
19-
rpc EditNews (News) returns (News) {}
20-
rpc AddNews (News) returns (News) {}
22+
rpc GetAllNews(google.protobuf.Empty) returns (NewsList) {}
23+
rpc GetNews(NewsId) returns (News) {}
24+
rpc GetMultipleNews(MultipleNewsId) returns (NewsList) {}
25+
rpc DeleteNews(NewsId) returns (google.protobuf.Empty) {}
26+
rpc EditNews(News) returns (News) {}
27+
rpc AddNews(News) returns (News) {}
2128
}
2229

23-
message NewsId {
24-
int32 id = 1;
25-
}
30+
message NewsId { int32 id = 1; }
2631

27-
message MultipleNewsId {
28-
repeated NewsId ids = 1;
29-
}
32+
message MultipleNewsId { repeated NewsId ids = 1; }
3033

31-
message NewsList {
32-
repeated News news = 1;
33-
}
34+
message NewsList { repeated News news = 1; }

src/main.rs

+5
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,35 @@ impl MyNewsService {
3737
title: "Note 1".into(),
3838
body: "Content 1".into(),
3939
post_image: "Post image 1".into(),
40+
status: 0,
4041
},
4142
News {
4243
id: 2,
4344
title: "Note 2".into(),
4445
body: "Content 2".into(),
4546
post_image: "Post image 2".into(),
47+
status: 1,
4648
},
4749
News {
4850
id: 3,
4951
title: "Note 3".into(),
5052
body: "Content 3".into(),
5153
post_image: "Post image 3".into(),
54+
status: 1,
5255
},
5356
News {
5457
id: 4,
5558
title: "Note 4".into(),
5659
body: "Content 4".into(),
5760
post_image: "Post image 4".into(),
61+
status: 1,
5862
},
5963
News {
6064
id: 5,
6165
title: "Note 5".into(),
6266
body: "Content 5".into(),
6367
post_image: "Post image 5".into(),
68+
status: 1,
6469
},
6570
];
6671
MyNewsService {

0 commit comments

Comments
 (0)