syntax = "proto3";

option go_package = "git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb";
import "rs_common.proto";
import "google/api/annotations.proto";

service User {
  rpc Login(LoginReq) returns (LoginResp) {}
  // 获取用户信息
  rpc GetUserInfo(GetUserInfoReq) returns (GetUserInfoResp) {
    option (google.api.http) = {
      post: "/user/info"
      body: "*"
    };
  }
  // 生成题目
  rpc GenerateQuestion(GenerateQuestionReq) returns (GenerateQuestionResp) {
    option (google.api.http) = {
      post: "/user/generate_question"
      body: "*"
    };
  }
  // 获取题目
  rpc GetQuestion(GetQuestionReq) returns (GetQuestionResp) {
    option (google.api.http) = {
      post: "/user/get_question"
      body: "*"
    };
  }
  // 回答题目
  rpc AnswerQuestion(AnswerQuestionReq) returns (AnswerQuestionResp) {
    option (google.api.http) = {
      post: "/user/answer_question"
      body: "*"
    };
  }
}

// ---------- Login ----------
message LoginReq {
  string Phone = 1 [json_name = "phone"]; // 手机号
  string Code = 2 [json_name = "code"]; // 验证码
}
message LoginResp {
  string USN = 1 [json_name = "usn"]; // 用户ID
  string Name = 2 [json_name = "name"]; // 用户名
}

// ---------- GetUserInfo ----------
message GetUserInfoReq {
  string USN = 1 [json_name = "usn"]; 
}
message GetUserInfoResp {
  string USN = 1 [json_name = "usn"]; 
  string Name = 2 [json_name = "name"]; 
}

// ---------- GenerateQuestion ----------
message GenerateQuestionReq {
  int32 Num = 1 [json_name = "num"]; // 生成数量
  string Category = 2 [json_name = "category"]; // 题目类型
}
message GenerateQuestionResp {
}

// ---------- GetQuestion ----------
message GetQuestionReq {
}
message GetQuestionResp {
  string Sn = 1 [json_name = "sn"]; // 题目唯一标识
  string Question = 2 [json_name = "question"]; // 题干
  repeated string Options = 3 [json_name = "options"]; // 选项
}

// ---------- AnswerQuestion ----------
message AnswerQuestionReq {
  string Sn = 1 [json_name = "sn"]; // 题目唯一标识
  string Answer = 2 [json_name = "answer"]; // 答案
}
message AnswerQuestionResp {
  string Answer = 1 [json_name = "answer"]; // 答案
  string Explanation = 2 [json_name = "explanation"]; // 解析
}