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/interface/openplatform/article/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/article",
tags = ["automanaged"],
deps = [
"//app/interface/main/app-feed/conf:go_default_library",
"//app/interface/openplatform/article/model:go_default_library",
"//app/interface/openplatform/article/rpc/client:go_default_library",
"//library/net/metadata: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,36 @@
package article
import (
"context"
"go-common/app/interface/main/app-feed/conf"
article "go-common/app/interface/openplatform/article/model"
artrpc "go-common/app/interface/openplatform/article/rpc/client"
"go-common/library/net/metadata"
"github.com/pkg/errors"
)
// Dao is archive dao.
type Dao struct {
// rpc
artRPC *artrpc.Service
}
// New new a archive dao.
func New(c *conf.Config) (d *Dao) {
d = &Dao{
// rpc
artRPC: artrpc.New(c.ArticleRPC),
}
return
}
func (d *Dao) Articles(c context.Context, aids []int64) (ms map[int64]*article.Meta, err error) {
ip := metadata.String(c, metadata.RemoteIP)
arg := &article.ArgAids{Aids: aids, RealIP: ip}
if ms, err = d.artRPC.ArticleMetas(c, arg); err != nil {
err = errors.Wrapf(err, "%v", aids)
}
return
}

View File

@@ -0,0 +1,62 @@
package article
import (
"context"
"go-common/app/interface/main/app-feed/conf"
article "go-common/app/interface/openplatform/article/model"
"reflect"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
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 {
t.Run(tt.name, func(t *testing.T) {
if gotD := New(tt.args.c); !reflect.DeepEqual(gotD, tt.wantD) {
t.Errorf("New() = %v, want %v", gotD, tt.wantD)
}
})
}
Convey("new", t, func() {
So(t, ShouldNotBeNil)
})
}
func TestDao_Articles(t *testing.T) {
type args struct {
c context.Context
aids []int64
}
tests := []struct {
name string
d *Dao
args args
wantMs map[int64]*article.Meta
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotMs, err := tt.d.Articles(tt.args.c, tt.args.aids)
if (err != nil) != tt.wantErr {
t.Errorf("Dao.Articles() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotMs, tt.wantMs) {
t.Errorf("Dao.Articles() = %v, want %v", gotMs, tt.wantMs)
}
})
}
}