contract_template.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'dart:convert';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:vitalapp/managers/interfaces/contract_template.dart';
  4. import 'package:vitalapp/rpc.dart';
  5. import 'package:vitalapp/store/store.dart';
  6. import 'package:fis_common/logger/logger.dart';
  7. class ContractTemplateManager implements IContractTemplateManager {
  8. @override
  9. Future<ContractTemplateDTO?> getContractTemplateDetail(String code) async {
  10. try {
  11. final result =
  12. await rpc.vitalContractTemplate.getContractTemplateDetailAsync(
  13. GetContractTemplateRequest(code: code, token: Store.user.token),
  14. );
  15. return result;
  16. } catch (e) {
  17. logger.e("ContractTemplate getContractTemplateDetail error.", e);
  18. return null;
  19. }
  20. }
  21. @override
  22. Future<ContractTemplateDTO?> getContractTemplateDetailByKey(
  23. String key) async {
  24. try {
  25. final result =
  26. await rpc.vitalContractTemplate.getContractTemplateDetailByKeyAsync(
  27. GetContractTemplateByKeyRequest(
  28. key: key,
  29. token: Store.user.token,
  30. ),
  31. );
  32. return result;
  33. } catch (e) {
  34. logger.e("ContractTemplate getContractTemplateDetailByKey error.", e);
  35. return null;
  36. }
  37. }
  38. @override
  39. Future<List<ContractTemplateDTO>?> getContractTemplatePageAsync() async {
  40. try {
  41. var request = ContractTemplatePageRequest(
  42. token: Store.user.token,
  43. pageIndex: 1,
  44. pageSize: 10,
  45. );
  46. print(jsonEncode(request));
  47. final result =
  48. await rpc.vitalContractTemplate.getContractTemplatePageAsync(request);
  49. return result.pageData;
  50. } catch (e) {
  51. logger.e("ContractTemplate getContractTemplatePageAsync error.", e);
  52. return null;
  53. }
  54. }
  55. }