parent
952cb82417
commit
7457f182f3
@ -0,0 +1,10 @@ |
||||
package io.openim.flutter_openim_sdk.listener; |
||||
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil; |
||||
|
||||
public class OnOrganizationListener implements open_im_sdk_callback.OnOrganizationListener { |
||||
@Override |
||||
public void onOrganizationUpdated() { |
||||
CommonUtil.emitEvent("organizationListener", "onOrganizationUpdated", null); |
||||
} |
||||
} |
@ -0,0 +1,54 @@ |
||||
package io.openim.flutter_openim_sdk.manager; |
||||
|
||||
import io.flutter.plugin.common.MethodCall; |
||||
import io.flutter.plugin.common.MethodChannel; |
||||
import io.openim.flutter_openim_sdk.listener.OnBaseListener; |
||||
import io.openim.flutter_openim_sdk.listener.OnOrganizationListener; |
||||
import open_im_sdk.Open_im_sdk; |
||||
|
||||
public class OrganizationManager extends BaseManager { |
||||
|
||||
public void setOrganizationListener(MethodCall methodCall, MethodChannel.Result result) { |
||||
Open_im_sdk.setOrganizationListener(new OnOrganizationListener()); |
||||
} |
||||
|
||||
public void getSubDepartment(MethodCall methodCall, MethodChannel.Result result) { |
||||
Open_im_sdk.getSubDepartment( |
||||
new OnBaseListener(result, methodCall), |
||||
value(methodCall, "operationID"), |
||||
value(methodCall, "departmentID"), |
||||
int2long(methodCall, "offset"), |
||||
int2long(methodCall, "count") |
||||
); |
||||
} |
||||
|
||||
public void getDepartmentMember(MethodCall methodCall, MethodChannel.Result result) { |
||||
Open_im_sdk.getDepartmentMember( |
||||
new OnBaseListener(result, methodCall), |
||||
value(methodCall, "operationID"), |
||||
value(methodCall, "departmentID"), |
||||
int2long(methodCall, "offset"), |
||||
int2long(methodCall, "count") |
||||
); |
||||
} |
||||
|
||||
public void getUserInDepartment(MethodCall methodCall, MethodChannel.Result result) { |
||||
Open_im_sdk.getUserInDepartment( |
||||
new OnBaseListener(result, methodCall), |
||||
value(methodCall, "operationID"), |
||||
value(methodCall, "userID") |
||||
); |
||||
} |
||||
|
||||
public void getDepartmentMemberAndSubDepartment(MethodCall methodCall, MethodChannel.Result result) { |
||||
Open_im_sdk.getDepartmentMemberAndSubDepartment( |
||||
new OnBaseListener(result, methodCall), |
||||
value(methodCall, "operationID"), |
||||
value(methodCall, "departmentID"), |
||||
int2long(methodCall, "departmentOffset"), |
||||
int2long(methodCall, "departmentCount"), |
||||
int2long(methodCall, "memberOffset"), |
||||
int2long(methodCall, "memberCount") |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,49 @@ |
||||
import Foundation |
||||
import OpenIMCore |
||||
|
||||
public class OrganizationManager: BaseServiceManager { |
||||
|
||||
public override func registerHandlers() { |
||||
super.registerHandlers() |
||||
self["setOrganizationListener"] = setOrganizationListener |
||||
self["getSubDepartment"] = getSubDepartment |
||||
self["getDepartmentMember"] = getDepartmentMember |
||||
self["getUserInDepartment"] = getUserInDepartment |
||||
self["getDepartmentMemberAndSubDepartment"] = getDepartmentMemberAndSubDepartment |
||||
} |
||||
|
||||
func setOrganizationListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ |
||||
Open_im_sdkSetOrganizationListener(OrganizationListener(channel: channel)) |
||||
callBack(result) |
||||
} |
||||
|
||||
func getSubDepartment(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { |
||||
Open_im_sdkGetSubDepartment(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "departmentID"], methodCall[int: "offset"], methodCall[int: "count"]) |
||||
} |
||||
|
||||
func getDepartmentMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { |
||||
Open_im_sdkGetDepartmentMember(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "departmentID"], methodCall[int: "offset"], methodCall[int: "count"]) |
||||
} |
||||
|
||||
func getUserInDepartment(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { |
||||
Open_im_sdkGetUserInDepartment(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"]) |
||||
} |
||||
|
||||
func getDepartmentMemberAndSubDepartment(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { |
||||
Open_im_sdkGetDepartmentMemberAndSubDepartment(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "departmentID"], methodCall[int: "departmentOffset"], methodCall[int: "departmentCount"], methodCall[int: "memberOffset"], methodCall[int: "memberCount"]) |
||||
} |
||||
} |
||||
|
||||
public class OrganizationListener: NSObject, Open_im_sdk_callbackOnOrganizationListenerProtocol { |
||||
|
||||
private let channel:FlutterMethodChannel |
||||
|
||||
init(channel:FlutterMethodChannel) { |
||||
self.channel = channel |
||||
} |
||||
|
||||
public func onOrganizationUpdated() { |
||||
CommonUtil.emitEvent(channel: self.channel, method: "organizationListener", type: "onOrganizationUpdated", errCode: nil, errMsg: nil, data: nil) |
||||
} |
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
class OnOrganizationListener { |
||||
Function()? onOrganizationUpdated; |
||||
|
||||
OnOrganizationListener({this.onOrganizationUpdated}); |
||||
|
||||
void organizationUpdated() { |
||||
onOrganizationUpdated?.call(); |
||||
} |
||||
} |
@ -0,0 +1,98 @@ |
||||
import 'package:flutter/services.dart'; |
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; |
||||
|
||||
class OrganizationManager { |
||||
MethodChannel _channel; |
||||
late OnOrganizationListener listener; |
||||
|
||||
OrganizationManager(this._channel); |
||||
|
||||
/// Observe organization info changes |
||||
/// 组织架构发生变化回调 |
||||
Future setOrganizationListener(OnOrganizationListener listener) { |
||||
this.listener = listener; |
||||
return _channel.invokeMethod('setOrganizationListener', _buildParam({})); |
||||
} |
||||
|
||||
/// Query sub department |
||||
/// 获取子部门列表 |
||||
Future<List<DeptInfo>> getSubDept({ |
||||
required String departmentID, |
||||
int offset = 0, |
||||
int count = 40, |
||||
String? operationID, |
||||
}) => |
||||
_channel |
||||
.invokeMethod( |
||||
'getSubDepartment', |
||||
_buildParam({ |
||||
'departmentID': departmentID, |
||||
'offset': offset, |
||||
'count': count, |
||||
'operationID': Utils.checkOperationID(operationID), |
||||
})) |
||||
.then((value) => Utils.toList(value, (v) => DeptInfo.fromJson(v))); |
||||
|
||||
/// Get member under a department |
||||
/// 获取部门下的成员列表 |
||||
Future<List<DeptMemberInfo>> getDeptMember({ |
||||
required String departmentID, |
||||
int offset = 0, |
||||
int count = 40, |
||||
String? operationID, |
||||
}) => |
||||
_channel |
||||
.invokeMethod( |
||||
'getDepartmentMember', |
||||
_buildParam({ |
||||
'departmentID': departmentID, |
||||
'offset': offset, |
||||
'count': count, |
||||
'operationID': Utils.checkOperationID(operationID), |
||||
})) |
||||
.then((value) => |
||||
Utils.toList(value, (v) => DeptMemberInfo.fromJson(v))); |
||||
|
||||
/// Get member's department |
||||
/// 获取成员所在的部门 |
||||
Future<List<UserInDept>> getUserInDept({ |
||||
required String userID, |
||||
String? operationID, |
||||
}) => |
||||
_channel |
||||
.invokeMethod( |
||||
'getUserInDepartment', |
||||
_buildParam({ |
||||
'userID': userID, |
||||
'operationID': Utils.checkOperationID(operationID), |
||||
})) |
||||
.then((value) => Utils.toList(value, (v) => UserInDept.fromJson(v))); |
||||
|
||||
/// Get the sub-departments and employees under the department |
||||
/// 获取部门下的子部门跟员工 |
||||
Future<List<UserInDept>> getDeptMemberAndSubDept({ |
||||
required String departmentID, |
||||
int departmentOffset = 0, |
||||
int departmentCount = 40, |
||||
int memberOffset = 0, |
||||
int memberCount = 40, |
||||
String? operationID, |
||||
}) => |
||||
_channel |
||||
.invokeMethod( |
||||
'getDepartmentMemberAndSubDepartment', |
||||
_buildParam({ |
||||
'departmentID': departmentID, |
||||
'departmentOffset': departmentOffset, |
||||
'departmentCount': departmentCount, |
||||
'memberOffset': memberOffset, |
||||
'memberCount': memberCount, |
||||
'operationID': Utils.checkOperationID(operationID), |
||||
})) |
||||
.then((value) => Utils.toList(value, (v) => UserInDept.fromJson(v))); |
||||
|
||||
static Map _buildParam(Map param) { |
||||
param["ManagerName"] = "organizationManager"; |
||||
return param; |
||||
} |
||||
} |
@ -0,0 +1,198 @@ |
||||
class DeptInfo { |
||||
String? departmentID; |
||||
String? faceURL; |
||||
String? name; |
||||
String? parentID; |
||||
int? order; |
||||
int? departmentType; |
||||
int? createTime; |
||||
int? subDepartmentNum; |
||||
int? memberNum; |
||||
String? ex; |
||||
String? attachedInfo; |
||||
|
||||
DeptInfo( |
||||
{this.departmentID, |
||||
this.faceURL, |
||||
this.name, |
||||
this.parentID, |
||||
this.order, |
||||
this.departmentType, |
||||
this.createTime, |
||||
this.subDepartmentNum, |
||||
this.memberNum, |
||||
this.ex, |
||||
this.attachedInfo}); |
||||
|
||||
DeptInfo.fromJson(Map<String, dynamic> json) { |
||||
departmentID = json['departmentID']; |
||||
faceURL = json['faceURL']; |
||||
name = json['name']; |
||||
parentID = json['parentID']; |
||||
order = json['order']; |
||||
departmentType = json['departmentType']; |
||||
createTime = json['createTime ']; |
||||
subDepartmentNum = json['subDepartmentNum ']; |
||||
memberNum = json['memberNum ']; |
||||
ex = json['ex ']; |
||||
attachedInfo = json['attachedInfo ']; |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final data = Map<String, dynamic>(); |
||||
data['departmentID'] = this.departmentID; |
||||
data['faceURL'] = this.faceURL; |
||||
data['name'] = this.name; |
||||
data['parentID'] = this.parentID; |
||||
data['order'] = this.order; |
||||
data['departmentType'] = this.departmentType; |
||||
data['createTime '] = this.createTime; |
||||
data['subDepartmentNum '] = this.subDepartmentNum; |
||||
data['memberNum '] = this.memberNum; |
||||
data['ex '] = this.ex; |
||||
data['attachedInfo '] = this.attachedInfo; |
||||
return data; |
||||
} |
||||
} |
||||
|
||||
class DeptMemberInfo { |
||||
String? userID; |
||||
String? nickname; |
||||
String? englishName; |
||||
String? faceURL; |
||||
int? gender; |
||||
String? mobile; |
||||
String? telephone; |
||||
int? birth; |
||||
String? email; |
||||
String? departmentID; |
||||
int? order; |
||||
String? position; |
||||
int? leader; |
||||
int? status; |
||||
int? createTime; |
||||
String? ex; |
||||
String? attachedInfo; |
||||
|
||||
DeptMemberInfo( |
||||
{this.userID, |
||||
this.nickname, |
||||
this.englishName, |
||||
this.faceURL, |
||||
this.gender, |
||||
this.mobile, |
||||
this.telephone, |
||||
this.birth, |
||||
this.email, |
||||
this.departmentID, |
||||
this.order, |
||||
this.position, |
||||
this.leader, |
||||
this.status, |
||||
this.createTime, |
||||
this.ex, |
||||
this.attachedInfo}); |
||||
|
||||
DeptMemberInfo.fromJson(Map<String, dynamic> json) { |
||||
userID = json['userID']; |
||||
nickname = json['nickname']; |
||||
englishName = json['englishName']; |
||||
faceURL = json['faceURL ']; |
||||
gender = json['gender ']; |
||||
mobile = json['mobile ']; |
||||
telephone = json['telephone ']; |
||||
birth = json['birth ']; |
||||
email = json['email ']; |
||||
departmentID = json['departmentID ']; |
||||
order = json['order ']; |
||||
position = json['position ']; |
||||
leader = json['leader ']; |
||||
status = json['status ']; |
||||
createTime = json['createTime ']; |
||||
ex = json['ex ']; |
||||
attachedInfo = json['attachedInfo ']; |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
data['userID'] = this.userID; |
||||
data['nickname'] = this.nickname; |
||||
data['englishName'] = this.englishName; |
||||
data['faceURL '] = this.faceURL; |
||||
data['gender '] = this.gender; |
||||
data['mobile '] = this.mobile; |
||||
data['telephone '] = this.telephone; |
||||
data['birth '] = this.birth; |
||||
data['email '] = this.email; |
||||
data['departmentID '] = this.departmentID; |
||||
data['order '] = this.order; |
||||
data['position '] = this.position; |
||||
data['leader '] = this.leader; |
||||
data['status '] = this.status; |
||||
data['createTime '] = this.createTime; |
||||
data['ex '] = this.ex; |
||||
data['attachedInfo '] = this.attachedInfo; |
||||
return data; |
||||
} |
||||
} |
||||
|
||||
class UserInDept { |
||||
DeptInfo? department; |
||||
DeptMemberInfo? member; |
||||
|
||||
UserInDept({this.department, this.member}); |
||||
|
||||
UserInDept.fromJson(Map<String, dynamic> json) { |
||||
department = json['department'] != null |
||||
? DeptInfo.fromJson(json['department']) |
||||
: null; |
||||
member = |
||||
json['member'] != null ? DeptMemberInfo.fromJson(json['member']) : null; |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final data = Map<String, dynamic>(); |
||||
if (this.department != null) { |
||||
data['department'] = this.department!.toJson(); |
||||
} |
||||
if (this.member != null) { |
||||
data['member'] = this.member!.toJson(); |
||||
} |
||||
return data; |
||||
} |
||||
} |
||||
|
||||
class DeptMemberAndSubDept { |
||||
List<DeptInfo>? departmentList; |
||||
List<DeptMemberInfo>? departmentMemberList; |
||||
|
||||
DeptMemberAndSubDept({this.departmentList, this.departmentMemberList}); |
||||
|
||||
DeptMemberAndSubDept.fromJson(Map<String, dynamic> json) { |
||||
if (json['departmentList'] != null) { |
||||
departmentList = <DeptInfo>[]; |
||||
json['departmentList'].forEach((v) { |
||||
departmentList!.add(DeptInfo.fromJson(v)); |
||||
}); |
||||
} |
||||
if (json['departmentMemberList'] != null) { |
||||
departmentMemberList = <DeptMemberInfo>[]; |
||||
json['departmentMemberList'].forEach((v) { |
||||
departmentMemberList!.add(DeptMemberInfo.fromJson(v)); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final data = Map<String, dynamic>(); |
||||
if (this.departmentList != null) { |
||||
data['departmentList'] = |
||||
this.departmentList!.map((v) => v.toJson()).toList(); |
||||
} |
||||
if (this.departmentMemberList != null) { |
||||
data['departmentMemberList'] = |
||||
this.departmentMemberList!.map((v) => v.toJson()).toList(); |
||||
} |
||||
return data; |
||||
} |
||||
} |
Loading…
Reference in new issue