Create & Init Project...
This commit is contained in:
47
app/interface/main/app-interface/dao/sp/BUILD
Normal file
47
app/interface/main/app-interface/dao/sp/BUILD
Normal 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-interface/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-interface/dao/sp",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/interface/main/app-interface/conf:go_default_library",
|
||||
"//app/interface/main/app-interface/model/sp:go_default_library",
|
||||
"//library/net/http/blademaster:go_default_library",
|
||||
"//library/net/metadata: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"],
|
||||
)
|
47
app/interface/main/app-interface/dao/sp/dao.go
Normal file
47
app/interface/main/app-interface/dao/sp/dao.go
Normal file
@ -0,0 +1,47 @@
|
||||
package sp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"go-common/app/interface/main/app-interface/conf"
|
||||
"go-common/app/interface/main/app-interface/model/sp"
|
||||
httpx "go-common/library/net/http/blademaster"
|
||||
"go-common/library/net/metadata"
|
||||
)
|
||||
|
||||
const (
|
||||
_specil = "/sp/list"
|
||||
)
|
||||
|
||||
// Dao is favorite dao
|
||||
type Dao struct {
|
||||
client *httpx.Client
|
||||
specil string
|
||||
}
|
||||
|
||||
// New initial favorite dao
|
||||
func New(c *conf.Config) (d *Dao) {
|
||||
d = &Dao{
|
||||
client: httpx.NewClient(c.HTTPClient),
|
||||
specil: c.Host.APICo + _specil,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Specil get specil from old BiliWEB api.
|
||||
func (d *Dao) Specil(c context.Context, accessKey, actionKey, device, mobiApp, platform string, build, pn, ps int) (res *sp.Specil, err error) {
|
||||
ip := metadata.String(c, metadata.RemoteIP)
|
||||
params := url.Values{}
|
||||
params.Set("access_key", accessKey)
|
||||
params.Set("actionKey", actionKey)
|
||||
params.Set("build", strconv.Itoa(build))
|
||||
params.Set("device", device)
|
||||
params.Set("mobi_app", mobiApp)
|
||||
params.Set("page", strconv.Itoa(pn))
|
||||
params.Set("pagesize", strconv.Itoa(ps))
|
||||
params.Set("platform", platform)
|
||||
err = d.client.Get(c, d.specil, ip, params, &res)
|
||||
return
|
||||
}
|
33
app/interface/main/app-interface/dao/sp/dao_test.go
Normal file
33
app/interface/main/app-interface/dao/sp/dao_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
package sp
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"go-common/app/interface/main/app-interface/conf"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
Convey("TestNew", t, func() {
|
||||
|
||||
})
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user