feat: aliyun sms

This commit is contained in:
zzw
2026-09-03 17:11:34 +08:00
parent 493416551b
commit 73a5fa41ff
17 changed files with 488 additions and 50 deletions
+93 -36
View File
@@ -82,15 +82,14 @@ func (x *Response) GetData() string {
return ""
}
// 统一登录:grant_type = openid | password | sms
type LoginReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClientCode string `protobuf:"bytes,1,opt,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` // 端编码,如 user_skin / user_o2 / sale_beauty
GrantType string `protobuf:"bytes,2,opt,name=grant_type,json=grantType,proto3" json:"grant_type,omitempty"` // openid | password | sms
Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` // grant_type=openid 时传微信 login code
Mobile string `protobuf:"bytes,4,opt,name=mobile,proto3" json:"mobile,omitempty"` // grant_type=password|sms
Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"` // grant_type=password
SmsCode string `protobuf:"bytes,6,opt,name=sms_code,json=smsCode,proto3" json:"sms_code,omitempty"` // grant_type=sms
ClientCode string `protobuf:"bytes,1,opt,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"`
GrantType string `protobuf:"bytes,2,opt,name=grant_type,json=grantType,proto3" json:"grant_type,omitempty"`
Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"`
Mobile string `protobuf:"bytes,4,opt,name=mobile,proto3" json:"mobile,omitempty"`
Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"`
SmsCode string `protobuf:"bytes,6,opt,name=sms_code,json=smsCode,proto3" json:"sms_code,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -167,7 +166,6 @@ func (x *LoginReq) GetSmsCode() string {
return ""
}
// 管理端用户列表
type UserItemsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"`
@@ -228,7 +226,6 @@ func (x *UserItemsReq) GetSize() int32 {
return 0
}
// 管理端修改用户状态
type UserStatusReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
@@ -837,6 +834,58 @@ func (x *RevokeBizClientData) GetRevoked() bool {
return false
}
type SendSmsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"`
Scene int32 `protobuf:"varint,2,opt,name=scene,proto3" json:"scene,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SendSmsReq) Reset() {
*x = SendSmsReq{}
mi := &file_user_user_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SendSmsReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SendSmsReq) ProtoMessage() {}
func (x *SendSmsReq) ProtoReflect() protoreflect.Message {
mi := &file_user_user_proto_msgTypes[13]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SendSmsReq.ProtoReflect.Descriptor instead.
func (*SendSmsReq) Descriptor() ([]byte, []int) {
return file_user_user_proto_rawDescGZIP(), []int{13}
}
func (x *SendSmsReq) GetMobile() string {
if x != nil {
return x.Mobile
}
return ""
}
func (x *SendSmsReq) GetScene() int32 {
if x != nil {
return x.Scene
}
return 0
}
type InfoReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -845,7 +894,7 @@ type InfoReq struct {
func (x *InfoReq) Reset() {
*x = InfoReq{}
mi := &file_user_user_proto_msgTypes[13]
mi := &file_user_user_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -857,7 +906,7 @@ func (x *InfoReq) String() string {
func (*InfoReq) ProtoMessage() {}
func (x *InfoReq) ProtoReflect() protoreflect.Message {
mi := &file_user_user_proto_msgTypes[13]
mi := &file_user_user_proto_msgTypes[14]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -870,7 +919,7 @@ func (x *InfoReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use InfoReq.ProtoReflect.Descriptor instead.
func (*InfoReq) Descriptor() ([]byte, []int) {
return file_user_user_proto_rawDescGZIP(), []int{13}
return file_user_user_proto_rawDescGZIP(), []int{14}
}
var File_user_user_proto protoreflect.FileDescriptor
@@ -939,9 +988,14 @@ const file_user_user_proto_rawDesc = "" +
"\vclient_code\x18\x02 \x01(\tR\n" +
"clientCode\"/\n" +
"\x13RevokeBizClientData\x12\x18\n" +
"\arevoked\x18\x01 \x01(\bR\arevoked\"\t\n" +
"\aInfoReq2\xc3\x04\n" +
"\x04User\x12A\n" +
"\arevoked\x18\x01 \x01(\bR\arevoked\":\n" +
"\n" +
"SendSmsReq\x12\x16\n" +
"\x06mobile\x18\x01 \x01(\tR\x06mobile\x12\x14\n" +
"\x05scene\x18\x02 \x01(\x05R\x05scene\"\t\n" +
"\aInfoReq2\x8d\x05\n" +
"\x04User\x12H\n" +
"\aSendSms\x12\x10.user.SendSmsReq\x1a\x0e.user.Response\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/api/v3/sms/send\x12A\n" +
"\x05Login\x12\x0e.user.LoginReq\x1a\x0e.user.Response\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v3/login\x12C\n" +
"\x04Info\x12\r.user.InfoReq\x1a\x0e.user.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x12\x11/api/v3/user/info\x12P\n" +
"\tUserItems\x12\x12.user.UserItemsReq\x1a\x0e.user.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/user/items\x12S\n" +
@@ -965,7 +1019,7 @@ func file_user_user_proto_rawDescGZIP() []byte {
return file_user_user_proto_rawDescData
}
var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
var file_user_user_proto_goTypes = []any{
(*Response)(nil), // 0: user.Response
(*LoginReq)(nil), // 1: user.LoginReq
@@ -980,28 +1034,31 @@ var file_user_user_proto_goTypes = []any{
(*UpdateMobileData)(nil), // 10: user.UpdateMobileData
(*RevokeBizClientReq)(nil), // 11: user.RevokeBizClientReq
(*RevokeBizClientData)(nil), // 12: user.RevokeBizClientData
(*InfoReq)(nil), // 13: user.InfoReq
(*SendSmsReq)(nil), // 13: user.SendSmsReq
(*InfoReq)(nil), // 14: user.InfoReq
}
var file_user_user_proto_depIdxs = []int32{
7, // 0: user.UsersByIdsData.items:type_name -> user.UserBriefItem
1, // 1: user.User.Login:input_type -> user.LoginReq
13, // 2: user.User.Info:input_type -> user.InfoReq
2, // 3: user.User.UserItems:input_type -> user.UserItemsReq
3, // 4: user.User.UserStatus:input_type -> user.UserStatusReq
4, // 5: user.User.EnsureBizIdentity:input_type -> user.EnsureBizIdentityReq
6, // 6: user.User.UsersByIds:input_type -> user.UsersByIdsReq
9, // 7: user.User.UpdateMobile:input_type -> user.UpdateMobileReq
11, // 8: user.User.RevokeBizClient:input_type -> user.RevokeBizClientReq
0, // 9: user.User.Login:output_type -> user.Response
0, // 10: user.User.Info:output_type -> user.Response
0, // 11: user.User.UserItems:output_type -> user.Response
0, // 12: user.User.UserStatus:output_type -> user.Response
5, // 13: user.User.EnsureBizIdentity:output_type -> user.EnsureBizIdentityData
8, // 14: user.User.UsersByIds:output_type -> user.UsersByIdsData
10, // 15: user.User.UpdateMobile:output_type -> user.UpdateMobileData
12, // 16: user.User.RevokeBizClient:output_type -> user.RevokeBizClientData
9, // [9:17] is the sub-list for method output_type
1, // [1:9] is the sub-list for method input_type
13, // 1: user.User.SendSms:input_type -> user.SendSmsReq
1, // 2: user.User.Login:input_type -> user.LoginReq
14, // 3: user.User.Info:input_type -> user.InfoReq
2, // 4: user.User.UserItems:input_type -> user.UserItemsReq
3, // 5: user.User.UserStatus:input_type -> user.UserStatusReq
4, // 6: user.User.EnsureBizIdentity:input_type -> user.EnsureBizIdentityReq
6, // 7: user.User.UsersByIds:input_type -> user.UsersByIdsReq
9, // 8: user.User.UpdateMobile:input_type -> user.UpdateMobileReq
11, // 9: user.User.RevokeBizClient:input_type -> user.RevokeBizClientReq
0, // 10: user.User.SendSms:output_type -> user.Response
0, // 11: user.User.Login:output_type -> user.Response
0, // 12: user.User.Info:output_type -> user.Response
0, // 13: user.User.UserItems:output_type -> user.Response
0, // 14: user.User.UserStatus:output_type -> user.Response
5, // 15: user.User.EnsureBizIdentity:output_type -> user.EnsureBizIdentityData
8, // 16: user.User.UsersByIds:output_type -> user.UsersByIdsData
10, // 17: user.User.UpdateMobile:output_type -> user.UpdateMobileData
12, // 18: user.User.RevokeBizClient:output_type -> user.RevokeBizClientData
10, // [10:19] is the sub-list for method output_type
1, // [1:10] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
@@ -1018,7 +1075,7 @@ func file_user_user_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_user_user_proto_rawDesc), len(file_user_user_proto_rawDesc)),
NumEnums: 0,
NumMessages: 14,
NumMessages: 15,
NumExtensions: 0,
NumServices: 1,
},
+38
View File
@@ -19,6 +19,7 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
User_SendSms_FullMethodName = "/user.User/SendSms"
User_Login_FullMethodName = "/user.User/Login"
User_Info_FullMethodName = "/user.User/Info"
User_UserItems_FullMethodName = "/user.User/UserItems"
@@ -33,6 +34,7 @@ const (
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type UserClient interface {
SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error)
Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error)
Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error)
UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error)
@@ -51,6 +53,16 @@ func NewUserClient(cc grpc.ClientConnInterface) UserClient {
return &userClient{cc}
}
func (c *userClient) SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Response)
err := c.cc.Invoke(ctx, User_SendSms_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Response)
@@ -135,6 +147,7 @@ func (c *userClient) RevokeBizClient(ctx context.Context, in *RevokeBizClientReq
// All implementations must embed UnimplementedUserServer
// for forward compatibility.
type UserServer interface {
SendSms(context.Context, *SendSmsReq) (*Response, error)
Login(context.Context, *LoginReq) (*Response, error)
Info(context.Context, *InfoReq) (*Response, error)
UserItems(context.Context, *UserItemsReq) (*Response, error)
@@ -153,6 +166,9 @@ type UserServer interface {
// pointer dereference when methods are called.
type UnimplementedUserServer struct{}
func (UnimplementedUserServer) SendSms(context.Context, *SendSmsReq) (*Response, error) {
return nil, status.Error(codes.Unimplemented, "method SendSms not implemented")
}
func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*Response, error) {
return nil, status.Error(codes.Unimplemented, "method Login not implemented")
}
@@ -198,6 +214,24 @@ func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) {
s.RegisterService(&User_ServiceDesc, srv)
}
func _User_SendSms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SendSmsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).SendSms(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: User_SendSms_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).SendSms(ctx, req.(*SendSmsReq))
}
return interceptor(ctx, in, info, handler)
}
func _User_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginReq)
if err := dec(in); err != nil {
@@ -349,6 +383,10 @@ var User_ServiceDesc = grpc.ServiceDesc{
ServiceName: "user.User",
HandlerType: (*UserServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SendSms",
Handler: _User_SendSms_Handler,
},
{
MethodName: "Login",
Handler: _User_Login_Handler,