using ce.autofac.extension;
using learun.iapplication;
using learun.util;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace learun.application
{
///
/// 版 本 EasyCode EC管理后台
/// Copyright (c) 2019-present EC管理有限公司
/// 创建人:tobin
/// 日 期:2019.11.05
/// 描 述:即时通讯用户注册
///
public class IMSysUserBLL : BLLBase, IMSysUserIBLL, BLL
{
private readonly IMSysUserService iMSysUserService = new IMSysUserService();
private readonly IMMsgService iMMsgService = new IMMsgService();
#region 获取数据
///
/// 获取列表数据
///
/// 查询关键字
///
public Task> GetList(string keyWord)
{
return iMSysUserService.GetList(keyWord);
}
///
/// 获取列表分页数据
///
/// 分页参数
/// 查询关键字
///
public Task> GetPageList(Pagination pagination, string keyWord)
{
return iMSysUserService.GetPageList(pagination, keyWord);
}
///
/// 获取实体数据
///
/// 主键
///
public Task GetEntity(string keyValue)
{
return iMSysUserService.GetEntity(keyValue);
}
#endregion 获取数据
#region 提交数据
///
/// 删除实体数据(虚拟)
///
/// 主键
///
public async Task DeleteEntity(string keyValue)
{
await iMSysUserService.DeleteEntity(keyValue);
}
///
/// 保存实体数据(新增、修改)
///
/// 主键
/// 实体
///
public async Task SaveEntity(string keyValue, IMSysUserEntity entity)
{
await iMSysUserService.SaveEntity(keyValue, entity);
}
#endregion 提交数据
#region 扩展方法
///
/// 发送消息
///
/// 编码
/// 用户列表
/// 消息内容
public async Task SendMsg(string code, IEnumerable userIdList, string content)
{
if (!string.IsNullOrEmpty(content) && userIdList != null)
{
var entity = await iMSysUserService.GetEntityByCode(code);
if (entity != null)
{
foreach (var userId in userIdList)
{
IMMsgEntity iMMsgEntity = new IMMsgEntity();
iMMsgEntity.F_SendUserId = code;
iMMsgEntity.F_RecvUserId = userId;
iMMsgEntity.F_Content = content;
await iMMsgService.SaveEntity(iMMsgEntity);
await SendHubs.callMethod("sendMsg2", code, userId, content, 1);
}
}
}
}
#endregion 扩展方法
}
}