user

package
v0.0.0-...-6a8978f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 20 Imported by: 0

README

用户管理

用户的CRUD(管理员操作), 组织管理

业务建模

用户的属性:

  • 用户域: 用户成名的namespace, 不同的公司或不同的组织
  • 用户名称
  • 用户密码
  • 用户类型: 主账号/子账号
  • profile: 性别,年龄,手机

如何创建主账号

系统初始化

Documentation

Index

Constants

View Source
const (
	AppName = "user"
)

Variables

View Source
var (
	DESCRIBE_BY_name = map[int32]string{
		0: "USER_ID",
		1: "USER_NAME",
	}
	DESCRIBE_BY_value = map[string]int32{
		"USER_ID":   0,
		"USER_NAME": 1,
	}
)

Enum value maps for DESCRIBE_BY.

View Source
var (
	Gender_name = map[int32]string{
		0: "UNKNOWN",
		1: "MALE",
		2: "FEMALE",
	}
	Gender_value = map[string]int32{
		"UNKNOWN": 0,
		"MALE":    1,
		"FEMALE":  2,
	}
)

Enum value maps for Gender.

View Source
var (
	PROVIDER_name = map[int32]string{
		0: "LOCAL",
		1: "LDAP",
	}
	PROVIDER_value = map[string]int32{
		"LOCAL": 0,
		"LDAP":  1,
	}
)

Enum value maps for PROVIDER.

View Source
var (
	TYPE_name = map[int32]string{
		0:  "SUB",
		10: "PRIMARY",
		15: "SUPPER",
	}
	TYPE_value = map[string]int32{
		"SUB":     0,
		"PRIMARY": 10,
		"SUPPER":  15,
	}
)

Enum value maps for TYPE.

View Source
var (
	CREATE_BY_name = map[int32]string{
		0: "ADMIN",
		1: "SELF",
	}
	CREATE_BY_value = map[string]int32{
		"ADMIN": 0,
		"SELF":  1,
	}
)

Enum value maps for CREATE_BY.

View Source
var File_apps_user_pb_rpc_proto protoreflect.FileDescriptor
View Source
var File_apps_user_pb_user_proto protoreflect.FileDescriptor
View Source
var RPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "go8.devcloud.mcenter.user.RPC",
	HandlerType: (*RPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryUser",
			Handler:    _RPC_QueryUser_Handler,
		},
		{
			MethodName: "DescribeUser",
			Handler:    _RPC_DescribeUser_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/user/pb/rpc.proto",
}

RPC_ServiceDesc is the grpc.ServiceDesc for RPC service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRPCServer

func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)

Types

type CREATE_BY

type CREATE_BY int32
const (
	// 管理员创建
	CREATE_BY_ADMIN CREATE_BY = 0
	// 自己注册
	CREATE_BY_SELF CREATE_BY = 1
)

func ParseCREATE_BYFromString

func ParseCREATE_BYFromString(str string) (CREATE_BY, error)

ParseCREATE_BYFromString Parse CREATE_BY from string

func (CREATE_BY) Descriptor

func (CREATE_BY) Descriptor() protoreflect.EnumDescriptor

func (CREATE_BY) Enum

func (x CREATE_BY) Enum() *CREATE_BY

func (CREATE_BY) EnumDescriptor deprecated

func (CREATE_BY) EnumDescriptor() ([]byte, []int)

Deprecated: Use CREATE_BY.Descriptor instead.

func (CREATE_BY) Equal

func (t CREATE_BY) Equal(target CREATE_BY) bool

Equal type compare

func (CREATE_BY) IsIn

func (t CREATE_BY) IsIn(targets ...CREATE_BY) bool

IsIn todo

func (CREATE_BY) MarshalJSON

func (t CREATE_BY) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (CREATE_BY) Number

func (x CREATE_BY) Number() protoreflect.EnumNumber

func (CREATE_BY) String

func (x CREATE_BY) String() string

func (CREATE_BY) Type

func (*CREATE_BY) UnmarshalJSON

func (t *CREATE_BY) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type CreateUserRequest

