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,57 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "v1_proto",
srcs = ["api.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/main/coupon/api",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["client.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/main/coupon/api",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/warden:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context: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"],
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,77 @@
syntax = "proto3";
// use {app_id}.{version} as package name
package account.coupon;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option go_package = "v1";
message CaptchaTokenReq {
string ip = 1;
}
message CaptchaTokenReply {
string token = 1;
string url = 2;
}
message UseCouponCodeReq{
string token =1;
string code = 2;
string verify =3;
string ip =4;
int64 mid = 5;
}
message UseCouponCodeResp{
string coupon_token = 1;
double coupon_amount = 2;
double full_amount = 3;
string platfrom_limit_explain = 4;
int32 product_limit_month = 5;
int32 product_limit_renewal = 6;
}
message UsableAllowanceCouponV2Req{
int64 mid =1;
repeated ModelPriceInfo priceInfo = 2;
}
message ModelPriceInfo {
double price = 1;
int64 plat = 2;
int32 prodLimMonth = 3;
int32 prodLimRenewal = 4;
}
message UsableAllowanceCouponV2Reply{
string coupon_tip = 1;
ModelCouponAllowancePanelInfo coupon_info = 2;
}
message ModelCouponAllowancePanelInfo{
string coupon_token = 1;
double coupon_amount = 2;
int32 state = 3;
string full_limit_explain = 4;
string scope_explain = 5;
double full_amount = 6;
double coupon_discount_price = 7;
int64 start_time = 8;
int64 expire_time = 9;
int32 selected = 10;
string disables_explains = 11;
string order_no = 12;
string name = 13;
int32 usable = 14;
}
service Coupon {
// CaptchaToken captcha token.
rpc CaptchaToken(CaptchaTokenReq) returns(CaptchaTokenReply);
// UseCouponCode use coupon code.
rpc UseCouponCode(UseCouponCodeReq) returns(UseCouponCodeResp);
// UsableAllowanceCouponV2 use allowance coupon v2.
rpc UsableAllowanceCouponV2(UsableAllowanceCouponV2Req) returns(UsableAllowanceCouponV2Reply);
}

View File

@@ -0,0 +1,23 @@
package v1
import (
"fmt"
"go-common/library/net/rpc/warden"
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// AppID .
const AppID = "account.service.coupon"
// NewClient new grpc client
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (CouponClient, error) {
client := warden.NewClient(cfg, opts...)
cc, err := client.Dial(context.Background(), fmt.Sprintf("discovery://default/%s", AppID))
if err != nil {
return nil, err
}
return NewCouponClient(cc), nil
}