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,16 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/captcha/api/liverpc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,37 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["client.go"],
importpath = "go-common/app/service/live/captcha/api/liverpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/captcha/api/liverpc/v0:go_default_library",
"//app/service/live/captcha/api/liverpc/v1:go_default_library",
"//library/net/rpc/liverpc:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/captcha/api/liverpc/v0:all-srcs",
"//app/service/live/captcha/api/liverpc/v1:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,46 @@
// Code generated by liverpcgen, DO NOT EDIT.
// source: *.proto files under this directory
// If you want to change this file, Please see README in go-common/app/tool/liverpc/protoc-gen-liverpc/
package liverpc
import (
"go-common/app/service/live/captcha/api/liverpc/v0"
"go-common/app/service/live/captcha/api/liverpc/v1"
"go-common/library/net/rpc/liverpc"
)
// Client that represents a liverpc captcha service api
type Client struct {
cli *liverpc.Client
// V0Captcha presents the controller in liverpc
V0Captcha v0.CaptchaRPCClient
// V1Captcha presents the controller in liverpc
V1Captcha v1.CaptchaRPCClient
}
// DiscoveryAppId the discovery id is not the tree name
var DiscoveryAppId = "live.captcha"
// New a Client that represents a liverpc live.captcha service api
// conf can be empty, and it will use discovery to find service by default
// conf.AppID will be overwrite by a fixed value DiscoveryAppId
// therefore is no need to set
func New(conf *liverpc.ClientConfig) *Client {
if conf == nil {
conf = &liverpc.ClientConfig{}
}
conf.AppID = DiscoveryAppId
var realCli = liverpc.NewClient(conf)
cli := &Client{cli: realCli}
cli.clientInit(realCli)
return cli
}
func (cli *Client) GetRawCli() *liverpc.Client {
return cli.cli
}
func (cli *Client) clientInit(realCli *liverpc.Client) {
cli.V0Captcha = v0.NewCaptchaRPCClient(realCli)
cli.V1Captcha = v1.NewCaptchaRPCClient(realCli)
}

View File

