Commit 305134ed by Li Feifei

实现Im配置

parent 88103fa6
File added
...@@ -54,7 +54,7 @@ func newMysqlClient() { ...@@ -54,7 +54,7 @@ func newMysqlClient() {
log.Println("db connect error => ", err) log.Println("db connect error => ", err)
return return
} }
orm.RegisterModel(new(CompanyApp)) orm.RegisterModel(new(CompanyApp), new(ImBase))
MysqlClient = orm.NewOrm() MysqlClient = orm.NewOrm()
log.Println("MySQL connect success") log.Println("MySQL connect success")
} }
package db package db
type CompanyApp struct { type CompanyApp struct {
Id int Id int
Name string Name string
...@@ -8,3 +7,10 @@ type CompanyApp struct { ...@@ -8,3 +7,10 @@ type CompanyApp struct {
Secret string Secret string
Cid int64 Cid int64
} }
type ImBase struct {
Id int
CompanyUserId int64
MultideviceType int64
MsgHookUrl string
}
...@@ -11,6 +11,7 @@ require ( ...@@ -11,6 +11,7 @@ require (
github.com/leodido/go-urn v1.2.0 // indirect github.com/leodido/go-urn v1.2.0 // indirect
github.com/rs/xid v1.2.1 github.com/rs/xid v1.2.1
github.com/segmentio/ksuid v1.0.2 github.com/segmentio/ksuid v1.0.2
golang.org/x/net v0.0.0-20190923162816-aa69164e4478
google.golang.org/grpc v1.30.0 google.golang.org/grpc v1.30.0
google.golang.org/protobuf v1.24.0 google.golang.org/protobuf v1.24.0
gopkg.in/go-playground/validator.v9 v9.31.0 gopkg.in/go-playground/validator.v9 v9.31.0
......
...@@ -3,14 +3,14 @@ package helper ...@@ -3,14 +3,14 @@ package helper
import "im-microservice/db" import "im-microservice/db"
const ( const (
table_name = "company_app" table_name = "company_app"
app_name = "name" app_name = "name"
app_key = "key" app_key = "key"
app_secret = "secret" app_secret = "secret"
app_cid = "cid" app_cid = "cid"
) )
func GetSecretByKey(key string) (error, string) { func GetSecretByKey(key string) (error, string) {
var u_app db.CompanyApp var u_app db.CompanyApp
err := db.MysqlClient.QueryTable(table_name).Filter(app_key, key).One(&u_app, app_secret) err := db.MysqlClient.QueryTable(table_name).Filter(app_key, key).One(&u_app, app_secret)
if err != nil { if err != nil {
...@@ -18,4 +18,3 @@ func GetSecretByKey(key string) (error, string) { ...@@ -18,4 +18,3 @@ func GetSecretByKey(key string) (error, string) {
} }
return nil, u_app.Secret return nil, u_app.Secret
} }
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
func Valiator(in interface{}) error { func Valiator(in interface{}) error {
validate := validator.New() validate := validator.New()
err := validate.Struct(in) err := validate.Struct(in)
if err != nil { if err != nil {
for _, err := range err.(validator.ValidationErrors) { for _, err := range err.(validator.ValidationErrors) {
...@@ -18,4 +19,3 @@ func Valiator(in interface{}) error { ...@@ -18,4 +19,3 @@ func Valiator(in interface{}) error {
} }
return nil return nil
} }
package helper
import (
"errors"
"github.com/astaxie/beego/orm"
"im-microservice/db"
"im-microservice/validator_struct"
)
const (
b_table_name = "im_base"
b_user_id = "company_user_id"
b_type = "multidevice_type"
b_url = "msg_hook_url"
)
func GetImBaseByUserId(user_id int64) (db.ImBase, error) {
var im_base db.ImBase
err := db.MysqlClient.QueryTable(b_table_name).Filter(b_user_id, user_id).One(&im_base)
if err != nil {
return im_base, err
}
return im_base, nil
}
func AddImBase(im *validator_struct.ConfigureAddStruct) error {
configure := new(db.ImBase)
configure.CompanyUserId = im.CompanyUserId
configure.MsgHookUrl = im.MsgHookUrl
configure.MultideviceType = im.MultideviceType
if _, err := db.MysqlClient.Insert(configure); err != nil {
return err
}
return nil
}
func DelConfigure(user_id int64) error {
configure := new(db.ImBase)
configure.CompanyUserId = user_id
if _, err := db.MysqlClient.Delete(configure); err != nil {
return err
}
return nil
}
func GetConfigureAll() []*db.ImBase{
var configurs []*db.ImBase
_, _ = db.MysqlClient.QueryTable(b_table_name).All(&configurs)
return configurs
}
func UpdateConfiguer(im *validator_struct.ConfigureUpdateStruct ) error {
orm_params := make(orm.Params)
if im.MsgHookUrl != "" {
orm_params["msg_hook_url"] = im.MsgHookUrl
}
if im.MultideviceType != 0 {
orm_params["multidevice_type"] = im.MultideviceType
}
if len(orm_params) == 0 {
return errors.New("没有数据更改")
}
_, err := db.MysqlClient.QueryTable(b_table_name).Filter(b_user_id, im.CompanyUserId).Update(orm_params)
if err != nil {
return err
}
return nil
}
\ No newline at end of file
package main package main
import ( import (
"crypto/sha1"
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"log" "log"
"net" "net"
"crypto/sha1" "regexp"
"strconv" "strconv"
"strings"
"time" "time"
"im-microservice/helper" "im-microservice/helper"
"im-microservice/pb"
ic "im-microservice/sevice/im_configure"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc" "google.golang.org/grpc"
...@@ -21,31 +22,30 @@ import ( ...@@ -21,31 +22,30 @@ import (
) )
const ( const (
port = ":50051" port = ":50051"
) )
func checksum(req map[string]string) error {
func checksum(req map[string]string) (error) { err, AppSecret := helper.GetSecretByKey(req["Appkey"])
err,AppSecret := helper.GetSecretByKey(req["appkey"])
if err != nil { if err != nil {
return err return errors.New("appkey不存在")
} }
server_time := time.Now().Unix() server_time := time.Now().Unix()
client_time,err := strconv.Atoi(req["curtime"]) client_time, err := strconv.Atoi(req["Curtime"])
if err != nil { if err != nil {
return err return err
} }
if server_time > int64(client_time) { if server_time > int64(client_time) {
return errors.New("当前客户端时间不能小于服务端时间") return errors.New("当前客户端时间不能小于服务端时间")
} }
sha11 := sha1.New() sha11 := sha1.New()
sha11.Write([]byte(AppSecret+req["nonce"] + req["curtime"])) sha11.Write([]byte(AppSecret + req["Nonce"] + req["Curtime"]))
sevice_checksum := hex.EncodeToString(sha11.Sum([]byte(nil))) sevice_checksum := hex.EncodeToString(sha11.Sum([]byte(nil)))
if sevice_checksum != req["checksum"] { if sevice_checksum != req["Checksum"] {
return errors.New("加密串不正确") return errors.New("加密串不正确")
} }
return nil return nil
} }
...@@ -55,31 +55,38 @@ func auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, hand ...@@ -55,31 +55,38 @@ func auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, hand
if !ok { if !ok {
return nil, grpc.Errorf(codes.Unauthenticated, "无Token认证信息") return nil, grpc.Errorf(codes.Unauthenticated, "无Token认证信息")
} }
request_map := make(map[string]string) request_map := make(map[string]string)
s := fmt.Sprintf("%v", req) s := fmt.Sprintf("%v", req)
reqs := strings.Fields(s)
if len(reqs) > 0 {
for _, v := range reqs {
params := strings.Split(v, ":")
request_map[params[0]] = params[1]
}
}
if len(request_map) < 0 {
return nil, errors.New("请求参数为空")
}
if _, ok := request_map["appkey"]; !ok { key_r, _ := regexp.Compile(`Appkey:"(.*?)"`)
nonce_r, _ := regexp.Compile(`Nonce:"(.*?)"`)
c_r, _ := regexp.Compile(`Curtime:"(.*?)"`)
cs_r, _ := regexp.Compile(`Checksum:"(.*?)"`)
appkey := key_r.FindAllStringSubmatch(s, -1)
nonce := nonce_r.FindAllStringSubmatch(s, -1)
curtime := c_r.FindAllStringSubmatch(s, -1)
check_sum := cs_r.FindAllStringSubmatch(s, -1)
if len(appkey) < 1 {
return nil, errors.New("缺少appkey") return nil, errors.New("缺少appkey")
} }
if _, ok := request_map["nonce"]; !ok { if len(nonce) < 1 {
return nil, errors.New("缺少nonce") return nil, errors.New("缺少nonce")
} }
if _, ok := request_map["curtime"]; !ok { if len(curtime) < 1 {
return nil, errors.New("缺少nonce") return nil, errors.New("缺少curtime")
} }
if _, ok := request_map["checksum"]; !ok { if len(check_sum) < 1 {
return nil, errors.New("checksum") return nil, errors.New("缺少checksum")
} }
request_map["Appkey"] = appkey[0][1]
request_map["Nonce"] = nonce[0][1]
request_map["Curtime"] = curtime[0][1]
request_map["Checksum"] = check_sum[0][1]
if err := checksum(request_map); err != nil { if err := checksum(request_map); err != nil {
return nil, err return nil, err
} }
...@@ -97,9 +104,8 @@ func main() { ...@@ -97,9 +104,8 @@ func main() {
var opts []grpc.ServerOption var opts []grpc.ServerOption
opts = append(opts, grpc.UnaryInterceptor(auth)) opts = append(opts, grpc.UnaryInterceptor(auth))
s := grpc.NewServer(opts...) s := grpc.NewServer(opts...)
//s := grpc.NewServer()
//pb.RegisterUserServer(s, &user.UserSevice{}) pb.RegisterConfigureSeviceServer(s, &ic.ConfigureSevice{})
//pb.RegisterAppServer(s, &app.AppSevice{})
if err := s.Serve(lis); err != nil { if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err) log.Fatalf("failed to serve: %v", err)
} }
......
No preview for this file type
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0
// protoc v3.12.3
// source: u-proto/common.proto
package pb
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Common struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Appkey string `protobuf:"bytes,1,opt,name=Appkey,proto3" json:"Appkey,omitempty"`
Nonce string `protobuf:"bytes,2,opt,name=Nonce,proto3" json:"Nonce,omitempty"`
Curtime string `protobuf:"bytes,3,opt,name=Curtime,proto3" json:"Curtime,omitempty"`
Checksum string `protobuf:"bytes,4,opt,name=Checksum,proto3" json:"Checksum,omitempty"`
}
func (x *Common) Reset() {
*x = Common{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Common) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Common) ProtoMessage() {}
func (x *Common) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_common_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Common.ProtoReflect.Descriptor instead.
func (*Common) Descriptor() ([]byte, []int) {
return file_u_proto_common_proto_rawDescGZIP(), []int{0}
}
func (x *Common) GetAppkey() string {
if x != nil {
return x.Appkey
}
return ""
}
func (x *Common) GetNonce() string {
if x != nil {
return x.Nonce
}
return ""
}
func (x *Common) GetCurtime() string {
if x != nil {
return x.Curtime
}
return ""
}
func (x *Common) GetChecksum() string {
if x != nil {
return x.Checksum
}
return ""
}
var File_u_proto_common_proto protoreflect.FileDescriptor
var file_u_proto_common_proto_rawDesc = []byte{
0x0a, 0x14, 0x75, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0x6c,
0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x70, 0x70, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x41, 0x70, 0x70, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x75, 0x72, 0x74, 0x69, 0x6d,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x75, 0x72, 0x74, 0x69, 0x6d, 0x65,
0x12, 0x1a, 0x0a, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_u_proto_common_proto_rawDescOnce sync.Once
file_u_proto_common_proto_rawDescData = file_u_proto_common_proto_rawDesc
)
func file_u_proto_common_proto_rawDescGZIP() []byte {
file_u_proto_common_proto_rawDescOnce.Do(func() {
file_u_proto_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_u_proto_common_proto_rawDescData)
})
return file_u_proto_common_proto_rawDescData
}
var file_u_proto_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_u_proto_common_proto_goTypes = []interface{}{
(*Common)(nil), // 0: common.Common
}
var file_u_proto_common_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_u_proto_common_proto_init() }
func file_u_proto_common_proto_init() {
if File_u_proto_common_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_u_proto_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Common); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_u_proto_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_u_proto_common_proto_goTypes,
DependencyIndexes: file_u_proto_common_proto_depIdxs,
MessageInfos: file_u_proto_common_proto_msgTypes,
}.Build()
File_u_proto_common_proto = out.File
file_u_proto_common_proto_rawDesc = nil
file_u_proto_common_proto_goTypes = nil
file_u_proto_common_proto_depIdxs = nil
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0
// protoc v3.12.3
// source: u-proto/im_base.proto
package pb
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Public struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CompanyUserId int64 `protobuf:"varint,1,opt,name=CompanyUserId,proto3" json:"CompanyUserId,omitempty"`
MultideviceType int64 `protobuf:"varint,2,opt,name=MultideviceType,proto3" json:"MultideviceType,omitempty"`
MsgHookUrl string `protobuf:"bytes,3,opt,name=MsgHookUrl,proto3" json:"MsgHookUrl,omitempty"`
}
func (x *Public) Reset() {
*x = Public{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Public) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Public) ProtoMessage() {}
func (x *Public) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Public.ProtoReflect.Descriptor instead.
func (*Public) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{0}
}
func (x *Public) GetCompanyUserId() int64 {
if x != nil {
return x.CompanyUserId
}
return 0
}
func (x *Public) GetMultideviceType() int64 {
if x != nil {
return x.MultideviceType
}
return 0
}
func (x *Public) GetMsgHookUrl() string {
if x != nil {
return x.MsgHookUrl
}
return ""
}
type ConfigureRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Common *Common `protobuf:"bytes,1,opt,name=Common,proto3" json:"Common,omitempty"`
Public *Public `protobuf:"bytes,2,opt,name=Public,proto3" json:"Public,omitempty"`
}
func (x *ConfigureRequest) Reset() {
*x = ConfigureRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ConfigureRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureRequest) ProtoMessage() {}
func (x *ConfigureRequest) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureRequest.ProtoReflect.Descriptor instead.
func (*ConfigureRequest) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{1}
}
func (x *ConfigureRequest) GetCommon() *Common {
if x != nil {
return x.Common
}
return nil
}
func (x *ConfigureRequest) GetPublic() *Public {
if x != nil {
return x.Public
}
return nil
}
type ConfigureReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ConfigureReply) Reset() {
*x = ConfigureReply{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ConfigureReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureReply) ProtoMessage() {}
func (x *ConfigureReply) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureReply.ProtoReflect.Descriptor instead.
func (*ConfigureReply) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{2}
}
type ConfigureDelRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CompanyUserId int64 `protobuf:"varint,1,opt,name=CompanyUserId,proto3" json:"CompanyUserId,omitempty"`
Common *Common `protobuf:"bytes,2,opt,name=Common,proto3" json:"Common,omitempty"`
}
func (x *ConfigureDelRequest) Reset() {
*x = ConfigureDelRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ConfigureDelRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureDelRequest) ProtoMessage() {}
func (x *ConfigureDelRequest) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureDelRequest.ProtoReflect.Descriptor instead.
func (*ConfigureDelRequest) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{3}
}
func (x *ConfigureDelRequest) GetCompanyUserId() int64 {
if x != nil {
return x.CompanyUserId
}
return 0
}
func (x *ConfigureDelRequest) GetCommon() *Common {
if x != nil {
return x.Common
}
return nil
}
type GetAllRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Common *Common `protobuf:"bytes,1,opt,name=Common,proto3" json:"Common,omitempty"`
}
func (x *GetAllRequest) Reset() {
*x = GetAllRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAllRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAllRequest) ProtoMessage() {}
func (x *GetAllRequest) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetAllRequest.ProtoReflect.Descriptor instead.
func (*GetAllRequest) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{4}
}
func (x *GetAllRequest) GetCommon() *Common {
if x != nil {
return x.Common
}
return nil
}
type GetAllOneReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Reply *Public `protobuf:"bytes,1,opt,name=Reply,proto3" json:"Reply,omitempty"`
}
func (x *GetAllOneReply) Reset() {
*x = GetAllOneReply{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAllOneReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAllOneReply) ProtoMessage() {}
func (x *GetAllOneReply) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetAllOneReply.ProtoReflect.Descriptor instead.
func (*GetAllOneReply) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{5}
}
func (x *GetAllOneReply) GetReply() *Public {
if x != nil {
return x.Reply
}
return nil
}
type GetAllReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
GetAll []*GetAllOneReply `protobuf:"bytes,1,rep,name=GetAll,proto3" json:"GetAll,omitempty"`
}
func (x *GetAllReply) Reset() {
*x = GetAllReply{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAllReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAllReply) ProtoMessage() {}
func (x *GetAllReply) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetAllReply.ProtoReflect.Descriptor instead.
func (*GetAllReply) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{6}
}
func (x *GetAllReply) GetGetAll() []*GetAllOneReply {
if x != nil {
return x.GetAll
}
return nil
}
type UpdateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Common *Common `protobuf:"bytes,1,opt,name=Common,proto3" json:"Common,omitempty"`
Public *Public `protobuf:"bytes,2,opt,name=Public,proto3" json:"Public,omitempty"`
}
func (x *UpdateRequest) Reset() {
*x = UpdateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_im_base_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateRequest) ProtoMessage() {}
func (x *UpdateRequest) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_im_base_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateRequest.ProtoReflect.Descriptor instead.
func (*UpdateRequest) Descriptor() ([]byte, []int) {
return file_u_proto_im_base_proto_rawDescGZIP(), []int{7}
}
func (x *UpdateRequest) GetCommon() *Common {
if x != nil {
return x.Common
}
return nil
}
func (x *UpdateRequest) GetPublic() *Public {
if x != nil {
return x.Public
}
return nil
}
var File_u_proto_im_base_proto protoreflect.FileDescriptor
var file_u_proto_im_base_proto_rawDesc = []byte{
0x0a, 0x15, 0x75, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6d, 0x5f, 0x62, 0x61, 0x73,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x14, 0x75, 0x2d, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x78, 0x0a, 0x06, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x24, 0x0a, 0x0d, 0x43,
0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x03, 0x52, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49,
0x64, 0x12, 0x28, 0x0a, 0x0f, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65,
0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x4d, 0x75, 0x6c, 0x74,
0x69, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x4d,
0x73, 0x67, 0x48, 0x6f, 0x6f, 0x6b, 0x55, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0a, 0x4d, 0x73, 0x67, 0x48, 0x6f, 0x6f, 0x6b, 0x55, 0x72, 0x6c, 0x22, 0x5a, 0x0a, 0x10, 0x43,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x06, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x52,
0x06, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x22, 0x10, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x5f, 0x0a, 0x13, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x24, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x52, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x0d, 0x47, 0x65,
0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x43,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62,
0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22,
0x32, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x4f, 0x6e, 0x65, 0x52, 0x65, 0x70, 0x6c,
0x79, 0x12, 0x20, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x52, 0x05, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x22, 0x39, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70,
0x6c, 0x79, 0x12, 0x2a, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x18, 0x01, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x4f, 0x6e,
0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x52, 0x06, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x22, 0x57,
0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x06, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x52,
0x06, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x32, 0xe0, 0x01, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x75, 0x72, 0x65, 0x53, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x53,
0x65, 0x6c, 0x65, 0x63, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c,
0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65,
0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x03, 0x41,
0x64, 0x64, 0x12, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x37,
0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x12, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x75, 0x72, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
file_u_proto_im_base_proto_rawDescOnce sync.Once
file_u_proto_im_base_proto_rawDescData = file_u_proto_im_base_proto_rawDesc
)
func file_u_proto_im_base_proto_rawDescGZIP() []byte {
file_u_proto_im_base_proto_rawDescOnce.Do(func() {
file_u_proto_im_base_proto_rawDescData = protoimpl.X.CompressGZIP(file_u_proto_im_base_proto_rawDescData)
})
return file_u_proto_im_base_proto_rawDescData
}
var file_u_proto_im_base_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_u_proto_im_base_proto_goTypes = []interface{}{
(*Public)(nil), // 0: pb.Public
(*ConfigureRequest)(nil), // 1: pb.ConfigureRequest
(*ConfigureReply)(nil), // 2: pb.ConfigureReply
(*ConfigureDelRequest)(nil), // 3: pb.ConfigureDelRequest
(*GetAllRequest)(nil), // 4: pb.GetAllRequest
(*GetAllOneReply)(nil), // 5: pb.GetAllOneReply
(*GetAllReply)(nil), // 6: pb.GetAllReply
(*UpdateRequest)(nil), // 7: pb.UpdateRequest
(*Common)(nil), // 8: pb.Common
}
var file_u_proto_im_base_proto_depIdxs = []int32{
8, // 0: pb.ConfigureRequest.Common:type_name -> pb.Common
0, // 1: pb.ConfigureRequest.Public:type_name -> pb.Public
8, // 2: pb.ConfigureDelRequest.Common:type_name -> pb.Common
8, // 3: pb.GetAllRequest.Common:type_name -> pb.Common
0, // 4: pb.GetAllOneReply.Reply:type_name -> pb.Public
5, // 5: pb.GetAllReply.GetAll:type_name -> pb.GetAllOneReply
8, // 6: pb.UpdateRequest.Common:type_name -> pb.Common
0, // 7: pb.UpdateRequest.Public:type_name -> pb.Public
4, // 8: pb.ConfigureSevice.Select:input_type -> pb.GetAllRequest
1, // 9: pb.ConfigureSevice.Add:input_type -> pb.ConfigureRequest
3, // 10: pb.ConfigureSevice.Delete:input_type -> pb.ConfigureDelRequest
7, // 11: pb.ConfigureSevice.Update:input_type -> pb.UpdateRequest
6, // 12: pb.ConfigureSevice.Select:output_type -> pb.GetAllReply
2, // 13: pb.ConfigureSevice.Add:output_type -> pb.ConfigureReply
2, // 14: pb.ConfigureSevice.Delete:output_type -> pb.ConfigureReply
2, // 15: pb.ConfigureSevice.Update:output_type -> pb.ConfigureReply
12, // [12:16] is the sub-list for method output_type
8, // [8:12] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_u_proto_im_base_proto_init() }
func file_u_proto_im_base_proto_init() {
if File_u_proto_im_base_proto != nil {
return
}
file_u_proto_common_proto_init()
if !protoimpl.UnsafeEnabled {
file_u_proto_im_base_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Public); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ConfigureRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ConfigureReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ConfigureDelRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAllRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAllOneReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAllReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_im_base_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_u_proto_im_base_proto_rawDesc,
NumEnums: 0,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_u_proto_im_base_proto_goTypes,
DependencyIndexes: file_u_proto_im_base_proto_depIdxs,
MessageInfos: file_u_proto_im_base_proto_msgTypes,
}.Build()
File_u_proto_im_base_proto = out.File
file_u_proto_im_base_proto_rawDesc = nil
file_u_proto_im_base_proto_goTypes = nil
file_u_proto_im_base_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// ConfigureSeviceClient is the client API for ConfigureSevice service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ConfigureSeviceClient interface {
Select(ctx context.Context, in *GetAllRequest, opts ...grpc.CallOption) (*GetAllReply, error)
Add(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureReply, error)
Delete(ctx context.Context, in *ConfigureDelRequest, opts ...grpc.CallOption) (*ConfigureReply, error)
Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*ConfigureReply, error)
}
type configureSeviceClient struct {
cc grpc.ClientConnInterface
}
func NewConfigureSeviceClient(cc grpc.ClientConnInterface) ConfigureSeviceClient {
return &configureSeviceClient{cc}
}
func (c *configureSeviceClient) Select(ctx context.Context, in *GetAllRequest, opts ...grpc.CallOption) (*GetAllReply, error) {
out := new(GetAllReply)
err := c.cc.Invoke(ctx, "/pb.ConfigureSevice/Select", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *configureSeviceClient) Add(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureReply, error) {
out := new(ConfigureReply)
err := c.cc.Invoke(ctx, "/pb.ConfigureSevice/Add", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *configureSeviceClient) Delete(ctx context.Context, in *ConfigureDelRequest, opts ...grpc.CallOption) (*ConfigureReply, error) {
out := new(ConfigureReply)
err := c.cc.Invoke(ctx, "/pb.ConfigureSevice/Delete", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *configureSeviceClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*ConfigureReply, error) {
out := new(ConfigureReply)
err := c.cc.Invoke(ctx, "/pb.ConfigureSevice/Update", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ConfigureSeviceServer is the server API for ConfigureSevice service.
type ConfigureSeviceServer interface {
Select(context.Context, *GetAllRequest) (*GetAllReply, error)
Add(context.Context, *ConfigureRequest) (*ConfigureReply, error)
Delete(context.Context, *ConfigureDelRequest) (*ConfigureReply, error)
Update(context.Context, *UpdateRequest) (*ConfigureReply, error)
}
// UnimplementedConfigureSeviceServer can be embedded to have forward compatible implementations.
type UnimplementedConfigureSeviceServer struct {
}
func (*UnimplementedConfigureSeviceServer) Select(context.Context, *GetAllRequest) (*GetAllReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Select not implemented")
}
func (*UnimplementedConfigureSeviceServer) Add(context.Context, *ConfigureRequest) (*ConfigureReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Add not implemented")
}
func (*UnimplementedConfigureSeviceServer) Delete(context.Context, *ConfigureDelRequest) (*ConfigureReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
}
func (*UnimplementedConfigureSeviceServer) Update(context.Context, *UpdateRequest) (*ConfigureReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
}
func RegisterConfigureSeviceServer(s *grpc.Server, srv ConfigureSeviceServer) {
s.RegisterService(&_ConfigureSevice_serviceDesc, srv)
}
func _ConfigureSevice_Select_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAllRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigureSeviceServer).Select(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.ConfigureSevice/Select",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigureSeviceServer).Select(ctx, req.(*GetAllRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ConfigureSevice_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ConfigureRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigureSeviceServer).Add(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.ConfigureSevice/Add",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigureSeviceServer).Add(ctx, req.(*ConfigureRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ConfigureSevice_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ConfigureDelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigureSeviceServer).Delete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.ConfigureSevice/Delete",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigureSeviceServer).Delete(ctx, req.(*ConfigureDelRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ConfigureSevice_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ConfigureSeviceServer).Update(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.ConfigureSevice/Update",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ConfigureSeviceServer).Update(ctx, req.(*UpdateRequest))
}
return interceptor(ctx, in, info, handler)
}
var _ConfigureSevice_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.ConfigureSevice",
HandlerType: (*ConfigureSeviceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Select",
Handler: _ConfigureSevice_Select_Handler,
},
{
MethodName: "Add",
Handler: _ConfigureSevice_Add_Handler,
},
{
MethodName: "Delete",
Handler: _ConfigureSevice_Delete_Handler,
},
{
MethodName: "Update",
Handler: _ConfigureSevice_Update_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "u-proto/im_base.proto",
}
package im_configure
import (
"context"
"errors"
"im-microservice/helper"
"im-microservice/pb"
vs "im-microservice/validator_struct"
)
type ConfigureSevice struct {
pb.UnimplementedConfigureSeviceServer
}
func (cs *ConfigureSevice) Add(ctx context.Context, in *pb.ConfigureRequest) (reply *pb.ConfigureReply, err error) {
configure_add_struct := vs.NewConfigureAddStruct(in)
if err = helper.Valiator(configure_add_struct); err != nil {
return
}
// 已经添加过配置无需在添加
if _, err = helper.GetImBaseByUserId(configure_add_struct.CompanyUserId); err == nil {
err = errors.New("已经添加过配置,无需再添加")
return
}
// 添加配置
if err = helper.AddImBase(configure_add_struct); err != nil {
return
}
reply = &pb.ConfigureReply{}
return
}
func (cs *ConfigureSevice) Delete(ctx context.Context, in *pb.ConfigureDelRequest) (reply *pb.ConfigureReply, err error) {
cds := vs.NewConfigureDelStruct(in)
if err = helper.Valiator(cds); err != nil {
return
}
// 执行删除操作
if err = helper.DelConfigure(cds.CompanyUserId); err != nil {
return
}
reply = &pb.ConfigureReply{}
return
}
func (cs *ConfigureSevice) Select(ctx context.Context, in *pb.GetAllRequest) (reply *pb.GetAllReply, err error) {
reply = &pb.GetAllReply{}
configs := helper.GetConfigureAll()
if len(configs) > 0 {
for _, v := range configs {
reply.GetAll = append(reply.GetAll, &pb.GetAllOneReply{
Reply:&pb.Public{
CompanyUserId: v.CompanyUserId,
MultideviceType: v.MultideviceType,
MsgHookUrl: v.MsgHookUrl,
},
})
}
}
return
}
func (cs *ConfigureSevice) Update(ctx context.Context, in *pb.UpdateRequest) (reply *pb.ConfigureReply, err error) {
configure_add_struct := vs.NewConfigureUpdateStruct(in)
if err = helper.Valiator(configure_add_struct); err != nil {
return
}
// 更新数据
if err = helper.UpdateConfiguer(configure_add_struct); err != nil {
return
}
reply = &pb.ConfigureReply{}
return
}
syntax = "proto3";
package pb;
message Common {
string Appkey = 1;
string Nonce = 2;
string Curtime = 3;
string Checksum = 4;
}
\ No newline at end of file
syntax = "proto3";
package pb;
import "u-proto/common.proto";
message Public {
int64 CompanyUserId = 1;
int64 MultideviceType = 2;
string MsgHookUrl = 3;
}
message ConfigureRequest {
Common Common = 1;
Public Public = 2;
}
message ConfigureReply {}
message ConfigureDelRequest {
int64 CompanyUserId = 1;
Common Common = 2;
}
message GetAllRequest {
Common Common = 1;
}
message GetAllOneReply {
Public Reply = 1;
}
message GetAllReply {
repeated GetAllOneReply GetAll = 1;
}
message UpdateRequest {
Common Common = 1;
Public Public = 2;
}
service ConfigureSevice{
rpc Select(GetAllRequest) returns(GetAllReply) {}
rpc Add (ConfigureRequest) returns(ConfigureReply) {}
rpc Delete(ConfigureDelRequest) returns(ConfigureReply) {}
rpc Update(UpdateRequest) returns(ConfigureReply) {}
}
package validator_struct
import "im-microservice/pb"
type ConfigureAddStruct struct {
CompanyUserId int64 `validate:"required,numeric"`
MultideviceType int64 `validate:"required,numeric"`
MsgHookUrl string `validate:"required"`
}
type ConfigureUpdateStruct struct {
CompanyUserId int64 `validate:"required,numeric"`
MultideviceType int64
MsgHookUrl string
}
type ConfigureDelStruct struct {
CompanyUserId int64 `validate:"required,numeric"`
}
func NewConfigureAddStruct(in *pb.ConfigureRequest) *ConfigureAddStruct {
return &ConfigureAddStruct{
CompanyUserId: in.Public.GetCompanyUserId(),
MultideviceType: in.Public.GetMultideviceType(),
MsgHookUrl: in.Public.GetMsgHookUrl(),
}
}
func NewConfigureDelStruct(in *pb.ConfigureDelRequest) *ConfigureDelStruct {
return &ConfigureDelStruct{CompanyUserId: in.GetCompanyUserId()}
}
func NewConfigureUpdateStruct(in *pb.UpdateRequest) *ConfigureUpdateStruct {
return &ConfigureUpdateStruct{
CompanyUserId: in.Public.GetCompanyUserId(),
MultideviceType: in.Public.GetMultideviceType(),
MsgHookUrl: in.Public.GetMsgHookUrl(),
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment