syntax = "proto3";

message DictionaryInfo {
  int64 ID = 1;
  string status = 2;
  string created_at = 3;
  string updated_at = 4;
  string title = 5;
  string name = 6;
  string description = 7;
  // relations
  repeated DictionaryDetailInfo details = 10;
}

message DictionaryDetailInfo {
  int64 ID = 1;
  string status = 2;
  string created_at = 3;
  string updated_at = 4;
  string title = 5;
  string key = 6;
  string value = 7;
  uint32 sort = 8;
  int64 dictionary_id = 9;

  // relations
  DictionaryInfo dictionary = 10;
}

message DictionaryReq {
  int64 ID = 1;
  string name = 2; // like
  string title = 3; // like

  bool with_details = 4; // 同时查询details

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

message DictionaryListResp {
  optional Pagination page = 1;
  repeated DictionaryInfo data = 2;
}

message DictionaryDetailReq {
  // 分页查询
  optional Pagination page = 1;

  int64 ID = 2;
  int64 dict_id = 3; // dictionary id
  string title = 4;
  string key = 5;
  string value = 6;

  bool with_dictionary = 7;
}

message DictionaryDetailListResp {
  optional Pagination page = 1;
  repeated DictionaryDetailInfo data = 2;
}

message DeleteDictionaryDetailReq {
  repeated int64 ids = 1;
  int64 dict_id = 2;
}

service Core {
  // Dictionary Management
  // group: dictionary
  rpc createDictionary (DictionaryInfo) returns (BaseIDResp);
  // group: dictionary
  rpc updateDictionary (DictionaryInfo) returns (BaseResp);
  // group: dictionary
  rpc getDictionaryList (DictionaryReq) returns (DictionaryListResp);
  // group: dictionary
  rpc getDictionary (DictionaryReq) returns (DictionaryInfo);
  // group: dictionary
  rpc deleteDictionary (IDsReq) returns (BaseResp);
  // Details
  // group: dictionary
  rpc createDictionaryDetail (DictionaryDetailInfo) returns (BaseIDResp);
  // group: dictionary
  rpc updateDictionaryDetail (DictionaryDetailInfo) returns (BaseResp);
  // group: dictionary
  rpc getDictionaryDetailList (DictionaryDetailReq) returns (DictionaryDetailListResp);
  // group: dictionary
  rpc getDictionaryDetail (DictionaryDetailReq) returns (DictionaryDetailInfo);
  // group: dictionary
  rpc deleteDictionaryDetail (DeleteDictionaryDetailReq) returns (BaseResp);
}