Browse Source

同步Server最新接口更改

loki.wu 2 years ago
parent
commit
508ec16977
4 changed files with 132 additions and 0 deletions
  1. 3 0
      lib/rpc.dart
  2. 2 0
      lib/services/index.dart
  3. 39 0
      lib/services/lock.dart
  4. 88 0
      lib/services/lock.m.dart

+ 3 - 0
lib/rpc.dart

@@ -74,6 +74,9 @@ class JsonRpcProxy {
 	IdentityApplyService get identityApply =>
 	findService(() => new IdentityApplyService(currentHostAddress));
 
+	LockService get lock =>
+	findService(() => new LockService(currentHostAddress));
+
 	LoginService get login =>
 	findService(() => new LoginService(currentHostAddress));
 

+ 2 - 0
lib/services/index.dart

@@ -7,6 +7,7 @@ export 'device.dart';
 export 'email.dart';
 export 'identityApply.dart';
 export 'liveConsultation.dart';
+export 'lock.dart';
 export 'login.dart';
 export 'organization.dart';
 export 'patient.dart';
@@ -30,6 +31,7 @@ export 'dBLog.m.dart';
 export 'device.m.dart';
 export 'identityApply.m.dart';
 export 'liveConsultation.m.dart';
+export 'lock.m.dart';
 export 'login.m.dart';
 export 'organization.m.dart';
 export 'patient.m.dart';

+ 39 - 0
lib/services/lock.dart

@@ -0,0 +1,39 @@
+import 'dart:core';
+
+import 'package:fis_jsonrpc/client_base.dart';
+import 'package:fis_common/json_convert.dart';
+
+import 'lock.m.dart';
+
+
+class LockService extends JsonRpcClientBase {
+	LockService(
+		String host, {
+		String serviceName = "ILockService",
+		Map<String, String>? headers,
+		int? timeout,
+	}) : super(
+						host,
+						serviceName,
+						headers: headers,
+						timeout: timeout,
+				) {
+		/// 注册响应实体反序列化处理器
+		FJsonConvert.setDecoder((map) => ApplyLockResult.fromJson(map));
+		FJsonConvert.setDecoder((map) => ReleaseLockResult.fromJson(map));
+	}
+
+	Future<ApplyLockResult> applyLockAsync(ApplyLockRequest request) async {
+		var rpcRst = await call("ApplyLockAsync", request);
+		var result = ApplyLockResult.fromJson(rpcRst as Map<String, dynamic>);
+		return result;
+	}
+
+	Future<ReleaseLockResult> releaseLockAsync(ReleaseLockRequest request) async {
+		var rpcRst = await call("ReleaseLockAsync", request);
+		var result = ReleaseLockResult.fromJson(rpcRst as Map<String, dynamic>);
+		return result;
+	}
+
+}
+

+ 88 - 0
lib/services/lock.m.dart

@@ -0,0 +1,88 @@
+class ApplyLockResult {
+	bool isSuccess;
+	String? lockUniqueCode;
+
+	ApplyLockResult({
+		this.isSuccess = false,
+		this.lockUniqueCode,
+	});
+
+	factory ApplyLockResult.fromJson(Map<String, dynamic> map) {
+		return ApplyLockResult( 
+			isSuccess: map['IsSuccess'],
+			lockUniqueCode: map['LockUniqueCode'],
+		);
+	}
+
+	Map<String, dynamic> toJson() {
+		final map = Map<String, dynamic>();
+		map['IsSuccess'] = isSuccess;
+		if(lockUniqueCode != null)
+			map['LockUniqueCode'] = lockUniqueCode;
+		return map;
+	}
+}
+
+class ApplyLockRequest {
+	String? lockKey;
+
+	ApplyLockRequest({
+		this.lockKey,
+	});
+
+	factory ApplyLockRequest.fromJson(Map<String, dynamic> map) {
+		return ApplyLockRequest( 
+			lockKey: map['LockKey'],
+		);
+	}
+
+	Map<String, dynamic> toJson() {
+		final map = Map<String, dynamic>();
+		if(lockKey != null)
+			map['LockKey'] = lockKey;
+		return map;
+	}
+}
+
+class ReleaseLockResult {
+	bool isSuccess;
+
+	ReleaseLockResult({
+		this.isSuccess = false,
+	});
+
+	factory ReleaseLockResult.fromJson(Map<String, dynamic> map) {
+		return ReleaseLockResult( 
+			isSuccess: map['IsSuccess'],
+		);
+	}
+
+	Map<String, dynamic> toJson() {
+		final map = Map<String, dynamic>();
+		map['IsSuccess'] = isSuccess;
+		return map;
+	}
+}
+
+class ReleaseLockRequest {
+	String? lockUniqueCode;
+
+	ReleaseLockRequest({
+		this.lockUniqueCode,
+	});
+
+	factory ReleaseLockRequest.fromJson(Map<String, dynamic> map) {
+		return ReleaseLockRequest( 
+			lockUniqueCode: map['LockUniqueCode'],
+		);
+	}
+
+	Map<String, dynamic> toJson() {
+		final map = Map<String, dynamic>();
+		if(lockUniqueCode != null)
+			map['LockUniqueCode'] = lockUniqueCode;
+		return map;
+	}
+}
+
+