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_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = ["point.go"],
importpath = "go-common/app/interface/main/account/service/point",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/account/conf:go_default_library",
"//app/service/main/point/model:go_default_library",
"//app/service/main/point/rpc/client: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"],
)
go_test(
name = "go_default_test",
srcs = ["point_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/interface/main/account/conf:go_default_library",
"//app/service/main/point/model:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)

View File

@@ -0,0 +1,38 @@
package point
import (
"context"
"go-common/app/interface/main/account/conf"
"go-common/app/service/main/point/model"
pointrpc "go-common/app/service/main/point/rpc/client"
)
// Service struct of service.
type Service struct {
// conf
c *conf.Config
// rpc
pointRPC *pointrpc.Service
}
// New create service instance and return.
func New(c *conf.Config) (s *Service) {
s = &Service{
c: c,
pointRPC: pointrpc.New(c.RPCClient2.Point),
}
return
}
// PointInfo point info.
func (s *Service) PointInfo(c context.Context, mid int64) (res *model.PointInfo, err error) {
res, err = s.pointRPC.PointInfo(c, &model.ArgRPCMid{Mid: mid})
return
}
// PointPage point page.
func (s *Service) PointPage(c context.Context, a *model.ArgRPCPointHistory) (res *model.PointHistoryResp, err error) {
res, err = s.pointRPC.PointHistory(c, a)
return
}

View File

@@ -0,0 +1,43 @@
package point
import (
"context"
"flag"
"testing"
"go-common/app/interface/main/account/conf"
"go-common/app/service/main/point/model"
. "github.com/smartystreets/goconvey/convey"
)
var (
s *Service
)
func init() {
flag.Set("conf", "../../cmd/account-interface-example.toml")
var err error
if err = conf.Init(); err != nil {
panic(err)
}
s = New(conf.Conf)
}
// go test -test.v -test.run TestServicePointInfo
func TestServicePointInfo(t *testing.T) {
Convey("TestServicePointInfo", t, func() {
res, err := s.PointInfo(context.TODO(), 110000262)
t.Logf("info: %v", res)
So(err, ShouldBeNil)
})
}
// go test -test.v -test.run TestServicePointPage
func TestServicePointPage(t *testing.T) {
Convey("TestServicePointPage", t, func() {
res, err := s.PointPage(context.TODO(), &model.ArgRPCPointHistory{Mid: 2089809, PN: 1, PS: 10})
t.Logf("res: %v", res)
So(err, ShouldBeNil)
})
}