syntax = "proto3";

message UserInfo {
  int64 ID = 1;
  string status = 2;
  string created_at = 3;
  string updated_at = 4;
  string username = 5;
  optional string phone_number = 6;
  optional string email = 7;
  string password = 8;
  optional string nickname = 9;
  // meta
  map<string, string> metas = 10;
  // relations
  repeated RoleInfo roles = 20;
  repeated UserSocialInfo socials = 21;
  repeated DepartmentInfo departments = 22;
  repeated TokenInfo tokens = 23;
  LoginRecordInfo login_record = 24;
}

message UserReq {
  int64 ID = 1;
  string username = 2;
  string phone_number = 3;
  string email = 4;
  string nickname = 5;

  bool with_role = 6;
  bool with_social = 7;
  bool with_department = 8;
  bool with_token = 9;
  bool with_login_record = 10;

  // 分页查询
  optional Pagination page = 20;
}

message UserListResp {
  optional Pagination page = 1;
  repeated UserInfo data = 2;
}

service Core {
  // User Management
  // group: user
  rpc createUser (UserInfo) returns (BaseIDResp);
  // group: user
  rpc updateUser (UserInfo) returns (BaseResp);
  // group: user
  rpc getUserList (UserReq) returns (UserListResp);
  // group: user
  rpc getUser (UserReq) returns (UserInfo);
  // group: user
  rpc deleteUser (IDsReq) returns (BaseResp);
}