Initial commit: 91dj android client dev_1.0.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import 'package:jydj/tools_base/net/base_resp_bean.dart';
|
||||
import 'package:jydj/tools_base/net/http_manager.dart';
|
||||
|
||||
import '../im_ad/im_ad_item.dart';
|
||||
import '../model/im_user_model.dart';
|
||||
|
||||
class IMApiService {
|
||||
///重新获取 用户 imToken
|
||||
static Future<ImTokenInfo?> getImToken() async {
|
||||
final result = await httpManager.fetchResponseByPOST('/im/token',
|
||||
param: {}, jsonTransformation: (json) => ImTokenInfo.fromJson(json));
|
||||
return result.data;
|
||||
}
|
||||
|
||||
///获取 用户 im userid
|
||||
static Future<ImUserModel?> getImUserInfo({int? uid, int? imUserId}) async {
|
||||
var data = {'userId': uid, 'imUserId': imUserId};
|
||||
data.removeWhere((key, value) => value == null);
|
||||
final result = await httpManager.fetchResponseByPOST('/im/user-id',
|
||||
param: data, jsonTransformation: (json) => ImUserModel.fromJson(json));
|
||||
|
||||
return result.data;
|
||||
}
|
||||
|
||||
///添加好友
|
||||
static Future<ImUserModel> ensureFriend(int? uid) async {
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/im/friend/ensure',
|
||||
param: {'peerId': uid},
|
||||
jsonTransformation: (json) => ImUserModel.fromJson(json),
|
||||
);
|
||||
|
||||
return result.data;
|
||||
}
|
||||
|
||||
///发送im消息
|
||||
static Future<BaseRespBean> sendGroupMessage(int? groupId, String? content, String? image) async {
|
||||
var data = {'groupId': groupId, 'content': content, 'image': image};
|
||||
data.removeWhere((key, value) => value == null);
|
||||
final result = await httpManager.fetchResponseByPOST('/immessage/send', param: data);
|
||||
return result;
|
||||
}
|
||||
|
||||
static Future<ImAdResp> getImAdList(List<String> positions) async {
|
||||
var data = {'positions': positions};
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/im/ad',
|
||||
param: data,
|
||||
jsonTransformation: (json) => ImAdResp.fromJson(json),
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
///发送私信消息(后端转发到 IM,同时扣费)
|
||||
///[takeUid] 接收用户uid [content] 消息内容 [linkUrl] 附带链接 [imgUrl] 图片链接列表
|
||||
static Future<BaseRespBean> sendPriLetter({
|
||||
required int takeUid,
|
||||
String? content,
|
||||
String? linkUrl,
|
||||
List<String>? imgUrl,
|
||||
}) async {
|
||||
var data = {
|
||||
'takeUid': takeUid,
|
||||
'content': content,
|
||||
'linkUrl': linkUrl,
|
||||
'imgUrl': imgUrl,
|
||||
};
|
||||
data.removeWhere((key, value) => value == null || (value is List && value.isEmpty));
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/im/message/send',
|
||||
param: data,
|
||||
jsonTransformation: (json) => ImUserWallet.fromJson(json),
|
||||
);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user