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,17 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/main/account/rpc/client:all-srcs",
"//app/service/main/account/rpc/server:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["account3.go"],
importpath = "go-common/app/service/main/account/rpc/client",
tags = ["automanaged"],
deps = [
"//app/service/main/account/api:go_default_library",
"//app/service/main/account/model:go_default_library",
"//library/net/rpc: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,137 @@
package client
import (
"context"
v1 "go-common/app/service/main/account/api"
"go-common/app/service/main/account/model"
"go-common/library/net/rpc"
)
const (
_info3 = "RPC.Info3"
_card3 = "RPC.Card3"
_infos3 = "RPC.Infos3"
_infosByName3 = "RPC.InfosByName3"
_cards3 = "RPC.Cards3"
_profile3 = "RPC.Profile3"
_profileStat3 = "RPC.ProfileWithStat3"
_addExp3 = "RPC.AddExp3"
_addMoral3 = "RPC.AddMoral3"
_relation3 = "RPC.Relation3"
_relations3 = "RPC.Relations3"
_attentions3 = "RPC.Attentions3"
_blacks3 = "RPC.Blacks3"
_richRelations3 = "RPC.RichRelations3"
)
const (
_appid = "account.service"
)
var (
_noArg = &struct{}{}
)
// Service3 for server client3
type Service3 struct {
client *rpc.Client2
}
// New3 for new struct Service2 obj
func New3(c *rpc.ClientConfig) (s *Service3) {
s = &Service3{}
s.client = rpc.NewDiscoveryCli(_appid, c)
return
}
// Info3 receive ArgMid contains mid and real ip, then init user info.
func (s *Service3) Info3(c context.Context, arg *model.ArgMid) (res *v1.Info, err error) {
res = new(v1.Info)
err = s.client.Call(c, _info3, arg, res)
return
}
// Card3 receive ArgMid contains mid and real ip, then init user card.
func (s *Service3) Card3(c context.Context, arg *model.ArgMid) (res *v1.Card, err error) {
res = new(v1.Card)
err = s.client.Call(c, _card3, arg, res)
return
}
// Infos3 receive ArgMids contains mid and real ip, then init user info.
func (s *Service3) Infos3(c context.Context, arg *model.ArgMids) (res map[int64]*v1.Info, err error) {
err = s.client.Call(c, _infos3, arg, &res)
return
}
// InfosByName3 receive ArgMids contains mid and real ip, then init user info.
func (s *Service3) InfosByName3(c context.Context, arg *model.ArgNames) (res map[int64]*v1.Info, err error) {
err = s.client.Call(c, _infosByName3, arg, &res)
return
}
// Cards3 receive ArgMids contains mid and real ip, then init user card.
func (s *Service3) Cards3(c context.Context, arg *model.ArgMids) (res map[int64]*v1.Card, err error) {
err = s.client.Call(c, _cards3, arg, &res)
return
}
// Profile3 get user profile.
func (s *Service3) Profile3(c context.Context, arg *model.ArgMid) (res *v1.Profile, err error) {
res = new(v1.Profile)
err = s.client.Call(c, _profile3, arg, res)
return
}
// ProfileWithStat3 get user profile.
func (s *Service3) ProfileWithStat3(c context.Context, arg *model.ArgMid) (res *model.ProfileStat, err error) {
res = new(model.ProfileStat)
err = s.client.Call(c, _profileStat3, arg, res)
return
}
// AddExp3 receive ArgExp contains mid, money and reason, then add exp for user.
func (s *Service3) AddExp3(c context.Context, arg *model.ArgExp) (err error) {
err = s.client.Call(c, _addExp3, arg, _noArg)
return
}
// AddMoral3 receive ArgMoral contains mid, moral, oper, reason and remark, then add moral for user.
func (s *Service3) AddMoral3(c context.Context, arg *model.ArgMoral) (err error) {
err = s.client.Call(c, _addMoral3, arg, _noArg)
return
}
// Relation3 get user friend relation.
func (s *Service3) Relation3(c context.Context, arg *model.ArgRelation) (res *model.Relation, err error) {
res = new(model.Relation)
err = s.client.Call(c, _relation3, arg, res)
return
}
// Relations3 batch get user friend relation.
func (s *Service3) Relations3(c context.Context, arg *model.ArgRelations) (res map[int64]*model.Relation, err error) {
err = s.client.Call(c, _relations3, arg, &res)
return
}
// Attentions3 get user attentions ,include followings and whispers.
func (s *Service3) Attentions3(c context.Context, arg *model.ArgMid) (res []int64, err error) {
err = s.client.Call(c, _attentions3, arg, &res)
return
}
// Blacks3 get user black list.
func (s *Service3) Blacks3(c context.Context, arg *model.ArgMid) (res map[int64]struct{}, err error) {
err = s.client.Call(c, _blacks3, arg, &res)
return
}
// RichRelations3 get relation between owner and mids.
func (s *Service3) RichRelations3(c context.Context, arg *model.ArgRichRelation) (res map[int64]int, err error) {
err = s.client.Call(c, _richRelations3, arg, &res)
return
}

View File

@@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"rpc.go",
"rpc3.go",
],
importpath = "go-common/app/service/main/account/rpc/server",
tags = ["automanaged"],
deps = [
"//app/service/main/account/api:go_default_library",
"//app/service/main/account/conf:go_default_library",
"//app/service/main/account/model:go_default_library",
"//app/service/main/account/service:go_default_library",
"//library/net/rpc:go_default_library",
"//library/net/rpc/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,28 @@
package server
import (
"go-common/app/service/main/account/conf"
"go-common/app/service/main/account/service"
"go-common/library/net/rpc"
"go-common/library/net/rpc/context"
)
// RPC server
type RPC struct {
s *service.Service
}
// New new rpc server.
func New(c *conf.Config, s *service.Service) (svr *rpc.Server) {
r := &RPC{s: s}
svr = rpc.NewServer(c.RPCServer)
if err := svr.Register(r); err != nil {
panic(err)
}
return
}
// Ping check connection success.
func (r *RPC) Ping(c context.Context, arg *struct{}, res *struct{}) (err error) {
return
}

View File

@@ -0,0 +1,106 @@
package server
import (
v1 "go-common/app/service/main/account/api"
"go-common/app/service/main/account/model"
"go-common/library/net/rpc/context"
)
// Info3 receive ArgMid contains mid and real ip, then init user info.
func (r *RPC) Info3(c context.Context, arg *model.ArgMid, res *v1.Info) (err error) {
var info *v1.Info
if info, err = r.s.Info(c, arg.Mid); err == nil && info != nil {
*res = *info
}
return
}
// Infos3 receive ArgMids contains mids and real ip, then multi init user info.
func (r *RPC) Infos3(c context.Context, a *model.ArgMids, res *map[int64]*v1.Info) (err error) {
*res, err = r.s.Infos(c, a.Mids)
return
}
// InfosByName3 receive ArgMids contains mids and real ip, then multi init user info.
func (r *RPC) InfosByName3(c context.Context, a *model.ArgNames, res *map[int64]*v1.Info) (err error) {
*res, err = r.s.InfosByName(c, a.Names)
return
}
// Card3 receive ArgMid contains mid and real ip, then init user card.
func (r *RPC) Card3(c context.Context, arg *model.ArgMid, res *v1.Card) (err error) {
var card *v1.Card
if card, err = r.s.Card(c, arg.Mid); err == nil && res != nil {
*res = *card
}
return
}
// Cards3 receive ArgMids contains mids and real ip, then multi init user card.
func (r *RPC) Cards3(c context.Context, a *model.ArgMids, res *map[int64]*v1.Card) (err error) {
*res, err = r.s.Cards(c, a.Mids)
return
}
// Profile3 get user audit info.
func (r *RPC) Profile3(c context.Context, arg *model.ArgMid, res *v1.Profile) (err error) {
var p *v1.Profile
if p, err = r.s.Profile(c, arg.Mid); err == nil && p != nil {
*res = *p
}
return
}
// ProfileWithStat3 get user audit info.
func (r *RPC) ProfileWithStat3(c context.Context, arg *model.ArgMid, res *model.ProfileStat) (err error) {
var p *model.ProfileStat
if p, err = r.s.ProfileWithStat(c, arg.Mid); err == nil && p != nil {
*res = *p
}
return
}
// AddExp3 add exp for user.
func (r *RPC) AddExp3(c context.Context, a *model.ArgExp, res *struct{}) (err error) {
err = r.s.AddExp(c, a.Mid, a.Exp, a.Operater, a.Operate, a.Reason)
return
}
// AddMoral3 receive ArgMoral contains mid, moral, oper, reason and remark, then add moral for user.
func (r *RPC) AddMoral3(c context.Context, a *model.ArgMoral, res *struct{}) (err error) {
err = r.s.AddMoral(c, a.Mid, a.Moral, a.Oper, a.Reason, a.Remark)
return
}
// Relation3 get friend relation.
func (r *RPC) Relation3(c context.Context, a *model.ArgRelation, res *model.Relation) (err error) {
var rl *model.Relation
if rl, err = r.s.Relation(c, a.Mid, a.Owner); err == nil && rl != nil {
*res = *rl
}
return
}
// Attentions3 get attentions list ,including following and whisper.
func (r *RPC) Attentions3(c context.Context, a *model.ArgMid, res *[]int64) (err error) {
*res, err = r.s.Attentions(c, a.Mid)
return
}
// Blacks3 get user black list.
func (r *RPC) Blacks3(c context.Context, a *model.ArgMid, res *map[int64]struct{}) (err error) {
*res, err = r.s.Blacks(c, a.Mid)
return
}
// Relations3 get friend relations.
func (r *RPC) Relations3(c context.Context, a *model.ArgRelations, res *map[int64]*model.Relation) (err error) {
*res, err = r.s.Relations(c, a.Mid, a.Owners)
return
}
// RichRelations3 get friend relations.
func (r *RPC) RichRelations3(c context.Context, a *model.ArgRichRelation, res *map[int64]int) (err error) {
*res, err = r.s.RichRelations2(c, a.Owner, a.Mids)
return
}