type CreateUserRequest struct {

	// 账号提供方
	// @gotags: json:"provider" bson:"provider"
	Provider PROVIDER `protobuf:"varint,1,opt,name=provider,proto3,enum=go8.devcloud.mcenter.user.PROVIDER" json:"provider" bson:"provider"`
	// 用户类型
	// @gotags: json:"type" bson:"type"
	Type TYPE `protobuf:"varint,2,opt,name=type,proto3,enum=go8.devcloud.mcenter.user.TYPE" json:"type" bson:"type"`
	// 创建类型
	// @gotags: json:"create_by" bson:"create_by"
	CreateBy CREATE_BY `` /* 134-byte string literal not displayed */
	// 域信息
	// @gotags: json:"domain" bson:"domain" validate:"required"
	Domain string `protobuf:"bytes,4,opt,name=domain,proto3" json:"domain" bson:"domain" validate:"required"`
	// 用户账号名称
	// @gotags: json:"username" bson:"username" validate:"required,lte=60"
	Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username" bson:"username" validate:"required,lte=60"`
	// 密码相关信息
	// @gotags: json:"password" bson:"-" validate:"required,lte=80"
	Password string `protobuf:"bytes,6,opt,name=password,proto3" json:"password" bson:"-" validate:"required,lte=80"`
	// 用户描述
	// @gotags: json:"description"
	Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description"`
	// contains filtered or unexported fields
}

CreateUserRequest 创建用户请求

func NewCreateUserRequest

func NewCreateUserRequest() *CreateUserRequest

func (*CreateUserRequest) Descriptor deprecated

