syntax = "proto3";

package live.resource.v1;

option go_package = "v1";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";


service titans {
    //获取team下某个keyword的配置 `internal:"true"`
    rpc get_config_by_keyword(GetConfigReq) returns (GetConfigResp);

    //设置team下某个keyword配置 `internal:"true"`
    rpc set_config_by_keyword(SetConfigReq) returns (SetConfigResp);

    //管理后台根据条件获取配置 `internal:"true"`
    rpc get_configs_by_params(ParamsConfigReq) returns (ParamsConfigResp);

    //获取discover_id对应的全部配置 `internal:"true"`
    rpc getByTreeId(TreeIdReq) returns (TreeIdResp);

    //获取多个team或索引的的全部配置 `internal:"true"`
    rpc get_configs_by_likes(LikesConfigReq) returns (LikesConfigResp);

}

message GetConfigReq {
    //team
    int64 team = 1 [(gogoproto.moretags) = 'form:"team"'];
    //索引名称
    string keyword = 2 [(gogoproto.moretags) = 'form:"keyword"'];
    //id
    int64 id = 3 [(gogoproto.moretags) = 'form:"id"'];
}

message GetConfigResp {
    //team
    int64 team = 1 [(gogoproto.jsontag) = "team"];
    //索引名称
    string keyword = 2 [(gogoproto.jsontag) = "keyword"];
    //配置值
    string value = 3 [(gogoproto.jsontag) = "value"];
    //配置解释
    string name = 4 [(gogoproto.jsontag) = "name"];
    //创建时间
    string ctime = 5 [(gogoproto.jsontag) = "ctime"];
    //最近更新时间
    string mtime = 6 [(gogoproto.jsontag) = "mtime"];
    //状态
    int64 status = 7 [(gogoproto.jsontag) = "status"];
    //状态
    int64 id = 8 [(gogoproto.jsontag) = "id"];
}

message SetConfigReq {
    //team
    int64 team = 1 [(gogoproto.moretags) = 'form:"team"'];
    //索引名称
    string keyword = 2 [(gogoproto.moretags) = 'form:"keyword" validate:"required"'];
    //配置值
    string value = 3 [(gogoproto.moretags) = 'form:"value" validate:"required"'];
    //配置解释
    string name = 4 [(gogoproto.moretags) = 'form:"name"'];
    //编辑时id
    int64 id = 5 [(gogoproto.moretags) = 'form:"id"'];
    //记录状态 新增时默认为0
    int64 status = 6 [(gogoproto.moretags) = 'form:"status"'];
}

message SetConfigResp {
    int64 id = 1 [(gogoproto.jsontag) = "id"];

}
message ParamsConfigReq{
    int64 team = 1 [(gogoproto.moretags) = 'form:"team"'];
    string keyword = 2 [(gogoproto.moretags) = 'form:"keyword"'];
    string name = 3 [(gogoproto.moretags) = 'form:"name"'];
    int64 status = 4 [(gogoproto.moretags) = 'form:"status"'];
    int64 page = 5 [(gogoproto.moretags) = 'form:"page" validate:"required"'];
    //页量
    int64 page_size = 6 [(gogoproto.moretags) = 'form:"page_size" validate:"required"'];
    //id
    int64 id = 7 [(gogoproto.moretags) = 'form:"id"'];
}
message ParamsConfigResp{
    //数据列表
    repeated List list = 1 [(gogoproto.jsontag) = "list"];
    //记录总数
    int64 total_num = 2 [(gogoproto.jsontag) = "total_num"];
}



message List {
    //Id
    int64 id = 1 [(gogoproto.jsontag) = "id"];
    //team
    int64 team = 2 [(gogoproto.jsontag) = "team"];
    //索引名称
    string keyword = 3 [(gogoproto.jsontag) = "keyword"];
    //配置值
    string value = 4 [(gogoproto.jsontag) = "value"];
    //配置解释
    string name = 5 [(gogoproto.jsontag) = "name"];
    //创建时间
    string ctime = 6 [(gogoproto.jsontag) = "ctime"];
    //最近更新时间
    string mtime = 7 [(gogoproto.jsontag) = "mtime"];
    //状态
    int64 status = 8 [(gogoproto.jsontag) = "status"];
}

message LikesConfigReq{
    repeated string params = 1 [(gogoproto.moretags) = 'form:"params" validate:"required"'];
}

message LikesConfigResp{
   map<int64, Child> list = 1 [(gogoproto.jsontag) = "list"];
}
message Child {
    map<string, string> keys = 1 [(gogoproto.jsontag) = "keys"];
}

message TreeIdReq{
    int64 tree_id = 1 [(gogoproto.moretags) = 'form:"tree_id" validate:"required"'];
}

message TreeIdResp{
    map<string, string> list = 1 [(gogoproto.jsontag) = "list"];
}