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 = ["resource_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/interface/main/app-show/conf:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = ["resource.go"],
importpath = "go-common/app/interface/main/app-show/dao/resource",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/app-show/conf:go_default_library",
"//app/service/main/resource/model:go_default_library",
"//app/service/main/resource/rpc/client:go_default_library",
"//library/log: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,51 @@
package resource
import (
"context"
"go-common/app/interface/main/app-show/conf"
resource "go-common/app/service/main/resource/model"
resrpc "go-common/app/service/main/resource/rpc/client"
"go-common/library/log"
)
type Dao struct {
c *conf.Config
// rpc
resRpc *resrpc.Service
}
func New(c *conf.Config) (d *Dao) {
d = &Dao{
c: c,
// rpc
resRpc: resrpc.New(c.ResourceRPC),
}
return
}
func (d *Dao) ResBanner(ctx context.Context, plat int8, build int, mid int64, resIDStr, channel, ip, buvid, network, mobiApp, device, adExtra string, isAd bool) (res map[int][]*resource.Banner, err error) {
arg := &resource.ArgBanner{
Plat: plat,
ResIDs: resIDStr,
Build: build,
MID: mid,
Channel: channel,
IP: ip,
Buvid: buvid,
Network: network,
MobiApp: mobiApp,
Device: device,
IsAd: isAd,
AdExtra: adExtra,
}
var bs *resource.Banners
if bs, err = d.resRpc.Banners(ctx, arg); err != nil || bs == nil {
log.Error("d.resRpc.Banners(%v) error(%v)", arg, err)
return
}
if len(bs.Banner) > 0 {
res = bs.Banner
}
return
}

View File

@@ -0,0 +1,37 @@
package resource
import (
"context"
"flag"
"path/filepath"
"testing"
"time"
"go-common/app/interface/main/app-show/conf"
. "github.com/smartystreets/goconvey/convey"
)
var (
d *Dao
)
func ctx() context.Context {
return context.Background()
}
func init() {
dir, _ := filepath.Abs("../../cmd/app-show-test.toml")
flag.Set("conf", dir)
conf.Init()
d = New(conf.Conf)
time.Sleep(time.Second)
}
func TestResBanner(t *testing.T) {
Convey("ResBanner", t, func() {
res, err := d.ResBanner(ctx(), 1, 1, 1, "", "", "", "", "", "", "", "", false)
So(res, ShouldNotBeEmpty)
So(err, ShouldBeNil)
})
}