login.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'dart:core';
  2. import 'package:fiscommon/json_convert.dart';
  3. import 'package:fisjsonrpc/client_base.dart';
  4. import 'login.m.dart';
  5. /// 登录服务
  6. class LoginService extends JsonRpcClientBase {
  7. LoginService(
  8. String host, {
  9. String serviceName = "ILoginService",
  10. Map<String, String>? headers,
  11. int? timeout,
  12. }) : super(
  13. host,
  14. serviceName,
  15. headers: headers,
  16. timeout: timeout,
  17. ) {
  18. /// 注册响应实体反序列化处理器
  19. FJsonConvert.setDecoder((map) => LoginResult.fromJson(map));
  20. }
  21. /// 登录
  22. Future<LoginResult> clientLoginAsync(LoginRequest request) async {
  23. var rpcRst = await call("ClientLoginAsync", request);
  24. var result = LoginResult.fromJson(rpcRst as Map<String, dynamic>);
  25. return result;
  26. }
  27. /// 注册
  28. Future<bool> signInAsync(SignInRequest request) async {
  29. var rpcRst = await call("SignInAsync", request);
  30. return rpcRst == true;
  31. }
  32. /// 发送邮件验证码
  33. Future<bool> sendEmailVerificationCode(String address) async {
  34. var rpcRst = await call("SendEmailVerificationCode", address);
  35. return rpcRst == true;
  36. }
  37. /// 校验邮件验证码
  38. Future<bool> checkEmailVerificationCode(String address, String code) async {
  39. var rpcRst = await call("CheckEmailVerificationCode", [address, code]);
  40. return rpcRst == true;
  41. }
  42. /// 发送短信验证码
  43. Future<bool> sendSMSVerificationCode(String phone) async {
  44. var rpcRst = await call("SendSMSVerificationCode", phone);
  45. return rpcRst == true;
  46. }
  47. /// 校验短信验证码
  48. Future<bool> checkSMSVerificationCode(String phone, String code) async {
  49. var rpcRst = await call("CheckSMSVerificationCode", [phone, code]);
  50. return rpcRst == true;
  51. }
  52. }