label.dart 988 B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:vitalapp/rpc.dart';
  3. import 'package:vitalapp/store/store.dart';
  4. import 'interfaces/label.dart';
  5. import 'package:fis_common/logger/logger.dart';
  6. class LabelManager implements ILabelManager {
  7. @override
  8. Future<List<LabelDTO>?> getLabelListByKey(String key) async {
  9. try {
  10. final result = await rpc.label.getLabelListByKeyAsync(
  11. GetLabelListByKeyRequest(key: key, token: Store.user.token),
  12. );
  13. return result;
  14. } catch (e) {
  15. logger.e("LabelManager get labels by key-$key error.", e);
  16. return null;
  17. }
  18. }
  19. @override
  20. Future<List<LabelDTO>> getNormalCrowdLabels() async {
  21. return (await getLabelListByKey("RQFL")) ?? [];
  22. }
  23. @override
  24. Future<List<LabelDTO>> getDiseaseCrowdLabels() async {
  25. return (await getLabelListByKey("CJJB")) ?? [];
  26. }
  27. @override
  28. Future<List<LabelDTO>> getSpecialCareCrowdLabels() async {
  29. return (await getLabelListByKey("TSZG")) ?? [];
  30. }
  31. }