Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "v1_proto",
srcs = [
"api.proto",
"exp.proto",
"guard.proto",
"vip.proto",
],
tags = ["automanaged"],
deps = [
"//app/service/live/xuser/api/grpc:grpc_proto",
"@gogo_special_proto//github.com/gogo/protobuf/gogoproto",
],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/xuser/api/grpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = [
"//app/service/live/xuser/api/grpc:grpc_go_proto",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"api.bm.go",
"client.go",
"exp.bm.go",
"guard.bm.go",
"vip.bm.go",
],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/xuser/api/grpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/xuser/api/grpc:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//library/net/http/blademaster/binding:go_default_library",
"//library/net/rpc/warden:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,61 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "v1_proto",
srcs = ["api.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/xuser/api/grpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = [
"api.bm.go",
"client.go",
],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/xuser/api/grpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/http/blademaster:go_default_library",
"//library/net/rpc/warden:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,198 @@
// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: api/grpc/v1/api.proto
/*
Package v1 is a generated blademaster stub package.
This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
It is generated from these files:
api/grpc/v1/api.proto
*/
package v1
import (
"context"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
)
// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator
// ===================
// RoomAdmin Interface
// ===================
// History 相关服务
type RoomAdmin interface {
// 根据登录态获取功能入口是否显示, 需要登录态
IsAny(ctx context.Context, req *RoomAdminShowEntryReq) (resp *RoomAdminShowEntryResp, err error)
// 获取用户拥有的的所有房管身份
GetByUid(ctx context.Context, req *RoomAdminGetByUidReq) (resp *RoomAdminGetByUidResp, err error)
// 辞职房管
Resign(ctx context.Context, req *RoomAdminResignRoomAdminReq) (resp *RoomAdminResignRoomAdminResp, err error)
// 查询需要添加的房管
SearchForAdmin(ctx context.Context, req *RoomAdminSearchForAdminReq) (resp *RoomAdminSearchForAdminResp, err error)
// 获取主播拥有的的所有房管
GetByAnchor(ctx context.Context, req *RoomAdminGetByAnchorReq) (resp *RoomAdminGetByAnchorResp, err error)
// 获取主播拥有的的所有房管,房间号维度
GetByRoom(ctx context.Context, req *RoomAdminGetByRoomReq) (resp *RoomAdminGetByRoomResp, err error)
// 撤销房管
Dismiss(ctx context.Context, req *RoomAdminDismissAdminReq) (resp *RoomAdminDismissAdminResp, err error)
// 任命房管
Appoint(ctx context.Context, req *RoomAdminAddReq) (resp *RoomAdminAddResp, err error)
// 是否房管
IsAdmin(ctx context.Context, req *RoomAdminIsAdminReq) (resp *RoomAdminIsAdminResp, err error)
// 是否房管, 不额外返回用户信息, 不判断是否主播自己
IsAdminShort(ctx context.Context, req *RoomAdminIsAdminShortReq) (resp *RoomAdminIsAdminShortResp, err error)
}
var v1RoomAdminSvc RoomAdmin
// @params RoomAdminShowEntryReq
// @router GET /xlive/xuser/v1/roomAdmin/is_any
// @response RoomAdminShowEntryResp
func roomAdminIsAny(c *bm.Context) {
p := new(RoomAdminShowEntryReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.IsAny(c, p)
c.JSON(resp, err)
}
// @params RoomAdminGetByUidReq
// @router GET /xlive/xuser/v1/roomAdmin/get_by_uid
// @response RoomAdminGetByUidResp
func roomAdminGetByUid(c *bm.Context) {
p := new(RoomAdminGetByUidReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.GetByUid(c, p)
c.JSON(resp, err)
}
// @params RoomAdminResignRoomAdminReq
// @router GET /xlive/xuser/v1/roomAdmin/resign
// @response RoomAdminResignRoomAdminResp
func roomAdminResign(c *bm.Context) {
p := new(RoomAdminResignRoomAdminReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.Resign(c, p)
c.JSON(resp, err)
}
// @params RoomAdminSearchForAdminReq
// @router GET /xlive/xuser/v1/roomAdmin/search_for_admin
// @response RoomAdminSearchForAdminResp
func roomAdminSearchForAdmin(c *bm.Context) {
p := new(RoomAdminSearchForAdminReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.SearchForAdmin(c, p)
c.JSON(resp, err)
}
// @params RoomAdminGetByAnchorReq
// @router GET /xlive/xuser/v1/roomAdmin/get_by_anchor
// @response RoomAdminGetByAnchorResp
func roomAdminGetByAnchor(c *bm.Context) {
p := new(RoomAdminGetByAnchorReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.GetByAnchor(c, p)
c.JSON(resp, err)
}
// @params RoomAdminGetByRoomReq
// @router GET /xlive/xuser/v1/roomAdmin/get_by_room
// @response RoomAdminGetByRoomResp
func roomAdminGetByRoom(c *bm.Context) {
p := new(RoomAdminGetByRoomReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.GetByRoom(c, p)
c.JSON(resp, err)
}
// @params RoomAdminDismissAdminReq
// @router GET /xlive/xuser/v1/roomAdmin/dismiss
// @response RoomAdminDismissAdminResp
func roomAdminDismiss(c *bm.Context) {
p := new(RoomAdminDismissAdminReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.Dismiss(c, p)
c.JSON(resp, err)
}
// @params RoomAdminAddReq
// @router GET /xlive/xuser/v1/roomAdmin/appoint
// @response RoomAdminAddResp
func roomAdminAppoint(c *bm.Context) {
p := new(RoomAdminAddReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.Appoint(c, p)
c.JSON(resp, err)
}
// @params RoomAdminIsAdminReq
// @router GET /xlive/xuser/v1/roomAdmin/is_admin
// @response RoomAdminIsAdminResp
func roomAdminIsAdmin(c *bm.Context) {
p := new(RoomAdminIsAdminReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.IsAdmin(c, p)
c.JSON(resp, err)
}
// @params RoomAdminIsAdminShortReq
// @router GET /xlive/xuser/v1/roomAdmin/is_admin_short
// @response RoomAdminIsAdminShortResp
func roomAdminIsAdminShort(c *bm.Context) {
p := new(RoomAdminIsAdminShortReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1RoomAdminSvc.IsAdminShort(c, p)
c.JSON(resp, err)
}
// RegisterV1RoomAdminService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1RoomAdminService(e *bm.Engine, svc RoomAdmin, midMap map[string]bm.HandlerFunc) {
v1RoomAdminSvc = svc
e.GET("/xlive/xuser/v1/roomAdmin/is_any", roomAdminIsAny)
e.GET("/xlive/xuser/v1/roomAdmin/get_by_uid", roomAdminGetByUid)
e.GET("/xlive/xuser/v1/roomAdmin/resign", roomAdminResign)
e.GET("/xlive/xuser/v1/roomAdmin/search_for_admin", roomAdminSearchForAdmin)
e.GET("/xlive/xuser/v1/roomAdmin/get_by_anchor", roomAdminGetByAnchor)
e.GET("/xlive/xuser/v1/roomAdmin/get_by_room", roomAdminGetByRoom)
e.GET("/xlive/xuser/v1/roomAdmin/dismiss", roomAdminDismiss)
e.GET("/xlive/xuser/v1/roomAdmin/appoint", roomAdminAppoint)
e.GET("/xlive/xuser/v1/roomAdmin/is_admin", roomAdminIsAdmin)
e.GET("/xlive/xuser/v1/roomAdmin/is_admin_short", roomAdminIsAdminShort)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,250 @@
syntax = "proto3";
package live.xuser.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
// History 相关服务
service RoomAdmin {
// 根据登录态获取功能入口是否显示, 需要登录态
rpc is_any (RoomAdminShowEntryReq) returns (RoomAdminShowEntryResp);
// 获取用户拥有的的所有房管身份
rpc get_by_uid (RoomAdminGetByUidReq) returns (RoomAdminGetByUidResp);
// 辞职房管
rpc resign (RoomAdminResignRoomAdminReq) returns (RoomAdminResignRoomAdminResp);
// 查询需要添加的房管
rpc search_for_admin (RoomAdminSearchForAdminReq) returns (RoomAdminSearchForAdminResp);
// 获取主播拥有的的所有房管
rpc get_by_anchor (RoomAdminGetByAnchorReq) returns (RoomAdminGetByAnchorResp);
// 获取主播拥有的的所有房管,房间号维度
rpc get_by_room (RoomAdminGetByRoomReq) returns (RoomAdminGetByRoomResp);
// 撤销房管
rpc dismiss (RoomAdminDismissAdminReq) returns (RoomAdminDismissAdminResp);
// 任命房管
rpc appoint (RoomAdminAddReq) returns (RoomAdminAddResp);
// 是否房管
rpc is_admin (RoomAdminIsAdminReq) returns (RoomAdminIsAdminResp);
// 是否房管, 不额外返回用户信息, 不判断是否主播自己
rpc is_admin_short (RoomAdminIsAdminShortReq) returns (RoomAdminIsAdminShortResp);
}
// 历史记录请求参数定义
message RoomAdminShowEntryReq {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
}
// 获取接口返回响应
message RoomAdminShowEntryResp {
// 是否有房管
int64 has_admin = 1;
}
message RoomAdminSearchForAdminReq {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
string key_word = 2 [(gogoproto.moretags) = 'form:"key_word" validate:"required"'];
}
message RoomAdminSearchForAdminResp {
repeated Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 用户id
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 是否房管
int64 is_admin = 2 [(gogoproto.jsontag) = "is_admin"];
// 用户名
string uname = 4 [(gogoproto.jsontag) = "uname"];
// 用户头像
string face = 5 [(gogoproto.jsontag) = "face"];
// 粉丝勋章名称
string medal_name = 6 [(gogoproto.jsontag) = "medal_name"];
// 粉丝勋章等级
int64 level = 7 [(gogoproto.jsontag) = "level"];
}
}
message RoomAdminResignRoomAdminReq {
// 房间号
int64 roomid = 1 [(gogoproto.moretags) = 'form:"roomid" validate:"required"'];
// 用户uid
int64 uid = 2 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
}
message RoomAdminResignRoomAdminResp {
}
message RoomAdminGetByUidReq {
// 用户uid
int64 uid = 2 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
// 页数
int64 page = 1 [(gogoproto.moretags) = 'form:"page"'];
}
message RoomAdminGetByUidResp {
//
Page page = 1;
//
repeated Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 用户id
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 房间号
int64 roomid = 2 [(gogoproto.jsontag) = "roomid"];
// 主播的用户id
int64 anchor_id = 3 [(gogoproto.jsontag) = "anchor_id"];
// 主播用户名
string uname = 4 [(gogoproto.jsontag) = "uname"];
// 主播封面
string anchor_cover = 5 [(gogoproto.jsontag) = "anchor_cover"];
// 上任时间
string ctime = 6 [(gogoproto.jsontag) = "ctime"];
}
message Page {
// 当前页码
int64 page = 1;
// 每页大小
int64 page_size = 2;
// 总页数
int64 total_page = 3;
// 总记录数
int64 total_count = 4;
}
}
message RoomAdminGetByAnchorReq {
// 页数
int64 page = 1 [(gogoproto.moretags) = 'form:"page"'];
// 用户uid
int64 uid = 2 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
}
message RoomAdminGetByRoomReq {
// 房间号
int64 roomid = 1 [(gogoproto.moretags) = 'form:"roomid" validate:"required"'];
}
message RoomAdminGetByAnchorResp {
//
Page page = 1;
//
repeated Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 用户id
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 用户名
string uname = 4 [(gogoproto.jsontag) = "uname"];
// 用户头像
string face = 5 [(gogoproto.jsontag) = "face"];
// 上任时间
string ctime = 6 [(gogoproto.jsontag) = "ctime"];
// 粉丝勋章名称
string medal_name = 8 [(gogoproto.jsontag) = "medal_name"];
// 粉丝勋章等级
int64 level = 9 [(gogoproto.jsontag) = "level"];
// 房间号
int64 roomid = 10 [(gogoproto.jsontag) = "roomid"];
}
message Page {
// 当前页码
int64 page = 1;
// 每页大小
int64 page_size = 2;
// 总页数
int64 total_page = 3;
// 总记录数
int64 total_count = 4;
}
}
message RoomAdminDismissAdminReq {
// 房管的用户uid
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
// 主播uid
int64 anchor_id = 2 [(gogoproto.moretags) = 'form:"anchor_id" validate:"required"'];
}
message RoomAdminDismissAdminResp {
}
message RoomAdminAddReq {
// 房管的uid
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
// 主播uid
int64 anchor_id = 2 [(gogoproto.moretags) = 'form:"anchor_id" validate:"required"'];
}
message RoomAdminAddResp {
message UI {
// 用户id
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 用户名
string uname = 2 [(gogoproto.jsontag) = "uname"];
}
// banner
UI userinfo = 1 [(gogoproto.jsontag) = "userinfo"];
// 房管的用户id
int64 uid = 2 [(gogoproto.jsontag) = "uid"];
// 房间号
int64 roomid = 3 [(gogoproto.jsontag) = "roomid"];
}
message RoomAdminIsAdminShortReq {
// 房管的uid
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
// 房间号
int64 roomid = 3 [(gogoproto.moretags) = 'form:"roomid" validate:"required"'];
}
message RoomAdminIsAdminReq {
// 房管的uid
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"required"'];
// 主播uid
int64 anchor_id = 2 [(gogoproto.moretags) = 'form:"anchor_id" validate:"required"'];
// 房间号
int64 roomid = 3 [(gogoproto.moretags) = 'form:"roomid" validate:"required"'];
}
message RoomAdminIsAdminShortResp {
// 是否房管 0:不是,1:是
int64 result = 1 [(gogoproto.jsontag) = "result"];
}
message RoomAdminIsAdminResp {
message UI {
// 用户id
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 用户名
string uname = 2 [(gogoproto.jsontag) = "uname"];
}
// banner
UI userinfo = 1 [(gogoproto.jsontag) = "userinfo"];
// 房管的用户id
int64 uid = 2 [(gogoproto.jsontag) = "uid"];
// 房间号
int64 roomid = 3 [(gogoproto.jsontag) = "roomid"];
}
message RoomAdminGetByRoomResp {
repeated Data data = 1 [(gogoproto.jsontag) = "data"];
message Data {
// 上任时间
string ctime = 1 [(gogoproto.jsontag) = "ctime"];
// 房管的用户id
int64 uid = 2 [(gogoproto.jsontag) = "uid"];
// 房间号
int64 roomid = 3 [(gogoproto.jsontag) = "roomid"];
}
}

View File

@@ -0,0 +1,305 @@
## 根据登录态获取功能入口是否显示, 需要登录态
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/is_any`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
```json
{
"code": 0,
"message": "ok",
"data": {
// 是否有房管
"has_admin": 0
}
}
```
## 获取用户拥有的的所有房管身份
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/get_by_uid`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer| 用户uid|
|page|否|integer| 页数|
```json
{
"code": 0,
"message": "ok",
"data": {
"page": {
// 当前页码
"page": 0,
// 每页大小
"page_size": 0,
// 总页数
"total_page": 0,
// 总记录数
"total_count": 0
},
"data": [
{
// 用户id
"uid": 0,
// 房间号
"roomid": 0,
// 主播的用户id
"anchor_id": 0,
// 主播用户名
"uname": "",
// 主播封面
"anchor_cover": "",
// 上任时间
"ctime": ""
}
]
}
}
```
## 辞职房管
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/resign`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|roomid|是|integer| 房间号|
|uid|是|integer| 用户uid|
```json
{
"code": 0,
"message": "ok",
"data": {
}
}
```
## 查询需要添加的房管
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/search_for_admin`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
|key_word|是|string||
```json
{
"code": 0,
"message": "ok",
"data": {
"data": [
{
// 用户id
"uid": 0,
// 是否房管
"is_admin": 0,
// 用户名
"uname": "",
// 用户头像
"face": "",
// 粉丝勋章名称
"medal_name": "",
// 粉丝勋章等级
"level": 0
}
]
}
}
```
## 获取主播拥有的的所有房管
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/get_by_anchor`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|page|否|integer| 页数|
|uid|是|integer| 用户uid|
```json
{
"code": 0,
"message": "ok",
"data": {
"page": {
// 当前页码
"page": 0,
// 每页大小
"page_size": 0,
// 总页数
"total_page": 0,
// 总记录数
"total_count": 0
},
"data": [
{
// 用户id
"uid": 0,
// 用户名
"uname": "",
// 用户头像
"face": "",
// 上任时间
"ctime": "",
// 粉丝勋章名称
"medal_name": "",
// 粉丝勋章等级
"level": 0,
// 房间号
"roomid": 0
}
]
}
}
```
## 获取主播拥有的的所有房管,房间号维度
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/get_by_room`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|roomid|是|integer| 房间号|
```json
{
"code": 0,
"message": "ok",
"data": {
"data": [
{
// 上任时间
"ctime": "",
// 房管的用户id
"uid": 0,
// 房间号
"roomid": 0
}
]
}
}
```
## 撤销房管
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/dismiss`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer| 房管的用户uid|
|anchor_id|是|integer| 主播uid|
```json
{
"code": 0,
"message": "ok",
"data": {
}
}
```
## 任命房管
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/appoint`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer| 房管的uid|
|anchor_id|是|integer| 主播uid|
```json
{
"code": 0,
"message": "ok",
"data": {
// banner
"userinfo": {
// 用户id
"uid": 0,
// 用户名
"uname": ""
},
// 房管的用户id
"uid": 0,
// 房间号
"roomid": 0
}
}
```
## 是否房管
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/is_admin`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer| 房管的uid|
|anchor_id|是|integer| 主播uid|
|roomid|是|integer| 房间号|
```json
{
"code": 0,
"message": "ok",
"data": {
// banner
"userinfo": {
// 用户id
"uid": 0,
// 用户名
"uname": ""
},
// 房管的用户id
"uid": 0,
// 房间号
"roomid": 0
}
}
```
## 是否房管, 不额外返回用户信息, 不判断是否主播自己
`GET http://api.live.bilibili.com/xlive/xuser/v1/roomAdmin/is_admin_short`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer| 房管的uid|
|roomid|是|integer| 房间号|
```json
{
"code": 0,
"message": "ok",
"data": {
// 是否房管 0:不是,1:是
"result": 0
}
}
```

View File

@@ -0,0 +1,45 @@
package v1
import (
"context"
"go-common/library/net/rpc/warden"
"google.golang.org/grpc"
)
// AppID unique app id for service discovery
const AppID = "live.xuser"
// Client client
type Client struct {
UserExpClient
VipClient
GuardClient
}
// NewXuserRoomAdminClient new member grpc client
func NewXuserRoomAdminClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (RoomAdminClient, error) {
client := warden.NewClient(cfg, opts...)
conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
//conn, err := client.Dial(context.Background(), "127.0.0.1:9000")
if err != nil {
return nil, err
}
return NewRoomAdminClient(conn), nil
}
// NewClient new resource gRPC client
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
client := warden.NewClient(cfg, opts...)
conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
if err != nil {
return nil, err
}
cli := &Client{}
cli.UserExpClient = NewUserExpClient(conn)
cli.GuardClient = NewGuardClient(conn)
cli.VipClient = NewVipClient(conn)
return cli, nil
}

View File

@@ -0,0 +1,70 @@
// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: api/grpc/v1/exp.proto
/*
Package v1 is a generated blademaster stub package.
This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
It is generated from these files:
api/grpc/v1/exp.proto
*/
package v1
import (
"context"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
)
// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator
// =================
// UserExp Interface
// =================
// UserExp 相关服务
type UserExp interface {
// GetUserExpMulti 获取用户经验与等级信息,支持批量
GetUserExp(ctx context.Context, req *GetUserExpReq) (resp *GetUserExpResp, err error)
// AddUserExp 增加用户经验,不支持批量
AddUserExp(ctx context.Context, req *AddUserExpReq) (resp *AddUserExpResp, err error)
}
var v1UserExpSvc UserExp
// @params GetUserExpReq
// @router GET /xlive/xuser/v1/userExp/GetUserExp
// @response GetUserExpResp
func userExpGetUserExp(c *bm.Context) {
p := new(GetUserExpReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1UserExpSvc.GetUserExp(c, p)
c.JSON(resp, err)
}
// @params AddUserExpReq
// @router GET /xlive/xuser/v1/userExp/AddUserExp
// @response AddUserExpResp
func userExpAddUserExp(c *bm.Context) {
p := new(AddUserExpReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1UserExpSvc.AddUserExp(c, p)
c.JSON(resp, err)
}
// RegisterV1UserExpService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1UserExpService(e *bm.Engine, svc UserExp, midMap map[string]bm.HandlerFunc) {
v1UserExpSvc = svc
e.GET("/xlive/xuser/v1/userExp/GetUserExp", userExpGetUserExp)
e.GET("/xlive/xuser/v1/userExp/AddUserExp", userExpAddUserExp)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,92 @@
syntax = "proto3";
package live.xuser.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
// UserExp 相关服务
service UserExp {
// GetUserExpMulti 获取用户经验与等级信息,支持批量
rpc GetUserExp(GetUserExpReq) returns (GetUserExpResp);
// AddUserExp 增加用户经验,不支持批量
rpc AddUserExp(AddUserExpReq) returns (AddUserExpResp);
}
message AddUserExpReq {
UserExpChunk userInfo = 1 [(gogoproto.moretags) = 'form:"userInfo" validate:"required"'];
}
message UserExpChunk {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
int64 req_biz = 2 [(gogoproto.moretags) = 'form:"req_biz" validate:"required"'];
int64 type = 3 [(gogoproto.moretags) = 'form:"type" validate:"gt=0,required"'];
int64 num = 4 [(gogoproto.moretags) = 'form:"num" validate:"gt=0,required"'];
}
message AddUserExpResp{
}
// GetUserExpReq 请求
message GetUserExpReq {
repeated int64 uids = 1 [(gogoproto.moretags) = 'form:"uids" validate:"gt=0,required"'];
}
// GetUserExpResp 响应
message GetUserExpResp {
map<int64, LevelInfo> data = 1 [(gogoproto.jsontag) = "data"];
}
message LevelInfo {
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
UserLevelInfo userLevel = 2 [(gogoproto.jsontag) = "userLevel"];
AnchorLevelInfo anchorLevel = 3 [(gogoproto.jsontag) = "anchorLevel"];
}
message UserLevelInfo {
// 当前用户等级
int64 level = 1 [(gogoproto.jsontag) = "level"];
// 下一等级
int64 nextLevel = 2 [(gogoproto.jsontag) = "nextLevel"];
// 当前等级对应的经验
int64 userExpLeft = 3 [(gogoproto.jsontag) = "userExpLeft"];
// 下一等级对应的经验
int64 userExpRight = 4 [(gogoproto.jsontag) = "userExpRight"];
// 用户当前经验
int64 userExp = 5 [(gogoproto.jsontag) = "userExp"];
// 升级到下一等级对应的经验
int64 userExpNextLevel = 6 [(gogoproto.jsontag) = "userExpNextLevel"];
// 当前等级颜色
int64 color = 7 [(gogoproto.jsontag) = "color"];
// 下一等级左侧对应的经验
int64 userExpNextLeft = 8 [(gogoproto.jsontag) = "userExpNextLeft"];
// 下一等级右侧对应的经验
int64 userExpNextRight = 9 [(gogoproto.jsontag) = "userExpNextRight"];
int64 isLevelTop = 10 [(gogoproto.jsontag) = "isLevelTop"];
}
message AnchorLevelInfo {
// 当前用户等级
int64 level = 1 [(gogoproto.jsontag) = "level"];
// 下一等级
int64 nextLevel = 2 [(gogoproto.jsontag) = "nextLevel"];
// 当前等级对应的经验
int64 userExpLeft = 3 [(gogoproto.jsontag) = "userExpLeft"];
// 下一等级对应的经验
int64 userExpRight = 4 [(gogoproto.jsontag) = "userExpRight"];
// 用户当前经验
int64 userExp = 5 [(gogoproto.jsontag) = "userExp"];
// 升级到下一等级对应的经验
int64 userExpNextLevel = 6 [(gogoproto.jsontag) = "userExpNextLevel"];
// 当前等级颜色
int64 color = 7 [(gogoproto.jsontag) = "color"];
// 下一等级左侧对应的经验
int64 userExpNextLeft = 8 [(gogoproto.jsontag) = "userExpNextLeft"];
// 下一等级右侧对应的经验
int64 userExpNextRight = 9 [(gogoproto.jsontag) = "userExpNextRight"];
// 主播积分,userExp/100
int64 anchorScore = 10 [(gogoproto.jsontag) = "anchorScore"];
int64 isLevelTop = 11 [(gogoproto.jsontag) = "isLevelTop"];
}

View File

@@ -0,0 +1,94 @@
## GetUserExpMulti 获取用户经验与等级信息,支持批量
`GET http://api.live.bilibili.com/xlive/xuser/v1/userExp/GetUserExp`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uids|是|多个integer||
```json
{
"code": 0,
"message": "ok",
"data": {
"data": {
"1": {
"uid": 0,
"userLevel": {
// 当前用户等级
"level": 0,
// 下一等级
"nextLevel": 0,
// 当前等级对应的经验
"userExpLeft": 0,
// 下一等级对应的经验
"userExpRight": 0,
// 用户当前经验
"userExp": 0,
// 升级到下一等级对应的经验
"userExpNextLevel": 0,
// 当前等级颜色
"color": 0,
// 下一等级左侧对应的经验
"userExpNextLeft": 0,
// 下一等级右侧对应的经验
"userExpNextRight": 0,
"isLevelTop": 0
},
"anchorLevel": {
// 当前用户等级
"level": 0,
// 下一等级
"nextLevel": 0,
// 当前等级对应的经验
"userExpLeft": 0,
// 下一等级对应的经验
"userExpRight": 0,
// 用户当前经验
"userExp": 0,
// 升级到下一等级对应的经验
"userExpNextLevel": 0,
// 当前等级颜色
"color": 0,
// 下一等级左侧对应的经验
"userExpNextLeft": 0,
// 下一等级右侧对应的经验
"userExpNextRight": 0,
// 主播积分,userExp/100
"anchorScore": 0,
"isLevelTop": 0
}
}
}
}
}
```
## AddUserExp 增加用户经验,不支持批量
`GET http://api.live.bilibili.com/xlive/xuser/v1/userExp/AddUserExp`
### 请求参数
```json
{
"userInfo": {
"uid": 0,
"req_biz": 0,
"type": 0,
"num": 0
}
}
```
```json
{
"code": 0,
"message": "ok",
"data": {
}
}
```

View File

@@ -0,0 +1,177 @@
// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: guard.proto
/*
Package v1 is a generated blademaster stub package.
This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
It is generated from these files:
guard.proto
*/
package v1
import (
"context"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
)
// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator
var PathGuardBuy = "/live.xuser.v1.Guard/Buy"
var PathGuardGetByUIDTargetID = "/live.xuser.v1.Guard/GetByUIDTargetID"
var PathGuardGetByTargetIdsBatch = "/live.xuser.v1.Guard/GetByTargetIdsBatch"
var PathGuardGetByUIDTargetIds = "/live.xuser.v1.Guard/GetByUIDTargetIds"
var PathGuardGetByUIDForGift = "/live.xuser.v1.Guard/GetByUIDForGift"
var PathGuardGetByUIDBatch = "/live.xuser.v1.Guard/GetByUIDBatch"
var PathGuardGetAnchorRecentTopGuard = "/live.xuser.v1.Guard/GetAnchorRecentTopGuard"
var PathGuardGetTopListGuard = "/live.xuser.v1.Guard/GetTopListGuard"
var PathGuardGetTopListGuardNum = "/live.xuser.v1.Guard/GetTopListGuardNum"
var PathGuardClearUIDCache = "/live.xuser.v1.Guard/ClearUIDCache"
// ===============
// Guard Interface
// ===============
type GuardBMServer interface {
// Buy 购买大航海
Buy(ctx context.Context, req *GuardBuyReq) (resp *GuardBuyReply, err error)
// GetByUIDTargetID 获取我与目标用户守护关系,不支持批量(P0级)
GetByUIDTargetID(ctx context.Context, req *GetByUidTargetIdReq) (resp *GetByUidTargetIdResp, err error)
// GetByTargetIdsBatch 获取我与目标用户守护关系,支持批量(P2级,必要时刻降级)
GetByTargetIdsBatch(ctx context.Context, req *GetByTargetIdsReq) (resp *GetByTargetIdsResp, err error)
// GetByUIDTargetIds 根据uids批量获取所有守护关系,粉丝勋章使用
GetByUIDTargetIds(ctx context.Context, req *GetByUidTargetIdsReq) (resp *GetByUidTargetIdsResp, err error)
// GetByUID 获取我所有的守护,不支持批量(P0级)
GetByUIDForGift(ctx context.Context, req *GetByUidReq) (resp *GetByUidResp, err error)
// GetByUIDBatch 根据uids获取所有的守护,支持批量(P2级)
GetByUIDBatch(ctx context.Context, req *GetByUidBatchReq) (resp *GetByUidBatchResp, err error)
// GetAnchorRecentTopGuard 获取最近的提督弹窗提醒
GetAnchorRecentTopGuard(ctx context.Context, req *GetAnchorRecentTopGuardReq) (resp *GetAnchorRecentTopGuardResp, err error)
// GetTopListGuard 获取某个up主的守护排行榜
GetTopListGuard(ctx context.Context, req *GetTopListGuardReq) (resp *GetTopListGuardResp, err error)
// GetTopListGuardNum 获取某个up主所有的守护数量,和GetTopListGuard接口的区别是此接口用于房间页首屏,逻辑比较简单,因此拆分开来
GetTopListGuardNum(ctx context.Context, req *GetTopListGuardNumReq) (resp *GetTopListGuardNumResp, err error)
// ClearUIDCache 清除cache
ClearUIDCache(ctx context.Context, req *ClearUIDCacheReq) (resp *ClearUIDCacheResp, err error)
}
var v1GuardSvc GuardBMServer
func guardBuy(c *bm.Context) {
p := new(GuardBuyReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.Buy(c, p)
c.JSON(resp, err)
}
func guardGetByUIDTargetID(c *bm.Context) {
p := new(GetByUidTargetIdReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetByUIDTargetID(c, p)
c.JSON(resp, err)
}
func guardGetByTargetIdsBatch(c *bm.Context) {
p := new(GetByTargetIdsReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetByTargetIdsBatch(c, p)
c.JSON(resp, err)
}
func guardGetByUIDTargetIds(c *bm.Context) {
p := new(GetByUidTargetIdsReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetByUIDTargetIds(c, p)
c.JSON(resp, err)
}
func guardGetByUIDForGift(c *bm.Context) {
p := new(GetByUidReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetByUIDForGift(c, p)
c.JSON(resp, err)
}
func guardGetByUIDBatch(c *bm.Context) {
p := new(GetByUidBatchReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetByUIDBatch(c, p)
c.JSON(resp, err)
}
func guardGetAnchorRecentTopGuard(c *bm.Context) {
p := new(GetAnchorRecentTopGuardReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetAnchorRecentTopGuard(c, p)
c.JSON(resp, err)
}
func guardGetTopListGuard(c *bm.Context) {
p := new(GetTopListGuardReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetTopListGuard(c, p)
c.JSON(resp, err)
}
func guardGetTopListGuardNum(c *bm.Context) {
p := new(GetTopListGuardNumReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.GetTopListGuardNum(c, p)
c.JSON(resp, err)
}
func guardClearUIDCache(c *bm.Context) {
p := new(ClearUIDCacheReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1GuardSvc.ClearUIDCache(c, p)
c.JSON(resp, err)
}
// RegisterGuardBMServer Register the blademaster route
func RegisterGuardBMServer(e *bm.Engine, server GuardBMServer) {
v1GuardSvc = server
e.GET("/live.xuser.v1.Guard/Buy", guardBuy)
e.GET("/live.xuser.v1.Guard/GetByUIDTargetID", guardGetByUIDTargetID)
e.GET("/live.xuser.v1.Guard/GetByTargetIdsBatch", guardGetByTargetIdsBatch)
e.GET("/live.xuser.v1.Guard/GetByUIDTargetIds", guardGetByUIDTargetIds)
e.GET("/live.xuser.v1.Guard/GetByUIDForGift", guardGetByUIDForGift)
e.GET("/live.xuser.v1.Guard/GetByUIDBatch", guardGetByUIDBatch)
e.GET("/live.xuser.v1.Guard/GetAnchorRecentTopGuard", guardGetAnchorRecentTopGuard)
e.GET("/live.xuser.v1.Guard/GetTopListGuard", guardGetTopListGuard)
e.GET("/live.xuser.v1.Guard/GetTopListGuardNum", guardGetTopListGuardNum)
e.GET("/live.xuser.v1.Guard/ClearUIDCache", guardClearUIDCache)
}

View File

@@ -0,0 +1,382 @@
<!-- package=live.xuser.v1 -->
- [/live.xuser.v1.Guard/Buy](#live.xuser.v1.GuardBuy) Buy 购买大航海
- [/live.xuser.v1.Guard/GetByUIDTargetID](#live.xuser.v1.GuardGetByUIDTargetID) GetByUIDTargetID 获取我与目标用户守护关系,不支持批量(P0级)
- [/live.xuser.v1.Guard/GetByTargetIdsBatch](#live.xuser.v1.GuardGetByTargetIdsBatch) GetByTargetIdsBatch 获取我与目标用户守护关系,支持批量(P2级,必要时刻降级)
- [/live.xuser.v1.Guard/GetByUIDTargetIds](#live.xuser.v1.GuardGetByUIDTargetIds) GetByUIDTargetIds 根据uids批量获取所有守护关系,粉丝勋章使用
- [/live.xuser.v1.Guard/GetByUIDForGift](#live.xuser.v1.GuardGetByUIDForGift) GetByUID 获取我所有的守护,不支持批量(P0级)
- [/live.xuser.v1.Guard/GetByUIDBatch](#live.xuser.v1.GuardGetByUIDBatch) GetByUIDBatch 根据uids获取所有的守护,支持批量(P2级)
- [/live.xuser.v1.Guard/GetAnchorRecentTopGuard](#live.xuser.v1.GuardGetAnchorRecentTopGuard) GetAnchorRecentTopGuard 获取最近的提督弹窗提醒
- [/live.xuser.v1.Guard/GetTopListGuard](#live.xuser.v1.GuardGetTopListGuard) GetTopListGuard 获取某个up主的守护排行榜
- [/live.xuser.v1.Guard/GetTopListGuardNum](#live.xuser.v1.GuardGetTopListGuardNum) GetTopListGuardNum 获取某个up主所有的守护数量,和GetTopListGuard接口的区别是此接口用于房间页首屏,逻辑比较简单,因此拆分开来
- [/live.xuser.v1.Guard/ClearUIDCache](#live.xuser.v1.GuardClearUIDCache) ClearUIDCache 清除cache
## /live.xuser.v1.Guard/Buy
### Buy 购买大航海
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|order_id|是|string||
|uid|是|integer||
|ruid|是|integer||
|guard_level|是|integer||
|num|是|integer||
|platform|是|integer||
|source|是|string||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
"status": 0
}
}
```
## /live.xuser.v1.Guard/GetByUIDTargetID
### GetByUIDTargetID 获取我与目标用户守护关系,不支持批量(P0级)
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
|target_id|是|integer||
|sort_type|否|integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
"data": {
"1": {
// 主键
"id": 0,
// uid
"uid": 0,
// target_id
"target_id": 0,
// 守护类型 1为总督2为提督3为舰长
"privilege_type": 0,
// start_time
"start_time": "",
// expired_time
"expired_time": "",
// ctime
"ctime": "",
// utime
"utime": ""
}
}
}
}
```
## /live.xuser.v1.Guard/GetByTargetIdsBatch
### GetByTargetIdsBatch 获取我与目标用户守护关系,支持批量(P2级,必要时刻降级)
#### 方法GET
#### 请求参数
```javascript
{
"targetIDs": [
{
"target_id": 0,
"sort_type": 0
}
]
}
```
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
}
}
```
## /live.xuser.v1.Guard/GetByUIDTargetIds
### GetByUIDTargetIds 根据uids批量获取所有守护关系,粉丝勋章使用
#### 方法GET
#### 请求参数
```javascript
{
"uid": 0,
"targetIDs": [
{
"target_id": 0,
"sort_type": 0
}
]
}
```
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
"data": {
"1": {
// 主键
"id": 0,
// uid
"uid": 0,
// target_id
"target_id": 0,
// 守护类型 1为总督2为提督3为舰长
"privilege_type": 0,
// start_time
"start_time": "",
// expired_time
"expired_time": "",
// ctime
"ctime": "",
// utime
"utime": ""
}
}
}
}
```
## /live.xuser.v1.Guard/GetByUIDForGift
### GetByUID 获取我所有的守护,不支持批量(P0级)
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
"data": {
"1": {
// 主键
"id": 0,
// uid
"uid": 0,
// target_id
"target_id": 0,
// 守护类型 1为总督2为提督3为舰长
"privilege_type": 0,
// start_time
"start_time": "",
// expired_time
"expired_time": "",
// ctime
"ctime": "",
// utime
"utime": ""
}
}
}
}
```
## /live.xuser.v1.Guard/GetByUIDBatch
### GetByUIDBatch 根据uids获取所有的守护,支持批量(P2级)
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uids|是|多个integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
"data": {
"1": {
"list": [
{
// 主键
"id": 0,
// uid
"uid": 0,
// target_id
"target_id": 0,
// 守护类型 1为总督2为提督3为舰长
"privilege_type": 0,
// start_time
"start_time": "",
// expired_time
"expired_time": "",
// ctime
"ctime": "",
// utime
"utime": ""
}
]
}
}
}
}
```
## /live.xuser.v1.Guard/GetAnchorRecentTopGuard
### GetAnchorRecentTopGuard 获取最近的提督弹窗提醒
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 主键
"cnt": 0,
"list": [
{
"uid": 0,
"end_time": 0,
"is_open": 0
}
]
}
}
```
## /live.xuser.v1.Guard/GetTopListGuard
### GetTopListGuard 获取某个up主的守护排行榜
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
|page|否|integer||
|page_size|否|integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 守护总数量
"num": 0,
"page": 0,
"now": 0,
"list": [
{
"uid": 0,
"ruid": 0,
"rank": 0,
"guard_level": 0
}
],
"top3": [
{
"uid": 0,
"ruid": 0,
"rank": 0,
"guard_level": 0
}
]
}
}
```
## /live.xuser.v1.Guard/GetTopListGuardNum
### GetTopListGuardNum 获取某个up主所有的守护数量,和GetTopListGuard接口的区别是此接口用于房间页首屏,逻辑比较简单,因此拆分开来
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
"total_count": 0
}
}
```
## /live.xuser.v1.Guard/ClearUIDCache
### ClearUIDCache 清除cache
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
|magic_key|是|string||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
}
}
```

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,204 @@
syntax = "proto3";
package live.xuser.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "app/service/live/xuser/api/grpc/xuser.proto";
message GuardBuyReq {
string order_id = 1 [(gogoproto.moretags) = "validate:\"required\""];
int64 uid = 2 [(gogoproto.moretags) = "validate:\"gt=0,required\""];
int64 ruid = 3 [(gogoproto.moretags) = "validate:\"gt=0,required\""];
int32 guard_level = 4 [(gogoproto.moretags) = "validate:\"gt=0,required\"", (gogoproto.casttype) = "int"];
int32 num = 5 [(gogoproto.moretags) = "validate:\"gt=0,required\"", (gogoproto.casttype) = "int"];
Platform platform = 6 [(gogoproto.moretags) = "validate:\"required\""];
string source = 7 [(gogoproto.moretags) = "validate:\"required\""];
}
message GuardBuyReply {
int32 status = 1 [(gogoproto.jsontag) = "status", (gogoproto.casttype) = "int"];
}
// GetByUidTargetIdReq 1:1请求
message ClearUIDCacheReq {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
string magic_key = 2 [(gogoproto.moretags) = 'form:"magic_key" validate:"alpha,required"'];
}
message ClearUIDCacheResp {
}
// GetByUidTargetIdReq 1:1请求
message GetByUidTargetIdReq {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
int64 target_id = 2 [(gogoproto.moretags) = 'form:"target_id" validate:"required"'];
int64 sort_type = 3 [(gogoproto.moretags) = 'form:"sort_type" validate:"gte=0"'];
}
message GetByUidTargetIdResp {
map<int64, DaHangHaiInfo> data = 1 [(gogoproto.jsontag) = "data"];
}
message AllDaHangHaiInfo {
map<int64,DaHangHaiInfo> guardInfo = 1 [(gogoproto.moretags) = 'validate:"required"'];
}
message FilterDaHangHaiInfo {
map<int64,DaHangHaiInfo> guardInfo = 1 [(gogoproto.moretags) = 'validate:"required"'];
}
message DaHangHaiInfo {
// 主键
int64 id = 1 [(gogoproto.jsontag) = "id"];
// uid
int64 uid = 2 [(gogoproto.jsontag) = "uid"];
// target_id
int64 target_id = 3 [(gogoproto.jsontag) = "target_id"];
// 守护类型 1为总督2为提督3为舰长
int64 privilege_type = 4 [(gogoproto.jsontag) = "privilege_type"];
// start_time
string start_time = 5 [(gogoproto.jsontag) = "start_time"];
// expired_time
string expired_time = 6 [(gogoproto.jsontag) = "expired_time"];
// ctime
string ctime = 7 [(gogoproto.jsontag) = "ctime"];
// utime
string utime = 8 [(gogoproto.jsontag) = "utime"];
}
message DaHangHaiInfoList {
repeated DaHangHaiInfo list = 1 [(gogoproto.jsontag) = "list"];
}
message GetByUidTargetIdsReq {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
repeated TargetIds targetIDs = 2 [(gogoproto.moretags) = 'form:"targetIDs" validate:"required"'];
}
message GetByUidTargetIdsResp {
map<int64, DaHangHaiInfo> data = 1 [(gogoproto.jsontag) = "data"];
}
message TargetIds {
int64 target_id = 1 [(gogoproto.moretags) = 'form:"target_id" validate:"gt=0,required"'];
int64 sort_type = 2 [(gogoproto.moretags) = 'form:"sort_type" validate:"gt=0"'];
}
// GetByTargetIdsBatchReq 根据uids批量获取所有守护关系
message GetByTargetIdsReq {
repeated TargetIds targetIDs = 1 [(gogoproto.moretags) = 'form:"targetIDs" validate:"required"'];
}
// TODO 实现
message GetByTargetIdsResp {
}
// GetAllShouHuReq 目标全部守护数据
message GetByUidReq {
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
}
message GetByUidResp {
map<int64, DaHangHaiInfo> data = 1 [(gogoproto.jsontag) = "data"];
}
// GetAllShouHuBatchReq 目标全部守护数据(批量)
message GetByUidBatchReq {
repeated int64 uids = 1 [(gogoproto.moretags) = 'form:"uids" validate:"required"'];
}
message GetByUidBatchResp {
map<int64, DaHangHaiInfoList> data = 1 [(gogoproto.jsontag) = "data"];
}
message GetAnchorRecentTopGuardReq{
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
}
message GetAnchorRecentTopGuardResp{
// 主键
int64 cnt = 1 [(gogoproto.jsontag) = "cnt"];
repeated GetAnchorRecentTopGuardList list = 2 [(gogoproto.jsontag) = "list"];
}
message GetAnchorRecentTopGuardList{
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
int64 end_time = 2 [(gogoproto.jsontag) = "end_time"];
int64 is_open = 3 [(gogoproto.jsontag) = "is_open"];
}
message GetTopListGuardReq{
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
int64 page = 2 [(gogoproto.moretags) = 'form:"page" validate:"gte=1"'];
int64 page_size = 3 [(gogoproto.moretags) = 'form:"page_size" validate:"gte=1"'];
}
message GetTopListGuardResp{
// 守护总数量
int64 num = 1 [(gogoproto.jsontag) = "num"];
int64 page = 2 [(gogoproto.jsontag) = "page"];
int64 now = 3 [(gogoproto.jsontag) = "now"];
repeated TopListGuard list = 4[(gogoproto.jsontag) = "list"];
repeated TopListGuard top3 = 5[(gogoproto.jsontag) = "top3"];
}
message TopListGuard{
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
int64 ruid = 2 [(gogoproto.jsontag) = "ruid"];
int64 rank = 4 [(gogoproto.jsontag) = "rank"];
int64 guard_level = 3 [(gogoproto.jsontag) = "guard_level"];
}
message GetTopListGuardNumReq{
int64 uid = 1 [(gogoproto.moretags) = 'form:"uid" validate:"gt=0,required"'];
}
message GetTopListGuardNumResp{
int64 total_count = 1 [(gogoproto.jsontag) = "total_count"];
}
service Guard {
// Buy 购买大航海
rpc Buy(GuardBuyReq) returns (GuardBuyReply);
// GetByUIDTargetID 获取我与目标用户守护关系,不支持批量(P0级)
rpc GetByUIDTargetID (GetByUidTargetIdReq) returns (GetByUidTargetIdResp);
// GetByTargetIdsBatch 获取我与目标用户守护关系,支持批量(P2级,必要时刻降级)
rpc GetByTargetIdsBatch (GetByTargetIdsReq) returns (GetByTargetIdsResp);
// GetByUIDTargetIds 根据uids批量获取所有守护关系,粉丝勋章使用
rpc GetByUIDTargetIds (GetByUidTargetIdsReq) returns (GetByUidTargetIdsResp);
// GetByUID 获取我所有的守护,不支持批量(P0级)
rpc GetByUIDForGift (GetByUidReq) returns (GetByUidResp);
// GetByUIDBatch 根据uids获取所有的守护,支持批量(P2级)
rpc GetByUIDBatch (GetByUidBatchReq) returns (GetByUidBatchResp);
// GetAnchorRecentTopGuard 获取最近的提督弹窗提醒
rpc GetAnchorRecentTopGuard (GetAnchorRecentTopGuardReq) returns (GetAnchorRecentTopGuardResp);
// GetTopListGuard 获取某个up主的守护排行榜
rpc GetTopListGuard (GetTopListGuardReq) returns (GetTopListGuardResp);
// GetTopListGuardNum 获取某个up主所有的守护数量,和GetTopListGuard接口的区别是此接口用于房间页首屏,逻辑比较简单,因此拆分开来
rpc GetTopListGuardNum (GetTopListGuardNumReq) returns (GetTopListGuardNumResp);
// ClearUIDCache 清除cache
rpc ClearUIDCache (ClearUIDCacheReq) returns (ClearUIDCacheResp);
}

View File

@@ -0,0 +1,69 @@
// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: api/grpc/v1/vip.proto
/*
Package v1 is a generated blademaster stub package.
This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
It is generated from these files:
api/grpc/v1/vip.proto
*/
package v1
import (
"context"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
)
// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator
// =============
// Vip Interface
// =============
type Vip interface {
// Info 返回用户vip信息
Info(ctx context.Context, req *UidReq) (resp *InfoReply, err error)
// Buy 购买月费/年费姥爷
Buy(ctx context.Context, req *BuyReq) (resp *BuyReply, err error)
}
var v1VipSvc Vip
// @params UidReq
// @router GET /xlive/xuser/v1/vip/Info
// @response InfoReply
func vipInfo(c *bm.Context) {
p := new(UidReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1VipSvc.Info(c, p)
c.JSON(resp, err)
}
// @params BuyReq
// @router GET /xlive/xuser/v1/vip/Buy
// @response BuyReply
func vipBuy(c *bm.Context) {
p := new(BuyReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1VipSvc.Buy(c, p)
c.JSON(resp, err)
}
// RegisterV1VipService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1VipService(e *bm.Engine, svc Vip, midMap map[string]bm.HandlerFunc) {
v1VipSvc = svc
e.GET("/xlive/xuser/v1/vip/Info", vipInfo)
e.GET("/xlive/xuser/v1/vip/Buy", vipBuy)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
syntax = "proto3";
package live.xuser.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "app/service/live/xuser/api/grpc/xuser.proto";
message UidReq {
int64 uid = 1 [(gogoproto.moretags) = "validate:\"gt=0,required\""];
}
message Info {
int32 vip = 1 [(gogoproto.jsontag) = "vip", (gogoproto.casttype) = "int"];
int32 svip = 2 [(gogoproto.jsontag) = "svip", (gogoproto.casttype) = "int"];
string vip_time = 3 [(gogoproto.jsontag) = "vip_time"];
string svip_time = 4 [(gogoproto.jsontag) = "svip_time"];
}
message InfoReply {
Info info = 1;
}
message BuyReq {
string order_id = 1 [(gogoproto.moretags) = "validate:\"required\""];
int64 uid = 2 [(gogoproto.moretags) = "validate:\"gt=0,required\""];
int32 good_id = 3 [(gogoproto.moretags) = "validate:\"gt=0,required\"", (gogoproto.casttype) = "int"];
int32 good_num = 4 [(gogoproto.moretags) = "validate:\"gt=0,required\"", (gogoproto.casttype) = "int"];
Platform platform = 5 [(gogoproto.moretags) = "validate:\"required\""];
string source = 6 [(gogoproto.moretags) = "validate:\"required\""];
}
message BuyReply {
int32 status = 1 [(gogoproto.jsontag) = "status", (gogoproto.casttype) = "int"];
}
service Vip {
// Info 返回用户vip信息
rpc Info(UidReq) returns (InfoReply);
// Buy 购买月费/年费姥爷
rpc Buy(BuyReq) returns (BuyReply);
}

View File

@@ -0,0 +1,50 @@
## Info 返回用户vip信息
`GET http://api.live.bilibili.com/xlive/xuser/v1/vip/Info`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|是|integer||
```json
{
"code": 0,
"message": "ok",
"data": {
"info": {
"vip": 0,
"svip": 0,
"vip_time": "",
"svip_time": ""
}
}
}
```
## Buy 购买月费/年费姥爷
`GET http://api.live.bilibili.com/xlive/xuser/v1/vip/Buy`
### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|order_id|是|string||
|uid|是|integer||
|good_id|是|integer||
|good_num|是|integer||
|platform|是|integer||
|source|是|string||
```json
{
"code": 0,
"message": "ok",
"data": {
"status": 0
}
}
```