syntax = "proto3";

option go_package ="./pb";

package pb;

// ------------------------------------
// Messages
// ------------------------------------

//--------------------------------reviews--------------------------------
message Reviews {
  int64 id = 1; //id
  int64 orderId = 2; //orderId
  int64 fromUserId = 3; //fromUserId
  string fromUserName = 4; //fromUserName
  string fromUserAvatar = 5; //fromUserAvatar
  int64 toUserId = 6; //toUserId
  int32 rating = 7; //rating
  string content = 8; //content
  bool sealed = 9; //sealed
  int64 createdAt = 10; //createdAt
  int64 unsealedAt = 11; //unsealedAt
}

message AddReviewsReq {
  int64 orderId = 1; //orderId
  int64 fromUserId = 2; //fromUserId
  string fromUserName = 3; //fromUserName
  string fromUserAvatar = 4; //fromUserAvatar
  int64 toUserId = 5; //toUserId
  int32 rating = 6; //rating
  string content = 7; //content
  bool sealed = 8; //sealed
  int64 createdAt = 9; //createdAt
}

message AddReviewsResp {
  int64 id = 1; //id
}

message UpdateReviewsReq {
  int64 id = 1; //id
  optional int64 orderId = 2; //orderId
  optional int64 fromUserId = 3; //fromUserId
  optional string fromUserName = 4; //fromUserName
  optional string fromUserAvatar = 5; //fromUserAvatar
  optional int64 toUserId = 6; //toUserId
  optional int32 rating = 7; //rating
  optional string content = 8; //content
  optional bool sealed = 9; //sealed
  optional int64 createdAt = 10; //createdAt
  optional int64 unsealedAt = 11; //unsealedAt
}

message UpdateReviewsResp {
}

message DelReviewsReq {
  int64 id = 1; //id
}

message DelReviewsResp {
}

message GetReviewsByIdReq {
  int64 id = 1; //id
}

message GetReviewsByIdResp {
  Reviews reviews = 1; //reviews
}

message SearchReviewsReq {
  int64 offset = 1; //offset
  int64 limit = 2; //limit
  optional int64 id = 3; //id
  optional int64 orderId = 4; //orderId
  optional int64 fromUserId = 5; //fromUserId
  optional int64 toUserId = 6; //toUserId
  optional bool sealed = 7; //sealed
}

message SearchReviewsResp {
  repeated Reviews reviews = 1; //reviews
}

// ------------------------------------
// Rpc Func
// ------------------------------------

service reviewService {
  //-----------------------reviews-----------------------
  rpc AddReviews(AddReviewsReq) returns (AddReviewsResp);
  rpc UpdateReviews(UpdateReviewsReq) returns (UpdateReviewsResp);
  rpc DelReviews(DelReviewsReq) returns (DelReviewsResp);
  rpc GetReviewsById(GetReviewsByIdReq) returns (GetReviewsByIdResp);
  rpc SearchReviews(SearchReviewsReq) returns (SearchReviewsResp);
}