func (*CreateUserRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.

func (*CreateUserRequest) GetCreateBy

func (x *CreateUserRequest) GetCreateBy() CREATE_BY

func (*CreateUserRequest) GetDescription

func (x *CreateUserRequest) GetDescription() string

func (*CreateUserRequest) GetDomain

func (x *CreateUserRequest) GetDomain() string

func (*CreateUserRequest) GetPassword

func (x *CreateUserRequest) GetPassword() string

func (*CreateUserRequest) GetProvider

func (x *CreateUserRequest) GetProvider() PROVIDER

func (*CreateUserRequest) GetType

func (x *CreateUserRequest) GetType() TYPE

func (*CreateUserRequest) GetUsername

func (x *CreateUserRequest) GetUsername() string

func (*CreateUserRequest) ProtoMessage

func (*CreateUserRequest) ProtoMessage()

func (*CreateUserRequest) ProtoReflect

func (x *CreateUserRequest) ProtoReflect() protoreflect.Message

func (*CreateUserRequest) Reset

func (x *CreateUserRequest) Reset()

func (*CreateUserRequest) String

func (x *CreateUserRequest) String() string

func (*CreateUserRequest) Validate

func (req *CreateUserRequest) Validate() error

Validate 校验请求是否合法

type DESCRIBE_BY

type DESCRIBE_BY int32
const (
	// 通过UserId查询用户
	DESCRIBE_BY_USER_ID DESCRIBE_BY = 0
	// 通过Username查询用户
	DESCRIBE_BY_USER_NAME DESCRIBE_BY = 1
)

func ParseDESCRIBE_BYFromString

func ParseDESCRIBE_BYFromString(str string) (DESCRIBE_BY, error)

ParseDESCRIBE_BYFromString Parse DESCRIBE_BY from string

func (DESCRIBE_BY) Descriptor

func (DESCRIBE_BY) Enum

func (x DESCRIBE_BY) Enum() *DESCRIBE_BY

func (DESCRIBE_BY) EnumDescriptor deprecated

func (DESCRIBE_BY) EnumDescriptor() ([]byte, []int)

Deprecated: Use DESCRIBE_BY.Descriptor instead.

func (DESCRIBE_BY) Equal

func (t DESCRIBE_BY) Equal(target DESCRIBE_BY) bool

Equal type compare

func (DESCRIBE_BY) IsIn

func (t DESCRIBE_BY) IsIn(targets ...DESCRIBE_BY) bool

IsIn todo

func (DESCRIBE_BY) MarshalJSON

func (t DESCRIBE_BY) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (DESCRIBE_BY) Number

func (x DESCRIBE_BY) Number() protoreflect.EnumNumber

func (DESCRIBE_BY) String

func (x DESCRIBE_BY) String() string

func (DESCRIBE_BY) Type

func (*DESCRIBE_BY) UnmarshalJSON

func (t *DESCRIBE_BY) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type DeleteUserRequest

type DeleteUserRequest struct {

	// 用户账号id
	// @gotags: json:"user_ids" validate:"required,lte=60"
	UserIds []string `protobuf:"bytes,2,rep,name=user_ids,json=userIds,proto3" json:"user_ids" validate:"required,lte=60"`
	// contains filtered or unexported fields
}

func (*DeleteUserRequest) Descriptor deprecated

func (*DeleteUserRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead.

func (*DeleteUserRequest) GetUserIds

func (x *DeleteUserRequest) GetUserIds() []string

func (*DeleteUserRequest) ProtoMessage

func (*DeleteUserRequest) ProtoMessage()

func (*DeleteUserRequest) ProtoReflect

func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message

func (*DeleteUserRequest) Reset

func (x *DeleteUserRequest) Reset()

func (*DeleteUserRequest) String

func (x *DeleteUserRequest) String() string

type DescribeUserRequest

type DescribeUserRequest struct {

	// 查询方式
	// @gotags: json:"describe_by"
	DescribeBy DESCRIBE_BY `protobuf:"varint,1,opt,name=describe_by,json=describeBy,proto3,enum=go8.devcloud.mcenter.user.DESCRIBE_BY" json:"describe_by"`
	// 用户账号id
	// @gotags: json:"id"
	Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"`
	// 用户账号
	// @gotags: json:"username"
	Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username"`
	// contains filtered or unexported fields
}

DescribeUserRequest 查询用户详情

func NewDescriptUserRequestWithId

func NewDescriptUserRequestWithId(id string) *DescribeUserRequest

NewDescriptUserRequestWithId 查询详情请求

func NewDescriptUserRequestWithName

func NewDescriptUserRequestWithName(username string) *DescribeUserRequest

NewDescriptUserRequestWithId 查询详情请求

func (*DescribeUserRequest) Descriptor deprecated

func (*DescribeUserRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribeUserRequest.ProtoReflect.Descriptor instead.

func (*DescribeUserRequest) GetDescribeBy

func (x *DescribeUserRequest) GetDescribeBy() DESCRIBE_BY

func (*DescribeUserRequest) GetId

func (x *DescribeUserRequest) GetId() string

func (*DescribeUserRequest) GetUsername

func (x *DescribeUserRequest) GetUsername() string

func (*DescribeUserRequest) ProtoMessage

func (*DescribeUserRequest) ProtoMessage()

func (*DescribeUserRequest) ProtoReflect

func (x *DescribeUserRequest) ProtoReflect() protoreflect.Message

func (*DescribeUserRequest) Reset

func (x *DescribeUserRequest) Reset()

func (*DescribeUserRequest) String

func (x *DescribeUserRequest) String() string

type Gender

type Gender int32
const (
	// 保密
	Gender_UNKNOWN Gender = 0
	// 男
	Gender_MALE Gender = 1
	// 女
	Gender_FEMALE Gender = 2
)

func ParseGenderFromString

func ParseGenderFromString(str string) (Gender, error)

ParseGenderFromString Parse Gender from string

func (Gender) Descriptor

func (Gender) Descriptor() protoreflect.EnumDescriptor

func (Gender) Enum

func (x Gender) Enum() *Gender

func (Gender) EnumDescriptor deprecated

func (Gender) EnumDescriptor() ([]byte, []int)

Deprecated: Use Gender.Descriptor instead.

func (Gender) Equal

func (t Gender) Equal(target Gender) bool

Equal type compare

func (Gender) IsIn

func (t Gender) IsIn(targets ...Gender) bool

IsIn todo

func (Gender) MarshalJSON

func (t Gender) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (Gender) Number

func (x Gender) Number() protoreflect.EnumNumber

func (Gender) String

func (x Gender) String() string

func (Gender) Type

func (Gender) Type() protoreflect.EnumType

func (*Gender) UnmarshalJSON

func (t *Gender) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type PROVIDER

type PROVIDER int32
const (
	// 本地数据库
	PROVIDER_LOCAL PROVIDER = 0
	// 来源LDAP
	PROVIDER_LDAP PROVIDER = 1
)

func ParsePROVIDERFromString

func ParsePROVIDERFromString(str string) (PROVIDER, error)

ParsePROVIDERFromString Parse PROVIDER from string

func (PROVIDER) Descriptor

func (PROVIDER) Descriptor() protoreflect.EnumDescriptor

func (PROVIDER) Enum

func (x PROVIDER) Enum() *PROVIDER

func (PROVIDER) EnumDescriptor deprecated

func (PROVIDER) EnumDescriptor() ([]byte, []int)

Deprecated: Use PROVIDER.Descriptor instead.

func (PROVIDER) Equal

func (t PROVIDER) Equal(target PROVIDER) bool

Equal type compare

func (PROVIDER) IsIn

func (t PROVIDER) IsIn(targets ...PROVIDER) bool

IsIn todo

func (PROVIDER) MarshalJSON

func (t PROVIDER) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (PROVIDER) Number

func (x PROVIDER) Number() protoreflect.EnumNumber

func (PROVIDER) String

func (x PROVIDER) String() string

func (PROVIDER) Type

func (*PROVIDER) UnmarshalJSON

func (t *PROVIDER) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type Password

type Password struct {

	// hash过后的密码
	// @gotags: bson:"password" json:"password,omitempty"
	Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty" bson:"password"`
	// 密码创建时间
	// @gotags: bson:"create_at" json:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// 密码更新时间
	// @gotags: bson:"update_at" json:"update_at"
	UpdateAt int64 `protobuf:"varint,3,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"`
	// 密码需要被重置
	// @gotags: bson:"need_reset" json:"need_reset"
	NeedReset bool `protobuf:"varint,4,opt,name=need_reset,json=needReset,proto3" json:"need_reset" bson:"need_reset"`
	// 需要重置的原因
	// @gotags: bson:"reset_reason" json:"reset_reason"
	ResetReason string `protobuf:"bytes,5,opt,name=reset_reason,json=resetReason,proto3" json:"reset_reason" bson:"reset_reason"`
	// 密码过期时间, 密码过期后要求用户重置密码
	// @gotags: bson:"expired_days" json:"expired_days"
	ExpiredDays uint32 `protobuf:"varint,6,opt,name=expired_days,json=expiredDays,proto3" json:"expired_days" bson:"expired_days"`
	// 密码过期前多少天开始提醒
	// @gotags: bson:"expired_remind" json:"expired_remind"
	ExpiredRemind uint32 `protobuf:"varint,7,opt,name=expired_remind,json=expiredRemind,proto3" json:"expired_remind" bson:"expired_remind"`
	// 历史密码
	// @gotags: bson:"history" json:"history,omitempty"
	History []string `protobuf:"bytes,8,rep,name=history,proto3" json:"history,omitempty" bson:"history"`
	// contains filtered or unexported fields
}

func NewHashedPassword

func NewHashedPassword(password string) (*Password, error)

NewHashedPassword 生产hash后的密码对象 bcrypt专门用于密码hash的 散列算法

func (*Password) CheckPassword

func (p *Password) CheckPassword(password string) error

CheckPassword 判断password 是否正确, 是明文的

func (*Password) Descriptor deprecated

func (*Password) Descriptor() ([]byte, []int)

Deprecated: Use Password.ProtoReflect.Descriptor instead.

func (*Password) GetCreateAt

func (x *Password) GetCreateAt() int64

func (*Password) GetExpiredDays

func (x *Password) GetExpiredDays() uint32

func (*Password) GetExpiredRemind

func (x *Password) GetExpiredRemind() uint32

func (*Password) GetHistory

func (x *Password) GetHistory() []string

func (*Password) GetNeedReset

func (x *Password) GetNeedReset() bool

func (*Password) GetPassword

func (x *Password) GetPassword() string

func (*Password) GetResetReason

func (x *Password) GetResetReason() string

func (*Password) GetUpdateAt

func (x *Password) GetUpdateAt() int64

func (*Password) ProtoMessage

func (*Password) ProtoMessage()

func (*Password) ProtoReflect

func (x *Password) ProtoReflect() protoreflect.Message

func (*Password) Reset

func (x *Password) Reset()

func (*Password) SetNeedReset

func (p *Password) SetNeedReset(format string, a ...interface{})

SetNeedReset 需要被重置

func (*Password) String

func (x *Password) String() string

type Profile

type Profile struct {

	// 用户真实姓名
	// @gotags: bson:"real_name" json:"real_name" validate:"lte=10"
	RealName string `protobuf:"bytes,1,opt,name=real_name,json=realName,proto3" json:"real_name" bson:"real_name" validate:"lte=10"`
	// 用户昵称, 用于在界面进行展示
	// @gotags: bson:"nick_name" json:"nick_name" validate:"lte=30"
	NickName string `protobuf:"bytes,2,opt,name=nick_name,json=nickName,proto3" json:"nick_name" bson:"nick_name" validate:"lte=30"`
	// 手机号码, 用户可以通过手机进行注册和密码找回, 还可以通过手机号进行登录
	// @gotags: bson:"phone" json:"phone" validate:"lte=30"
	Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone" bson:"phone" validate:"lte=30"`
	// 邮箱, 用户可以通过邮箱进行注册和照明密码
	// @gotags: bson:"email" json:"email" validate:"lte=30"
	Email string `protobuf:"bytes,4,opt,name=email,proto3" json:"email" bson:"email" validate:"lte=30"`
	// 用户住址
	// @gotags: bson:"address" json:"address" validate:"lte=120"
	Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address" bson:"address" validate:"lte=120"`
	// 性别
	// @gotags: bson:"gender" json:"gender" validate:"lte=10"
	Gender Gender `` /* 126-byte string literal not displayed */
	// 头像
	// @gotags: bson:"avatar" json:"avatar" validate:"lte=300"
	Avatar string `protobuf:"bytes,7,opt,name=avatar,proto3" json:"avatar" bson:"avatar" validate:"lte=300"`
	// 用户使用的语言
	// @gotags: bson:"language" json:"language" validate:"lte=40"
	Language string `protobuf:"bytes,8,opt,name=language,proto3" json:"language" bson:"language" validate:"lte=40"`
	// 用户所在的城市
	// @gotags: bson:"city" json:"city" validate:"lte=40"
	City string `protobuf:"bytes,9,opt,name=city,proto3" json:"city" bson:"city" validate:"lte=40"`
	// 用户所在的省
	// @gotags: bson:"province" json:"province" validate:"lte=40"
	Province string `protobuf:"bytes,10,opt,name=province,proto3" json:"province" bson:"province" validate:"lte=40"`
	// contains filtered or unexported fields
}

Profile todo

func (*Profile) Descriptor deprecated

func (*Profile) Descriptor() ([]byte, []int)

Deprecated: Use Profile.ProtoReflect.Descriptor instead.

func (*Profile) GetAddress

func (x *Profile) GetAddress() string

func (*Profile) GetAvatar

func (x *Profile) GetAvatar() string

func (*Profile) GetCity

func (x *Profile) GetCity() string

func (*Profile) GetEmail

func (x *Profile) GetEmail() string

func (*Profile) GetGender

func (x *Profile) GetGender() Gender

func (*Profile) GetLanguage

func (x *Profile) GetLanguage() string

func (*Profile) GetNickName

func (x *Profile) GetNickName() string

func (*Profile) GetPhone

func (x *Profile) GetPhone() string

func (*Profile) GetProvince

func (x *Profile) GetProvince() string

func (*Profile) GetRealName

func (x *Profile) GetRealName() string

func (*Profile) ProtoMessage

func (*Profile) ProtoMessage()

func (*Profile) ProtoReflect

func (x *Profile) ProtoReflect() protoreflect.Message

func (*Profile) Reset

func (x *Profile) Reset()

func (*Profile) String

func (x *Profile) String() string

type QueryUserRequest

type QueryUserRequest struct {

	// 分页参数
	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// 用户所属Domain
	// @gotags: json:"domain" validate:"required"
	Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain" validate:"required"`
	// 账号提供方
	// @gotags: json:"provider"
	Provider *PROVIDER `protobuf:"varint,3,opt,name=provider,proto3,enum=go8.devcloud.mcenter.user.PROVIDER,oneof" json:"provider"`
	// 用户类型
	// @gotags: json:"type"
	Type *TYPE `protobuf:"varint,4,opt,name=type,proto3,enum=go8.devcloud.mcenter.user.TYPE,oneof" json:"type"`
	// 通过Id
	// @gotags: json:"user_ids"
	UserIds []string `protobuf:"bytes,5,rep,name=user_ids,json=userIds,proto3" json:"user_ids"`
	// 是否获取数据
	// @gotags: json:"skip_items"
	SkipItems bool `protobuf:"varint,8,opt,name=skip_items,json=skipItems,proto3" json:"skip_items"`
	// 关键字查询
	// @gotags: json:"keywords"
	Keywords string `protobuf:"bytes,9,opt,name=keywords,proto3" json:"keywords"`
	// contains filtered or unexported fields
}

QueryUserRequest 获取子账号列表

func NewQueryUserRequest

func NewQueryUserRequest() *QueryUserRequest

NewQueryUserRequest 列表查询请求

func NewQueryUserRequestFromHTTP

func NewQueryUserRequestFromHTTP(r *http.Request) *QueryUserRequest

NewQueryUserRequestFromHTTP todo

func (*QueryUserRequest) Descriptor deprecated

func (*QueryUserRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryUserRequest.ProtoReflect.Descriptor instead.

func (*QueryUserRequest) GetDomain

func (x *QueryUserRequest) GetDomain() string

func (*QueryUserRequest) GetKeywords

func (x *QueryUserRequest) GetKeywords() string

func (*QueryUserRequest) GetPage

func (x *QueryUserRequest) GetPage() *request.PageRequest

func (*QueryUserRequest) GetProvider

func (x *QueryUserRequest) GetProvider() PROVIDER

func (*QueryUserRequest) GetSkipItems

func (x *QueryUserRequest) GetSkipItems() bool

func (*QueryUserRequest) GetType

func (x *QueryUserRequest) GetType() TYPE

func (*QueryUserRequest) GetUserIds

func (x *QueryUserRequest) GetUserIds() []string

func (*QueryUserRequest) ProtoMessage

func (*QueryUserRequest) ProtoMessage()

func (*QueryUserRequest) ProtoReflect

func (x *QueryUserRequest) ProtoReflect() protoreflect.Message

func (*QueryUserRequest) Reset

func (x *QueryUserRequest) Reset()

func (*QueryUserRequest) String

func (x *QueryUserRequest) String() string

func (*QueryUserRequest) WithType

func (req *QueryUserRequest) WithType(t TYPE)

type RPCClient

type RPCClient interface {
	// 查询用户列表
	QueryUser(ctx context.Context, in *QueryUserRequest, opts ...grpc.CallOption) (*UserSet, error)
	// 查询用户详情
	DescribeUser(ctx context.Context, in *DescribeUserRequest, opts ...grpc.CallOption) (*User, error)
}

RPCClient is the client API for RPC 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 NewRPCClient

func NewRPCClient(cc grpc.ClientConnInterface) RPCClient

type RPCServer

type RPCServer interface {
	// 查询用户列表
	QueryUser(context.Context, *QueryUserRequest) (*UserSet, error)
	// 查询用户详情
	DescribeUser(context.Context, *DescribeUserRequest) (*User, error)
	// contains filtered or unexported methods
}

RPCServer is the server API for RPC service. All implementations must embed UnimplementedRPCServer for forward compatibility

type ResetPasswordRequest

type ResetPasswordRequest struct {

	// 用户名
	// @gotags: json:"user_id"
	UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id"`
	// 新密码
	// @gotags: json:"new_pass"
	NewPass string `protobuf:"bytes,3,opt,name=new_pass,json=newPass,proto3" json:"new_pass"`
	// 是否重置
	// @gotags: json:"is_reset"
	IsReset bool `protobuf:"varint,4,opt,name=is_reset,json=isReset,proto3" json:"is_reset"`
	// 重置原因
	// @gotags: json:"reset_reason"
	ResetReason string `protobuf:"bytes,5,opt,name=reset_reason,json=resetReason,proto3" json:"reset_reason"`
	// contains filtered or unexported fields
}

重置密码, 用户忘了自己的密码, 管理员使用

func (*ResetPasswordRequest) Descriptor deprecated

func (*ResetPasswordRequest) Descriptor() ([]byte, []int)

Deprecated: Use ResetPasswordRequest.ProtoReflect.Descriptor instead.

func (*ResetPasswordRequest) GetIsReset

func (x *ResetPasswordRequest) GetIsReset() bool

func (*ResetPasswordRequest) GetNewPass

func (x *ResetPasswordRequest) GetNewPass() string

func (*ResetPasswordRequest) GetResetReason

func (x *ResetPasswordRequest) GetResetReason() string

func (*ResetPasswordRequest) GetUserId

func (x *ResetPasswordRequest) GetUserId() string

func (*ResetPasswordRequest) ProtoMessage

func (*ResetPasswordRequest) ProtoMessage()

func (*ResetPasswordRequest) ProtoReflect

func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message

func (*ResetPasswordRequest) Reset

func (x *ResetPasswordRequest) Reset()

func (*ResetPasswordRequest) String

func (x *ResetPasswordRequest) String() string

type Service

type Service interface {
	// 创建用户
	CreateUser(context.Context, *CreateUserRequest) (*User, error)
	// 查询用户列表
	UpdateUser(context.Context, *UpdateUserRequest) (*User, error)
	// 删除用户
	DeleteUser(context.Context, *DeleteUserRequest) (*User, error)
	// 修改用户密码, 用户需要知道原先密码
	UpdatePassword(context.Context, *UpdatePasswordRequest) (*Password, error)
	// 重置密码, 无需知道原先密码, 主账号执行
	ResetPassword(context.Context, *ResetPasswordRequest) (*Password, error)
	// rpc接口
	RPCServer
}

模块内部接口(进程内部调用接口) RPC只暴露查询接口

type Status

type Status struct {

	// 是否冻结
	// @gotags: bson:"locked" json:"locked"
	Locked bool `protobuf:"varint,1,opt,name=locked,proto3" json:"locked" bson:"locked"`
	// 冻结时间
	// @gotags: bson:"locked_time" json:"locked_time"
	LockedTime int64 `protobuf:"varint,2,opt,name=locked_time,json=lockedTime,proto3" json:"locked_time" bson:"locked_time"`
	// 冻结原因
	// @gotags: bson:"locked_reson" json:"locked_reson"
	LockedReson string `protobuf:"bytes,3,opt,name=locked_reson,json=lockedReson,proto3" json:"locked_reson" bson:"locked_reson"`
	// 解冻时间
	// @gotags: bson:"unlock_time" json:"unlock_time"
	UnlockTime int64 `protobuf:"varint,4,opt,name=unlock_time,json=unlockTime,proto3" json:"unlock_time" bson:"unlock_time"`
	// contains filtered or unexported fields
}

Status 用户状态

func (*Status) Descriptor deprecated

func (*Status) Descriptor() ([]byte, []int)

Deprecated: Use Status.ProtoReflect.Descriptor instead.

func (*Status) GetLocked

func (x *Status) GetLocked() bool

func (*Status) GetLockedReson

func (x *Status) GetLockedReson() string

func (*Status) GetLockedTime

func (x *Status) GetLockedTime() int64

func (*Status) GetUnlockTime

func (x *Status) GetUnlockTime() int64

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) ProtoReflect

func (x *Status) ProtoReflect() protoreflect.Message

func (*Status) Reset

func (x *Status) Reset()

func (*Status) String

func (x *Status) String() string

type TYPE

type TYPE int32

为了防止越权, 用户可以调整的权限范围只有10已下的权限

const (
	// 子账号, 无用户中心后台管理权限
	TYPE_SUB TYPE = 0
	// 主账号, 具有本域的所有权限
	TYPE_PRIMARY TYPE = 10
	// 超级管理员, 系统管理员, 万能的人, 不受权限系统约束
	TYPE_SUPPER TYPE = 15
)

func ParseTYPEFromString

func ParseTYPEFromString(str string) (TYPE, error)

ParseTYPEFromString Parse TYPE from string

func (TYPE) Descriptor

func (TYPE) Descriptor() protoreflect.EnumDescriptor

func (TYPE) Enum

func (x TYPE) Enum() *TYPE

func (TYPE) EnumDescriptor deprecated

func (TYPE) EnumDescriptor() ([]byte, []int)

Deprecated: Use TYPE.Descriptor instead.

func (TYPE) Equal

func (t TYPE) Equal(target TYPE) bool

Equal type compare

func (TYPE) IsIn

func (t TYPE) IsIn(targets ...TYPE) bool

IsIn todo

func (TYPE) MarshalJSON

func (t TYPE) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (TYPE) Number

func (x TYPE) Number() protoreflect.EnumNumber

func (TYPE) String

func (x TYPE) String() string

func (TYPE) Type

func (TYPE) Type() protoreflect.EnumType

func (*TYPE) UnmarshalJSON

func (t *TYPE) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type UnimplementedRPCServer

type UnimplementedRPCServer struct {
}

UnimplementedRPCServer must be embedded to have forward compatible implementations.

func (UnimplementedRPCServer) DescribeUser

func (UnimplementedRPCServer) QueryUser

type UnsafeRPCServer

type UnsafeRPCServer interface {
	// contains filtered or unexported methods
}

UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RPCServer will result in compilation errors.

type UpdatePasswordRequest

type UpdatePasswordRequest struct {

	// 用户Id
	// @gotags: json:"user_id"
	UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id"`
	// 旧密码
	// @gotags: json:"old_pass"
	OldPass string `protobuf:"bytes,2,opt,name=old_pass,json=oldPass,proto3" json:"old_pass"`
	// 新密码
	// @gotags: json:"new_pass"
	NewPass string `protobuf:"bytes,3,opt,name=new_pass,json=newPass,proto3" json:"new_pass"`
	// 是否重置
	// @gotags: json:"is_reset"
	IsReset bool `protobuf:"varint,4,opt,name=is_reset,json=isReset,proto3" json:"is_reset"`
	// 重置原因
	// @gotags: json:"reset_reason"
	ResetReason string `protobuf:"bytes,5,opt,name=reset_reason,json=resetReason,proto3" json:"reset_reason"`
	// contains filtered or unexported fields
}

UpdatePasswordRequest 密码更新(需要知道原密码) 用户自己使用

func (*UpdatePasswordRequest) Descriptor deprecated

func (*UpdatePasswordRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdatePasswordRequest.ProtoReflect.Descriptor instead.

func (*UpdatePasswordRequest) GetIsReset

func (x *UpdatePasswordRequest) GetIsReset() bool

func (*UpdatePasswordRequest) GetNewPass

func (x *UpdatePasswordRequest) GetNewPass() string

func (*UpdatePasswordRequest) GetOldPass

func (x *UpdatePasswordRequest) GetOldPass() string

func (*UpdatePasswordRequest) GetResetReason

func (x *UpdatePasswordRequest) GetResetReason() string

func (*UpdatePasswordRequest) GetUserId

func (x *UpdatePasswordRequest) GetUserId() string

func (*UpdatePasswordRequest) ProtoMessage

func (*UpdatePasswordRequest) ProtoMessage()

func (*UpdatePasswordRequest) ProtoReflect

func (x *UpdatePasswordRequest) ProtoReflect() protoreflect.Message

func (*UpdatePasswordRequest) Reset

func (x *UpdatePasswordRequest) Reset()

func (*UpdatePasswordRequest) String

func (x *UpdatePasswordRequest) String() string

type UpdateUserRequest

type UpdateUserRequest struct {

	// 更新模式
	// @gotags: json:"update_mode"
	UpdateMode request1.UpdateMode `protobuf:"varint,1,opt,name=update_mode,json=updateMode,proto3,enum=infraboard.mcube.request.UpdateMode" json:"update_mode"`
	// 用户Id
	// @gotags: json:"user_id" validate:"required,lte=120"
	UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id" validate:"required,lte=120"`
	// profile 账号profile
	// @gotags: json:"profile"
	Profile *Profile `protobuf:"bytes,3,opt,name=profile,proto3" json:"profile"`
	// contains filtered or unexported fields
}

UpdateUserRequest todo

func (*UpdateUserRequest) Descriptor deprecated

func (*UpdateUserRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateUserRequest.ProtoReflect.Descriptor instead.

func (*UpdateUserRequest) GetProfile

func (x *UpdateUserRequest) GetProfile() *Profile

func (*UpdateUserRequest) GetUpdateMode

func (x *UpdateUserRequest) GetUpdateMode() request1.UpdateMode

func (*UpdateUserRequest) GetUserId

func (x *UpdateUserRequest) GetUserId() string

func (*UpdateUserRequest) ProtoMessage

func (*UpdateUserRequest) ProtoMessage()

func (*UpdateUserRequest) ProtoReflect

func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message

func (*UpdateUserRequest) Reset

func (x *UpdateUserRequest) Reset()

func (*UpdateUserRequest) String

func (x *UpdateUserRequest) String() string

type User

type User struct {

	// 用户Id
	// @gotags: bson:"_id" json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 用户创建的时间
	// @gotags: bson:"create_at" json:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// 修改时间
	// @gotags: bson:"update_at" json:"update_at"
	UpdateAt int64 `protobuf:"varint,3,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"`
	// 定义信息
	// @gotags: bson:"spec" json:"spec"
	Spec *CreateUserRequest `protobuf:"bytes,4,opt,name=spec,proto3" json:"spec" bson:"spec"`
	// Profile信息
	// @gotags: json:"profile"
	Profile *Profile `protobuf:"bytes,5,opt,name=profile,proto3" json:"profile"`
	// 用户是否初始化
	// @gotags: bson:"is_initialized" json:"is_initialized"
	IsInitialized bool `protobuf:"varint,6,opt,name=is_initialized,json=isInitialized,proto3" json:"is_initialized" bson:"is_initialized"`
	// 密码相关信息
	// @gotags: bson:"password" json:"password"
	Password *Password `protobuf:"bytes,7,opt,name=password,proto3" json:"password" bson:"password"`
	// 用户状态
	// @gotags: bson:"status" json:"status"
	Status *Status `protobuf:"bytes,8,opt,name=status,proto3" json:"status" bson:"status"`
	// contains filtered or unexported fields
}

func New

func New(req *CreateUserRequest) (*User, error)

New 实例

func NewDefaultUser

func NewDefaultUser() *User

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) Desensitize

func (u *User) Desensitize()

Desensitize 关键数据脱敏

func (*User) GetCreateAt

func (x *User) GetCreateAt() int64

func (*User) GetId

func (x *User) GetId() string

func (*User) GetIsInitialized

func (x *User) GetIsInitialized() bool

func (*User) GetPassword

func (x *User) GetPassword() *Password

func (*User) GetProfile

func (x *User) GetProfile() *Profile

func (*User) GetSpec

func (x *User) GetSpec() *CreateUserRequest

func (*User) GetStatus

func (x *User) GetStatus() *Status

func (*User) GetUpdateAt

func (x *User) GetUpdateAt() int64

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

type UserSet

type UserSet struct {

	// 总数量
	// @gotags: bson:"total" json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	// 数据项
	// @gotags: bson:"items" json:"items"
	Items []*User `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

func NewUserSet

func NewUserSet() *UserSet

func (*UserSet) Add

func (s *UserSet) Add(item *User)

func (*UserSet) Descriptor deprecated

func (*UserSet) Descriptor() ([]byte, []int)

Deprecated: Use UserSet.ProtoReflect.Descriptor instead.

func (*UserSet) GetItems

func (x *UserSet) GetItems() []*User

func (*UserSet) GetTotal

func (x *UserSet) GetTotal() int64

func (*UserSet) ProtoMessage

func (*UserSet) ProtoMessage()

func (*UserSet) ProtoReflect

func (x *UserSet) ProtoReflect() protoreflect.Message

func (*UserSet) Reset

func (x *UserSet) Reset()

func (*UserSet) String

func (x *UserSet) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL