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,48 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_test",
"go_library",
)
go_test(
name = "go_default_test",
srcs = ["dao_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/interface/main/app-feed/conf:go_default_library",
"//app/service/main/relation/model:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = ["dao.go"],
importpath = "go-common/app/interface/main/app-feed/dao/relation",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/app-feed/conf:go_default_library",
"//app/service/main/relation/model:go_default_library",
"//app/service/main/relation/rpc/client:go_default_library",
"//vendor/github.com/pkg/errors: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,35 @@
package relation
import (
"context"
"go-common/app/interface/main/app-feed/conf"
relation "go-common/app/service/main/relation/model"
relrpc "go-common/app/service/main/relation/rpc/client"
"github.com/pkg/errors"
)
// Dao is rpc dao.
type Dao struct {
// relation rpc
relRPC *relrpc.Service
}
// New new a relation dao.
func New(c *conf.Config) (d *Dao) {
d = &Dao{
// relation rpc
relRPC: relrpc.New(c.RelationRPC),
}
return
}
// Stats fids stats
func (d *Dao) Stats(ctx context.Context, mids []int64) (res map[int64]*relation.Stat, err error) {
arg := &relation.ArgMids{Mids: mids}
if res, err = d.relRPC.Stats(ctx, arg); err != nil {
err = errors.Wrapf(err, "%v", arg)
}
return
}

View File

@@ -0,0 +1,59 @@
package relation
import (
. "github.com/smartystreets/goconvey/convey"
"context"
"reflect"
"testing"
"go-common/app/interface/main/app-feed/conf"
relation "go-common/app/service/main/relation/model"
)
func TestNew(t *testing.T) {
type args struct {
c *conf.Config
}
tests := []struct {
name string
args args
wantD *Dao
}{
// TODO: Add test cases.
}
for _, tt := range tests {
Convey(tt.name, t, func() {
gotD := New(tt.args.c)
So(gotD, ShouldEqual, tt.wantD)
})
}
}
func TestDao_Stats(t *testing.T) {
type args struct {
ctx context.Context
mids []int64
}
tests := []struct {
name string
d *Dao
args args
wantRes map[int64]*relation.Stat
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotRes, err := tt.d.Stats(tt.args.ctx, tt.args.mids)
if (err != nil) != tt.wantErr {
t.Errorf("Dao.Stats() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotRes, tt.wantRes) {
t.Errorf("Dao.Stats() = %v, want %v", gotRes, tt.wantRes)
}
})
}
}