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,47 @@
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-view/conf: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-view/dao/resource",
tags = ["automanaged"],
deps = [
"//app/interface/main/app-view/conf:go_default_library",
"//app/service/main/resource/model:go_default_library",
"//app/service/main/resource/rpc/client:go_default_library",
"//library/ecode: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,44 @@
package resource
import (
"context"
"go-common/app/interface/main/app-view/conf"
"go-common/app/service/main/resource/model"
rscrpc "go-common/app/service/main/resource/rpc/client"
"go-common/library/ecode"
"github.com/pkg/errors"
)
// Dao is archive dao.
type Dao struct {
// rpc
rscRPC *rscrpc.Service
}
// New new a archive dao.
func New(c *conf.Config) (d *Dao) {
d = &Dao{
// rpc
rscRPC: rscrpc.New(c.ResourceRPC),
}
return
}
func (d *Dao) Paster(c context.Context, plat, adType int8, aid, typeID, buvid string) (res *model.Paster, err error) {
arg := &model.ArgPaster{Platform: plat, AdType: adType, Aid: aid, TypeId: typeID, Buvid: buvid}
if res, err = d.rscRPC.PasterAPP(c, arg); err != nil {
err = errors.Wrapf(err, "%v", arg)
}
return
}
func (d *Dao) PlayerIcon(c context.Context) (res *model.PlayerIcon, err error) {
if res, err = d.rscRPC.PlayerIcon(c); err != nil {
if ecode.Cause(err) == ecode.NothingFound {
res, err = nil, nil
}
}
return
}

View File

@@ -0,0 +1,37 @@
package resource
import (
"context"
"flag"
"path/filepath"
"testing"
"go-common/app/interface/main/app-view/conf"
. "github.com/smartystreets/goconvey/convey"
)
var (
d *Dao
)
func init() {
dir, _ := filepath.Abs("../../cmd/app-view-test.toml")
flag.Set("conf", dir)
conf.Init()
d = New(conf.Conf)
}
func Test_Paster(t *testing.T) {
Convey("should get banner", t, func() {
_, err := d.Paster(context.Background(), 1, 2, "", "", "")
So(err, ShouldBeNil)
})
}
func Test_PlayerIcon(t *testing.T) {
Convey("should get player icon", t, func() {
_, err := d.PlayerIcon(context.Background())
So(err, ShouldBeNil)
})
}