Blame view

lib/common/request/dao/user_dao.dart 2.63 KB
94342c3f   Key   feat: user util
1
  import 'package:wow_english/common/core/user_util.dart';
05f9b20a   Key   fixed: api调用方式,未完善
2
3
  import 'package:wow_english/models/user_entity.dart';
  
056970d8   Key   feat: api
4
5
  import '../request_client.dart';
  
da82bd70   Key   feat: user_inform...
6
7
  enum SmsType { login, change_passWord, stdDestroy }
  
056970d8   Key   feat: api
8
  class UserDao {
c95453ce   Key   feat: User界面完善
9
    /// 登录
94342c3f   Key   feat: user util
10
    static Future<UserEntity?> login(phoneNumber, type, checkKey, checkNumber) async {
05f9b20a   Key   fixed: api调用方式,未完善
11
      var params = {'phoneNum': phoneNumber, 'type': type, checkKey: checkNumber};
94342c3f   Key   feat: user util
12
      var data = await requestClient.post<UserEntity>(
05f9b20a   Key   fixed: api调用方式,未完善
13
14
15
        Apis.login,
        data: params,
      );
aa4e28be   Key   removed: cache_bl...
16
      if (data != null) {
94342c3f   Key   feat: user util
17
18
        UserUtil.saveUser(data);
      }
05f9b20a   Key   fixed: api调用方式,未完善
19
      return data;
056970d8   Key   feat: api
20
    }
39e06486   liangchengyou   feat:获取验证码逻辑处理
21
  
c95453ce   Key   feat: User界面完善
22
23
24
25
26
27
28
29
30
    /// 登出
    static Future logout() async {
      var result = await requestClient.post(Apis.logout);
      print('logout result=$result');
      UserUtil.logout();
      return result;
    }
  
    /// 发送验证码
da82bd70   Key   feat: user_inform...
31
    /// [msgType] 消息类型 登录:login, 更改密码:change_passWord, 账号注销:stdDestroy
c95453ce   Key   feat: User界面完善
32
33
34
35
36
    static Future sendCode(phoneNumber, {smsType = 'login'}) async {
      final params = {'phoneNum': phoneNumber, 'smsType': smsType};
      await requestClient.post(Apis.sendSmsCode, data: params);
    }
  
4b2c2f07   Key   feat: 三种修改密码的类型及接口
37
38
39
40
41
42
43
44
    /// 设置密码,初始化密码
    /// [password] 密码
    static Future initPassword(String password) async {
      final params = {'password': password};
      await requestClient.post(Apis.initPassword, data: params);
    }
  
    /// 修改密码
da82bd70   Key   feat: user_inform...
45
    /// [phoneNum] 手机号
4b2c2f07   Key   feat: 三种修改密码的类型及接口
46
    /// [password] 密码
da82bd70   Key   feat: user_inform...
47
48
49
    /// [smsCode] 短信验证码
    static Future changePassword(String phoneNum, String password, String smsCode) async {
      final params = {'phoneNum': phoneNum, 'password': password, 'code': smsCode};
4b2c2f07   Key   feat: 三种修改密码的类型及接口
50
51
52
53
      await requestClient.post(Apis.changePassword, data: params);
    }
  
    /// 忘记密码
da82bd70   Key   feat: user_inform...
54
    /// [phoneNum] 手机号
4b2c2f07   Key   feat: 三种修改密码的类型及接口
55
    /// [password] 密码
da82bd70   Key   feat: user_inform...
56
    /// [smsCode] 短信验证码
4b2c2f07   Key   feat: 三种修改密码的类型及接口
57
58
59
60
61
    static Future resetPassword(String phoneNum, String password, String smsCode) async {
      final params = {'phoneNum': phoneNum, 'password': password, 'code': smsCode};
      await requestClient.post(Apis.resetPassword, data: params);
    }
  
da82bd70   Key   feat: user_inform...
62
63
64
65
66
67
68
    /// 验证短信验证码
    /// [msgType] 消息类型 登录:login, 更改密码:change_passWord, 账号注销:stdDestroy
    static Future checkSmsCode(String phoneNum, String smsCode, String msgType) async {
      final params = {'phoneNum': phoneNum, 'code': smsCode, 'msgType': msgType};
      await requestClient.post(Apis.checkSmsCode, data: params);
    }
  
c95453ce   Key   feat: User界面完善
69
70
71
72
73
74
75
76
    /// 获取用户信息
    static Future<UserEntity?> getUserInfo() async {
      return await requestClient.post(Apis.getUserInfo);
    }
  
    /// 更新用户信息,返回即成功,无body
    static Future updateUserInfo(UserEntity userEntity) async {
      return await requestClient.put(Apis.setUserInfo, data: userEntity.toUpdateJson());
39e06486   liangchengyou   feat:获取验证码逻辑处理
77
    }
056970d8   Key   feat: api
78
  }