doctor.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:vitalapp/rpc.dart';
  3. import 'package:vitalapp/store/store.dart';
  4. import 'package:fis_common/logger/logger.dart';
  5. import 'interfaces/doctor.dart';
  6. class DoctorManager implements IDoctorManager {
  7. @override
  8. Future<void> syncInfo() async {
  9. try {
  10. final userInfo = await rpc.user.getUserDetailAsync(
  11. GetUserRequest(token: Store.user.token),
  12. );
  13. await Store.user.updateUserInfo(userInfo);
  14. } catch (e) {
  15. logger.e("DoctorManager sync user info error.", e);
  16. }
  17. }
  18. @override
  19. Future<bool> setSignature(String signature) async {
  20. try {
  21. final request = SetSignatureRequest(
  22. token: Store.user.token,
  23. code: Store.user.userCode,
  24. signature: signature,
  25. );
  26. final result = await rpc.user.setSignatureAsync(request);
  27. if (result) {
  28. // 更新全局状态
  29. await Store.user.updateSignature(signature);
  30. }
  31. return result;
  32. } catch (e) {
  33. logger.e("DoctorManager set signature error.", e);
  34. return false;
  35. }
  36. }
  37. }