diff --git a/protoc-gen-go-crud/api/v1/users/users.pb.go b/protoc-gen-go-crud/api/v1/users/users.pb.go new file mode 100644 index 0000000..f645b7f --- /dev/null +++ b/protoc-gen-go-crud/api/v1/users/users.pb.go @@ -0,0 +1,1360 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: v1/users/users.proto + +package usersV1 + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + components "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/api/v1/components" + empty "github.com/golang/protobuf/ptypes/empty" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListUsersRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 姓名 + Nickname string `protobuf:"bytes,1,opt,name=nickname,proto3" json:"nickname,omitempty"` + // 邮箱 + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + // 手机号 + Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"` + // 状态 + Status components.EnableStatus `protobuf:"varint,4,opt,name=status,proto3,enum=componentsV1.EnableStatus" json:"status,omitempty"` + // 角色ID + RoleId string `protobuf:"bytes,5,opt,name=role_id,json=roleId,proto3" json:"role_id,omitempty"` + // 页码 + Page int64 `protobuf:"varint,6,opt,name=page,proto3" json:"page,omitempty"` + // 每页数量 + PageSize int64 `protobuf:"varint,7,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` +} + +func (x *ListUsersRequest) Reset() { + *x = ListUsersRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListUsersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUsersRequest) ProtoMessage() {} + +func (x *ListUsersRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListUsersRequest.ProtoReflect.Descriptor instead. +func (*ListUsersRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{0} +} + +func (x *ListUsersRequest) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *ListUsersRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *ListUsersRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *ListUsersRequest) GetStatus() components.EnableStatus { + if x != nil { + return x.Status + } + return components.EnableStatus(0) +} + +func (x *ListUsersRequest) GetRoleId() string { + if x != nil { + return x.RoleId + } + return "" +} + +func (x *ListUsersRequest) GetPage() int64 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListUsersRequest) GetPageSize() int64 { + if x != nil { + return x.PageSize + } + return 0 +} + +type ListUsersReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户列表 + List []*components.User `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` + // 分页信息 + PageInfo *components.PageInfo `protobuf:"bytes,2,opt,name=page_info,json=pageInfo,proto3" json:"page_info,omitempty"` +} + +func (x *ListUsersReply) Reset() { + *x = ListUsersReply{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListUsersReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUsersReply) ProtoMessage() {} + +func (x *ListUsersReply) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListUsersReply.ProtoReflect.Descriptor instead. +func (*ListUsersReply) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{1} +} + +func (x *ListUsersReply) GetList() []*components.User { + if x != nil { + return x.List + } + return nil +} + +func (x *ListUsersReply) GetPageInfo() *components.PageInfo { + if x != nil { + return x.PageInfo + } + return nil +} + +type CreateUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 姓名 + Nickname string `protobuf:"bytes,1,opt,name=nickname,proto3" json:"nickname,omitempty"` + // 邮箱 + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + // 手机区号 + PhoneCode string `protobuf:"bytes,3,opt,name=phone_code,json=phoneCode,proto3" json:"phone_code,omitempty"` + // 手机号 + Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"` + // 启用状态 + Enabled components.EnableStatus `protobuf:"varint,5,opt,name=enabled,proto3,enum=componentsV1.EnableStatus" json:"enabled,omitempty"` + // 角色IDs + RoleIds []string `protobuf:"bytes,6,rep,name=role_ids,json=roleIds,proto3" json:"role_ids,omitempty"` +} + +func (x *CreateUserRequest) Reset() { + *x = CreateUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUserRequest) ProtoMessage() {} + +func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead. +func (*CreateUserRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateUserRequest) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *CreateUserRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *CreateUserRequest) GetPhoneCode() string { + if x != nil { + return x.PhoneCode + } + return "" +} + +func (x *CreateUserRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *CreateUserRequest) GetEnabled() components.EnableStatus { + if x != nil { + return x.Enabled + } + return components.EnableStatus(0) +} + +func (x *CreateUserRequest) GetRoleIds() []string { + if x != nil { + return x.RoleIds + } + return nil +} + +type UpdateUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // [] 姓名 + Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` + // [] 手机区号 + PhoneCode string `protobuf:"bytes,3,opt,name=phone_code,json=phoneCode,proto3" json:"phone_code,omitempty"` + // [] 手机号 + Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"` + // [] 头像 + Avatar string `protobuf:"bytes,5,opt,name=avatar,proto3" json:"avatar,omitempty"` + // [] 角色IDs + RoleIds []string `protobuf:"bytes,6,rep,name=role_ids,json=roleIds,proto3" json:"role_ids,omitempty"` + // [] 时区 + Timezone string `protobuf:"bytes,7,opt,name=timezone,proto3" json:"timezone,omitempty"` +} + +func (x *UpdateUserRequest) Reset() { + *x = UpdateUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserRequest) ProtoMessage() {} + +func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateUserRequest.ProtoReflect.Descriptor instead. +func (*UpdateUserRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{3} +} + +func (x *UpdateUserRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UpdateUserRequest) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *UpdateUserRequest) GetPhoneCode() string { + if x != nil { + return x.PhoneCode + } + return "" +} + +func (x *UpdateUserRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *UpdateUserRequest) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *UpdateUserRequest) GetRoleIds() []string { + if x != nil { + return x.RoleIds + } + return nil +} + +func (x *UpdateUserRequest) GetTimezone() string { + if x != nil { + return x.Timezone + } + return "" +} + +type GetUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetUserRequest) Reset() { + *x = GetUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserRequest) ProtoMessage() {} + +func (x *GetUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead. +func (*GetUserRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{4} +} + +func (x *GetUserRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type DeleteUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *DeleteUserRequest) Reset() { + *x = DeleteUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserRequest) ProtoMessage() {} + +func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead. +func (*DeleteUserRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{5} +} + +func (x *DeleteUserRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type UploadProfileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 图片信息 + Avatar string `protobuf:"bytes,1,opt,name=avatar,proto3" json:"avatar,omitempty"` +} + +func (x *UploadProfileRequest) Reset() { + *x = UploadProfileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadProfileRequest) ProtoMessage() {} + +func (x *UploadProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UploadProfileRequest.ProtoReflect.Descriptor instead. +func (*UploadProfileRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{6} +} + +func (x *UploadProfileRequest) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +type UploadProfileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 头像路径 + AvatarUrl string `protobuf:"bytes,1,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"` +} + +func (x *UploadProfileResponse) Reset() { + *x = UploadProfileResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadProfileResponse) ProtoMessage() {} + +func (x *UploadProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UploadProfileResponse.ProtoReflect.Descriptor instead. +func (*UploadProfileResponse) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{7} +} + +func (x *UploadProfileResponse) GetAvatarUrl() string { + if x != nil { + return x.AvatarUrl + } + return "" +} + +type ResetActivateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *ResetActivateRequest) Reset() { + *x = ResetActivateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResetActivateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResetActivateRequest) ProtoMessage() {} + +func (x *ResetActivateRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResetActivateRequest.ProtoReflect.Descriptor instead. +func (*ResetActivateRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{8} +} + +func (x *ResetActivateRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type ResetPasswordRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *ResetPasswordRequest) Reset() { + *x = ResetPasswordRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResetPasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResetPasswordRequest) ProtoMessage() {} + +func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResetPasswordRequest.ProtoReflect.Descriptor instead. +func (*ResetPasswordRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{9} +} + +func (x *ResetPasswordRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type ChangePasswordRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 密码 + Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *ChangePasswordRequest) Reset() { + *x = ChangePasswordRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ChangePasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChangePasswordRequest) ProtoMessage() {} + +func (x *ChangePasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChangePasswordRequest.ProtoReflect.Descriptor instead. +func (*ChangePasswordRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{10} +} + +func (x *ChangePasswordRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type Reset2FARequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *Reset2FARequest) Reset() { + *x = Reset2FARequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Reset2FARequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Reset2FARequest) ProtoMessage() {} + +func (x *Reset2FARequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Reset2FARequest.ProtoReflect.Descriptor instead. +func (*Reset2FARequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{11} +} + +func (x *Reset2FARequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type EnableUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 用户ID + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // 状态 + Status components.EnableStatus `protobuf:"varint,2,opt,name=status,proto3,enum=componentsV1.EnableStatus" json:"status,omitempty"` +} + +func (x *EnableUserRequest) Reset() { + *x = EnableUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EnableUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnableUserRequest) ProtoMessage() {} + +func (x *EnableUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EnableUserRequest.ProtoReflect.Descriptor instead. +func (*EnableUserRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{12} +} + +func (x *EnableUserRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *EnableUserRequest) GetStatus() components.EnableStatus { + if x != nil { + return x.Status + } + return components.EnableStatus(0) +} + +type UpdateCurrentUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // [] 姓名 + Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` + // [] 手机区号 + PhoneCode string `protobuf:"bytes,3,opt,name=phone_code,json=phoneCode,proto3" json:"phone_code,omitempty"` + // [] 手机号 + Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"` + // [] 头像 + Avatar string `protobuf:"bytes,5,opt,name=avatar,proto3" json:"avatar,omitempty"` + // [] 时区 + Timezone string `protobuf:"bytes,6,opt,name=timezone,proto3" json:"timezone,omitempty"` +} + +func (x *UpdateCurrentUserRequest) Reset() { + *x = UpdateCurrentUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_users_users_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateCurrentUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateCurrentUserRequest) ProtoMessage() {} + +func (x *UpdateCurrentUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_users_users_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateCurrentUserRequest.ProtoReflect.Descriptor instead. +func (*UpdateCurrentUserRequest) Descriptor() ([]byte, []int) { + return file_v1_users_users_proto_rawDescGZIP(), []int{13} +} + +func (x *UpdateCurrentUserRequest) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *UpdateCurrentUserRequest) GetPhoneCode() string { + if x != nil { + return x.PhoneCode + } + return "" +} + +func (x *UpdateCurrentUserRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *UpdateCurrentUserRequest) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *UpdateCurrentUserRequest) GetTimezone() string { + if x != nil { + return x.Timezone + } + return "" +} + +var File_v1_users_users_proto protoreflect.FileDescriptor + +var file_v1_users_users_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x1a, + 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x73, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x18, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x2f, + 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf8, 0x01, 0x0a, 0x10, 0x4c, + 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x24, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0xd0, 0x01, 0x01, 0x52, 0x08, 0x6e, 0x69, 0x63, + 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0xd0, 0x01, 0x01, 0x52, 0x05, + 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x20, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x72, 0x05, 0x18, 0x0b, 0xd0, 0x01, 0x01, + 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x32, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, + 0x65, 0x6e, 0x74, 0x73, 0x56, 0x31, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x72, + 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, + 0x6c, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, + 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x6d, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x26, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x73, 0x56, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, + 0x33, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x56, + 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xf8, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, 0x6e, 0x69, + 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, + 0x06, 0x72, 0x04, 0x10, 0x01, 0x18, 0x1e, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x20, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x72, 0x05, 0x10, 0x01, 0x18, 0x80, 0x01, 0x52, 0x05, 0x65, 0x6d, + 0x61, 0x69, 0x6c, 0x12, 0x28, 0x0a, 0x0a, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x01, + 0x18, 0x0a, 0x52, 0x09, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1f, 0x0a, + 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, + 0x06, 0x72, 0x04, 0x10, 0x01, 0x18, 0x14, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x34, + 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1a, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x56, 0x31, 0x2e, 0x45, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x07, 0x65, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x73, + 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x49, 0x64, 0x73, 0x22, + 0xde, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x18, 0x1e, + 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0a, 0x70, 0x68, + 0x6f, 0x6e, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, + 0xfa, 0x42, 0x04, 0x72, 0x02, 0x18, 0x0a, 0x52, 0x09, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x43, 0x6f, + 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x18, 0x14, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x6f, 0x6c, + 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x72, 0x6f, 0x6c, + 0x65, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, + 0x22, 0x20, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x22, 0x23, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2e, 0x0a, 0x14, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x36, 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, 0x72, 0x6c, 0x22, + 0x26, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x65, 0x74, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x26, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x65, 0x74, + 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, + 0x33, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x22, 0x21, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x65, 0x74, 0x32, 0x46, 0x41, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x57, 0x0a, 0x11, 0x45, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x56, 0x31, 0x2e, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x22, 0x9f, 0x01, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x68, 0x6f, + 0x6e, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, + 0x68, 0x6f, 0x6e, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, + 0x6e, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, + 0x6e, 0x65, 0x32, 0xed, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x52, 0x0a, 0x09, + 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x56, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x11, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x12, 0x56, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, + 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x01, 0x2a, 0x22, 0x09, 0x2f, + 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x5b, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x1a, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x4e, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x56, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x16, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x58, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x2a, + 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, + 0x72, 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, + 0x12, 0x1d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x01, 0x2a, 0x22, 0x17, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x2d, 0x70, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x12, 0x6a, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x65, 0x74, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x52, + 0x65, 0x73, 0x65, 0x74, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x22, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1c, 0x3a, 0x01, 0x2a, 0x22, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x12, + 0x70, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x65, 0x74, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, + 0x12, 0x1d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x65, 0x74, + 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x3a, + 0x01, 0x2a, 0x22, 0x1d, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x69, + 0x64, 0x7d, 0x2f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2f, 0x72, 0x65, 0x73, 0x65, + 0x74, 0x12, 0x61, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x65, 0x74, 0x32, 0x46, 0x41, 0x12, 0x18, 0x2e, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x65, 0x74, 0x32, 0x46, 0x41, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, + 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x3a, 0x01, 0x2a, 0x22, 0x18, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x32, 0x66, 0x61, 0x2f, 0x72, + 0x65, 0x73, 0x65, 0x74, 0x12, 0x62, 0x0a, 0x0a, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x55, 0x73, + 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x45, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, + 0x2a, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x69, 0x64, + 0x7d, 0x2f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x44, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x56, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x10, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x12, 0x6d, + 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, + 0x12, 0x1e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, + 0x3a, 0x01, 0x2a, 0x1a, 0x18, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x63, 0x0a, + 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x12, 0x21, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x13, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x3a, 0x01, 0x2a, 0x1a, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, + 0x65, 0x72, 0x42, 0x35, 0x5a, 0x33, 0x62, 0x69, 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x2e, + 0x6f, 0x72, 0x67, 0x2f, 0x61, 0x6e, 0x74, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x64, 0x65, 0x76, 0x2f, + 0x65, 0x61, 0x72, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x3b, 0x75, 0x73, 0x65, 0x72, 0x73, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_v1_users_users_proto_rawDescOnce sync.Once + file_v1_users_users_proto_rawDescData = file_v1_users_users_proto_rawDesc +) + +func file_v1_users_users_proto_rawDescGZIP() []byte { + file_v1_users_users_proto_rawDescOnce.Do(func() { + file_v1_users_users_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_users_users_proto_rawDescData) + }) + return file_v1_users_users_proto_rawDescData +} + +var file_v1_users_users_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_v1_users_users_proto_goTypes = []interface{}{ + (*ListUsersRequest)(nil), // 0: usersV1.ListUsersRequest + (*ListUsersReply)(nil), // 1: usersV1.ListUsersReply + (*CreateUserRequest)(nil), // 2: usersV1.CreateUserRequest + (*UpdateUserRequest)(nil), // 3: usersV1.UpdateUserRequest + (*GetUserRequest)(nil), // 4: usersV1.GetUserRequest + (*DeleteUserRequest)(nil), // 5: usersV1.DeleteUserRequest + (*UploadProfileRequest)(nil), // 6: usersV1.UploadProfileRequest + (*UploadProfileResponse)(nil), // 7: usersV1.UploadProfileResponse + (*ResetActivateRequest)(nil), // 8: usersV1.ResetActivateRequest + (*ResetPasswordRequest)(nil), // 9: usersV1.ResetPasswordRequest + (*ChangePasswordRequest)(nil), // 10: usersV1.ChangePasswordRequest + (*Reset2FARequest)(nil), // 11: usersV1.Reset2FARequest + (*EnableUserRequest)(nil), // 12: usersV1.EnableUserRequest + (*UpdateCurrentUserRequest)(nil), // 13: usersV1.UpdateCurrentUserRequest + (components.EnableStatus)(0), // 14: componentsV1.EnableStatus + (*components.User)(nil), // 15: componentsV1.User + (*components.PageInfo)(nil), // 16: componentsV1.PageInfo + (*empty.Empty)(nil), // 17: google.protobuf.Empty +} +var file_v1_users_users_proto_depIdxs = []int32{ + 14, // 0: usersV1.ListUsersRequest.status:type_name -> componentsV1.EnableStatus + 15, // 1: usersV1.ListUsersReply.list:type_name -> componentsV1.User + 16, // 2: usersV1.ListUsersReply.page_info:type_name -> componentsV1.PageInfo + 14, // 3: usersV1.CreateUserRequest.enabled:type_name -> componentsV1.EnableStatus + 14, // 4: usersV1.EnableUserRequest.status:type_name -> componentsV1.EnableStatus + 0, // 5: usersV1.Users.ListUsers:input_type -> usersV1.ListUsersRequest + 2, // 6: usersV1.Users.CreateUser:input_type -> usersV1.CreateUserRequest + 3, // 7: usersV1.Users.UpdateUser:input_type -> usersV1.UpdateUserRequest + 4, // 8: usersV1.Users.GetUser:input_type -> usersV1.GetUserRequest + 5, // 9: usersV1.Users.DeleteUser:input_type -> usersV1.DeleteUserRequest + 6, // 10: usersV1.Users.UploadProfile:input_type -> usersV1.UploadProfileRequest + 8, // 11: usersV1.Users.ResetActivate:input_type -> usersV1.ResetActivateRequest + 9, // 12: usersV1.Users.ResetPassword:input_type -> usersV1.ResetPasswordRequest + 11, // 13: usersV1.Users.Reset2FA:input_type -> usersV1.Reset2FARequest + 12, // 14: usersV1.Users.EnableUser:input_type -> usersV1.EnableUserRequest + 17, // 15: usersV1.Users.User:input_type -> google.protobuf.Empty + 10, // 16: usersV1.Users.ChangePassword:input_type -> usersV1.ChangePasswordRequest + 13, // 17: usersV1.Users.UpdateCurrentUser:input_type -> usersV1.UpdateCurrentUserRequest + 1, // 18: usersV1.Users.ListUsers:output_type -> usersV1.ListUsersReply + 17, // 19: usersV1.Users.CreateUser:output_type -> google.protobuf.Empty + 17, // 20: usersV1.Users.UpdateUser:output_type -> google.protobuf.Empty + 15, // 21: usersV1.Users.GetUser:output_type -> componentsV1.User + 17, // 22: usersV1.Users.DeleteUser:output_type -> google.protobuf.Empty + 7, // 23: usersV1.Users.UploadProfile:output_type -> usersV1.UploadProfileResponse + 17, // 24: usersV1.Users.ResetActivate:output_type -> google.protobuf.Empty + 17, // 25: usersV1.Users.ResetPassword:output_type -> google.protobuf.Empty + 17, // 26: usersV1.Users.Reset2FA:output_type -> google.protobuf.Empty + 17, // 27: usersV1.Users.EnableUser:output_type -> google.protobuf.Empty + 15, // 28: usersV1.Users.User:output_type -> componentsV1.User + 17, // 29: usersV1.Users.ChangePassword:output_type -> google.protobuf.Empty + 17, // 30: usersV1.Users.UpdateCurrentUser:output_type -> google.protobuf.Empty + 18, // [18:31] is the sub-list for method output_type + 5, // [5:18] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_v1_users_users_proto_init() } +func file_v1_users_users_proto_init() { + if File_v1_users_users_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_v1_users_users_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListUsersRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListUsersReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadProfileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadProfileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResetActivateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResetPasswordRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ChangePasswordRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Reset2FARequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EnableUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_users_users_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateCurrentUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_v1_users_users_proto_rawDesc, + NumEnums: 0, + NumMessages: 14, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_v1_users_users_proto_goTypes, + DependencyIndexes: file_v1_users_users_proto_depIdxs, + MessageInfos: file_v1_users_users_proto_msgTypes, + }.Build() + File_v1_users_users_proto = out.File + file_v1_users_users_proto_rawDesc = nil + file_v1_users_users_proto_goTypes = nil + file_v1_users_users_proto_depIdxs = nil +} diff --git a/protoc-gen-go-crud/api/v1/users/users.pb.validate.go b/protoc-gen-go-crud/api/v1/users/users.pb.validate.go new file mode 100644 index 0000000..a439dae --- /dev/null +++ b/protoc-gen-go-crud/api/v1/users/users.pb.validate.go @@ -0,0 +1,1669 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: v1/users/users.proto + +package usersV1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" + + componentsV1 "bitbucket.org/antalphadev/earn/api/v1/components" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort + + _ = componentsV1.EnableStatus(0) +) + +// Validate checks the field values on ListUsersRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ListUsersRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUsersRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListUsersRequestMultiError, or nil if none found. +func (m *ListUsersRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUsersRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetNickname() != "" { + + } + + if m.GetEmail() != "" { + + } + + if m.GetPhone() != "" { + + if utf8.RuneCountInString(m.GetPhone()) > 11 { + err := ListUsersRequestValidationError{ + field: "Phone", + reason: "value length must be at most 11 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + } + + // no validation rules for Status + + // no validation rules for RoleId + + // no validation rules for Page + + // no validation rules for PageSize + + if len(errors) > 0 { + return ListUsersRequestMultiError(errors) + } + + return nil +} + +// ListUsersRequestMultiError is an error wrapping multiple validation errors +// returned by ListUsersRequest.ValidateAll() if the designated constraints +// aren't met. +type ListUsersRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUsersRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListUsersRequestMultiError) AllErrors() []error { return m } + +// ListUsersRequestValidationError is the validation error returned by +// ListUsersRequest.Validate if the designated constraints aren't met. +type ListUsersRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUsersRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUsersRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUsersRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUsersRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUsersRequestValidationError) ErrorName() string { return "ListUsersRequestValidationError" } + +// Error satisfies the builtin error interface +func (e ListUsersRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sListUsersRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUsersRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUsersRequestValidationError{} + +// Validate checks the field values on ListUsersReply with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *ListUsersReply) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUsersReply with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ListUsersReplyMultiError, +// or nil if none found. +func (m *ListUsersReply) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUsersReply) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetList() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUsersReplyValidationError{ + field: fmt.Sprintf("List[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUsersReplyValidationError{ + field: fmt.Sprintf("List[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUsersReplyValidationError{ + field: fmt.Sprintf("List[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetPageInfo()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUsersReplyValidationError{ + field: "PageInfo", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUsersReplyValidationError{ + field: "PageInfo", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPageInfo()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUsersReplyValidationError{ + field: "PageInfo", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ListUsersReplyMultiError(errors) + } + + return nil +} + +// ListUsersReplyMultiError is an error wrapping multiple validation errors +// returned by ListUsersReply.ValidateAll() if the designated constraints +// aren't met. +type ListUsersReplyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUsersReplyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListUsersReplyMultiError) AllErrors() []error { return m } + +// ListUsersReplyValidationError is the validation error returned by +// ListUsersReply.Validate if the designated constraints aren't met. +type ListUsersReplyValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUsersReplyValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUsersReplyValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUsersReplyValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUsersReplyValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUsersReplyValidationError) ErrorName() string { return "ListUsersReplyValidationError" } + +// Error satisfies the builtin error interface +func (e ListUsersReplyValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sListUsersReply.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUsersReplyValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUsersReplyValidationError{} + +// Validate checks the field values on CreateUserRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *CreateUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateUserRequestMultiError, or nil if none found. +func (m *CreateUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if l := utf8.RuneCountInString(m.GetNickname()); l < 1 || l > 30 { + err := CreateUserRequestValidationError{ + field: "Nickname", + reason: "value length must be between 1 and 30 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + if l := utf8.RuneCountInString(m.GetEmail()); l < 1 || l > 128 { + err := CreateUserRequestValidationError{ + field: "Email", + reason: "value length must be between 1 and 128 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + if l := utf8.RuneCountInString(m.GetPhoneCode()); l < 1 || l > 10 { + err := CreateUserRequestValidationError{ + field: "PhoneCode", + reason: "value length must be between 1 and 10 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + if l := utf8.RuneCountInString(m.GetPhone()); l < 1 || l > 20 { + err := CreateUserRequestValidationError{ + field: "Phone", + reason: "value length must be between 1 and 20 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Enabled + + if len(errors) > 0 { + return CreateUserRequestMultiError(errors) + } + + return nil +} + +// CreateUserRequestMultiError is an error wrapping multiple validation errors +// returned by CreateUserRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateUserRequestMultiError) AllErrors() []error { return m } + +// CreateUserRequestValidationError is the validation error returned by +// CreateUserRequest.Validate if the designated constraints aren't met. +type CreateUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUserRequestValidationError) ErrorName() string { + return "CreateUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCreateUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUserRequestValidationError{} + +// Validate checks the field values on UpdateUserRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *UpdateUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateUserRequestMultiError, or nil if none found. +func (m *UpdateUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if utf8.RuneCountInString(m.GetNickname()) > 30 { + err := UpdateUserRequestValidationError{ + field: "Nickname", + reason: "value length must be at most 30 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetPhoneCode()) > 10 { + err := UpdateUserRequestValidationError{ + field: "PhoneCode", + reason: "value length must be at most 10 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetPhone()) > 20 { + err := UpdateUserRequestValidationError{ + field: "Phone", + reason: "value length must be at most 20 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Avatar + + // no validation rules for Timezone + + if len(errors) > 0 { + return UpdateUserRequestMultiError(errors) + } + + return nil +} + +// UpdateUserRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateUserRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateUserRequestMultiError) AllErrors() []error { return m } + +// UpdateUserRequestValidationError is the validation error returned by +// UpdateUserRequest.Validate if the designated constraints aren't met. +type UpdateUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserRequestValidationError) ErrorName() string { + return "UpdateUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUpdateUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserRequestValidationError{} + +// Validate checks the field values on GetUserRequest with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *GetUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetUserRequestMultiError, +// or nil if none found. +func (m *GetUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetUserRequestMultiError(errors) + } + + return nil +} + +// GetUserRequestMultiError is an error wrapping multiple validation errors +// returned by GetUserRequest.ValidateAll() if the designated constraints +// aren't met. +type GetUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetUserRequestMultiError) AllErrors() []error { return m } + +// GetUserRequestValidationError is the validation error returned by +// GetUserRequest.Validate if the designated constraints aren't met. +type GetUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserRequestValidationError) ErrorName() string { return "GetUserRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserRequestValidationError{} + +// Validate checks the field values on DeleteUserRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DeleteUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeleteUserRequestMultiError, or nil if none found. +func (m *DeleteUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteUserRequestMultiError(errors) + } + + return nil +} + +// DeleteUserRequestMultiError is an error wrapping multiple validation errors +// returned by DeleteUserRequest.ValidateAll() if the designated constraints +// aren't met. +type DeleteUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeleteUserRequestMultiError) AllErrors() []error { return m } + +// DeleteUserRequestValidationError is the validation error returned by +// DeleteUserRequest.Validate if the designated constraints aren't met. +type DeleteUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUserRequestValidationError) ErrorName() string { + return "DeleteUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeleteUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUserRequestValidationError{} + +// Validate checks the field values on UploadProfileRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *UploadProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UploadProfileRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UploadProfileRequestMultiError, or nil if none found. +func (m *UploadProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UploadProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Avatar + + if len(errors) > 0 { + return UploadProfileRequestMultiError(errors) + } + + return nil +} + +// UploadProfileRequestMultiError is an error wrapping multiple validation +// errors returned by UploadProfileRequest.ValidateAll() if the designated +// constraints aren't met. +type UploadProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UploadProfileRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UploadProfileRequestMultiError) AllErrors() []error { return m } + +// UploadProfileRequestValidationError is the validation error returned by +// UploadProfileRequest.Validate if the designated constraints aren't met. +type UploadProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UploadProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UploadProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UploadProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UploadProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UploadProfileRequestValidationError) ErrorName() string { + return "UploadProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UploadProfileRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUploadProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UploadProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UploadProfileRequestValidationError{} + +// Validate checks the field values on UploadProfileResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *UploadProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UploadProfileResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UploadProfileResponseMultiError, or nil if none found. +func (m *UploadProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UploadProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for AvatarUrl + + if len(errors) > 0 { + return UploadProfileResponseMultiError(errors) + } + + return nil +} + +// UploadProfileResponseMultiError is an error wrapping multiple validation +// errors returned by UploadProfileResponse.ValidateAll() if the designated +// constraints aren't met. +type UploadProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UploadProfileResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UploadProfileResponseMultiError) AllErrors() []error { return m } + +// UploadProfileResponseValidationError is the validation error returned by +// UploadProfileResponse.Validate if the designated constraints aren't met. +type UploadProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UploadProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UploadProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UploadProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UploadProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UploadProfileResponseValidationError) ErrorName() string { + return "UploadProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UploadProfileResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUploadProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UploadProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UploadProfileResponseValidationError{} + +// Validate checks the field values on ResetActivateRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ResetActivateRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResetActivateRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ResetActivateRequestMultiError, or nil if none found. +func (m *ResetActivateRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ResetActivateRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return ResetActivateRequestMultiError(errors) + } + + return nil +} + +// ResetActivateRequestMultiError is an error wrapping multiple validation +// errors returned by ResetActivateRequest.ValidateAll() if the designated +// constraints aren't met. +type ResetActivateRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResetActivateRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ResetActivateRequestMultiError) AllErrors() []error { return m } + +// ResetActivateRequestValidationError is the validation error returned by +// ResetActivateRequest.Validate if the designated constraints aren't met. +type ResetActivateRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResetActivateRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResetActivateRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResetActivateRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResetActivateRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResetActivateRequestValidationError) ErrorName() string { + return "ResetActivateRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ResetActivateRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sResetActivateRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResetActivateRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResetActivateRequestValidationError{} + +// Validate checks the field values on ResetPasswordRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ResetPasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResetPasswordRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ResetPasswordRequestMultiError, or nil if none found. +func (m *ResetPasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ResetPasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return ResetPasswordRequestMultiError(errors) + } + + return nil +} + +// ResetPasswordRequestMultiError is an error wrapping multiple validation +// errors returned by ResetPasswordRequest.ValidateAll() if the designated +// constraints aren't met. +type ResetPasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResetPasswordRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ResetPasswordRequestMultiError) AllErrors() []error { return m } + +// ResetPasswordRequestValidationError is the validation error returned by +// ResetPasswordRequest.Validate if the designated constraints aren't met. +type ResetPasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResetPasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResetPasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResetPasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResetPasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResetPasswordRequestValidationError) ErrorName() string { + return "ResetPasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ResetPasswordRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sResetPasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResetPasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResetPasswordRequestValidationError{} + +// Validate checks the field values on ChangePasswordRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ChangePasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ChangePasswordRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ChangePasswordRequestMultiError, or nil if none found. +func (m *ChangePasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ChangePasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Password + + if len(errors) > 0 { + return ChangePasswordRequestMultiError(errors) + } + + return nil +} + +// ChangePasswordRequestMultiError is an error wrapping multiple validation +// errors returned by ChangePasswordRequest.ValidateAll() if the designated +// constraints aren't met. +type ChangePasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ChangePasswordRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ChangePasswordRequestMultiError) AllErrors() []error { return m } + +// ChangePasswordRequestValidationError is the validation error returned by +// ChangePasswordRequest.Validate if the designated constraints aren't met. +type ChangePasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ChangePasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ChangePasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ChangePasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ChangePasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ChangePasswordRequestValidationError) ErrorName() string { + return "ChangePasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ChangePasswordRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sChangePasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ChangePasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ChangePasswordRequestValidationError{} + +// Validate checks the field values on Reset2FARequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *Reset2FARequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Reset2FARequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// Reset2FARequestMultiError, or nil if none found. +func (m *Reset2FARequest) ValidateAll() error { + return m.validate(true) +} + +func (m *Reset2FARequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return Reset2FARequestMultiError(errors) + } + + return nil +} + +// Reset2FARequestMultiError is an error wrapping multiple validation errors +// returned by Reset2FARequest.ValidateAll() if the designated constraints +// aren't met. +type Reset2FARequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m Reset2FARequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m Reset2FARequestMultiError) AllErrors() []error { return m } + +// Reset2FARequestValidationError is the validation error returned by +// Reset2FARequest.Validate if the designated constraints aren't met. +type Reset2FARequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e Reset2FARequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e Reset2FARequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e Reset2FARequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e Reset2FARequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e Reset2FARequestValidationError) ErrorName() string { return "Reset2FARequestValidationError" } + +// Error satisfies the builtin error interface +func (e Reset2FARequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReset2FARequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = Reset2FARequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = Reset2FARequestValidationError{} + +// Validate checks the field values on EnableUserRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *EnableUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on EnableUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// EnableUserRequestMultiError, or nil if none found. +func (m *EnableUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *EnableUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Status + + if len(errors) > 0 { + return EnableUserRequestMultiError(errors) + } + + return nil +} + +// EnableUserRequestMultiError is an error wrapping multiple validation errors +// returned by EnableUserRequest.ValidateAll() if the designated constraints +// aren't met. +type EnableUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m EnableUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m EnableUserRequestMultiError) AllErrors() []error { return m } + +// EnableUserRequestValidationError is the validation error returned by +// EnableUserRequest.Validate if the designated constraints aren't met. +type EnableUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e EnableUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e EnableUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e EnableUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e EnableUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e EnableUserRequestValidationError) ErrorName() string { + return "EnableUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e EnableUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sEnableUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = EnableUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = EnableUserRequestValidationError{} + +// Validate checks the field values on UpdateCurrentUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *UpdateCurrentUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateCurrentUserRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateCurrentUserRequestMultiError, or nil if none found. +func (m *UpdateCurrentUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateCurrentUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Nickname + + // no validation rules for PhoneCode + + // no validation rules for Phone + + // no validation rules for Avatar + + // no validation rules for Timezone + + if len(errors) > 0 { + return UpdateCurrentUserRequestMultiError(errors) + } + + return nil +} + +// UpdateCurrentUserRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateCurrentUserRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateCurrentUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateCurrentUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateCurrentUserRequestMultiError) AllErrors() []error { return m } + +// UpdateCurrentUserRequestValidationError is the validation error returned by +// UpdateCurrentUserRequest.Validate if the designated constraints aren't met. +type UpdateCurrentUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateCurrentUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateCurrentUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateCurrentUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateCurrentUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateCurrentUserRequestValidationError) ErrorName() string { + return "UpdateCurrentUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateCurrentUserRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUpdateCurrentUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateCurrentUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateCurrentUserRequestValidationError{} diff --git a/protoc-gen-go-crud/api/v1/users/users.proto b/protoc-gen-go-crud/api/v1/users/users.proto new file mode 100644 index 0000000..1d7e296 --- /dev/null +++ b/protoc-gen-go-crud/api/v1/users/users.proto @@ -0,0 +1,200 @@ +syntax = "proto3"; + +package usersV1; + +import "google/api/annotations.proto"; +import "validate/validate.proto"; + +import "google/protobuf/empty.proto"; + +import "v1/components/schemas.proto"; +import "v1/components/enum.proto"; + +option go_package = "bitbucket.org/antalphadev/earn/api/v1/users;usersV1"; + + +// 用户管理 +service Users { + // 用户列表 + rpc ListUsers(ListUsersRequest) returns (ListUsersReply) { + option (google.api.http) = {get: "/v1/users"}; + } + // 新增用户 + rpc CreateUser(CreateUserRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {post: "/v1/users" body: "*"}; + } + // 更新用户 + rpc UpdateUser(UpdateUserRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {put: "/v1/users/{id}" body: "*"}; + } + // 查看用户详情 + rpc GetUser(GetUserRequest) returns (componentsV1.User) { + option (google.api.http) = {get: "/v1/users/{id}"}; + } + // 删除用户 + rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {delete: "/v1/users/{id}"}; + } + // 上传头像 + rpc UploadProfile(UploadProfileRequest) returns (UploadProfileResponse) { + option (google.api.http) = {post: "/v1/user/upload-profile" body: "*"}; + } + // 重新激活 + rpc ResetActivate(ResetActivateRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {post: "/v1/users/{id}/activate" body: "*"}; + } + // 重置密码 + rpc ResetPassword(ResetPasswordRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {post: "/v1/users/{id}/password/reset" body: "*"}; + } + // 重置2fa + rpc Reset2FA(Reset2FARequest) returns (google.protobuf.Empty) { + option (google.api.http) = {post: "/v1/users/{id}/2fa/reset" body: "*"}; + } + // 用户启用/禁用 + rpc EnableUser(EnableUserRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {post: "/v1/users/{id}/enable" body: "*"}; + } + + // 当前用户 + rpc User(google.protobuf.Empty) returns (componentsV1.User) { + option (google.api.http) = {get: "/v1/user"}; + } + // 当前用户修改密码 + rpc ChangePassword(ChangePasswordRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {put: "/v1/user/password/change" body: "*"}; + } + // 当前用户更新 + rpc UpdateCurrentUser(UpdateCurrentUserRequest) returns (google.protobuf.Empty) { + option (google.api.http) = {put: "/v1/user" body: "*"}; + } +} + +message ListUsersRequest { + // 姓名 + string nickname = 1 [(validate.rules).string = { + ignore_empty:true, + // pattern: "[a-zA-Z0-9\u4e00-\u9fa5]+", + }]; + // 邮箱 + string email = 2 [(validate.rules).string = { + ignore_empty:true, + // pattern: "[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+", + }]; + + // 手机号 + string phone = 3 [(validate.rules).string = { + ignore_empty:true, + // pattern: "[0-9]+", + max_len:11, + }]; + // 状态 + componentsV1.EnableStatus status = 4; + // 角色ID + string role_id = 5; + // 页码 + int64 page = 6; + // 每页数量 + int64 page_size = 7; +} + +message ListUsersReply { + // 用户列表 + repeated componentsV1.User list = 1; + // 分页信息 + componentsV1.PageInfo page_info = 2; +} + +message CreateUserRequest { + // 姓名 + string nickname = 1 [(validate.rules).string.min_len = 1, (validate.rules).string.max_len = 30]; + // 邮箱 + string email = 2 [(validate.rules).string.min_len = 1, (validate.rules).string.max_len = 128]; + // 手机区号 + string phone_code = 3 [(validate.rules).string.min_len = 1, (validate.rules).string.max_len = 10]; + // 手机号 + string phone = 4 [(validate.rules).string.min_len = 1, (validate.rules).string.max_len = 20]; + // 启用状态 + componentsV1.EnableStatus enabled = 5; + // 角色IDs + repeated string role_ids = 6; +} + +message UpdateUserRequest { + // 用户ID + string id = 1; + // [] 姓名 + string nickname = 2 [(validate.rules).string.max_len = 30]; + // [] 手机区号 + string phone_code = 3 [(validate.rules).string.max_len = 10]; + // [] 手机号 + string phone = 4 [(validate.rules).string.max_len = 20]; + // [] 头像 + string avatar = 5; + // [] 角色IDs + repeated string role_ids = 6; + // [] 时区 + string timezone = 7; +} + +message GetUserRequest { + // 用户ID + string id = 1; +} + +message DeleteUserRequest { + // 用户ID + string id = 1; +} + +message UploadProfileRequest{ + // 图片信息 + string avatar = 1; +} + +message UploadProfileResponse{ + // 头像路径 + string avatar_url = 1; +} + +message ResetActivateRequest { + // 用户ID + string id = 1; +} + +message ResetPasswordRequest { + // 用户ID + string id = 1; +} + +message ChangePasswordRequest { + // 密码 + string password = 1; +} + + +message Reset2FARequest { + // 用户ID + string id = 1; +} + +message EnableUserRequest { + // 用户ID + string id = 1; + // 状态 + componentsV1.EnableStatus status = 2; +} + + +message UpdateCurrentUserRequest { + // [] 姓名 + string nickname = 2; + // [] 手机区号 + string phone_code = 3; + // [] 手机号 + string phone = 4; + // [] 头像 + string avatar = 5; + // [] 时区 + string timezone = 6; +} diff --git a/protoc-gen-go-crud/api/v1/users/users.swagger.json b/protoc-gen-go-crud/api/v1/users/users.swagger.json new file mode 100644 index 0000000..bcd598b --- /dev/null +++ b/protoc-gen-go-crud/api/v1/users/users.swagger.json @@ -0,0 +1,804 @@ +{ + "swagger": "2.0", + "info": { + "title": "v1/users/users.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "Users" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v1/user": { + "get": { + "summary": "当前用户", + "operationId": "Users_User", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/componentsV1User" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": [ + "Users" + ] + }, + "put": { + "summary": "当前用户更新", + "operationId": "Users_UpdateCurrentUser", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/usersV1UpdateCurrentUserRequest" + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/user/password/change": { + "put": { + "summary": "当前用户修改密码", + "operationId": "Users_ChangePassword", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/usersV1ChangePasswordRequest" + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/user/upload-profile": { + "post": { + "summary": "上传头像", + "operationId": "Users_UploadProfile", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/usersV1UploadProfileResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/usersV1UploadProfileRequest" + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/users": { + "get": { + "summary": "用户列表", + "operationId": "Users_ListUsers", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/usersV1ListUsersReply" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "nickname", + "description": "姓名", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "email", + "description": "邮箱", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "phone", + "description": "手机号", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "status", + "description": "状态\n\n - ENABLE_STATUS_DEFAULT: 默认值\n - ENABLE: 启用\n - DISABLE: 禁用", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "ENABLE_STATUS_DEFAULT", + "ENABLE", + "DISABLE" + ], + "default": "ENABLE_STATUS_DEFAULT" + }, + { + "name": "role_id", + "description": "角色ID", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "page", + "description": "页码", + "in": "query", + "required": false, + "type": "string", + "format": "int64" + }, + { + "name": "page_size", + "description": "每页数量", + "in": "query", + "required": false, + "type": "string", + "format": "int64" + } + ], + "tags": [ + "Users" + ] + }, + "post": { + "summary": "新增用户", + "operationId": "Users_CreateUser", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/usersV1CreateUserRequest" + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/users/{id}": { + "get": { + "summary": "查看用户详情", + "operationId": "Users_GetUser", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/componentsV1User" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "Users" + ] + }, + "delete": { + "summary": "删除用户", + "operationId": "Users_DeleteUser", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "Users" + ] + }, + "put": { + "summary": "更新用户", + "operationId": "Users_UpdateUser", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "title": "[] 姓名" + }, + "phone_code": { + "type": "string", + "title": "[] 手机区号" + }, + "phone": { + "type": "string", + "title": "[] 手机号" + }, + "avatar": { + "type": "string", + "title": "[] 头像" + }, + "role_ids": { + "type": "array", + "items": { + "type": "string" + }, + "title": "[] 角色IDs" + }, + "timezone": { + "type": "string", + "title": "[] 时区" + } + } + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/users/{id}/2fa/reset": { + "post": { + "summary": "重置2fa", + "operationId": "Users_Reset2FA", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/users/{id}/activate": { + "post": { + "summary": "重新激活", + "operationId": "Users_ResetActivate", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/users/{id}/enable": { + "post": { + "summary": "用户启用/禁用", + "operationId": "Users_EnableUser", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "status": { + "$ref": "#/definitions/componentsV1EnableStatus", + "title": "状态" + } + } + } + } + ], + "tags": [ + "Users" + ] + } + }, + "/v1/users/{id}/password/reset": { + "post": { + "summary": "重置密码", + "operationId": "Users_ResetPassword", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": {} + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "用户ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "tags": [ + "Users" + ] + } + } + }, + "definitions": { + "componentsV1Dictionary": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "label": { + "type": "string" + } + } + }, + "componentsV1EnableStatus": { + "type": "string", + "enum": [ + "ENABLE_STATUS_DEFAULT", + "ENABLE", + "DISABLE" + ], + "default": "ENABLE_STATUS_DEFAULT", + "title": "- ENABLE_STATUS_DEFAULT: 默认值\n - ENABLE: 启用\n - DISABLE: 禁用" + }, + "componentsV1PageInfo": { + "type": "object", + "properties": { + "page": { + "type": "string", + "format": "int64", + "title": "当前页码" + }, + "page_size": { + "type": "string", + "format": "int64", + "title": "每页数量" + }, + "total": { + "type": "string", + "format": "int64", + "title": "总数量" + } + } + }, + "componentsV1User": { + "type": "object", + "properties": { + "id": { + "type": "string", + "title": "用户ID" + }, + "email": { + "type": "string", + "title": "邮箱" + }, + "email_verified_at": { + "type": "string", + "title": "邮箱验证时间" + }, + "nickname": { + "type": "string", + "title": "姓名" + }, + "phone_code": { + "type": "string", + "title": "手机区号" + }, + "phone": { + "type": "string", + "title": "手机号" + }, + "avatar": { + "type": "string", + "title": "头像" + }, + "roles": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/componentsV1Dictionary" + }, + "title": "角色" + }, + "status": { + "$ref": "#/definitions/componentsV1EnableStatus", + "title": "状态" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + }, + "title": "权限" + }, + "timezone": { + "type": "string", + "title": "时区" + }, + "created_at": { + "type": "string", + "title": "创建时间" + }, + "created_by": { + "type": "string", + "title": "创建人" + }, + "updated_at": { + "type": "string", + "title": "更新时间" + }, + "updated_by": { + "type": "string", + "title": "更新人" + } + } + }, + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/protobufAny" + } + } + } + }, + "usersV1ChangePasswordRequest": { + "type": "object", + "properties": { + "password": { + "type": "string", + "title": "密码" + } + } + }, + "usersV1CreateUserRequest": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "title": "姓名" + }, + "email": { + "type": "string", + "title": "邮箱" + }, + "phone_code": { + "type": "string", + "title": "手机区号" + }, + "phone": { + "type": "string", + "title": "手机号" + }, + "enabled": { + "$ref": "#/definitions/componentsV1EnableStatus", + "title": "启用状态" + }, + "role_ids": { + "type": "array", + "items": { + "type": "string" + }, + "title": "角色IDs" + } + } + }, + "usersV1ListUsersReply": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/componentsV1User" + }, + "title": "用户列表" + }, + "page_info": { + "$ref": "#/definitions/componentsV1PageInfo", + "title": "分页信息" + } + } + }, + "usersV1UpdateCurrentUserRequest": { + "type": "object", + "properties": { + "nickname": { + "type": "string", + "title": "[] 姓名" + }, + "phone_code": { + "type": "string", + "title": "[] 手机区号" + }, + "phone": { + "type": "string", + "title": "[] 手机号" + }, + "avatar": { + "type": "string", + "title": "[] 头像" + }, + "timezone": { + "type": "string", + "title": "[] 时区" + } + } + }, + "usersV1UploadProfileRequest": { + "type": "object", + "properties": { + "avatar": { + "type": "string", + "title": "图片信息" + } + } + }, + "usersV1UploadProfileResponse": { + "type": "object", + "properties": { + "avatar_url": { + "type": "string", + "title": "头像路径" + } + } + } + } +} diff --git a/protoc-gen-go-crud/api/v1/users/users_http.pb.go b/protoc-gen-go-crud/api/v1/users/users_http.pb.go new file mode 100644 index 0000000..2a9bb66 --- /dev/null +++ b/protoc-gen-go-crud/api/v1/users/users_http.pb.go @@ -0,0 +1,597 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v0.0.1 +// - protoc v3.21.12 +// source: v1/users/users.proto + +package usersV1 + +import ( + components "bitbucket.org/antalphadev/earn/api/v1/components" + bytes "bytes" + json "encoding/json" + gin "github.com/gin-gonic/gin" + jsonpb "github.com/golang/protobuf/jsonpb" + proto "github.com/golang/protobuf/proto" + empty "github.com/golang/protobuf/ptypes/empty" + http "net/http" +) + +// This is a compile-time assertion to ensure that this generated file +var _ = new(gin.Engine) +var _ = new(http.Request) +var _ = new(json.Encoder) +var _ = new(jsonpb.Marshaler) +var _ = new(proto.Message) +var _ = new(bytes.Buffer) + +const RouteUsersChangePassword = "/v1/user/password/change" +const RouteUsersCreateUser = "/v1/users" +const RouteUsersDeleteUser = "/v1/users/:id" +const RouteUsersEnableUser = "/v1/users/:id/enable" +const RouteUsersGetUser = "/v1/users/:id" +const RouteUsersListUsers = "/v1/users" +const RouteUsersReset2FA = "/v1/users/:id/2fa/reset" +const RouteUsersResetActivate = "/v1/users/:id/activate" +const RouteUsersResetPassword = "/v1/users/:id/password/reset" +const RouteUsersUpdateCurrentUser = "/v1/user" +const RouteUsersUpdateUser = "/v1/users/:id" +const RouteUsersUploadProfile = "/v1/user/upload-profile" +const RouteUsersUser = "/v1/user" + +type UsersHTTPServer interface { + // ChangePassword 当前用户修改密码 + ChangePassword(*gin.Context, *ChangePasswordRequest) (*empty.Empty, error) + // CreateUser 新增用户 + CreateUser(*gin.Context, *CreateUserRequest) (*empty.Empty, error) + // DeleteUser 删除用户 + DeleteUser(*gin.Context, *DeleteUserRequest) (*empty.Empty, error) + // EnableUser 用户启用/禁用 + EnableUser(*gin.Context, *EnableUserRequest) (*empty.Empty, error) + // GetUser 查看用户详情 + GetUser(*gin.Context, *GetUserRequest) (*components.User, error) + // ListUsers 用户列表 + ListUsers(*gin.Context, *ListUsersRequest) (*ListUsersReply, error) + // Reset2FA 重置2fa + Reset2FA(*gin.Context, *Reset2FARequest) (*empty.Empty, error) + // ResetActivate 重新激活 + ResetActivate(*gin.Context, *ResetActivateRequest) (*empty.Empty, error) + // ResetPassword 重置密码 + ResetPassword(*gin.Context, *ResetPasswordRequest) (*empty.Empty, error) + // UpdateCurrentUser 当前用户更新 + UpdateCurrentUser(*gin.Context, *UpdateCurrentUserRequest) (*empty.Empty, error) + // UpdateUser 更新用户 + UpdateUser(*gin.Context, *UpdateUserRequest) (*empty.Empty, error) + // UploadProfile 上传头像 + UploadProfile(*gin.Context, *UploadProfileRequest) (*UploadProfileResponse, error) + // User 当前用户 + User(*gin.Context, *empty.Empty) (*components.User, error) +} + +func RegisterUsersHTTPServer(r gin.IRouter, srv UsersHTTPServer) { + r.GET(RouteUsersListUsers, _Users_ListUsers0_HTTP_Handler(srv)) + r.POST(RouteUsersCreateUser, _Users_CreateUser0_HTTP_Handler(srv)) + r.PUT(RouteUsersUpdateUser, _Users_UpdateUser0_HTTP_Handler(srv)) + r.GET(RouteUsersGetUser, _Users_GetUser0_HTTP_Handler(srv)) + r.DELETE(RouteUsersDeleteUser, _Users_DeleteUser0_HTTP_Handler(srv)) + r.POST(RouteUsersUploadProfile, _Users_UploadProfile0_HTTP_Handler(srv)) + r.POST(RouteUsersResetActivate, _Users_ResetActivate0_HTTP_Handler(srv)) + r.POST(RouteUsersResetPassword, _Users_ResetPassword0_HTTP_Handler(srv)) + r.POST(RouteUsersReset2FA, _Users_Reset2FA0_HTTP_Handler(srv)) + r.POST(RouteUsersEnableUser, _Users_EnableUser0_HTTP_Handler(srv)) + r.GET(RouteUsersUser, _Users_User0_HTTP_Handler(srv)) + r.PUT(RouteUsersChangePassword, _Users_ChangePassword0_HTTP_Handler(srv)) + r.PUT(RouteUsersUpdateCurrentUser, _Users_UpdateCurrentUser0_HTTP_Handler(srv)) +} + +func _Users_ListUsers0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in ListUsersRequest + if err := c.BindQuery(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.ListUsers(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_CreateUser0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in CreateUserRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.CreateUser(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_UpdateUser0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in UpdateUserRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.UpdateUser(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_GetUser0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in GetUserRequest + if err := c.BindQuery(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.GetUser(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_DeleteUser0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in DeleteUserRequest + if err := c.BindQuery(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.DeleteUser(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_UploadProfile0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in UploadProfileRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.UploadProfile(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_ResetActivate0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in ResetActivateRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.ResetActivate(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_ResetPassword0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in ResetPasswordRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.ResetPassword(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_Reset2FA0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in Reset2FARequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.Reset2FA(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_EnableUser0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in EnableUserRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + if err := c.BindUri(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.EnableUser(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_User0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in empty.Empty + if err := c.BindQuery(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.User(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_ChangePassword0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in ChangePasswordRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.ChangePassword(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} + +func _Users_UpdateCurrentUser0_HTTP_Handler(srv UsersHTTPServer) gin.HandlerFunc { + return func(c *gin.Context) { + var in UpdateCurrentUserRequest + + if err := c.Bind(&in); err != nil { + c.Error(err) + c.Abort() + return + } + + out, err := srv.UpdateCurrentUser(c, &in) + if err != nil { + c.Error(err) + c.Abort() + return + } + if c.IsAborted() { + return + } + + var buffer bytes.Buffer + var data interface{} + var newData interface{} + + data = out + if message, ok := data.(proto.Message); ok { + t := jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true} + t.Marshal(&buffer, message) + json.Unmarshal(buffer.Bytes(), &newData) + } else { + newData = data + } + + c.JSON(http.StatusOK, newData) + } +} diff --git a/protoc-gen-go-crud/authorization/deliveries/authorization.go b/protoc-gen-go-crud/authorization/deliveries/authorization.go deleted file mode 100644 index 87da888..0000000 --- a/protoc-gen-go-crud/authorization/deliveries/authorization.go +++ /dev/null @@ -1,12 +0,0 @@ -package authorizationV1 - -import ( - empty "github.com/golang/protobuf/ptypes/empty" -) - -type AuthService struct { -} - -func (a AuthService) ListMenus(*gin.Context, *empty.Empty) (*authorizationV1.Menus, error) { - panic("todo") -} diff --git a/protoc-gen-go-crud/authorization/deliveries/role.go b/protoc-gen-go-crud/authorization/deliveries/role.go deleted file mode 100644 index e7f914f..0000000 --- a/protoc-gen-go-crud/authorization/deliveries/role.go +++ /dev/null @@ -1,29 +0,0 @@ -package authorizationV1 - -import ( - components "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/api/v1/components" - empty "github.com/golang/protobuf/ptypes/empty" -) - -type RoleService struct { -} - -func (a RoleService) CreateRole(*gin.Context, *authorizationV1.CreateRoleRequest) (*empty.Empty, error) { - panic("todo") -} - -func (a RoleService) EnableRole(*gin.Context, *authorizationV1.EnableRoleRequest) (*empty.Empty, error) { - panic("todo") -} - -func (a RoleService) GetRole(*gin.Context, *authorizationV1.GetRoleRequest) (*components.Role, error) { - panic("todo") -} - -func (a RoleService) ListRoles(*gin.Context, *authorizationV1.ListRolesRequest) (*authorizationV1.Roles, error) { - panic("todo") -} - -func (a RoleService) UpdateRole(*gin.Context, *authorizationV1.UpdateRoleRequest) (*empty.Empty, error) { - panic("todo") -} diff --git a/protoc-gen-go-crud/deliveries/wire.go b/protoc-gen-go-crud/deliveries/wire.go new file mode 100644 index 0000000..2c1cd68 --- /dev/null +++ b/protoc-gen-go-crud/deliveries/wire.go @@ -0,0 +1,63 @@ +package deliveries + +import ( + "fmt" + "os" + "strings" + "text/template" +) + +type TemplateParams struct { + FunctionNames []string +} + +func GenerateWireFile(path string, sets []string) error { + // 定义模板 + tmpl := `package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet({{ range $index, $element := .FunctionNames }}{{ if $index }}, {{ end }}{{ $element }}{{ end }})` + + // 解析模板 + t, err := template.New("generated-file").Parse(tmpl) + if err != nil { + return err + } + + f := strings.Split(path, "V1") + filename := fmt.Sprintf("./internal/%s/deliveries/wire.go", strings.ToLower(f[0])) + + functions := []string{} + for _, set := range sets { + functions = append(functions, fmt.Sprintf("New%sService", set)) + } + + params := TemplateParams{ + FunctionNames: functions, + } + + // 检查文件是否存在,如果不存在则创建它 + if _, err := os.Stat(filename); os.IsNotExist(err) { + file, err := os.Create(filename) + if err != nil { + return err + } + defer file.Close() + } + + // 打开文件 + file, err := os.OpenFile(filename, os.O_RDWR, 0644) + if err != nil { + return err + } + defer file.Close() + + // 生成新内容并写入文件 + err = t.Execute(file, params) + if err != nil { + return err + } + + return nil +} diff --git a/protoc-gen-go-crud/internal/authorization/deliveries/wire.go b/protoc-gen-go-crud/internal/authorization/deliveries/wire.go new file mode 100644 index 0000000..3f90fca --- /dev/null +++ b/protoc-gen-go-crud/internal/authorization/deliveries/wire.go @@ -0,0 +1,5 @@ +package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewRoleService, NewAuthService) \ No newline at end of file diff --git a/protoc-gen-go-crud/internal/authorization/repositories/wire.go b/protoc-gen-go-crud/internal/authorization/repositories/wire.go new file mode 100644 index 0000000..5b90617 --- /dev/null +++ b/protoc-gen-go-crud/internal/authorization/repositories/wire.go @@ -0,0 +1,5 @@ +package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewRoleRepo, NewAuthRepo) \ No newline at end of file diff --git a/protoc-gen-go-crud/internal/authorization/usecase/wire.go b/protoc-gen-go-crud/internal/authorization/usecase/wire.go new file mode 100644 index 0000000..a1ed56a --- /dev/null +++ b/protoc-gen-go-crud/internal/authorization/usecase/wire.go @@ -0,0 +1,5 @@ +package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewRoleUseCase, NewAuthUseCase) \ No newline at end of file diff --git a/protoc-gen-go-crud/internal/users/deliveries/users.go b/protoc-gen-go-crud/internal/users/deliveries/users.go new file mode 100644 index 0000000..5184e3a --- /dev/null +++ b/protoc-gen-go-crud/internal/users/deliveries/users.go @@ -0,0 +1,65 @@ +package deliveries + +import ( + components "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/api/v1/components" + empty "github.com/golang/protobuf/ptypes/empty" +) + +type UsersService struct { +} + +func (u UsersService) ChangePassword(c *gin.Context, in *usersV1.ChangePasswordRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) CreateUser(c *gin.Context, in *usersV1.CreateUserRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) DeleteUser(c *gin.Context, in *usersV1.DeleteUserRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) EnableUser(c *gin.Context, in *usersV1.EnableUserRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) GetUser(c *gin.Context, in *usersV1.GetUserRequest) (*components.User, error) { + panic("todo") +} + +func (u UsersService) ListUsers(c *gin.Context, in *usersV1.ListUsersRequest) (*usersV1.ListUsersReply, error) { + panic("todo") +} + +func (u UsersService) Reset2FA(c *gin.Context, in *usersV1.Reset2FARequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) ResetActivate(c *gin.Context, in *usersV1.ResetActivateRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) ResetPassword(c *gin.Context, in *usersV1.ResetPasswordRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) UpdateCurrentUser(c *gin.Context, in *usersV1.UpdateCurrentUserRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) UpdateUser(c *gin.Context, in *usersV1.UpdateUserRequest) (*empty.Empty, error) { + panic("todo") +} + +func (u UsersService) UploadProfile(c *gin.Context, in *usersV1.UploadProfileRequest) (*usersV1.UploadProfileResponse, error) { + panic("todo") +} + +func (u UsersService) User(c *gin.Context, in *empty.Empty) (*components.User, error) { + panic("todo") +} + +func (u UsersService) Log(c *gin.Context) *zap.SugaredLogger { + return global.Logger(ctx).Named("UsersRepo") +} diff --git a/protoc-gen-go-crud/internal/users/deliveries/wire.go b/protoc-gen-go-crud/internal/users/deliveries/wire.go new file mode 100644 index 0000000..6562a36 --- /dev/null +++ b/protoc-gen-go-crud/internal/users/deliveries/wire.go @@ -0,0 +1,5 @@ +package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewUsersService) \ No newline at end of file diff --git a/protoc-gen-go-crud/internal/users/entities/users.go b/protoc-gen-go-crud/internal/users/entities/users.go new file mode 100644 index 0000000..9816246 --- /dev/null +++ b/protoc-gen-go-crud/internal/users/entities/users.go @@ -0,0 +1,7 @@ +package entities + +type Users struct { + entity.BaseEntity +} + +func (u *Users) TableName() string { return "userss" } diff --git a/protoc-gen-go-crud/internal/users/repositories/users.go b/protoc-gen-go-crud/internal/users/repositories/users.go new file mode 100644 index 0000000..880be2c --- /dev/null +++ b/protoc-gen-go-crud/internal/users/repositories/users.go @@ -0,0 +1,41 @@ +package repositories + +type IUsersRepo interface { + CreateUsers(ctx context.Context, Users *entities.Users) error + UpdateUsers(ctx context.Context, updateFields []string, Users *entities.Users) error + GetUsers(ctx context.Context, id entity.ID) (*entities.Users, error) + GetUserss(ctx context.Context, filter *database.Filter) (res []*entities.User, count int64, err error) + DeleteUsers(ctx context.Context, id entity.ID) error + Log(ctx context.Context) *zap.SugaredLogger +} + +type UsersRepo struct { +} + +func (u *UsersRepo) DB(ctx context.Context) *gorm.DB { + return global.DBFromContext(ctx).Model(&entities.Users{}) +} + +func (u UsersRepo) CreateUsers(ctx context.Context, users *entities.Users) error { + panic("todo") +} + +func (u UsersRepo) UpdateUsers(ctx context.Context, updateFields []string, users *entities.Users) error { + panic("todo") +} + +func (u UsersRepo) GetUsers(ctx context.Context, id entity.ID) (*entities.Users, error) { + panic("todo") +} + +func (u UsersRepo) DeleteUsers(ctx context.Context, id entity.ID) error { + panic("todo") +} + +func (u UsersRepo) GetUserss(ctx context.Context, filter *database.Filter) (res []*entities.Users, count int64, err error) { + panic("todo") +} + +func (u UsersRepo) Log(ctx context.Context) *zap.SugaredLogger { + return global.Logger(ctx).Named("UsersRepo") +} diff --git a/protoc-gen-go-crud/internal/users/repositories/wire.go b/protoc-gen-go-crud/internal/users/repositories/wire.go new file mode 100644 index 0000000..0895672 --- /dev/null +++ b/protoc-gen-go-crud/internal/users/repositories/wire.go @@ -0,0 +1,5 @@ +package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewUsersRepo) \ No newline at end of file diff --git a/protoc-gen-go-crud/internal/users/usecase/users.go b/protoc-gen-go-crud/internal/users/usecase/users.go new file mode 100644 index 0000000..bae541b --- /dev/null +++ b/protoc-gen-go-crud/internal/users/usecase/users.go @@ -0,0 +1,41 @@ +package usecase + +type IUsersUsecase interface { + CreateUsers(ctx context.Context, in *usersV1.CreateUsersRequest) error + UpdateUsers(ctx context.Context, in *usersV1.UpdateUsersRequest) error + DeleteUsers(ctx context.Context, in *usersV1.DeleteUsersRequest) error + GetUsers(ctx context.Context, in *usersV1.GetUsersRequest) (*entities.Users, error) + ListUsers(ctx context.Context, in *usersV1.ListUsersRequest) ([]*entities.Users, int64, error) + Log(ctx context.Context) *zap.SugaredLogger +} + +type UsersUseCase struct { +} + +func NewUsersUseCase() IUsersUsecase { + return &UsersUseCase{} +} + +func (u *UsersUseCase) CreateUsers(ctx context.Context, in *usersV1.CreateUsersRequest) error { + panic("todo") +} + +func (u *UsersUseCase) UpdateUsers(ctx context.Context, in *usersV1.UpdateUsersRequest) error { + panic("todo") +} + +func (u *UsersUseCase) DeleteUsers(ctx context.Context, in *usersV1.DeleteUsersRequest) error { + panic("todo") +} + +func (u *UsersUseCase) GetUsers(ctx context.Context, in *usersV1.GetUsersRequest) (*entities.Users, error) { + panic("todo") +} + +func (u *UsersUseCase) ListUsers(ctx context.Context, in *usersV1.ListUsersRequest) ([]*entities.Users, int64, error) { + panic("todo") +} + +func (u UsersUseCase) Log(ctx context.Context) *zap.SugaredLogger { + return global.Logger(ctx).Named("UsersRepo") +} diff --git a/protoc-gen-go-crud/internal/users/usecase/wire.go b/protoc-gen-go-crud/internal/users/usecase/wire.go new file mode 100644 index 0000000..e06b65e --- /dev/null +++ b/protoc-gen-go-crud/internal/users/usecase/wire.go @@ -0,0 +1,5 @@ +package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet(NewUsersUseCase) \ No newline at end of file diff --git a/protoc-gen-go-crud/main.go b/protoc-gen-go-crud/main.go index 6a882af..bdc4c3f 100644 --- a/protoc-gen-go-crud/main.go +++ b/protoc-gen-go-crud/main.go @@ -5,7 +5,7 @@ import ( "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/deliveries" "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/entities" "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/repositories" - usecase "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/usecase" + "github.com/fynntang/protobuf-gen-go/protoc-gen-go-crud/usecase" _ "github.com/gin-gonic/gin" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/types/pluginpb" @@ -14,6 +14,7 @@ import ( var ( showVersion = flag.Bool("version", false, "print the version and exit") omitempty = flag.Bool("omitempty", true, "omit if google.api is empty") + wireMap = map[string][]string{} ) func main() { @@ -34,7 +35,18 @@ func main() { usecase.GenerateUseCasesFile(gen, f, *omitempty) entities.GenerateEntitiesFile(gen, f, *omitempty) repositories.GenerateRespositoriesFile(gen, f, *omitempty) + + for _, v := range f.Services { + wireMap[string(v.Desc.FullName().Parent().Name())] = append(wireMap[string(v.Desc.Parent().Name())], string(v.Desc.FullName().Name())) + } } + + for k, v := range wireMap { + deliveries.GenerateWireFile(k, v) + usecase.GenerateWireFile(k, v) + repositories.GenerateWireFile(k, v) + } + return nil }) } diff --git a/protoc-gen-go-crud/protoc-gen-go-crud b/protoc-gen-go-crud/protoc-gen-go-crud index 5632d1d..f1c8dbe 100755 Binary files a/protoc-gen-go-crud/protoc-gen-go-crud and b/protoc-gen-go-crud/protoc-gen-go-crud differ diff --git a/protoc-gen-go-crud/repositories/wire.go b/protoc-gen-go-crud/repositories/wire.go new file mode 100644 index 0000000..9dcf552 --- /dev/null +++ b/protoc-gen-go-crud/repositories/wire.go @@ -0,0 +1,63 @@ +package repositories + +import ( + "fmt" + "os" + "strings" + "text/template" +) + +type TemplateParams struct { + FunctionNames []string +} + +func GenerateWireFile(path string, sets []string) error { + // 定义模板 + tmpl := `package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet({{ range $index, $element := .FunctionNames }}{{ if $index }}, {{ end }}{{ $element }}{{ end }})` + + // 解析模板 + t, err := template.New("generated-file").Parse(tmpl) + if err != nil { + return err + } + + f := strings.Split(path, "V1") + filename := fmt.Sprintf("./internal/%s/repositories/wire.go", strings.ToLower(f[0])) + + functions := []string{} + for _, set := range sets { + functions = append(functions, fmt.Sprintf("New%sRepo", set)) + } + + params := TemplateParams{ + FunctionNames: functions, + } + + // 检查文件是否存在,如果不存在则创建它 + if _, err := os.Stat(filename); os.IsNotExist(err) { + file, err := os.Create(filename) + if err != nil { + return err + } + defer file.Close() + } + + // 打开文件 + file, err := os.OpenFile(filename, os.O_RDWR, 0644) + if err != nil { + return err + } + defer file.Close() + + // 生成新内容并写入文件 + err = t.Execute(file, params) + if err != nil { + return err + } + + return nil +} diff --git a/protoc-gen-go-crud/usecase/template.go b/protoc-gen-go-crud/usecase/template.go index 51f2e13..cbb73df 100644 --- a/protoc-gen-go-crud/usecase/template.go +++ b/protoc-gen-go-crud/usecase/template.go @@ -1,4 +1,4 @@ -package deliveries +package usecase import ( "bytes" diff --git a/protoc-gen-go-crud/usecase/usecase.go b/protoc-gen-go-crud/usecase/usecase.go index 5c6754a..1726b1e 100644 --- a/protoc-gen-go-crud/usecase/usecase.go +++ b/protoc-gen-go-crud/usecase/usecase.go @@ -1,4 +1,4 @@ -package deliveries +package usecase import ( "fmt" diff --git a/protoc-gen-go-crud/usecase/wire.go b/protoc-gen-go-crud/usecase/wire.go new file mode 100644 index 0000000..958b09f --- /dev/null +++ b/protoc-gen-go-crud/usecase/wire.go @@ -0,0 +1,63 @@ +package usecase + +import ( + "fmt" + "os" + "strings" + "text/template" +) + +type TemplateParams struct { + FunctionNames []string +} + +func GenerateWireFile(path string, sets []string) error { + // 定义模板 + tmpl := `package deliveries + +import "github.com/google/wire" + +var ProviderSet = wire.NewSet({{ range $index, $element := .FunctionNames }}{{ if $index }}, {{ end }}{{ $element }}{{ end }})` + + // 解析模板 + t, err := template.New("generated-file").Parse(tmpl) + if err != nil { + return err + } + + f := strings.Split(path, "V1") + filename := fmt.Sprintf("./internal/%s/usecase/wire.go", strings.ToLower(f[0])) + + functions := []string{} + for _, set := range sets { + functions = append(functions, fmt.Sprintf("New%sUseCase", set)) + } + + params := TemplateParams{ + FunctionNames: functions, + } + + // 检查文件是否存在,如果不存在则创建它 + if _, err := os.Stat(filename); os.IsNotExist(err) { + file, err := os.Create(filename) + if err != nil { + return err + } + defer file.Close() + } + + // 打开文件 + file, err := os.OpenFile(filename, os.O_RDWR, 0644) + if err != nil { + return err + } + defer file.Close() + + // 生成新内容并写入文件 + err = t.Execute(file, params) + if err != nil { + return err + } + + return nil +}