user_dao.dart 946 B

12345678910111213141516171819202122232425262728293031323334
  1. import 'package:gobang/model/user_model.dart';
  2. /// Description: user dao
  3. /// Time : 02/20/2024 Tuesday
  4. /// Author : liuyuqi.gov@msn.cn
  5. class UserDao {
  6. /// login
  7. /// @param username
  8. /// @param password
  9. /// @return Future<String>
  10. static Future<UserModel> login(String username, String password) async {
  11. await Future.delayed(Duration(seconds: 2));
  12. if (username == 'admin' && password == 'admin') {
  13. return UserModel.fromJson({"username": "admin", "password": "admin"});
  14. } else {
  15. throw Exception('username or password is incorrect');
  16. }
  17. }
  18. /// logout
  19. static Future<bool> logout() async {
  20. await Future.delayed(Duration(seconds: 2));
  21. return true;
  22. }
  23. /// register
  24. /// @param username
  25. /// @param password
  26. /// @return Future<String>
  27. static Future<String> register(String username, String password) async {
  28. await Future.delayed(Duration(seconds: 2));
  29. return 'success';
  30. }
  31. }