diff --git a/.gitignore b/.gitignore index a3fa9d2..0271a0c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ go.work *.vscode *buf +*.idea +*.env \ No newline at end of file diff --git a/Server/grpc-server.go b/Server/grpc-server.go index 7981734..f8af9a2 100644 --- a/Server/grpc-server.go +++ b/Server/grpc-server.go @@ -34,7 +34,6 @@ func StartGrpcServer() error { grpc_health_v1.RegisterHealthServer(server, health.NewServer()) err = server.Serve(listener) if err != nil { - logrus.WithFields(logrus.Fields{ "func": "StartGrpcServer", }).Warnf("server.Serve: %s", err.Error()) diff --git a/Service/user-service.go b/Service/user-service.go index d798c18..6fcd3a5 100644 --- a/Service/user-service.go +++ b/Service/user-service.go @@ -13,9 +13,6 @@ import ( "user-srv/redis" "github.com/sirupsen/logrus" - - "user-srv/base/utils" - "user-srv/base/wechat" ) type UserService struct { diff --git a/base/model/user-model.go b/base/model/user-model.go deleted file mode 100644 index 50c8b55..0000000 --- a/base/model/user-model.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "time" - - "gorm.io/gorm" -) - -/* -通过分库来区别不同版本的产品-现在的demo逻辑 -用户在后台注册,前台扫码登录,组织ID肯定存在(后期如果开放注册-组织ID可以不存在) -*/ - -type User struct { - ID uint `gorm:"primarykey"` - UserName string `gorm:"column:user_name;type:varchar(30);comment:用户名"` - NickName string `gorm:"column:nick_name;type:varchar(40);comment:昵称"` - OpenID string `gorm:"column:openid;type:varchar(100);not null;index;comment:公众号openid" json:"-"` - Avatar string `gorm:"column:avatar;type:varchar(300);comment:头像地址"` - Mobile string `gorm:"column:mobile;type:varchar(12);not null;index ;comment:手机号"` - Email string `gorm:"column:email;type:varchar(30);comment:email"` - ProjectID string `gorm:"column:project_id;type:varchar(40);comment:项目ID"` //项目 Id admin项目 Id 为 0 - Role string `gorm:"column:role;type:varchar(15);not null;default:guest;comment:角色类型"` // sys、so、admin - CreatedAt time.Time `gorm:"autoCreateTime"` - UpdatedAt time.Time `gorm:"autoUpdateTime"` - DeletedAt gorm.DeletedAt `gorm:"index"` -} diff --git a/base/utils/snowflake.go b/base/utils/snowflake.go deleted file mode 100644 index 33aaa86..0000000 --- a/base/utils/snowflake.go +++ /dev/null @@ -1,42 +0,0 @@ -package utils - -import ( - "errors" - "time" - - sf "github.com/bwmarrin/snowflake" -) - -const ( - _dafaultStartTime = "2023-12-31" // 默认开始时间 -) - -var node *sf.Node - -// Init 雪花算法组件初始化,正常应该把雪花算法当成一个独立的服务部署 -// startTime 开始时间 -// machineID 机器id -func Init(startTime string, machineID int64) (err error) { - if machineID < 0 { - return errors.New("snowflake need machineID") - } - if len(startTime) == 0 { - startTime = _dafaultStartTime - } - var st time.Time - st, err = time.Parse("2006-01-02", startTime) - if err != nil { - return - } - sf.Epoch = st.UnixNano() / 1000000 // 时间戳的开始时间,默认从1970年开始计算 - node, err = sf.NewNode(machineID) // 机器编号,最多1024 - return -} - -func GenID() int64 { - return node.Generate().Int64() -} - -func GenIDStr() string { - return node.Generate().String() -} diff --git a/base/utils/token.go b/base/utils/token.go deleted file mode 100644 index ac8bdbc..0000000 --- a/base/utils/token.go +++ /dev/null @@ -1,80 +0,0 @@ -package utils - -import ( - "errors" - "fmt" - "reflect" - "strings" - - "github.com/gin-gonic/gin" - "github.com/go-playground/locales/zh" - ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" - zhtrans "github.com/go-playground/validator/v10/translations/zh" - "github.com/google/uuid" -) - -// 生成用户token -func NewUserToken() string { - id := uuid.Must(uuid.NewRandom()).String() - return strings.ReplaceAll(id, "-", "") -} - -// NewRequestID 新请求ID生成 -func NewRequestID(c *gin.Context) string { - if c == nil { - return uuid.Must(uuid.NewRandom()).String() - } - reqid := c.Request.Header.Get("requestid") - if reqid == "" { - reqid = uuid.Must(uuid.NewRandom()).String() - } - return reqid -} - -// 新项目ID生成 -func NewProjectID() string { - id := strings.ReplaceAll(uuid.Must(uuid.NewRandom()).String(), "-", "") - return id[6:] -} - -func NewUserID() string { - id := strings.ReplaceAll(uuid.Must(uuid.NewRandom()).String(), "-", "") - return id[4:] -} - -// NewGroupID 新组ID -func NewGroupID() string { - id := strings.ReplaceAll(uuid.Must(uuid.NewRandom()).String(), "-", "") - return id[2:] -} - -func init() { - validate = validator.New() -} - -var validate *validator.Validate - -func ValidateError(req interface{}) error { - zh := zh.New() - uni := ut.New(zh) - trans, _ := uni.GetTranslator("zh") - - validate.RegisterTagNameFunc(func(field reflect.StructField) string { - return field.Tag.Get("label") - }) - - e := zhtrans.RegisterDefaultTranslations(validate, trans) - if e != nil { - return errors.New("翻译器注册失败") - } - - err := validate.Struct(req) - - if err != nil { - for _, err := range err.(validator.ValidationErrors) { - return fmt.Errorf(err.Translate(trans)) - } - } - return nil -} diff --git a/base/wechat/menu-wechat.go b/base/wechat/menu-wechat.go deleted file mode 100644 index aaf1163..0000000 --- a/base/wechat/menu-wechat.go +++ /dev/null @@ -1,8 +0,0 @@ -package wechat - -type MenuCustomConfigRequest struct { - Content string -} - -type MenuCustomConfigResponse struct { -} diff --git a/base/wechat/message-wechat.go b/base/wechat/message-wechat.go deleted file mode 100644 index 753fe89..0000000 --- a/base/wechat/message-wechat.go +++ /dev/null @@ -1,19 +0,0 @@ -package wechat - -type MessageTemplateSendRequest struct { - ToUser string `json:"touser"` // 必须, 接受者OpenID - TemplateID string `json:"template_id"` // 必须, 模版ID - URL string `json:"url,omitempty"` // 可选, 用户点击后跳转的URL, 该URL必须处于开发者在公众平台网站中设置的域中 - Color string `json:"color,omitempty"` // 可选, 整个消息的颜色, 可以不设置 - Data map[string]*TemplateDataItem `json:"data"` // 必须, 模板数据 - -} - -type TemplateDataItem struct { - Value string `json:"value"` - Color string `json:"color,omitempty"` -} - -type MessageTemplateSendResponse struct { - Msgid int64 `json:"msgid"` -} diff --git a/base/wechat/oauth-wechat.go b/base/wechat/oauth-wechat.go deleted file mode 100644 index c3f63a3..0000000 --- a/base/wechat/oauth-wechat.go +++ /dev/null @@ -1,25 +0,0 @@ -package wechat - -type OauthUserInfoRequest struct { - ID string `json:"id"` -} - -type OauthUserInfoResponse struct { - OpenID string `json:"openid"` -} - -type OauthAuthenticationRequest struct { - Code string `json:"code"` -} - -type OauthAuthenticationResponse struct { - OpenID string `json:"openid"` - Nickname string `json:"nickname"` - Sex int32 `json:"sex"` - Province string `json:"province"` - City string `json:"city"` - Country string `json:"country"` - HeadImgURL string `json:"headimgurl"` - Privilege []string `json:"privilege"` - Unionid string `json:"unionid"` -} diff --git a/buf.gen.yaml b/buf.gen.yaml deleted file mode 100644 index 4aaa0dc..0000000 --- a/buf.gen.yaml +++ /dev/null @@ -1,19 +0,0 @@ -version: v1 -plugins: - - plugin: go - out: pb/api - opt: - - paths=source_relative - - plugin: go-grpc - out: pb/api - opt: - - paths=source_relative - - name: grpc-gateway - out: pb/api - opt: - - paths=source_relative - - generate_unbound_methods=true - - name: openapiv2 - out: pb/swagger - opt: - - logtostderr=true \ No newline at end of file diff --git a/buf.lock b/buf.lock deleted file mode 100644 index d029c4d..0000000 --- a/buf.lock +++ /dev/null @@ -1,13 +0,0 @@ -# Generated by buf. DO NOT EDIT. -version: v1 -deps: - - remote: buf.build - owner: googleapis - repository: googleapis - commit: a86849a25cc04f4dbe9b15ddddfbc488 - digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943 - - remote: buf.build - owner: grpc-ecosystem - repository: grpc-gateway - commit: 3f42134f4c564983838425bc43c7a65f - digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92 diff --git a/buf.yaml b/buf.yaml deleted file mode 100644 index a31da26..0000000 --- a/buf.yaml +++ /dev/null @@ -1,12 +0,0 @@ -version: v1 -name: buf.build/tanglaobuer/tcq -breaking: - use: - - FILE -lint: - use: - - DEFAULT -## add -deps: -- buf.build/googleapis/googleapis -- buf.build/grpc-ecosystem/grpc-gateway \ No newline at end of file diff --git a/config/env.go b/config/env.go deleted file mode 100644 index 00b3f77..0000000 --- a/config/env.go +++ /dev/null @@ -1,131 +0,0 @@ -package config - -import ( - "os" - "strconv" -) - -var ( - GrpcAddress string - Grpcport int - GrpcPort int - GatewayAddress string - ConsulName string - ConsulTag string - ConsulAddress string - LOGLEVEL string - MYSQL_HOST string - RedisHost string - RedisPassword string - RedisDB int - WECHAT_DSN string -) - -func ConfigInit() { - // 从环境变量中读取配置信息 - //logrus - LOGLEVEL = func() string { - level := os.Getenv("LOGLEVEL") - if level == "" { - level = "debug" - } - return level - }() - //grpc - GrpcAddress = func() string { - address := os.Getenv("GRPC_ADDRESS") - if address == "" { - address = "127.0.0.1" - } - return address - }() - Grpcport = func() int { - port, err := strconv.Atoi(os.Getenv("GRPC_PORT")) - if err != nil { - port = 9090 - } - return port - }() - GrpcPort = func() int { - port, err := strconv.Atoi(os.Getenv("GRPC_PORT")) - if err != nil { - port = 9090 - } - return port - }() - - //grpc-gateway - GatewayAddress = func() string { - address := os.Getenv("GATEWAY_ADDRESS") - if address == "" { - address = "127.0.0.1:8080" - } - return address - }() - - //consul - ConsulAddress = func() string { - address := os.Getenv("CONSUL_ADDRESS") - if address == "" { - address = "127.0.0.1:8500" - } - return address - }() - - ConsulName = func() string { - name := os.Getenv("CONSUL_NAME") - if name == "" { - name = "user" - } - return name - }() - ConsulTag = func() string { - tag := os.Getenv("CONSUL_TAG") - if tag == "" { - tag = "userTag" - } - return tag - }() - - //mysql - MYSQL_HOST = func() string { - host := os.Getenv("MYSQL_HOST") - if host == "" { - host = "root:123456@tcp(127.0.0.1:3306)/grpc?charset=utf8mb4&parseTime=True&loc=Local" - } - return host - }() - - //redis - RedisHost = func() string { - host := os.Getenv("REDIS_HOST") - if host == "" { - host = "127.0.0.1:6379" - } - return host - }() - RedisPassword = func() string { - password := os.Getenv("REDIS_PWD") - if password == "" { - password = "123456" - } - return password - }() - RedisDB = func() int { - db, err := strconv.Atoi(os.Getenv("REDIS_DB")) - if err != nil { - db = 0 - } - return db - }() - - //微信 - WECHAT_DSN = func() string { - dsn := os.Getenv("WECHAT_DSN") - if dsn == "" { - dsn = "127.0.0.1:9091" - } - return dsn - }() - -} diff --git a/go.mod b/go.mod index cbf464d..520bf8f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module user-srv -go 1.21.1 +go 1.21.6 require ( github.com/gin-gonic/gin v1.9.1 @@ -44,6 +44,7 @@ require ( github.com/hashicorp/serf v0.10.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/jonboulle/clockwork v0.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect diff --git a/go.sum b/go.sum index 938b2ce..e607648 100644 --- a/go.sum +++ b/go.sum @@ -128,6 +128,8 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= diff --git a/logrus.go b/logrus.go index 8380d37..8bde90e 100644 --- a/logrus.go +++ b/logrus.go @@ -10,7 +10,7 @@ import ( "github.com/sirupsen/logrus" ) -func LogAdd() { +func init() { //日志初始化 level := os.Getenv("LOGLEVEL") switch level { diff --git a/main.go b/main.go index 8405c90..25f5e29 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "log" "os" "os/signal" "time" @@ -10,13 +11,20 @@ import ( "user-srv/mysql" "user-srv/redis" + "github.com/joho/godotenv" + "github.com/sirupsen/logrus" ) func main() { - //初始化环境变量 - config.ConfigInit() - // 初始化日志logrus + + //加载.env文件-给环境变量赋值,在线版本需注释-不使用 + err := godotenv.Load() + if err != nil { + log.Fatal(err) + } + + // 初始化 if err := runInit(); err != nil { logrus.WithFields(logrus.Fields{ "func": "runInit()", @@ -41,25 +49,6 @@ func main() { func runInit() error { - //初始化consul - if err := server.ConsulGrpc(); err != nil { - return err - } - //初始化mysql - // mysql初始化 - mysql.Init(&mysql.Config{ - ConnString: config.MYSQL_HOST, - ConnMaxLifetime: 5, - MaxIdleConns: 5, - MaxOpenConns: 100, - InitTable: true, - }) - if err := mysql.InitTable(); err != nil { - logrus.WithFields(logrus.Fields{ - "func": "runInit", - }).Warnf("mysql.InitTable:%v", err) - return err - } //初始化redis if err := redis.Init(&redis.Config{ Host: config.RedisHost, @@ -74,9 +63,30 @@ func runInit() error { }).Warnf("redis.Init:%v", err) return err } + //初始化mysql + // mysql初始化 + mysql.Init(&mysql.Config{ + ConnString: os.Getenv("MYSQL_DSN"), + ConnMaxLifetime: 5, + MaxIdleConns: 5, + MaxOpenConns: 100, + InitTable: true, + }) + if err := mysql.InitTable(); err != nil { + logrus.WithFields(logrus.Fields{ + "func": "runInit", + }).Warnf("mysql.InitTable:%v", err) + return err + } + //初始化grpc go server.StartGrpcServer() + // 初始化consul + if err := server.ConsulGrpc(); err != nil { + return err + } + //初始化 grpc-gateway return server.StartGwServer() diff --git a/mysql/tables-mysql.go b/mysql/tables-mysql.go index 9e2c863..e851345 100644 --- a/mysql/tables-mysql.go +++ b/mysql/tables-mysql.go @@ -1,17 +1,10 @@ package mysql -import ( - "user-srv/base/model" -) - func InitTable() error { //不初始化表时返回 if !_conf.InitTable { return nil } - //初始表 - db, _ := New() - db.AutoMigrate(&model.User{}) //成功初始化后返回 return nil diff --git a/mysql/user-mysql.go b/mysql/user-mysql.go index def2fb7..eac349c 100644 --- a/mysql/user-mysql.go +++ b/mysql/user-mysql.go @@ -2,7 +2,7 @@ package mysql import ( "gorm.io/gorm" - "user-srv/base/model" + "myscools.me/tcq/user-base/model" ) func UserDetailByOpenId(openid *string) (user *model.User, err error) { diff --git a/pb/api/user.pb.go b/pb/api/user.pb.go deleted file mode 100644 index 4261b1a..0000000 --- a/pb/api/user.pb.go +++ /dev/null @@ -1,856 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc (unknown) -// source: user.proto - -package user - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - 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) -) - -type RegisterRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserName string `protobuf:"bytes,1,opt,name=UserName,proto3" json:"UserName,omitempty"` - Avatar string `protobuf:"bytes,2,opt,name=Avatar,proto3" json:"Avatar,omitempty"` -} - -func (x *RegisterRequest) Reset() { - *x = RegisterRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterRequest) ProtoMessage() {} - -func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_user_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 RegisterRequest.ProtoReflect.Descriptor instead. -func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{0} -} - -func (x *RegisterRequest) GetUserName() string { - if x != nil { - return x.UserName - } - return "" -} - -func (x *RegisterRequest) GetAvatar() string { - if x != nil { - return x.Avatar - } - return "" -} - -type RegisterResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *RegisterResponse) Reset() { - *x = RegisterResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse) ProtoMessage() {} - -func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_user_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 RegisterResponse.ProtoReflect.Descriptor instead. -func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{1} -} - -// 扫码登录 -type LoginRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code string `protobuf:"bytes,1,opt,name=Code,proto3" json:"Code,omitempty"` -} - -func (x *LoginRequest) Reset() { - *x = LoginRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *LoginRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginRequest) ProtoMessage() {} - -func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_user_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 LoginRequest.ProtoReflect.Descriptor instead. -func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{2} -} - -func (x *LoginRequest) GetCode() string { - if x != nil { - return x.Code - } - return "" -} - -type LoginResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"` - Orgid string `protobuf:"bytes,2,opt,name=Orgid,proto3" json:"Orgid,omitempty"` -} - -func (x *LoginResponse) Reset() { - *x = LoginResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *LoginResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginResponse) ProtoMessage() {} - -func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_user_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 LoginResponse.ProtoReflect.Descriptor instead. -func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{3} -} - -func (x *LoginResponse) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -func (x *LoginResponse) GetOrgid() string { - if x != nil { - return x.Orgid - } - return "" -} - -type GetUserInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *GetUserInfoRequest) Reset() { - *x = GetUserInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetUserInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetUserInfoRequest) ProtoMessage() {} - -func (x *GetUserInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_user_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 GetUserInfoRequest.ProtoReflect.Descriptor instead. -func (*GetUserInfoRequest) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{4} -} - -func (x *GetUserInfoRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -type GetUserInfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetUserInfoResponse) Reset() { - *x = GetUserInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetUserInfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetUserInfoResponse) ProtoMessage() {} - -func (x *GetUserInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_user_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 GetUserInfoResponse.ProtoReflect.Descriptor instead. -func (*GetUserInfoResponse) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{5} -} - -type UpdateUserInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *UpdateUserInfoRequest) Reset() { - *x = UpdateUserInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateUserInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserInfoRequest) ProtoMessage() {} - -func (x *UpdateUserInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_user_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 UpdateUserInfoRequest.ProtoReflect.Descriptor instead. -func (*UpdateUserInfoRequest) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateUserInfoRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -type UpdateUserInfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *UpdateUserInfoResponse) Reset() { - *x = UpdateUserInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateUserInfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserInfoResponse) ProtoMessage() {} - -func (x *UpdateUserInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_user_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 UpdateUserInfoResponse.ProtoReflect.Descriptor instead. -func (*UpdateUserInfoResponse) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{7} -} - -type DeleteUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *DeleteUserRequest) Reset() { - *x = DeleteUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteUserRequest) ProtoMessage() {} - -func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[8] - 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 DeleteUserRequest.ProtoReflect.Descriptor instead. -func (*DeleteUserRequest) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteUserRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -type DeleteUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DeleteUserResponse) Reset() { - *x = DeleteUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteUserResponse) ProtoMessage() {} - -func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[9] - 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 DeleteUserResponse.ProtoReflect.Descriptor instead. -func (*DeleteUserResponse) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{9} -} - -type ListUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` - PageSize int32 `protobuf:"varint,10,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` -} - -func (x *ListUserRequest) Reset() { - *x = ListUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserRequest) ProtoMessage() {} - -func (x *ListUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[10] - 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 ListUserRequest.ProtoReflect.Descriptor instead. -func (*ListUserRequest) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{10} -} - -func (x *ListUserRequest) GetPage() int32 { - if x != nil { - return x.Page - } - return 0 -} - -func (x *ListUserRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -type ListUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ListUserResponse) Reset() { - *x = ListUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserResponse) ProtoMessage() {} - -func (x *ListUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[11] - 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 ListUserResponse.ProtoReflect.Descriptor instead. -func (*ListUserResponse) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{11} -} - -var File_user_proto protoreflect.FileDescriptor - -var file_user_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, - 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x45, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x16, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x12, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x0a, 0x0c, 0x4c, - 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x43, - 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, - 0x3b, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x72, 0x67, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x72, 0x67, 0x69, 0x64, 0x22, 0x24, 0x0a, 0x12, - 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, 0x0a, 0x15, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x0a, 0x11, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x22, 0x14, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, - 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x4c, - 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, - 0x94, 0x04, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x57, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x75, 0x73, - 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x4b, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, - 0x6e, 0x12, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, - 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, - 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x59, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, - 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x0f, 0x12, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x7b, 0x69, 0x64, 0x7d, - 0x12, 0x64, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x1a, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x51, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x55, 0x73, 0x65, 0x72, 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, - 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x2a, - 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x12, 0x4b, 0x0a, 0x08, 0x4c, 0x69, 0x73, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x75, - 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, - 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x75, 0x73, 0x65, 0x72, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_user_proto_rawDescOnce sync.Once - file_user_proto_rawDescData = file_user_proto_rawDesc -) - -func file_user_proto_rawDescGZIP() []byte { - file_user_proto_rawDescOnce.Do(func() { - file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData) - }) - return file_user_proto_rawDescData -} - -var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_user_proto_goTypes = []interface{}{ - (*RegisterRequest)(nil), // 0: user.RegisterRequest - (*RegisterResponse)(nil), // 1: user.RegisterResponse - (*LoginRequest)(nil), // 2: user.LoginRequest - (*LoginResponse)(nil), // 3: user.LoginResponse - (*GetUserInfoRequest)(nil), // 4: user.GetUserInfoRequest - (*GetUserInfoResponse)(nil), // 5: user.GetUserInfoResponse - (*UpdateUserInfoRequest)(nil), // 6: user.UpdateUserInfoRequest - (*UpdateUserInfoResponse)(nil), // 7: user.UpdateUserInfoResponse - (*DeleteUserRequest)(nil), // 8: user.DeleteUserRequest - (*DeleteUserResponse)(nil), // 9: user.DeleteUserResponse - (*ListUserRequest)(nil), // 10: user.ListUserRequest - (*ListUserResponse)(nil), // 11: user.ListUserResponse -} -var file_user_proto_depIdxs = []int32{ - 0, // 0: user.UserService.Register:input_type -> user.RegisterRequest - 2, // 1: user.UserService.Login:input_type -> user.LoginRequest - 4, // 2: user.UserService.GetUserInfo:input_type -> user.GetUserInfoRequest - 6, // 3: user.UserService.UpdateUserInfo:input_type -> user.UpdateUserInfoRequest - 8, // 4: user.UserService.DeleteUser:input_type -> user.DeleteUserRequest - 10, // 5: user.UserService.ListUser:input_type -> user.ListUserRequest - 1, // 6: user.UserService.Register:output_type -> user.RegisterResponse - 3, // 7: user.UserService.Login:output_type -> user.LoginResponse - 5, // 8: user.UserService.GetUserInfo:output_type -> user.GetUserInfoResponse - 7, // 9: user.UserService.UpdateUserInfo:output_type -> user.UpdateUserInfoResponse - 9, // 10: user.UserService.DeleteUser:output_type -> user.DeleteUserResponse - 11, // 11: user.UserService.ListUser:output_type -> user.ListUserResponse - 6, // [6:12] is the sub-list for method output_type - 0, // [0:6] 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_user_proto_init() } -func file_user_proto_init() { - if File_user_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LoginRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LoginResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUserInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUserInfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserInfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteUserResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserResponse); 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_user_proto_rawDesc, - NumEnums: 0, - NumMessages: 12, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_user_proto_goTypes, - DependencyIndexes: file_user_proto_depIdxs, - MessageInfos: file_user_proto_msgTypes, - }.Build() - File_user_proto = out.File - file_user_proto_rawDesc = nil - file_user_proto_goTypes = nil - file_user_proto_depIdxs = nil -} diff --git a/pb/api/user.pb.gw.go b/pb/api/user.pb.gw.go deleted file mode 100644 index ec85daf..0000000 --- a/pb/api/user.pb.gw.go +++ /dev/null @@ -1,604 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: user.proto - -/* -Package user is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package user - -import ( - "context" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join - -func request_UserService_Register_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RegisterRequest - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Register(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_UserService_Register_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq RegisterRequest - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Register(ctx, &protoReq) - return msg, metadata, err - -} - -func request_UserService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LoginRequest - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_UserService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LoginRequest - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Login(ctx, &protoReq) - return msg, metadata, err - -} - -func request_UserService_GetUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetUserInfoRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - msg, err := client.GetUserInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_UserService_GetUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetUserInfoRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - msg, err := server.GetUserInfo(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_UserService_UpdateUserInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_UserService_UpdateUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateUserInfoRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.UpdateUserInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_UserService_UpdateUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateUserInfoRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserInfo_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.UpdateUserInfo(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_UserService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteUserRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.DeleteUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteUserRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.DeleteUser(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_UserService_ListUser_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_UserService_ListUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListUserRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_ListUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.ListUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_UserService_ListUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListUserRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_ListUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.ListUser(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". -// UnaryRPC :call UserServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserServiceHandlerFromEndpoint instead. -func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error { - - mux.Handle("POST", pattern_UserService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserService/Register", runtime.WithHTTPPathPattern("/v1/user/register")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_UserService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserService/Login", runtime.WithHTTPPathPattern("/v1/user/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_UserService_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserService/GetUserInfo", runtime.WithHTTPPathPattern("/v1/user/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_GetUserInfo_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("PUT", pattern_UserService_UpdateUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserService/UpdateUserInfo", runtime.WithHTTPPathPattern("/v1/user/update")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_UpdateUserInfo_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_UpdateUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("DELETE", pattern_UserService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserService/DeleteUser", runtime.WithHTTPPathPattern("/v1/user")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_DeleteUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_UserService_ListUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/user.UserService/ListUser", runtime.WithHTTPPathPattern("/v1/user")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_ListUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_ListUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterUserServiceHandler(ctx, mux, conn) -} - -// RegisterUserServiceHandler registers the http handlers for service UserService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterUserServiceHandlerClient(ctx, mux, NewUserServiceClient(conn)) -} - -// RegisterUserServiceHandlerClient registers the http handlers for service UserService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "UserServiceClient" to call the correct interceptors. -func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error { - - mux.Handle("POST", pattern_UserService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserService/Register", runtime.WithHTTPPathPattern("/v1/user/register")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("POST", pattern_UserService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserService/Login", runtime.WithHTTPPathPattern("/v1/user/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_UserService_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserService/GetUserInfo", runtime.WithHTTPPathPattern("/v1/user/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_GetUserInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("PUT", pattern_UserService_UpdateUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserService/UpdateUserInfo", runtime.WithHTTPPathPattern("/v1/user/update")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_UpdateUserInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_UpdateUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("DELETE", pattern_UserService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserService/DeleteUser", runtime.WithHTTPPathPattern("/v1/user")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_DeleteUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_UserService_ListUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/user.UserService/ListUser", runtime.WithHTTPPathPattern("/v1/user")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_ListUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_UserService_ListUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_UserService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "user", "register"}, "")) - - pattern_UserService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "user", "login"}, "")) - - pattern_UserService_GetUserInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "user", "id"}, "")) - - pattern_UserService_UpdateUserInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "user", "update"}, "")) - - pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "user"}, "")) - - pattern_UserService_ListUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "user"}, "")) -) - -var ( - forward_UserService_Register_0 = runtime.ForwardResponseMessage - - forward_UserService_Login_0 = runtime.ForwardResponseMessage - - forward_UserService_GetUserInfo_0 = runtime.ForwardResponseMessage - - forward_UserService_UpdateUserInfo_0 = runtime.ForwardResponseMessage - - forward_UserService_DeleteUser_0 = runtime.ForwardResponseMessage - - forward_UserService_ListUser_0 = runtime.ForwardResponseMessage -) diff --git a/pb/api/user_grpc.pb.go b/pb/api/user_grpc.pb.go deleted file mode 100644 index db16104..0000000 --- a/pb/api/user_grpc.pb.go +++ /dev/null @@ -1,297 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc (unknown) -// source: user.proto - -package user - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// UserServiceClient is the client API for UserService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type UserServiceClient interface { - // 用户注册 - Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) - // 用户登录 - Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) - // 获取用户信息 - GetUserInfo(ctx context.Context, in *GetUserInfoRequest, opts ...grpc.CallOption) (*GetUserInfoResponse, error) - // 更新用户信息 - UpdateUserInfo(ctx context.Context, in *UpdateUserInfoRequest, opts ...grpc.CallOption) (*UpdateUserInfoResponse, error) - // 删除用户信息 - DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) - // 用户列表 - ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*ListUserResponse, error) -} - -type userServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { - return &userServiceClient{cc} -} - -func (c *userServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { - out := new(RegisterResponse) - err := c.cc.Invoke(ctx, "/user.UserService/Register", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { - out := new(LoginResponse) - err := c.cc.Invoke(ctx, "/user.UserService/Login", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) GetUserInfo(ctx context.Context, in *GetUserInfoRequest, opts ...grpc.CallOption) (*GetUserInfoResponse, error) { - out := new(GetUserInfoResponse) - err := c.cc.Invoke(ctx, "/user.UserService/GetUserInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoRequest, opts ...grpc.CallOption) (*UpdateUserInfoResponse, error) { - out := new(UpdateUserInfoResponse) - err := c.cc.Invoke(ctx, "/user.UserService/UpdateUserInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) { - out := new(DeleteUserResponse) - err := c.cc.Invoke(ctx, "/user.UserService/DeleteUser", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*ListUserResponse, error) { - out := new(ListUserResponse) - err := c.cc.Invoke(ctx, "/user.UserService/ListUser", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// UserServiceServer is the server API for UserService service. -// All implementations must embed UnimplementedUserServiceServer -// for forward compatibility -type UserServiceServer interface { - // 用户注册 - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - // 用户登录 - Login(context.Context, *LoginRequest) (*LoginResponse, error) - // 获取用户信息 - GetUserInfo(context.Context, *GetUserInfoRequest) (*GetUserInfoResponse, error) - // 更新用户信息 - UpdateUserInfo(context.Context, *UpdateUserInfoRequest) (*UpdateUserInfoResponse, error) - // 删除用户信息 - DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) - // 用户列表 - ListUser(context.Context, *ListUserRequest) (*ListUserResponse, error) - mustEmbedUnimplementedUserServiceServer() -} - -// UnimplementedUserServiceServer must be embedded to have forward compatible implementations. -type UnimplementedUserServiceServer struct { -} - -func (UnimplementedUserServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (UnimplementedUserServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") -} -func (UnimplementedUserServiceServer) GetUserInfo(context.Context, *GetUserInfoRequest) (*GetUserInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetUserInfo not implemented") -} -func (UnimplementedUserServiceServer) UpdateUserInfo(context.Context, *UpdateUserInfoRequest) (*UpdateUserInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateUserInfo not implemented") -} -func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") -} -func (UnimplementedUserServiceServer) ListUser(context.Context, *ListUserRequest) (*ListUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListUser not implemented") -} -func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} - -// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to UserServiceServer will -// result in compilation errors. -type UnsafeUserServiceServer interface { - mustEmbedUnimplementedUserServiceServer() -} - -func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { - s.RegisterService(&UserService_ServiceDesc, srv) -} - -func _UserService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/user.UserService/Register", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).Register(ctx, req.(*RegisterRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LoginRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).Login(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/user.UserService/Login", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).Login(ctx, req.(*LoginRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUserInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).GetUserInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/user.UserService/GetUserInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).GetUserInfo(ctx, req.(*GetUserInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_UpdateUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateUserInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).UpdateUserInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/user.UserService/UpdateUserInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).UpdateUserInfo(ctx, req.(*UpdateUserInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).DeleteUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/user.UserService/DeleteUser", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_ListUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).ListUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/user.UserService/ListUser", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).ListUser(ctx, req.(*ListUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var UserService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "user.UserService", - HandlerType: (*UserServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Register", - Handler: _UserService_Register_Handler, - }, - { - MethodName: "Login", - Handler: _UserService_Login_Handler, - }, - { - MethodName: "GetUserInfo", - Handler: _UserService_GetUserInfo_Handler, - }, - { - MethodName: "UpdateUserInfo", - Handler: _UserService_UpdateUserInfo_Handler, - }, - { - MethodName: "DeleteUser", - Handler: _UserService_DeleteUser_Handler, - }, - { - MethodName: "ListUser", - Handler: _UserService_ListUser_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "user.proto", -} diff --git a/pb/swagger/user.swagger.json b/pb/swagger/user.swagger.json deleted file mode 100644 index 1d1d77c..0000000 --- a/pb/swagger/user.swagger.json +++ /dev/null @@ -1,292 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "user.proto", - "version": "version not set" - }, - "tags": [ - { - "name": "UserService" - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/v1/user": { - "get": { - "summary": "用户列表", - "operationId": "UserService_ListUser", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/userListUserResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "page", - "in": "query", - "required": false, - "type": "integer", - "format": "int32" - }, - { - "name": "pageSize", - "in": "query", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "tags": [ - "UserService" - ] - }, - "delete": { - "summary": "删除用户信息", - "operationId": "UserService_DeleteUser", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/userDeleteUserResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "UserService" - ] - } - }, - "/v1/user/login": { - "post": { - "summary": "用户登录", - "operationId": "UserService_Login", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/userLoginResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/userLoginRequest" - } - } - ], - "tags": [ - "UserService" - ] - } - }, - "/v1/user/register": { - "post": { - "summary": "用户注册", - "operationId": "UserService_Register", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/userRegisterResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/userRegisterRequest" - } - } - ], - "tags": [ - "UserService" - ] - } - }, - "/v1/user/update": { - "put": { - "summary": "更新用户信息", - "operationId": "UserService_UpdateUserInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/userUpdateUserInfoResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "UserService" - ] - } - }, - "/v1/user/{id}": { - "get": { - "summary": "获取用户信息", - "operationId": "UserService_GetUserInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/userGetUserInfoResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "type": "string" - } - ], - "tags": [ - "UserService" - ] - } - } - }, - "definitions": { - "protobufAny": { - "type": "object", - "properties": { - "@type": { - "type": "string" - } - }, - "additionalProperties": {} - }, - "rpcStatus": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/protobufAny" - } - } - } - }, - "userDeleteUserResponse": { - "type": "object" - }, - "userGetUserInfoResponse": { - "type": "object" - }, - "userListUserResponse": { - "type": "object" - }, - "userLoginRequest": { - "type": "object", - "properties": { - "Code": { - "type": "string" - } - }, - "title": "扫码登录" - }, - "userLoginResponse": { - "type": "object", - "properties": { - "Token": { - "type": "string" - }, - "Orgid": { - "type": "string" - } - } - }, - "userRegisterRequest": { - "type": "object", - "properties": { - "UserName": { - "type": "string" - }, - "Avatar": { - "type": "string" - } - } - }, - "userRegisterResponse": { - "type": "object" - }, - "userUpdateUserInfoResponse": { - "type": "object" - } - } -} diff --git a/redis/user-redis.go b/redis/user-redis.go deleted file mode 100644 index 08f3a65..0000000 --- a/redis/user-redis.go +++ /dev/null @@ -1,41 +0,0 @@ -package redis - -import ( - "encoding/json" - "errors" - "time" - - "github.com/sirupsen/logrus" - model "user-srv/base/model" -) - -// 存储用户的Token -func UserTokenSet(key *string, usr *model.User) error { - - err := Set(*key, usr, 7210*time.Second) - if err != nil { - logrus.WithFields(logrus.Fields{ - "func": "UserTokenSet", - }).Warnf("Set: %s", err.Error()) - return err - } - return nil -} - -// 从redis中获取用户信息,最佳实践经验建议把此代码放service层 -func UserTokenGet(token *string) (*model.User, error) { - b, err := GetBytes(token) - if err != nil { - return nil, err - } - - if b == nil { - return nil, errors.New("无效token,请重新登录!") - } - - var user *model.User - if err := json.Unmarshal(*b, &user); err != nil { - return nil, err - } - return user, nil -} diff --git a/user.proto b/user.proto deleted file mode 100644 index ff1e8a6..0000000 --- a/user.proto +++ /dev/null @@ -1,90 +0,0 @@ -syntax = "proto3"; - -import "google/api/annotations.proto"; - -package user; - -option go_package="./user"; - -service UserService { - //用户注册 - rpc Register (RegisterRequest) returns (RegisterResponse) { - option (google.api.http) = { - post: "/v1/user/register" - body: "*" - }; - } - - //用户登录 - rpc Login (LoginRequest) returns (LoginResponse) { - option (google.api.http) = { - post: "/v1/user/login" - body: "*" - }; - } - - //获取用户信息 - rpc GetUserInfo (GetUserInfoRequest) returns (GetUserInfoResponse) { - option (google.api.http) = { - get: "/v1/user/{id}" - }; - } - //更新用户信息 - rpc UpdateUserInfo (UpdateUserInfoRequest) returns (UpdateUserInfoResponse) { - option (google.api.http) = { - put: "/v1/user/update" - }; - } - //删除用户信息 - rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse) { - option (google.api.http) = { - delete: "/v1/user" - }; - } - //用户列表 - rpc ListUser (ListUserRequest) returns (ListUserResponse) { - option (google.api.http) = { - get: "/v1/user" - }; - } - -} - -message RegisterRequest { - string UserName=1; - string Avatar=2; - -} -message RegisterResponse { - -} -//扫码登录 -message LoginRequest { - string Code =1; -} -message LoginResponse { - string Token =1; - string Orgid =2; -} -message GetUserInfoRequest { - string id = 1; -} -message GetUserInfoResponse { -} -message UpdateUserInfoRequest { - string id = 1; -} -message UpdateUserInfoResponse { -} -message DeleteUserRequest { - string id = 1; -} -message DeleteUserResponse { -} -message ListUserRequest { - int32 page = 1; - int32 page_size = 10; -} -message ListUserResponse { -} -