init: init refactor

This commit is contained in:
Blizzard
2026-04-27 00:02:18 +08:00
commit e515f6a287
360 changed files with 30713 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
Name: user.rpc
ListenOn: 0.0.0.0:9101
Etcd:
Hosts:
- 192.168.100.127:2379
Key: user.rpc
# MySQL
DB:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
# Redis
Cache:
- Host: 127.0.0.1:6379
Pass: sundynix
Type: node
# JWT
JwtAuth:
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872
AccessExpire: 7200
# 微信小程序配置
WxMini:
AppId: wxb463820bf36dd5d6
AppSecret: 731784a74c76c6d31fa00bb847af2c7d
+23
View File
@@ -0,0 +1,23 @@
package config
import "github.com/zeromicro/go-zero/zrpc"
type Config struct {
zrpc.RpcServerConf
DB struct {
DataSource string
}
Cache []struct {
Host string
Pass string
Type string
}
JwtAuth struct {
AccessSecret string
AccessExpire int64
}
WxMini struct {
AppId string
AppSecret string
}
}
@@ -0,0 +1,81 @@
package logic
import (
"context"
"errors"
"sundynix-micro-go/app/user/model"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
"sundynix-micro-go/common/utils/hash"
"sundynix-micro-go/common/utils/uniqueid"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gorm.io/gorm"
)
type CreateUserLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateUserLogic {
return &CreateUserLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 创建用户
func (l *CreateUserLogic) CreateUser(in *user.CreateUserReq) (*user.CreateUserResp, error) {
// 如果有OpenID,先检查是否存在
if in.OpenId != "" {
var existing model.SundynixUser
err := l.svcCtx.DB.Where("open_id = ?", in.OpenId).First(&existing).Error
if err == nil {
// 用户已存在,更新session_key
if in.SessionKey != "" {
l.svcCtx.DB.Model(&existing).UpdateColumn("session_key", in.SessionKey)
}
return &user.CreateUserResp{
User: convertUserToProto(&existing),
}, nil
}
if !errors.Is(err, gorm.ErrRecordNotFound) {
l.Errorf("查询用户失败: %v", err)
return nil, status.Error(codes.Internal, "查询用户失败")
}
}
// 创建新用户
name := in.Name
if name == "" {
name = uniqueid.GenerateName("用户")
}
newUser := model.SundynixUser{
Name: name,
OpenID: in.OpenId,
SessionKey: in.SessionKey,
ClientID: in.ClientId,
Phone: in.Phone,
}
// 如果有密码则加密
if in.Phone != "" {
newUser.Password = hash.BcryptHash(in.Phone) // 默认密码为手机号
}
if err := l.svcCtx.DB.Create(&newUser).Error; err != nil {
l.Errorf("创建用户失败: %v", err)
return nil, status.Error(codes.Internal, "创建用户失败")
}
return &user.CreateUserResp{
User: convertUserToProto(&newUser),
}, nil
}
@@ -0,0 +1,70 @@
package logic
import (
"context"
"sundynix-micro-go/app/user/model"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gorm.io/gorm"
)
type GetUserByIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserByIdLogic {
return &GetUserByIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 根据ID获取用户信息
func (l *GetUserByIdLogic) GetUserById(in *user.GetUserByIdReq) (*user.GetUserByIdResp, error) {
var u model.SundynixUser
err := l.svcCtx.DB.Where("id = ?", in.Id).First(&u).Error
if err != nil {
if err == gorm.ErrRecordNotFound {
return nil, status.Error(codes.NotFound, "用户不存在")
}
l.Errorf("查询用户失败: %v", err)
return nil, status.Error(codes.Internal, "查询用户失败")
}
return &user.GetUserByIdResp{
User: convertUserToProto(&u),
}, nil
}
// convertUserToProto 将GORM模型转换为proto消息
func convertUserToProto(u *model.SundynixUser) *user.UserInfo {
info := &user.UserInfo{
Id: u.ID,
TenantId: u.TenantID,
ClientId: u.ClientID,
Name: u.Name,
Account: u.Account,
NickName: u.NickName,
Phone: u.Phone,
SessionKey: u.SessionKey,
UnionId: u.UnionID,
OpenId: u.OpenID,
SaOpenId: u.SaOpenID,
AvatarId: u.AvatarID,
Gender: int32(u.Gender),
CreatedAt: u.CreatedAt.Unix(),
UpdatedAt: u.UpdatedAt.Unix(),
}
if u.LastLoginAt != nil {
info.LastLoginAt = u.LastLoginAt.Unix()
}
return info
}
@@ -0,0 +1,45 @@
package logic
import (
"context"
"sundynix-micro-go/app/user/model"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gorm.io/gorm"
)
type GetUserByOpenIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserByOpenIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserByOpenIdLogic {
return &GetUserByOpenIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 根据OpenId获取用户信息
func (l *GetUserByOpenIdLogic) GetUserByOpenId(in *user.GetUserByOpenIdReq) (*user.GetUserByOpenIdResp, error) {
var u model.SundynixUser
err := l.svcCtx.DB.Where("open_id = ?", in.OpenId).First(&u).Error
if err != nil {
if err == gorm.ErrRecordNotFound {
return nil, status.Error(codes.NotFound, "用户不存在")
}
l.Errorf("查询用户失败: %v", err)
return nil, status.Error(codes.Internal, "查询用户失败")
}
return &user.GetUserByOpenIdResp{
User: convertUserToProto(&u),
}, nil
}
@@ -0,0 +1,64 @@
package logic
import (
"context"
"sundynix-micro-go/app/user/model"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
type UpdateUserLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic {
return &UpdateUserLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 更新用户信息
func (l *UpdateUserLogic) UpdateUser(in *user.UpdateUserReq) (*user.CommonResp, error) {
var u model.SundynixUser
if err := l.svcCtx.DB.Where("id = ?", in.Id).First(&u).Error; err != nil {
return nil, status.Error(codes.NotFound, "用户不存在")
}
updates := map[string]interface{}{}
if in.Name != "" {
updates["name"] = in.Name
}
if in.Account != "" {
updates["account"] = in.Account
}
if in.Phone != "" {
updates["phone"] = in.Phone
}
if in.AvatarId != "" {
updates["avatar_id"] = in.AvatarId
}
if in.NickName != "" {
updates["nick_name"] = in.NickName
}
if len(updates) > 0 {
if err := l.svcCtx.DB.Model(&u).Updates(updates).Error; err != nil {
l.Errorf("更新用户失败: %v", err)
return nil, status.Error(codes.Internal, "更新用户失败")
}
}
return &user.CommonResp{
Code: 200,
Msg: "更新成功",
}, nil
}
@@ -0,0 +1,52 @@
package logic
import (
"context"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
"github.com/zeromicro/go-zero/core/logx"
)
type VerifyTokenLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewVerifyTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VerifyTokenLogic {
return &VerifyTokenLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 验证Token有效性
func (l *VerifyTokenLogic) VerifyToken(in *user.VerifyTokenReq) (*user.VerifyTokenResp, error) {
claims, err := l.svcCtx.JWT.ParseToken(in.Token)
if err != nil {
return &user.VerifyTokenResp{
Valid: false,
}, nil
}
// 检查Redis黑名单
if l.svcCtx.Redis != nil {
blacklistKey := "jwt:blacklist:" + claims.BaseClaims.ID
val, _ := l.svcCtx.Redis.Get(l.ctx, blacklistKey).Result()
if val == in.Token {
return &user.VerifyTokenResp{
Valid: false,
}, nil
}
}
return &user.VerifyTokenResp{
Valid: true,
UserId: claims.BaseClaims.ID,
Account: claims.BaseClaims.Account,
ExpiresAt: claims.ExpiresAt.Unix(),
}, nil
}
@@ -0,0 +1,54 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.10.1
// Source: user.proto
package server
import (
"context"
"sundynix-micro-go/app/user/rpc/internal/logic"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
)
type UserServiceServer struct {
svcCtx *svc.ServiceContext
user.UnimplementedUserServiceServer
}
func NewUserServiceServer(svcCtx *svc.ServiceContext) *UserServiceServer {
return &UserServiceServer{
svcCtx: svcCtx,
}
}
// 根据ID获取用户信息
func (s *UserServiceServer) GetUserById(ctx context.Context, in *user.GetUserByIdReq) (*user.GetUserByIdResp, error) {
l := logic.NewGetUserByIdLogic(ctx, s.svcCtx)
return l.GetUserById(in)
}
// 根据OpenId获取用户信息
func (s *UserServiceServer) GetUserByOpenId(ctx context.Context, in *user.GetUserByOpenIdReq) (*user.GetUserByOpenIdResp, error) {
l := logic.NewGetUserByOpenIdLogic(ctx, s.svcCtx)
return l.GetUserByOpenId(in)
}
// 验证Token有效性
func (s *UserServiceServer) VerifyToken(ctx context.Context, in *user.VerifyTokenReq) (*user.VerifyTokenResp, error) {
l := logic.NewVerifyTokenLogic(ctx, s.svcCtx)
return l.VerifyToken(in)
}
// 创建用户
func (s *UserServiceServer) CreateUser(ctx context.Context, in *user.CreateUserReq) (*user.CreateUserResp, error) {
l := logic.NewCreateUserLogic(ctx, s.svcCtx)
return l.CreateUser(in)
}
// 更新用户信息
func (s *UserServiceServer) UpdateUser(ctx context.Context, in *user.UpdateUserReq) (*user.CommonResp, error) {
l := logic.NewUpdateUserLogic(ctx, s.svcCtx)
return l.UpdateUser(in)
}
@@ -0,0 +1,52 @@
package svc
import (
"sundynix-micro-go/app/user/model"
"sundynix-micro-go/app/user/rpc/internal/config"
"sundynix-micro-go/common/utils/jwt"
"github.com/redis/go-redis/v9"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type ServiceContext struct {
Config config.Config
DB *gorm.DB
Redis *redis.Client
JWT *jwt.JWT
}
func NewServiceContext(c config.Config) *ServiceContext {
// 初始化GORM
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
if err != nil {
logx.Errorf("连接数据库失败: %v", err)
panic(err)
}
// 自动迁移
if err := db.AutoMigrate(&model.SundynixUser{}, &model.SundynixUserRole{}); err != nil {
logx.Errorf("数据库迁移失败: %v", err)
}
// 初始化Redis
var rdb *redis.Client
if len(c.Cache) > 0 {
rdb = redis.NewClient(&redis.Options{
Addr: c.Cache[0].Host,
Password: c.Cache[0].Pass,
})
}
// 初始化JWT
jwtUtil := jwt.NewJWT(c.JwtAuth.AccessSecret)
return &ServiceContext{
Config: c,
DB: db,
Redis: rdb,
JWT: jwtUtil,
}
}
+106
View File
@@ -0,0 +1,106 @@
syntax = "proto3";
package user;
option go_package = "./user";
// ---------- 通用消息 ----------
message CommonResp {
int64 code = 1;
string msg = 2;
}
// ---------- 用户信息 ----------
message UserInfo {
string id = 1;
string tenantId = 2;
string clientId = 3;
string name = 4;
string account = 5;
string nickName = 6;
string phone = 7;
string sessionKey = 8;
string unionId = 9;
string openId = 10;
string saOpenId = 11;
string avatarId = 12;
int32 gender = 13;
string country = 14;
string province = 15;
string city = 16;
string language = 17;
int32 isVip = 18;
int64 vipExpireAt = 19;
string lastLoginIp = 20;
int64 lastLoginAt = 21;
int64 createdAt = 22;
int64 updatedAt = 23;
string avatarUrl = 24;
}
// ---------- 请求/响应消息 ----------
message GetUserByIdReq {
string id = 1;
}
message GetUserByIdResp {
UserInfo user = 1;
}
message GetUserByOpenIdReq {
string openId = 1;
}
message GetUserByOpenIdResp {
UserInfo user = 1;
}
message VerifyTokenReq {
string token = 1;
}
message VerifyTokenResp {
bool valid = 1;
string userId = 2;
string account = 3;
int64 expiresAt = 4;
}
message CreateUserReq {
string name = 1;
string openId = 2;
string sessionKey = 3;
string clientId = 4;
string phone = 5;
}
message CreateUserResp {
UserInfo user = 1;
}
message UpdateUserReq {
string id = 1;
string name = 2;
string account = 3;
string phone = 4;
string avatarId = 5;
string nickName = 6;
}
// ---------- 服务定义 ----------
service UserService {
// 根据ID获取用户信息
rpc GetUserById(GetUserByIdReq) returns (GetUserByIdResp);
// 根据OpenId获取用户信息
rpc GetUserByOpenId(GetUserByOpenIdReq) returns (GetUserByOpenIdResp);
// 验证Token有效性
rpc VerifyToken(VerifyTokenReq) returns (VerifyTokenResp);
// 创建用户
rpc CreateUser(CreateUserReq) returns (CreateUserResp);
// 更新用户信息
rpc UpdateUser(UpdateUserReq) returns (CommonResp);
}
+39
View File
@@ -0,0 +1,39 @@
package main
import (
"flag"
"fmt"
"sundynix-micro-go/app/user/rpc/internal/config"
"sundynix-micro-go/app/user/rpc/internal/server"
"sundynix-micro-go/app/user/rpc/internal/svc"
"sundynix-micro-go/app/user/rpc/user"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/user.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
user.RegisterUserServiceServer(grpcServer, server.NewUserServiceServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}
+943
View File
@@ -0,0 +1,943 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc v7.34.1
// source: pb/user.proto
package user
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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 CommonResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CommonResp) Reset() {
*x = CommonResp{}
mi := &file_pb_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommonResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CommonResp) ProtoMessage() {}
func (x *CommonResp) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CommonResp.ProtoReflect.Descriptor instead.
func (*CommonResp) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{0}
}
func (x *CommonResp) GetCode() int64 {
if x != nil {
return x.Code
}
return 0
}
func (x *CommonResp) GetMsg() string {
if x != nil {
return x.Msg
}
return ""
}
type UserInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
TenantId string `protobuf:"bytes,2,opt,name=tenantId,proto3" json:"tenantId,omitempty"`
ClientId string `protobuf:"bytes,3,opt,name=clientId,proto3" json:"clientId,omitempty"`
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
Account string `protobuf:"bytes,5,opt,name=account,proto3" json:"account,omitempty"`
NickName string `protobuf:"bytes,6,opt,name=nickName,proto3" json:"nickName,omitempty"`
Phone string `protobuf:"bytes,7,opt,name=phone,proto3" json:"phone,omitempty"`
SessionKey string `protobuf:"bytes,8,opt,name=sessionKey,proto3" json:"sessionKey,omitempty"`
UnionId string `protobuf:"bytes,9,opt,name=unionId,proto3" json:"unionId,omitempty"`
OpenId string `protobuf:"bytes,10,opt,name=openId,proto3" json:"openId,omitempty"`
SaOpenId string `protobuf:"bytes,11,opt,name=saOpenId,proto3" json:"saOpenId,omitempty"`
AvatarId string `protobuf:"bytes,12,opt,name=avatarId,proto3" json:"avatarId,omitempty"`
Gender int32 `protobuf:"varint,13,opt,name=gender,proto3" json:"gender,omitempty"`
Country string `protobuf:"bytes,14,opt,name=country,proto3" json:"country,omitempty"`
Province string `protobuf:"bytes,15,opt,name=province,proto3" json:"province,omitempty"`
City string `protobuf:"bytes,16,opt,name=city,proto3" json:"city,omitempty"`
Language string `protobuf:"bytes,17,opt,name=language,proto3" json:"language,omitempty"`
IsVip int32 `protobuf:"varint,18,opt,name=isVip,proto3" json:"isVip,omitempty"`
VipExpireAt int64 `protobuf:"varint,19,opt,name=vipExpireAt,proto3" json:"vipExpireAt,omitempty"`
LastLoginIp string `protobuf:"bytes,20,opt,name=lastLoginIp,proto3" json:"lastLoginIp,omitempty"`
LastLoginAt int64 `protobuf:"varint,21,opt,name=lastLoginAt,proto3" json:"lastLoginAt,omitempty"`
CreatedAt int64 `protobuf:"varint,22,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
UpdatedAt int64 `protobuf:"varint,23,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"`
AvatarUrl string `protobuf:"bytes,24,opt,name=avatarUrl,proto3" json:"avatarUrl,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UserInfo) Reset() {
*x = UserInfo{}
mi := &file_pb_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UserInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserInfo) ProtoMessage() {}
func (x *UserInfo) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UserInfo.ProtoReflect.Descriptor instead.
func (*UserInfo) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{1}
}
func (x *UserInfo) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *UserInfo) GetTenantId() string {
if x != nil {
return x.TenantId
}
return ""
}
func (x *UserInfo) GetClientId() string {
if x != nil {
return x.ClientId
}
return ""
}
func (x *UserInfo) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *UserInfo) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *UserInfo) GetNickName() string {
if x != nil {
return x.NickName
}
return ""
}
func (x *UserInfo) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *UserInfo) GetSessionKey() string {
if x != nil {
return x.SessionKey
}
return ""
}
func (x *UserInfo) GetUnionId() string {
if x != nil {
return x.UnionId
}
return ""
}
func (x *UserInfo) GetOpenId() string {
if x != nil {
return x.OpenId
}
return ""
}
func (x *UserInfo) GetSaOpenId() string {
if x != nil {
return x.SaOpenId
}
return ""
}
func (x *UserInfo) GetAvatarId() string {
if x != nil {
return x.AvatarId
}
return ""
}
func (x *UserInfo) GetGender() int32 {
if x != nil {
return x.Gender
}
return 0
}
func (x *UserInfo) GetCountry() string {
if x != nil {
return x.Country
}
return ""
}
func (x *UserInfo) GetProvince() string {
if x != nil {
return x.Province
}
return ""
}
func (x *UserInfo) GetCity() string {
if x != nil {
return x.City
}
return ""
}
func (x *UserInfo) GetLanguage() string {
if x != nil {
return x.Language
}
return ""
}
func (x *UserInfo) GetIsVip() int32 {
if x != nil {
return x.IsVip
}
return 0
}
func (x *UserInfo) GetVipExpireAt() int64 {
if x != nil {
return x.VipExpireAt
}
return 0
}
func (x *UserInfo) GetLastLoginIp() string {
if x != nil {
return x.LastLoginIp
}
return ""
}
func (x *UserInfo) GetLastLoginAt() int64 {
if x != nil {
return x.LastLoginAt
}
return 0
}
func (x *UserInfo) GetCreatedAt() int64 {
if x != nil {
return x.CreatedAt
}
return 0
}
func (x *UserInfo) GetUpdatedAt() int64 {
if x != nil {
return x.UpdatedAt
}
return 0
}
func (x *UserInfo) GetAvatarUrl() string {
if x != nil {
return x.AvatarUrl
}
return ""
}
type GetUserByIdReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserByIdReq) Reset() {
*x = GetUserByIdReq{}
mi := &file_pb_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserByIdReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByIdReq) ProtoMessage() {}
func (x *GetUserByIdReq) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserByIdReq.ProtoReflect.Descriptor instead.
func (*GetUserByIdReq) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{2}
}
func (x *GetUserByIdReq) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type GetUserByIdResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *UserInfo `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserByIdResp) Reset() {
*x = GetUserByIdResp{}
mi := &file_pb_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserByIdResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByIdResp) ProtoMessage() {}
func (x *GetUserByIdResp) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserByIdResp.ProtoReflect.Descriptor instead.
func (*GetUserByIdResp) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{3}
}
func (x *GetUserByIdResp) GetUser() *UserInfo {
if x != nil {
return x.User
}
return nil
}
type GetUserByOpenIdReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
OpenId string `protobuf:"bytes,1,opt,name=openId,proto3" json:"openId,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserByOpenIdReq) Reset() {
*x = GetUserByOpenIdReq{}
mi := &file_pb_user_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserByOpenIdReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByOpenIdReq) ProtoMessage() {}
func (x *GetUserByOpenIdReq) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserByOpenIdReq.ProtoReflect.Descriptor instead.
func (*GetUserByOpenIdReq) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{4}
}
func (x *GetUserByOpenIdReq) GetOpenId() string {
if x != nil {
return x.OpenId
}
return ""
}
type GetUserByOpenIdResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *UserInfo `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserByOpenIdResp) Reset() {
*x = GetUserByOpenIdResp{}
mi := &file_pb_user_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserByOpenIdResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByOpenIdResp) ProtoMessage() {}
func (x *GetUserByOpenIdResp) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserByOpenIdResp.ProtoReflect.Descriptor instead.
func (*GetUserByOpenIdResp) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{5}
}
func (x *GetUserByOpenIdResp) GetUser() *UserInfo {
if x != nil {
return x.User
}
return nil
}
type VerifyTokenReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *VerifyTokenReq) Reset() {
*x = VerifyTokenReq{}
mi := &file_pb_user_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VerifyTokenReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*VerifyTokenReq) ProtoMessage() {}
func (x *VerifyTokenReq) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use VerifyTokenReq.ProtoReflect.Descriptor instead.
func (*VerifyTokenReq) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{6}
}
func (x *VerifyTokenReq) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
type VerifyTokenResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"`
UserId string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"`
Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"`
ExpiresAt int64 `protobuf:"varint,4,opt,name=expiresAt,proto3" json:"expiresAt,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *VerifyTokenResp) Reset() {
*x = VerifyTokenResp{}
mi := &file_pb_user_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VerifyTokenResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*VerifyTokenResp) ProtoMessage() {}
func (x *VerifyTokenResp) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use VerifyTokenResp.ProtoReflect.Descriptor instead.
func (*VerifyTokenResp) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{7}
}
func (x *VerifyTokenResp) GetValid() bool {
if x != nil {
return x.Valid
}
return false
}
func (x *VerifyTokenResp) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *VerifyTokenResp) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *VerifyTokenResp) GetExpiresAt() int64 {
if x != nil {
return x.ExpiresAt
}
return 0
}
type CreateUserReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
OpenId string `protobuf:"bytes,2,opt,name=openId,proto3" json:"openId,omitempty"`
SessionKey string `protobuf:"bytes,3,opt,name=sessionKey,proto3" json:"sessionKey,omitempty"`
ClientId string `protobuf:"bytes,4,opt,name=clientId,proto3" json:"clientId,omitempty"`
Phone string `protobuf:"bytes,5,opt,name=phone,proto3" json:"phone,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateUserReq) Reset() {
*x = CreateUserReq{}
mi := &file_pb_user_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateUserReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateUserReq) ProtoMessage() {}
func (x *CreateUserReq) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateUserReq.ProtoReflect.Descriptor instead.
func (*CreateUserReq) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{8}
}
func (x *CreateUserReq) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CreateUserReq) GetOpenId() string {
if x != nil {
return x.OpenId
}
return ""
}
func (x *CreateUserReq) GetSessionKey() string {
if x != nil {
return x.SessionKey
}
return ""
}
func (x *CreateUserReq) GetClientId() string {
if x != nil {
return x.ClientId
}
return ""
}
func (x *CreateUserReq) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
type CreateUserResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
User *UserInfo `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateUserResp) Reset() {
*x = CreateUserResp{}
mi := &file_pb_user_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateUserResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateUserResp) ProtoMessage() {}
func (x *CreateUserResp) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateUserResp.ProtoReflect.Descriptor instead.
func (*CreateUserResp) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{9}
}
func (x *CreateUserResp) GetUser() *UserInfo {
if x != nil {
return x.User
}
return nil
}
type UpdateUserReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"`
Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
AvatarId string `protobuf:"bytes,5,opt,name=avatarId,proto3" json:"avatarId,omitempty"`
NickName string `protobuf:"bytes,6,opt,name=nickName,proto3" json:"nickName,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UpdateUserReq) Reset() {
*x = UpdateUserReq{}
mi := &file_pb_user_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UpdateUserReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateUserReq) ProtoMessage() {}
func (x *UpdateUserReq) ProtoReflect() protoreflect.Message {
mi := &file_pb_user_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateUserReq.ProtoReflect.Descriptor instead.
func (*UpdateUserReq) Descriptor() ([]byte, []int) {
return file_pb_user_proto_rawDescGZIP(), []int{10}
}
func (x *UpdateUserReq) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *UpdateUserReq) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *UpdateUserReq) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *UpdateUserReq) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *UpdateUserReq) GetAvatarId() string {
if x != nil {
return x.AvatarId
}
return ""
}
func (x *UpdateUserReq) GetNickName() string {
if x != nil {
return x.NickName
}
return ""
}
var File_pb_user_proto protoreflect.FileDescriptor
const file_pb_user_proto_rawDesc = "" +
"\n" +
"\rpb/user.proto\x12\x04user\"2\n" +
"\n" +
"CommonResp\x12\x12\n" +
"\x04code\x18\x01 \x01(\x03R\x04code\x12\x10\n" +
"\x03msg\x18\x02 \x01(\tR\x03msg\"\x90\x05\n" +
"\bUserInfo\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1a\n" +
"\btenantId\x18\x02 \x01(\tR\btenantId\x12\x1a\n" +
"\bclientId\x18\x03 \x01(\tR\bclientId\x12\x12\n" +
"\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" +
"\aaccount\x18\x05 \x01(\tR\aaccount\x12\x1a\n" +
"\bnickName\x18\x06 \x01(\tR\bnickName\x12\x14\n" +
"\x05phone\x18\a \x01(\tR\x05phone\x12\x1e\n" +
"\n" +
"sessionKey\x18\b \x01(\tR\n" +
"sessionKey\x12\x18\n" +
"\aunionId\x18\t \x01(\tR\aunionId\x12\x16\n" +
"\x06openId\x18\n" +
" \x01(\tR\x06openId\x12\x1a\n" +
"\bsaOpenId\x18\v \x01(\tR\bsaOpenId\x12\x1a\n" +
"\bavatarId\x18\f \x01(\tR\bavatarId\x12\x16\n" +
"\x06gender\x18\r \x01(\x05R\x06gender\x12\x18\n" +
"\acountry\x18\x0e \x01(\tR\acountry\x12\x1a\n" +
"\bprovince\x18\x0f \x01(\tR\bprovince\x12\x12\n" +
"\x04city\x18\x10 \x01(\tR\x04city\x12\x1a\n" +
"\blanguage\x18\x11 \x01(\tR\blanguage\x12\x14\n" +
"\x05isVip\x18\x12 \x01(\x05R\x05isVip\x12 \n" +
"\vvipExpireAt\x18\x13 \x01(\x03R\vvipExpireAt\x12 \n" +
"\vlastLoginIp\x18\x14 \x01(\tR\vlastLoginIp\x12 \n" +
"\vlastLoginAt\x18\x15 \x01(\x03R\vlastLoginAt\x12\x1c\n" +
"\tcreatedAt\x18\x16 \x01(\x03R\tcreatedAt\x12\x1c\n" +
"\tupdatedAt\x18\x17 \x01(\x03R\tupdatedAt\x12\x1c\n" +
"\tavatarUrl\x18\x18 \x01(\tR\tavatarUrl\" \n" +
"\x0eGetUserByIdReq\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\"5\n" +
"\x0fGetUserByIdResp\x12\"\n" +
"\x04user\x18\x01 \x01(\v2\x0e.user.UserInfoR\x04user\",\n" +
"\x12GetUserByOpenIdReq\x12\x16\n" +
"\x06openId\x18\x01 \x01(\tR\x06openId\"9\n" +
"\x13GetUserByOpenIdResp\x12\"\n" +
"\x04user\x18\x01 \x01(\v2\x0e.user.UserInfoR\x04user\"&\n" +
"\x0eVerifyTokenReq\x12\x14\n" +
"\x05token\x18\x01 \x01(\tR\x05token\"w\n" +
"\x0fVerifyTokenResp\x12\x14\n" +
"\x05valid\x18\x01 \x01(\bR\x05valid\x12\x16\n" +
"\x06userId\x18\x02 \x01(\tR\x06userId\x12\x18\n" +
"\aaccount\x18\x03 \x01(\tR\aaccount\x12\x1c\n" +
"\texpiresAt\x18\x04 \x01(\x03R\texpiresAt\"\x8d\x01\n" +
"\rCreateUserReq\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" +
"\x06openId\x18\x02 \x01(\tR\x06openId\x12\x1e\n" +
"\n" +
"sessionKey\x18\x03 \x01(\tR\n" +
"sessionKey\x12\x1a\n" +
"\bclientId\x18\x04 \x01(\tR\bclientId\x12\x14\n" +
"\x05phone\x18\x05 \x01(\tR\x05phone\"4\n" +
"\x0eCreateUserResp\x12\"\n" +
"\x04user\x18\x01 \x01(\v2\x0e.user.UserInfoR\x04user\"\x9b\x01\n" +
"\rUpdateUserReq\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x18\n" +
"\aaccount\x18\x03 \x01(\tR\aaccount\x12\x14\n" +
"\x05phone\x18\x04 \x01(\tR\x05phone\x12\x1a\n" +
"\bavatarId\x18\x05 \x01(\tR\bavatarId\x12\x1a\n" +
"\bnickName\x18\x06 \x01(\tR\bnickName2\xbb\x02\n" +
"\vUserService\x12:\n" +
"\vGetUserById\x12\x14.user.GetUserByIdReq\x1a\x15.user.GetUserByIdResp\x12F\n" +
"\x0fGetUserByOpenId\x12\x18.user.GetUserByOpenIdReq\x1a\x19.user.GetUserByOpenIdResp\x12:\n" +
"\vVerifyToken\x12\x14.user.VerifyTokenReq\x1a\x15.user.VerifyTokenResp\x127\n" +
"\n" +
"CreateUser\x12\x13.user.CreateUserReq\x1a\x14.user.CreateUserResp\x123\n" +
"\n" +
"UpdateUser\x12\x13.user.UpdateUserReq\x1a\x10.user.CommonRespB\bZ\x06./userb\x06proto3"
var (
file_pb_user_proto_rawDescOnce sync.Once
file_pb_user_proto_rawDescData []byte
)
func file_pb_user_proto_rawDescGZIP() []byte {
file_pb_user_proto_rawDescOnce.Do(func() {
file_pb_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_pb_user_proto_rawDesc), len(file_pb_user_proto_rawDesc)))
})
return file_pb_user_proto_rawDescData
}
var file_pb_user_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_pb_user_proto_goTypes = []any{
(*CommonResp)(nil), // 0: user.CommonResp
(*UserInfo)(nil), // 1: user.UserInfo
(*GetUserByIdReq)(nil), // 2: user.GetUserByIdReq
(*GetUserByIdResp)(nil), // 3: user.GetUserByIdResp
(*GetUserByOpenIdReq)(nil), // 4: user.GetUserByOpenIdReq
(*GetUserByOpenIdResp)(nil), // 5: user.GetUserByOpenIdResp
(*VerifyTokenReq)(nil), // 6: user.VerifyTokenReq
(*VerifyTokenResp)(nil), // 7: user.VerifyTokenResp
(*CreateUserReq)(nil), // 8: user.CreateUserReq
(*CreateUserResp)(nil), // 9: user.CreateUserResp
(*UpdateUserReq)(nil), // 10: user.UpdateUserReq
}
var file_pb_user_proto_depIdxs = []int32{
1, // 0: user.GetUserByIdResp.user:type_name -> user.UserInfo
1, // 1: user.GetUserByOpenIdResp.user:type_name -> user.UserInfo
1, // 2: user.CreateUserResp.user:type_name -> user.UserInfo
2, // 3: user.UserService.GetUserById:input_type -> user.GetUserByIdReq
4, // 4: user.UserService.GetUserByOpenId:input_type -> user.GetUserByOpenIdReq
6, // 5: user.UserService.VerifyToken:input_type -> user.VerifyTokenReq
8, // 6: user.UserService.CreateUser:input_type -> user.CreateUserReq
10, // 7: user.UserService.UpdateUser:input_type -> user.UpdateUserReq
3, // 8: user.UserService.GetUserById:output_type -> user.GetUserByIdResp
5, // 9: user.UserService.GetUserByOpenId:output_type -> user.GetUserByOpenIdResp
7, // 10: user.UserService.VerifyToken:output_type -> user.VerifyTokenResp
9, // 11: user.UserService.CreateUser:output_type -> user.CreateUserResp
0, // 12: user.UserService.UpdateUser:output_type -> user.CommonResp
8, // [8:13] is the sub-list for method output_type
3, // [3:8] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_pb_user_proto_init() }
func file_pb_user_proto_init() {
if File_pb_user_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_pb_user_proto_rawDesc), len(file_pb_user_proto_rawDesc)),
NumEnums: 0,
NumMessages: 11,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_pb_user_proto_goTypes,
DependencyIndexes: file_pb_user_proto_depIdxs,
MessageInfos: file_pb_user_proto_msgTypes,
}.Build()
File_pb_user_proto = out.File
file_pb_user_proto_goTypes = nil
file_pb_user_proto_depIdxs = nil
}
+283
View File
@@ -0,0 +1,283 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc v7.34.1
// source: pb/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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
UserService_GetUserById_FullMethodName = "/user.UserService/GetUserById"
UserService_GetUserByOpenId_FullMethodName = "/user.UserService/GetUserByOpenId"
UserService_VerifyToken_FullMethodName = "/user.UserService/VerifyToken"
UserService_CreateUser_FullMethodName = "/user.UserService/CreateUser"
UserService_UpdateUser_FullMethodName = "/user.UserService/UpdateUser"
)
// 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 {
// 根据ID获取用户信息
GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error)
// 根据OpenId获取用户信息
GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error)
// 验证Token有效性
VerifyToken(ctx context.Context, in *VerifyTokenReq, opts ...grpc.CallOption) (*VerifyTokenResp, error)
// 创建用户
CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error)
// 更新用户信息
UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error)
}
type userServiceClient struct {
cc grpc.ClientConnInterface
}
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
return &userServiceClient{cc}
}
func (c *userServiceClient) GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserByIdResp)
err := c.cc.Invoke(ctx, UserService_GetUserById_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserByOpenIdResp)
err := c.cc.Invoke(ctx, UserService_GetUserByOpenId_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) VerifyToken(ctx context.Context, in *VerifyTokenReq, opts ...grpc.CallOption) (*VerifyTokenResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(VerifyTokenResp)
err := c.cc.Invoke(ctx, UserService_VerifyToken_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CreateUserResp)
err := c.cc.Invoke(ctx, UserService_CreateUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommonResp)
err := c.cc.Invoke(ctx, UserService_UpdateUser_FullMethodName, in, out, cOpts...)
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 {
// 根据ID获取用户信息
GetUserById(context.Context, *GetUserByIdReq) (*GetUserByIdResp, error)
// 根据OpenId获取用户信息
GetUserByOpenId(context.Context, *GetUserByOpenIdReq) (*GetUserByOpenIdResp, error)
// 验证Token有效性
VerifyToken(context.Context, *VerifyTokenReq) (*VerifyTokenResp, error)
// 创建用户
CreateUser(context.Context, *CreateUserReq) (*CreateUserResp, error)
// 更新用户信息
UpdateUser(context.Context, *UpdateUserReq) (*CommonResp, error)
mustEmbedUnimplementedUserServiceServer()
}
// UnimplementedUserServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedUserServiceServer struct{}
func (UnimplementedUserServiceServer) GetUserById(context.Context, *GetUserByIdReq) (*GetUserByIdResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserById not implemented")
}
func (UnimplementedUserServiceServer) GetUserByOpenId(context.Context, *GetUserByOpenIdReq) (*GetUserByOpenIdResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserByOpenId not implemented")
}
func (UnimplementedUserServiceServer) VerifyToken(context.Context, *VerifyTokenReq) (*VerifyTokenResp, error) {
return nil, status.Error(codes.Unimplemented, "method VerifyToken not implemented")
}
func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserReq) (*CreateUserResp, error) {
return nil, status.Error(codes.Unimplemented, "method CreateUser not implemented")
}
func (UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserReq) (*CommonResp, error) {
return nil, status.Error(codes.Unimplemented, "method UpdateUser not implemented")
}
func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
func (UnimplementedUserServiceServer) testEmbeddedByValue() {}
// 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) {
// If the following call panics, it indicates UnimplementedUserServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&UserService_ServiceDesc, srv)
}
func _UserService_GetUserById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByIdReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).GetUserById(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_GetUserById_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUserById(ctx, req.(*GetUserByIdReq))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_GetUserByOpenId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByOpenIdReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).GetUserByOpenId(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_GetUserByOpenId_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUserByOpenId(ctx, req.(*GetUserByOpenIdReq))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_VerifyToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VerifyTokenReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).VerifyToken(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_VerifyToken_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).VerifyToken(ctx, req.(*VerifyTokenReq))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateUserReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).CreateUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_CreateUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserReq))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateUserReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).UpdateUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_UpdateUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserReq))
}
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: "GetUserById",
Handler: _UserService_GetUserById_Handler,
},
{
MethodName: "GetUserByOpenId",
Handler: _UserService_GetUserByOpenId_Handler,
},
{
MethodName: "VerifyToken",
Handler: _UserService_VerifyToken_Handler,
},
{
MethodName: "CreateUser",
Handler: _UserService_CreateUser_Handler,
},
{
MethodName: "UpdateUser",
Handler: _UserService_UpdateUser_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pb/user.proto",
}
+81
View File
@@ -0,0 +1,81 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.10.1
// Source: user.proto
package userservice
import (
"context"
"sundynix-micro-go/app/user/rpc/user"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
CommonResp = user.CommonResp
CreateUserReq = user.CreateUserReq
CreateUserResp = user.CreateUserResp
GetUserByIdReq = user.GetUserByIdReq
GetUserByIdResp = user.GetUserByIdResp
GetUserByOpenIdReq = user.GetUserByOpenIdReq
GetUserByOpenIdResp = user.GetUserByOpenIdResp
UpdateUserReq = user.UpdateUserReq
UserInfo = user.UserInfo
VerifyTokenReq = user.VerifyTokenReq
VerifyTokenResp = user.VerifyTokenResp
UserService interface {
// 根据ID获取用户信息
GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error)
// 根据OpenId获取用户信息
GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error)
// 验证Token有效性
VerifyToken(ctx context.Context, in *VerifyTokenReq, opts ...grpc.CallOption) (*VerifyTokenResp, error)
// 创建用户
CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error)
// 更新用户信息
UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error)
}
defaultUserService struct {
cli zrpc.Client
}
)
func NewUserService(cli zrpc.Client) UserService {
return &defaultUserService{
cli: cli,
}
}
// 根据ID获取用户信息
func (m *defaultUserService) GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error) {
client := user.NewUserServiceClient(m.cli.Conn())
return client.GetUserById(ctx, in, opts...)
}
// 根据OpenId获取用户信息
func (m *defaultUserService) GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error) {
client := user.NewUserServiceClient(m.cli.Conn())
return client.GetUserByOpenId(ctx, in, opts...)
}
// 验证Token有效性
func (m *defaultUserService) VerifyToken(ctx context.Context, in *VerifyTokenReq, opts ...grpc.CallOption) (*VerifyTokenResp, error) {
client := user.NewUserServiceClient(m.cli.Conn())
return client.VerifyToken(ctx, in, opts...)
}
// 创建用户
func (m *defaultUserService) CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error) {
client := user.NewUserServiceClient(m.cli.Conn())
return client.CreateUser(ctx, in, opts...)
}
// 更新用户信息
func (m *defaultUserService) UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := user.NewUserServiceClient(m.cli.Conn())
return client.UpdateUser(ctx, in, opts...)
}