Documentation ¶
Overview ¶
@Author: Ciusyan 2023/1/25
Index ¶
- Constants
- Variables
- func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
- type LoginAndRegisterRequest
- func (*LoginAndRegisterRequest) Descriptor() ([]byte, []int)deprecated
- func (x *LoginAndRegisterRequest) GetPassword() string
- func (x *LoginAndRegisterRequest) GetUsername() string
- func (r *LoginAndRegisterRequest) Hash() *LoginAndRegisterRequest
- func (*LoginAndRegisterRequest) ProtoMessage()
- func (x *LoginAndRegisterRequest) ProtoReflect() protoreflect.Message
- func (x *LoginAndRegisterRequest) Reset()
- func (x *LoginAndRegisterRequest) String() string
- func (r *LoginAndRegisterRequest) Validate() error
- type ServiceClient
- type ServiceServer
- type TokenResponse
- func (*TokenResponse) Descriptor() ([]byte, []int)deprecated
- func (x *TokenResponse) GetToken() string
- func (x *TokenResponse) GetUserId() int64
- func (*TokenResponse) ProtoMessage()
- func (x *TokenResponse) ProtoReflect() protoreflect.Message
- func (x *TokenResponse) Reset()
- func (x *TokenResponse) String() string
- type UnimplementedServiceServer
- func (UnimplementedServiceServer) Login(context.Context, *LoginAndRegisterRequest) (*TokenResponse, error)
- func (UnimplementedServiceServer) Register(context.Context, *LoginAndRegisterRequest) (*TokenResponse, error)
- func (UnimplementedServiceServer) UserInfo(context.Context, *UserInfoRequest) (*UserInfoResponse, error)
- func (UnimplementedServiceServer) UserMap(context.Context, *UserMapRequest) (*UserMapResponse, error)
- type UnsafeServiceServer
- type User
- func (*User) Descriptor() ([]byte, []int)deprecated
- func (x *User) GetAvatar() string
- func (x *User) GetBackgroundImage() string
- func (x *User) GetFavoriteCount() int64
- func (x *User) GetFollowCount() int64
- func (x *User) GetFollowerCount() int64
- func (x *User) GetId() int64
- func (x *User) GetIsFollow() bool
- func (x *User) GetName() string
- func (x *User) GetSignature() string
- func (x *User) GetTotalFavorited() int64
- func (x *User) GetWorkCount() int64
- func (*User) ProtoMessage()
- func (x *User) ProtoReflect() protoreflect.Message
- func (x *User) Reset()
- func (x *User) String() string
- type UserInfoRequest
- func (*UserInfoRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UserInfoRequest) GetToken() string
- func (x *UserInfoRequest) GetUserId() int64
- func (*UserInfoRequest) ProtoMessage()
- func (x *UserInfoRequest) ProtoReflect() protoreflect.Message
- func (x *UserInfoRequest) Reset()
- func (x *UserInfoRequest) String() string
- func (r *UserInfoRequest) Validate() error
- type UserInfoResponse
- type UserMapRequest
- func (*UserMapRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UserMapRequest) GetToken() string
- func (x *UserMapRequest) GetUserIds() []int64
- func (*UserMapRequest) ProtoMessage()
- func (x *UserMapRequest) ProtoReflect() protoreflect.Message
- func (x *UserMapRequest) Reset()
- func (x *UserMapRequest) String() string
- func (r *UserMapRequest) Validate() error
- type UserMapResponse
- type UserPo
- func (u *UserPo) CheckHash(data any) bool
- func (*UserPo) Descriptor() ([]byte, []int)deprecated
- func (x *UserPo) GetId() int64
- func (x *UserPo) GetPassword() string
- func (x *UserPo) GetUsername() string
- func (po *UserPo) Po2vo() *User
- func (*UserPo) ProtoMessage()
- func (x *UserPo) ProtoReflect() protoreflect.Message
- func (x *UserPo) Reset()
- func (x *UserPo) String() string
- func (*UserPo) TableName() string
Constants ¶
const (
AppName = "user"
)
Variables ¶
var File_apps_user_pb_user_proto protoreflect.FileDescriptor
var Service_ServiceDesc = grpc.ServiceDesc{ ServiceName: "dousheng.user.Service", HandlerType: (*ServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Register", Handler: _Service_Register_Handler, }, { MethodName: "Login", Handler: _Service_Login_Handler, }, { MethodName: "UserInfo", Handler: _Service_UserInfo_Handler, }, { MethodName: "UserMap", Handler: _Service_UserMap_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "apps/user/pb/user.proto", }
Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterServiceServer ¶
func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
Types ¶
type LoginAndRegisterRequest ¶
type LoginAndRegisterRequest struct { // 用户名【注册的话,最长32个字符】 // @gotags: json:"username" form:"username" binding:"required,max=32" validate:"required,max=32" Username string `` /* 128-byte string literal not displayed */ // 密码 // @gotags: json:"password" form:"password" binding:"required,max=32" validate:"required,max=32" Password string `` /* 128-byte string literal not displayed */ // contains filtered or unexported fields }
用户注册 & 登录 的接口请求 model
func NewLoginAndRegisterRequest ¶
func NewLoginAndRegisterRequest() *LoginAndRegisterRequest
func (*LoginAndRegisterRequest) Descriptor
deprecated
func (*LoginAndRegisterRequest) Descriptor() ([]byte, []int)
Deprecated: Use LoginAndRegisterRequest.ProtoReflect.Descriptor instead.
func (*LoginAndRegisterRequest) GetPassword ¶
func (x *LoginAndRegisterRequest) GetPassword() string
func (*LoginAndRegisterRequest) GetUsername ¶
func (x *LoginAndRegisterRequest) GetUsername() string
func (*LoginAndRegisterRequest) Hash ¶
func (r *LoginAndRegisterRequest) Hash() *LoginAndRegisterRequest
Hash 将敏感信息做Hash
func (*LoginAndRegisterRequest) ProtoMessage ¶
func (*LoginAndRegisterRequest) ProtoMessage()
func (*LoginAndRegisterRequest) ProtoReflect ¶
func (x *LoginAndRegisterRequest) ProtoReflect() protoreflect.Message
func (*LoginAndRegisterRequest) Reset ¶
func (x *LoginAndRegisterRequest) Reset()
func (*LoginAndRegisterRequest) String ¶
func (x *LoginAndRegisterRequest) String() string
func (*LoginAndRegisterRequest) Validate ¶
func (r *LoginAndRegisterRequest) Validate() error
Validate 参数校验
type ServiceClient ¶
type ServiceClient interface { // 用户注册 Register(ctx context.Context, in *LoginAndRegisterRequest, opts ...grpc.CallOption) (*TokenResponse, error) // 用户登录 Login(ctx context.Context, in *LoginAndRegisterRequest, opts ...grpc.CallOption) (*TokenResponse, error) // 获取用户信息 UserInfo(ctx context.Context, in *UserInfoRequest, opts ...grpc.CallOption) (*UserInfoResponse, error) // 获取用户信息 map[userId] = User UserMap(ctx context.Context, in *UserMapRequest, opts ...grpc.CallOption) (*UserMapResponse, error) }
ServiceClient is the client API for Service 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.
func NewServiceClient ¶
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient
type ServiceServer ¶
type ServiceServer interface { // 用户注册 Register(context.Context, *LoginAndRegisterRequest) (*TokenResponse, error) // 用户登录 Login(context.Context, *LoginAndRegisterRequest) (*TokenResponse, error) // 获取用户信息 UserInfo(context.Context, *UserInfoRequest) (*UserInfoResponse, error) // 获取用户信息 map[userId] = User UserMap(context.Context, *UserMapRequest) (*UserMapResponse, error) // contains filtered or unexported methods }
ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility
type TokenResponse ¶
type TokenResponse struct { // 用户ID // @gotags: json:"user_id" UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id"` // 用户鉴权Token // @gotags: json:"token" Token string `protobuf:"bytes,4,opt,name=token,proto3" json:"token"` // contains filtered or unexported fields }
用户注册 & 登录 的接口响应 model
func NewTokenResponse ¶
func NewTokenResponse(id int64, token string) *TokenResponse
func (*TokenResponse) Descriptor
deprecated
func (*TokenResponse) Descriptor() ([]byte, []int)
Deprecated: Use TokenResponse.ProtoReflect.Descriptor instead.
func (*TokenResponse) GetToken ¶
func (x *TokenResponse) GetToken() string
func (*TokenResponse) GetUserId ¶
func (x *TokenResponse) GetUserId() int64
func (*TokenResponse) ProtoMessage ¶
func (*TokenResponse) ProtoMessage()
func (*TokenResponse) ProtoReflect ¶
func (x *TokenResponse) ProtoReflect() protoreflect.Message
func (*TokenResponse) Reset ¶
func (x *TokenResponse) Reset()
func (*TokenResponse) String ¶
func (x *TokenResponse) String() string
type UnimplementedServiceServer ¶
type UnimplementedServiceServer struct { }
UnimplementedServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedServiceServer) Login ¶
func (UnimplementedServiceServer) Login(context.Context, *LoginAndRegisterRequest) (*TokenResponse, error)
func (UnimplementedServiceServer) Register ¶
func (UnimplementedServiceServer) Register(context.Context, *LoginAndRegisterRequest) (*TokenResponse, error)
func (UnimplementedServiceServer) UserInfo ¶
func (UnimplementedServiceServer) UserInfo(context.Context, *UserInfoRequest) (*UserInfoResponse, error)
func (UnimplementedServiceServer) UserMap ¶
func (UnimplementedServiceServer) UserMap(context.Context, *UserMapRequest) (*UserMapResponse, error)
type UnsafeServiceServer ¶
type UnsafeServiceServer interface {
// contains filtered or unexported methods
}
UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ServiceServer will result in compilation errors.
type User ¶
type User struct { // @gotags: json:"id" Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id"` // 用户id // @gotags: json:"name" Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name"` // 用户名称 // @gotags: json:"follow_count" FollowCount *int64 `protobuf:"varint,3,opt,name=follow_count,json=followCount,proto3,oneof" json:"follow_count"` // 关注总数 // @gotags: json:"follower_count" FollowerCount *int64 `protobuf:"varint,4,opt,name=follower_count,json=followerCount,proto3,oneof" json:"follower_count"` // 粉丝总数 // @gotags: json:"is_follow" IsFollow bool `protobuf:"varint,5,opt,name=is_follow,json=isFollow,proto3" json:"is_follow"` // true-已关注,false-未关 // @gotags: json:"avatar" Avatar *string `protobuf:"bytes,6,opt,name=avatar,proto3,oneof" json:"avatar"` //用户头像 // @gotags: json:"background_image" BackgroundImage *string `protobuf:"bytes,7,opt,name=background_image,json=backgroundImage,proto3,oneof" json:"background_image"` //用户个人页顶部大图 // @gotags: json:"signature" Signature *string `protobuf:"bytes,8,opt,name=signature,proto3,oneof" json:"signature"` //个人简介 // @gotags: json:"total_favorited" TotalFavorited *int64 `protobuf:"varint,9,opt,name=total_favorited,json=totalFavorited,proto3,oneof" json:"total_favorited"` //获赞数量 // @gotags: json:"work_count" WorkCount *int64 `protobuf:"varint,10,opt,name=work_count,json=workCount,proto3,oneof" json:"work_count"` //作品数 // @gotags: json:"favorite_count" FavoriteCount *int64 `protobuf:"varint,11,opt,name=favorite_count,json=favoriteCount,proto3,oneof" json:"favorite_count"` //点赞数量 // contains filtered or unexported fields }
调用用户信息 时返回的User
func NewDefaultUser ¶
func NewDefaultUser() *User
func (*User) Descriptor
deprecated
func (*User) GetBackgroundImage ¶
func (*User) GetFavoriteCount ¶
func (*User) GetFollowCount ¶
func (*User) GetFollowerCount ¶
func (*User) GetIsFollow ¶
func (*User) GetSignature ¶
func (*User) GetTotalFavorited ¶
func (*User) GetWorkCount ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
type UserInfoRequest ¶
type UserInfoRequest struct { // 用户ID // @gotags: json:"user_id" form:"user_id" validate:"required" binding:"required" UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id" form:"user_id" validate:"required" binding:"required"` // 用户鉴权Token [注:这里用 validate,是因为内部方法也必须要用到 Token,并不是所有 token 都 validate] // @gotags: json:"token" form:"token" binding:"required" validate:"required" Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token" form:"token" binding:"required" validate:"required"` // contains filtered or unexported fields }
获取用户信息 的接口请求 model
func NewUserInfoRequest ¶
func NewUserInfoRequest() *UserInfoRequest
func (*UserInfoRequest) Descriptor
deprecated
func (*UserInfoRequest) Descriptor() ([]byte, []int)
Deprecated: Use UserInfoRequest.ProtoReflect.Descriptor instead.
func (*UserInfoRequest) GetToken ¶
func (x *UserInfoRequest) GetToken() string
func (*UserInfoRequest) GetUserId ¶
func (x *UserInfoRequest) GetUserId() int64
func (*UserInfoRequest) ProtoMessage ¶
func (*UserInfoRequest) ProtoMessage()
func (*UserInfoRequest) ProtoReflect ¶
func (x *UserInfoRequest) ProtoReflect() protoreflect.Message
func (*UserInfoRequest) Reset ¶
func (x *UserInfoRequest) Reset()
func (*UserInfoRequest) String ¶
func (x *UserInfoRequest) String() string
func (*UserInfoRequest) Validate ¶
func (r *UserInfoRequest) Validate() error
type UserInfoResponse ¶
type UserInfoResponse struct { // 用户信息 // @gotags: json:"user" User *User `protobuf:"bytes,3,opt,name=user,proto3" json:"user"` // contains filtered or unexported fields }
获取用户信息 的接口响应 model
func NewUserInfoResponse ¶
func NewUserInfoResponse() *UserInfoResponse
func (*UserInfoResponse) Descriptor
deprecated
func (*UserInfoResponse) Descriptor() ([]byte, []int)
Deprecated: Use UserInfoResponse.ProtoReflect.Descriptor instead.
func (*UserInfoResponse) GetUser ¶
func (x *UserInfoResponse) GetUser() *User
func (*UserInfoResponse) ProtoMessage ¶
func (*UserInfoResponse) ProtoMessage()
func (*UserInfoResponse) ProtoReflect ¶
func (x *UserInfoResponse) ProtoReflect() protoreflect.Message
func (*UserInfoResponse) Reset ¶
func (x *UserInfoResponse) Reset()
func (*UserInfoResponse) String ¶
func (x *UserInfoResponse) String() string
type UserMapRequest ¶
type UserMapRequest struct { // 用户ID 列表 // @gotags: json:"user_ids" UserIds []int64 `protobuf:"varint,1,rep,packed,name=user_ids,json=userIds,proto3" json:"user_ids"` // 用户鉴权Token [注:这里用 validate,是因为内部方法也必须要用到 Token,并不是所有 token 都 validate] // @gotags: json:"token" validate:"required" Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token" validate:"required"` // contains filtered or unexported fields }
用户IDs
func NewUserMapRequest ¶
func NewUserMapRequest() *UserMapRequest
func (*UserMapRequest) Descriptor
deprecated
func (*UserMapRequest) Descriptor() ([]byte, []int)
Deprecated: Use UserMapRequest.ProtoReflect.Descriptor instead.
func (*UserMapRequest) GetToken ¶
func (x *UserMapRequest) GetToken() string
func (*UserMapRequest) GetUserIds ¶
func (x *UserMapRequest) GetUserIds() []int64
func (*UserMapRequest) ProtoMessage ¶
func (*UserMapRequest) ProtoMessage()
func (*UserMapRequest) ProtoReflect ¶
func (x *UserMapRequest) ProtoReflect() protoreflect.Message
func (*UserMapRequest) Reset ¶
func (x *UserMapRequest) Reset()
func (*UserMapRequest) String ¶
func (x *UserMapRequest) String() string
func (*UserMapRequest) Validate ¶
func (r *UserMapRequest) Validate() error
type UserMapResponse ¶
type UserMapResponse struct { // 用户列表:map[userId] = User // @gotags: json:"user_map" UserMap map[int64]*User `` /* 161-byte string literal not displayed */ // contains filtered or unexported fields }
用户列表:map[userId] = User
func (*UserMapResponse) Descriptor
deprecated
func (*UserMapResponse) Descriptor() ([]byte, []int)
Deprecated: Use UserMapResponse.ProtoReflect.Descriptor instead.
func (*UserMapResponse) GetUserMap ¶
func (x *UserMapResponse) GetUserMap() map[int64]*User
func (*UserMapResponse) ProtoMessage ¶
func (*UserMapResponse) ProtoMessage()
func (*UserMapResponse) ProtoReflect ¶
func (x *UserMapResponse) ProtoReflect() protoreflect.Message
func (*UserMapResponse) Reset ¶
func (x *UserMapResponse) Reset()
func (*UserMapResponse) String ¶
func (x *UserMapResponse) String() string
type UserPo ¶
type UserPo struct { // 用户ID // @gotags: json:"id" gorm:"id" Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id" gorm:"id"` // 用户名称 // @gotags: json:"username" gorm:"username" Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username" gorm:"username"` // 用户名称 // @gotags: json:"password" gorm:"password" Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password" gorm:"password"` // contains filtered or unexported fields }
与数据库对应的 PO 对象
func NewDefaultUserPo ¶
func NewDefaultUserPo() *UserPo
func NewUserPo ¶
func NewUserPo(req *LoginAndRegisterRequest) *UserPo
func (*UserPo) Descriptor
deprecated
func (*UserPo) GetPassword ¶
func (*UserPo) GetUsername ¶
func (*UserPo) ProtoMessage ¶
func (*UserPo) ProtoMessage()
func (*UserPo) ProtoReflect ¶
func (x *UserPo) ProtoReflect() protoreflect.Message