@@ -0,0 +1,56 @@
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 = "v0_proto",
srcs = ["Captcha.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v0_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v0",
proto = ":v0_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["Captcha.liverpc.go"],
embed = [":v0_go_proto"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v0",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//proto: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,62 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v0/Captcha.proto
/*
Package v0 is a generated liverpc stub package.
This code was generated with go-common/app/tool/liverpc/protoc-gen-liverpc v0.1.
It is generated from these files:
v0/Captcha.proto
*/
package v0
import context "context"
import proto "github.com/golang/protobuf/proto"
import "go-common/library/net/rpc/liverpc"
var _ proto.Message // generate to suppress unused imports
// Imports only used by utility functions:
// =================
// Captcha Interface
// =================
type CaptchaRPCClient interface {
// * 校验验证码
//
Check(ctx context.Context, req *CaptchaCheckReq, opts ...liverpc.CallOption) (resp *CaptchaCheckResp, err error)
}
// =======================
// Captcha Live Rpc Client
// =======================
type captchaRPCClient struct {
client *liverpc.Client
}
// NewCaptchaRPCClient creates a client that implements the CaptchaRPCClient interface.
func NewCaptchaRPCClient(client *liverpc.Client) CaptchaRPCClient {
return &captchaRPCClient{
client: client,
}
}
func (c *captchaRPCClient) Check(ctx context.Context, in *CaptchaCheckReq, opts ...liverpc.CallOption) (*CaptchaCheckResp, error) {
out := new(CaptchaCheckResp)
err := doRPCRequest(ctx, c.client, 0, "Captcha.check", in, out, opts)
if err != nil {
return nil, err
}
return out, nil
}
// =====
// Utils
// =====
func doRPCRequest(ctx context.Context, client *liverpc.Client, version int, method string, in, out proto.Message, opts []liverpc.CallOption) (err error) {
err = client.Call(ctx, version, method, in, out, opts...)
return
}

View File

@@ -0,0 +1,715 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v0/Captcha.proto
package v0
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type CaptchaCheckReq struct {
// token值
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token"`
// 输入值
Phrase string `protobuf:"bytes,2,opt,name=phrase,proto3" json:"phrase"`
}
func (m *CaptchaCheckReq) Reset() { *m = CaptchaCheckReq{} }
func (m *CaptchaCheckReq) String() string { return proto.CompactTextString(m) }
func (*CaptchaCheckReq) ProtoMessage() {}
func (*CaptchaCheckReq) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_715baa8051ae2c15, []int{0}
}
func (m *CaptchaCheckReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCheckReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCheckReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCheckReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCheckReq.Merge(dst, src)
}
func (m *CaptchaCheckReq) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCheckReq) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCheckReq.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCheckReq proto.InternalMessageInfo
func (m *CaptchaCheckReq) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
func (m *CaptchaCheckReq) GetPhrase() string {
if m != nil {
return m.Phrase
}
return ""
}
type CaptchaCheckResp struct {
// code
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
// msg
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data map[int64]int64 `protobuf:"bytes,3,rep,name=data" json:"data" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
}
func (m *CaptchaCheckResp) Reset() { *m = CaptchaCheckResp{} }
func (m *CaptchaCheckResp) String() string { return proto.CompactTextString(m) }
func (*CaptchaCheckResp) ProtoMessage() {}
func (*CaptchaCheckResp) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_715baa8051ae2c15, []int{1}
}
func (m *CaptchaCheckResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCheckResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCheckResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCheckResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCheckResp.Merge(dst, src)
}
func (m *CaptchaCheckResp) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCheckResp) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCheckResp.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCheckResp proto.InternalMessageInfo
func (m *CaptchaCheckResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *CaptchaCheckResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *CaptchaCheckResp) GetData() map[int64]int64 {
if m != nil {
return m.Data
}
return nil
}
func init() {
proto.RegisterType((*CaptchaCheckReq)(nil), "captcha.v0.CaptchaCheckReq")
proto.RegisterType((*CaptchaCheckResp)(nil), "captcha.v0.CaptchaCheckResp")
proto.RegisterMapType((map[int64]int64)(nil), "captcha.v0.CaptchaCheckResp.DataEntry")
}
func (m *CaptchaCheckReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCheckReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Token) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Token)))
i += copy(dAtA[i:], m.Token)
}
if len(m.Phrase) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Phrase)))
i += copy(dAtA[i:], m.Phrase)
}
return i, nil
}
func (m *CaptchaCheckResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCheckResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if len(m.Data) > 0 {
for k, _ := range m.Data {
dAtA[i] = 0x1a
i++
v := m.Data[k]
mapSize := 1 + sovCaptcha(uint64(k)) + 1 + sovCaptcha(uint64(v))
i = encodeVarintCaptcha(dAtA, i, uint64(mapSize))
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(k))
dAtA[i] = 0x10
i++
i = encodeVarintCaptcha(dAtA, i, uint64(v))
}
}
return i, nil
}
func encodeVarintCaptcha(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *CaptchaCheckReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Token)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
l = len(m.Phrase)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
return n
}
func (m *CaptchaCheckResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovCaptcha(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
if len(m.Data) > 0 {
for k, v := range m.Data {
_ = k
_ = v
mapEntrySize := 1 + sovCaptcha(uint64(k)) + 1 + sovCaptcha(uint64(v))
n += mapEntrySize + 1 + sovCaptcha(uint64(mapEntrySize))
}
}
return n
}
func sovCaptcha(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCaptcha(x uint64) (n int) {
return sovCaptcha(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *CaptchaCheckReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCheckReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCheckReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Token = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Phrase", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Phrase = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CaptchaCheckResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCheckResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCheckResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = make(map[int64]int64)
}
var mapkey int64
var mapvalue int64
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
mapkey |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
} else if fieldNum == 2 {
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
mapvalue |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
} else {
iNdEx = entryPreIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Data[mapkey] = mapvalue
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCaptcha(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthCaptcha
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipCaptcha(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthCaptcha = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCaptcha = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v0/Captcha.proto", fileDescriptor_Captcha_715baa8051ae2c15) }
var fileDescriptor_Captcha_715baa8051ae2c15 = []byte{
// 323 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x3f, 0x4f, 0x3a, 0x41,
0x10, 0x65, 0x59, 0xfe, 0xfc, 0x98, 0x5f, 0x21, 0xd9, 0x58, 0x20, 0x92, 0x3d, 0x42, 0x61, 0x68,
0x3c, 0x08, 0x16, 0x1a, 0xcb, 0x03, 0x4b, 0x9b, 0x2d, 0x2c, 0xec, 0x96, 0x65, 0xbd, 0x33, 0x08,
0x7b, 0xc0, 0x72, 0x09, 0xdf, 0xc2, 0x8f, 0x65, 0xac, 0x28, 0xad, 0x2e, 0x86, 0xeb, 0xee, 0x53,
0x98, 0xdb, 0xdd, 0x68, 0x34, 0xd1, 0x66, 0x66, 0xde, 0xec, 0xcc, 0x7b, 0x6f, 0xb2, 0xd0, 0x4c,
0x86, 0x83, 0x31, 0x8f, 0xb5, 0x88, 0xb8, 0x1f, 0xaf, 0x95, 0x56, 0x04, 0x84, 0x83, 0xc9, 0xb0,
0x7d, 0x1e, 0x3e, 0xea, 0x68, 0x3b, 0xf5, 0x85, 0x5a, 0x0c, 0x42, 0x15, 0xaa, 0x81, 0x19, 0x99,
0x6e, 0x1f, 0x0c, 0x32, 0xc0, 0x54, 0x76, 0xb5, 0x77, 0x07, 0x47, 0x8e, 0x6b, 0x1c, 0x49, 0x31,
0x67, 0x72, 0x45, 0x3c, 0xa8, 0x6a, 0x35, 0x97, 0xcb, 0x16, 0xea, 0xa2, 0x7e, 0x23, 0x68, 0xe4,
0xa9, 0x67, 0x1b, 0xcc, 0x26, 0xd2, 0x83, 0x5a, 0x1c, 0xad, 0xf9, 0x46, 0xb6, 0xca, 0x66, 0x02,
0xf2, 0xd4, 0x73, 0x1d, 0xe6, 0x72, 0xef, 0x15, 0x41, 0xf3, 0x3b, 0xf1, 0x26, 0x26, 0x1d, 0xa8,
0x08, 0x35, 0x93, 0x86, 0x18, 0x07, 0xff, 0xf2, 0xd4, 0x33, 0x98, 0x99, 0x48, 0x4e, 0x00, 0x2f,
0x36, 0xa1, 0xe3, 0xac, 0xe7, 0xa9, 0x57, 0x40, 0x56, 0x04, 0x32, 0x81, 0xca, 0x8c, 0x6b, 0xde,
0xc2, 0x5d, 0xdc, 0xff, 0x3f, 0x3a, 0xf3, 0xbf, 0xee, 0xf5, 0x7f, 0x8a, 0xf8, 0x13, 0xae, 0xf9,
0xcd, 0x52, 0xaf, 0x77, 0x56, 0xa0, 0xd8, 0x63, 0x26, 0xb6, 0x2f, 0xa1, 0xf1, 0xf9, 0x48, 0x9a,
0x80, 0xe7, 0x72, 0x67, 0xad, 0xb0, 0xa2, 0x24, 0xc7, 0x50, 0x4d, 0xf8, 0xd3, 0xd6, 0x5e, 0x85,
0x99, 0x05, 0xd7, 0xe5, 0x2b, 0x34, 0xba, 0x85, 0xba, 0x93, 0x21, 0x01, 0x54, 0x45, 0x21, 0x45,
0x4e, 0x7f, 0x37, 0xb1, 0x6a, 0x77, 0xfe, 0x72, 0x18, 0x74, 0x5e, 0x0e, 0x14, 0xed, 0x0f, 0x14,
0xbd, 0x1f, 0x28, 0x7a, 0xce, 0x68, 0x69, 0x9f, 0xd1, 0xd2, 0x5b, 0x46, 0x4b, 0xf7, 0xe5, 0x64,
0x38, 0xad, 0x99, 0x8f, 0xb9, 0xf8, 0x08, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x9e, 0xe4, 0x4c, 0xe7,
0x01, 0x00, 0x00,
}

View File

@@ -0,0 +1,33 @@
syntax = "proto3";
package captcha.v0;
option go_package = "v0";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Captcha {
/** 校验验证码
*
*/
rpc check (CaptchaCheckReq) returns (CaptchaCheckResp);
}
message CaptchaCheckReq {
// token值
string token = 1 [(gogoproto.jsontag) = "token"];
// 输入值
string phrase = 2 [(gogoproto.jsontag) = "phrase"];
}
message CaptchaCheckResp {
// code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
map<int64, int64> data = 3 [(gogoproto.jsontag) = "data"];
}

View File

@@ -0,0 +1,56 @@
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 = ["Captcha.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/live/captcha/api/liverpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["Captcha.liverpc.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//proto: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,62 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/Captcha.proto
/*
Package v1 is a generated liverpc stub package.
This code was generated with go-common/app/tool/liverpc/protoc-gen-liverpc v0.1.
It is generated from these files:
v1/Captcha.proto
*/
package v1
import context "context"
import proto "github.com/golang/protobuf/proto"
import "go-common/library/net/rpc/liverpc"
var _ proto.Message // generate to suppress unused imports
// Imports only used by utility functions:
// =================
// Captcha Interface
// =================
type CaptchaRPCClient interface {
// * 创建图片数字验证码
//
Create(ctx context.Context, req *CaptchaCreateReq, opts ...liverpc.CallOption) (resp *CaptchaCreateResp, err error)
}
// =======================
// Captcha Live Rpc Client
// =======================
type captchaRPCClient struct {
client *liverpc.Client
}
// NewCaptchaRPCClient creates a client that implements the CaptchaRPCClient interface.
func NewCaptchaRPCClient(client *liverpc.Client) CaptchaRPCClient {
return &captchaRPCClient{
client: client,
}
}
func (c *captchaRPCClient) Create(ctx context.Context, in *CaptchaCreateReq, opts ...liverpc.CallOption) (*CaptchaCreateResp, error) {
out := new(CaptchaCreateResp)
err := doRPCRequest(ctx, c.client, 1, "Captcha.create", in, out, opts)
if err != nil {
return nil, err
}
return out, nil
}
// =====
// Utils
// =====
func doRPCRequest(ctx context.Context, client *liverpc.Client, version int, method string, in, out proto.Message, opts []liverpc.CallOption) (err error) {
err = client.Call(ctx, version, method, in, out, opts...)
return
}

View File

@@ -0,0 +1,827 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/Captcha.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type CaptchaCreateReq struct {
// 宽度
Width int64 `protobuf:"varint,1,opt,name=width,proto3" json:"width"`
// 高度
Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height"`
}
func (m *CaptchaCreateReq) Reset() { *m = CaptchaCreateReq{} }
func (m *CaptchaCreateReq) String() string { return proto.CompactTextString(m) }
func (*CaptchaCreateReq) ProtoMessage() {}
func (*CaptchaCreateReq) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_a2a8548161d89a91, []int{0}
}
func (m *CaptchaCreateReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCreateReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCreateReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCreateReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCreateReq.Merge(dst, src)
}
func (m *CaptchaCreateReq) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCreateReq) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCreateReq.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCreateReq proto.InternalMessageInfo
func (m *CaptchaCreateReq) GetWidth() int64 {
if m != nil {
return m.Width
}
return 0
}
func (m *CaptchaCreateReq) GetHeight() int64 {
if m != nil {
return m.Height
}
return 0
}
type CaptchaCreateResp struct {
// code
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
// msg
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *CaptchaCreateResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *CaptchaCreateResp) Reset() { *m = CaptchaCreateResp{} }
func (m *CaptchaCreateResp) String() string { return proto.CompactTextString(m) }
func (*CaptchaCreateResp) ProtoMessage() {}
func (*CaptchaCreateResp) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_a2a8548161d89a91, []int{1}
}
func (m *CaptchaCreateResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCreateResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCreateResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCreateResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCreateResp.Merge(dst, src)
}
func (m *CaptchaCreateResp) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCreateResp) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCreateResp.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCreateResp proto.InternalMessageInfo
func (m *CaptchaCreateResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *CaptchaCreateResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *CaptchaCreateResp) GetData() *CaptchaCreateResp_Data {
if m != nil {
return m.Data
}
return nil
}
type CaptchaCreateResp_Data struct {
//
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token"`
//
Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image"`
}
func (m *CaptchaCreateResp_Data) Reset() { *m = CaptchaCreateResp_Data{} }
func (m *CaptchaCreateResp_Data) String() string { return proto.CompactTextString(m) }
func (*CaptchaCreateResp_Data) ProtoMessage() {}
func (*CaptchaCreateResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_a2a8548161d89a91, []int{1, 0}
}
func (m *CaptchaCreateResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCreateResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCreateResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCreateResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCreateResp_Data.Merge(dst, src)
}
func (m *CaptchaCreateResp_Data) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCreateResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCreateResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCreateResp_Data proto.InternalMessageInfo
func (m *CaptchaCreateResp_Data) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
func (m *CaptchaCreateResp_Data) GetImage() string {
if m != nil {
return m.Image
}
return ""
}
func init() {
proto.RegisterType((*CaptchaCreateReq)(nil), "captcha.v1.CaptchaCreateReq")
proto.RegisterType((*CaptchaCreateResp)(nil), "captcha.v1.CaptchaCreateResp")
proto.RegisterType((*CaptchaCreateResp_Data)(nil), "captcha.v1.CaptchaCreateResp.Data")
}
func (m *CaptchaCreateReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCreateReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Width != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Width))
}
if m.Height != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Height))
}
return i, nil
}
func (m *CaptchaCreateResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCreateResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *CaptchaCreateResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCreateResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Token) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Token)))
i += copy(dAtA[i:], m.Token)
}
if len(m.Image) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Image)))
i += copy(dAtA[i:], m.Image)
}
return i, nil
}
func encodeVarintCaptcha(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *CaptchaCreateReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Width != 0 {
n += 1 + sovCaptcha(uint64(m.Width))
}
if m.Height != 0 {
n += 1 + sovCaptcha(uint64(m.Height))
}
return n
}
func (m *CaptchaCreateResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovCaptcha(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovCaptcha(uint64(l))
}
return n
}
func (m *CaptchaCreateResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Token)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
l = len(m.Image)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
return n
}
func sovCaptcha(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCaptcha(x uint64) (n int) {
return sovCaptcha(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *CaptchaCreateReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCreateReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCreateReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Width", wireType)
}
m.Width = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Width |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
}
m.Height = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Height |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CaptchaCreateResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCreateResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCreateResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &CaptchaCreateResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CaptchaCreateResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Token = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Image = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCaptcha(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthCaptcha
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipCaptcha(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthCaptcha = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCaptcha = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/Captcha.proto", fileDescriptor_Captcha_a2a8548161d89a91) }
var fileDescriptor_Captcha_a2a8548161d89a91 = []byte{
// 315 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x4d, 0x4f, 0xc2, 0x40,
0x14, 0x64, 0x01, 0x41, 0x9e, 0x17, 0xdc, 0x13, 0x12, 0xdc, 0x92, 0x9e, 0xb8, 0x58, 0x02, 0xfe,
0x01, 0x03, 0x9a, 0x78, 0x34, 0x7b, 0x31, 0xf1, 0xb6, 0x94, 0x75, 0xdb, 0x18, 0x5c, 0x3e, 0x96,
0xfa, 0x37, 0xfc, 0x59, 0x1e, 0x39, 0x72, 0x6a, 0x4c, 0x7b, 0xeb, 0xaf, 0x30, 0xfb, 0x76, 0x13,
0x13, 0x4d, 0xb8, 0xbc, 0xe9, 0x4c, 0x66, 0xe7, 0xcd, 0x4b, 0xa1, 0x9b, 0x4d, 0xc6, 0x73, 0xb1,
0x36, 0x71, 0x22, 0xa2, 0xf5, 0x56, 0x1b, 0x4d, 0x21, 0xf6, 0x34, 0x9b, 0xf4, 0x6f, 0x54, 0x6a,
0x92, 0xfd, 0x22, 0x8a, 0xf5, 0x6a, 0xac, 0xb4, 0xd2, 0x63, 0xb4, 0x2c, 0xf6, 0xaf, 0xc8, 0x90,
0xe0, 0x97, 0x7b, 0x1a, 0x3e, 0x43, 0xd7, 0x67, 0xcd, 0xb7, 0x52, 0x18, 0xc9, 0xe5, 0x86, 0x06,
0x70, 0xf6, 0x91, 0x2e, 0x4d, 0xd2, 0x23, 0x43, 0x32, 0x6a, 0xcc, 0x3a, 0x55, 0x1e, 0x38, 0x81,
0x3b, 0xa0, 0x21, 0xb4, 0x12, 0x99, 0xaa, 0xc4, 0xf4, 0xea, 0xe8, 0x80, 0x2a, 0x0f, 0xbc, 0xc2,
0x3d, 0x86, 0x47, 0x02, 0x97, 0x7f, 0x92, 0x77, 0x6b, 0x3a, 0x80, 0x66, 0xac, 0x97, 0xd2, 0x27,
0x9f, 0x57, 0x79, 0x80, 0x9c, 0xe3, 0xa4, 0x57, 0xd0, 0x58, 0xed, 0x14, 0x86, 0x76, 0x66, 0xed,
0x2a, 0x0f, 0x2c, 0xe5, 0x76, 0xd0, 0x3b, 0x68, 0x2e, 0x85, 0x11, 0xbd, 0xc6, 0x90, 0x8c, 0x2e,
0xa6, 0x61, 0xf4, 0x7b, 0x71, 0xf4, 0x6f, 0x4b, 0x74, 0x2f, 0x8c, 0x70, 0xe1, 0xf6, 0x0d, 0xc7,
0xd9, 0x7f, 0x84, 0xa6, 0xd5, 0xed, 0x75, 0x46, 0xbf, 0xc9, 0x77, 0xec, 0xd0, 0x71, 0xd7, 0xa1,
0xc0, 0x1d, 0x58, 0x43, 0xba, 0x12, 0x4a, 0xfa, 0x1e, 0x68, 0x40, 0x81, 0x3b, 0x98, 0x3e, 0x41,
0xdb, 0xef, 0xa4, 0x0f, 0xd0, 0x8a, 0x71, 0x2f, 0x1d, 0x9c, 0xa8, 0xb4, 0xe9, 0x5f, 0x9f, 0x2c,
0x3c, 0x1b, 0x7c, 0x15, 0x8c, 0x1c, 0x0a, 0x46, 0xbe, 0x0b, 0x46, 0x3e, 0x4b, 0x56, 0x3b, 0x94,
0xac, 0x76, 0x2c, 0x59, 0xed, 0xa5, 0x9e, 0x4d, 0x16, 0x2d, 0xfc, 0x55, 0xb7, 0x3f, 0x01, 0x00,
0x00, 0xff, 0xff, 0xfa, 0xba, 0xd4, 0x22, 0xf9, 0x01, 0x00, 0x00,
}

View File

@@ -0,0 +1,40 @@
syntax = "proto3";
package captcha.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Captcha {
/** 创建图片数字验证码
*
*/
rpc create (CaptchaCreateReq) returns (CaptchaCreateResp);
}
message CaptchaCreateReq {
// 宽度
int64 width = 1 [(gogoproto.jsontag) = "width"];
// 高度
int64 height = 2 [(gogoproto.jsontag) = "height"];
}
message CaptchaCreateResp {
// code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
//
string token = 1 [(gogoproto.jsontag) = "token"];
//
string image = 2 [(gogoproto.jsontag) = "image"];
}
}