demo.proto 1.6 KB
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
syntax = "proto3";

package demo;

import "google/api/annotations.proto";

option go_package = "hilo/api/demo;demo";

// 定义服务
service Demo {
  rpc Hello (HelloReq) returns (HelloRep) {
    option (google.api.http) = {
      get: "/demo/hello/{name}"
    };
  }

  rpc Create (CreateReq) returns (OKRep) {
    option (google.api.http) = {
      post: "/demo/create",
      body: "*"
    };
  }

  rpc Update (UpdateReq) returns (OKRep) {
    option (google.api.http) = {
      post: "/demo/update",
      body: "*"
    };
  }

  rpc Get (IdReq) returns (DemoModel) {
    option (google.api.http) = {
      get: "/demo/get",
    };
  }

  rpc List (ListReq) returns (ListRep) {
    option (google.api.http) = {
      get: "/demo/list",
    };
  }

  rpc Delete (IdReq) returns (OKRep) {
    option (google.api.http) = {
      get: "/demo/delete",
    };
  }
}

message DemoModel {
  int64 id = 1;
  string name = 2;
  string value = 3;
  int64 created_at = 4;
  int64 updated_at = 5;
}

message IdReq  {
  int64 id = 1; // @gotags: validate:"required,min=1"
}

message ListReq  {
  int64 page = 1; // @gotags: validate:"min=0"
  int64 size = 2; // @gotags: validate:"min=0"
}

message ListRep {
  repeated DemoModel list = 1;
}

message CreateReq {
  string name = 1;  // @gotags: validate:"required"
  string value = 2;  // @gotags: validate:"required"
}

message UpdateReq {
  int64 id = 1; // @gotags: validate:"required"
  string name = 2;  // @gotags: validate:"required"
  string value = 3;  // @gotags: validate:"required"
}

message OKRep {}



message HelloReq {
  string name = 1;
}

message HelloRep {
  string message = 1;
}