Browse Source

更新注册验证码相关接口

melon.yin 3 years ago
parent
commit
51b96a54a1
4 changed files with 74 additions and 4 deletions
  1. 4 0
      lib/base_model.dart
  2. 30 0
      lib/services/login.dart
  3. 36 0
      lib/services/login.m.dart
  4. 4 4
      lib/services/remedical.m.dart

+ 4 - 0
lib/base_model.dart

@@ -33,6 +33,7 @@ class PagedData<T> {
   PagedData({
     required this.currentPage,
     required this.pageSize,
+    required this.dataCount,
     this.pageData = const [],
   });
 
@@ -45,6 +46,7 @@ class PagedData<T> {
     return PagedData(
       currentPage: map['CurrentPage'],
       pageSize: map['PageSize'],
+      dataCount: map['DataCount'],
       pageData: dataList,
     );
   }
@@ -53,12 +55,14 @@ class PagedData<T> {
     Map<String, dynamic> map = {};
     map['CurrentPage'] = this.currentPage;
     map['PageSize'] = this.pageSize;
+    map['DataCount'] = this.dataCount;
     map['PageData'] = this.pageData.map((dynamic e) => e.toJson()).toList();
     return map;
   }
 
   final int currentPage;
   final int pageSize;
+  final int dataCount;
   final List<T> pageData;
 }
 

+ 30 - 0
lib/services/login.dart

@@ -27,4 +27,34 @@ class LoginService extends JsonRpcClientBase {
     var result = LoginResult.fromJson(rpcRst as Map<String, dynamic>);
     return result;
   }
+
+  /// 注册
+  Future<bool> signInAsync(SignInRequest request) async {
+    var rpcRst = await call("SignInAsync", request);
+    return rpcRst == true;
+  }
+
+  /// 发送邮件验证码
+  Future<bool> sendEmailVerificationCode(String address) async {
+    var rpcRst = await call("SendEmailVerificationCode", address);
+    return rpcRst == true;
+  }
+
+  /// 校验邮件验证码
+  Future<bool> checkEmailVerificationCode(String address, String code) async {
+    var rpcRst = await call("CheckEmailVerificationCode", [address, code]);
+    return rpcRst == true;
+  }
+
+  /// 发送短信验证码
+  Future<bool> sendSMSVerificationCode(String phone) async {
+    var rpcRst = await call("SendSMSVerificationCode", phone);
+    return rpcRst == true;
+  }
+
+  /// 校验短信验证码
+  Future<bool> checkSMSVerificationCode(String phone, String code) async {
+    var rpcRst = await call("CheckSMSVerificationCode", [phone, code]);
+    return rpcRst == true;
+  }
 }

+ 36 - 0
lib/services/login.m.dart

@@ -91,3 +91,39 @@ class LoginResult {
     );
   }
 }
+
+class SignInRequest {
+  final String userName;
+  final String secretPassword;
+  final String? phone;
+  final String? email;
+  final String? nickName;
+  final String? fullName;
+  final String? headImageToken;
+  final String? lastIp;
+
+  SignInRequest({
+    required this.userName,
+    required this.secretPassword,
+    this.phone,
+    this.email,
+    this.nickName,
+    this.fullName,
+    this.headImageToken,
+    this.lastIp,
+  });
+
+  Map<String, dynamic> toJson() {
+    final map = Map<String, dynamic>();
+    map['UserName'] = userName;
+    map['SecretPassword'] = secretPassword;
+    if (phone != null && phone!.isNotEmpty) map['Phone'] = phone;
+    if (email != null && email!.isNotEmpty) map['Email'] = email;
+    if (nickName != null && nickName!.isNotEmpty) map['NickName'] = nickName;
+    if (fullName != null && fullName!.isNotEmpty) map['FullName'] = fullName;
+    if (headImageToken != null && headImageToken!.isNotEmpty)
+      map['HeadImageToken'] = headImageToken;
+    if (lastIp != null && lastIp!.isNotEmpty) map['LastIp'] = lastIp;
+    return map;
+  }
+}

+ 4 - 4
lib/services/remedical.m.dart

@@ -16,26 +16,26 @@ class RemedicalFilterModel {
 
 class RemedicalQueryRequest extends PagedRequest {
   RemedicalQueryRequest({
+    required this.sessionId,
     int currentPage = 1,
     int pageSize = 10,
     this.filter = const {},
-    this.modelFilter,
   }) : super();
 
+  final String sessionId;
   final Map<String, String> filter;
-  RemedicalFilterModel? modelFilter;
 
   @override
   Map<String, dynamic> toJson() {
     var map = super.toJson();
     map['filter'] = this.filter;
-    if (this.modelFilter != null)
-      map['modelFilter'] = this.modelFilter!.toJson();
+    map['sessionId'] = this.sessionId;
     return map;
   }
 
   factory RemedicalQueryRequest.fromJson(Map<String, dynamic> map) {
     return RemedicalQueryRequest(
+      sessionId: map['sessionId'],
       currentPage: map['currentPage'],
       pageSize: map['pageSize'],
       filter: map['filter'],