新增PC端消息聊天

development
温天培 2 years ago
parent 5e64b591d0
commit 611d43a946

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Enum
{
/// <summary>
/// redis枚举配置
/// </summary>
public class SystemConst
{
#region 聊天
/// <summary>
/// 聊天历史列表
/// </summary>
public const string LIVE_HISTORYLIST = "Live_HistoryList:";
/// <summary>
/// 聊天详情
/// </summary>
public const string LIVE_MESSAGE = "Live_Message:";
#endregion
}
}

@ -189,6 +189,67 @@
好友ID 好友ID
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.Enum.SystemConst">
<summary>
redis枚举配置
</summary>
</member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_HISTORYLIST">
<summary>
聊天历史列表
</summary>
</member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_MESSAGE">
<summary>
聊天详情
</summary>
</member>
<member name="T:GDZZ.Application.Help.CacheService">
<summary>
系统缓存服务
</summary>
</member>
<member name="M:GDZZ.Application.Help.CacheService.#ctor">
<summary>
</summary>
</member>
<member name="M:GDZZ.Application.Help.CacheService.GetLiveHistoryService(System.Int64)">
<summary>
获取聊天列表
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Help.CacheService.SetLiveHistoryService(System.Int64,System.Collections.Generic.List{GDZZ.Application.LiveHistoryLists})">
<summary>
设置聊天列表
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Help.CacheService.DelLiveHistoryService(System.Int64)">
<summary>
删除聊天列表
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Help.CacheService.GetMessage(System.Int64,System.Int64)">
<summary>
获取聊天列表
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Help.CacheService.SetMessage(System.Collections.Generic.List{GDZZ.Application.LiveMessageList},System.Int64,System.Int64)">
<summary>
获取聊天列表
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Help.CacheService.DelMessage(System.Int64,System.Int64)">
<summary>
获取聊天列表
</summary>
<returns></returns>
</member>
<member name="F:GDZZ.Application.Service.Auth.AuthService._oauthConfig"> <member name="F:GDZZ.Application.Service.Auth.AuthService._oauthConfig">
<summary> <summary>
获取配置文件 获取配置文件
@ -216,14 +277,6 @@
<param name="chatHubContext"></param> <param name="chatHubContext"></param>
<param name="_sysOnlineUerRep"></param> <param name="_sysOnlineUerRep"></param>
</member> </member>
<member name="M:GDZZ.Application.Service.LiveChat.LiveChatService.PushMessages(System.Collections.Generic.List{System.Int64},System.String)">
<summary>
发送消息
</summary>
<param name="message"></param>
<param name="userIds"></param>
<returns></returns>
</member>
<member name="T:GDZZ.Application.Service.WXPay.IWXPayService"> <member name="T:GDZZ.Application.Service.WXPay.IWXPayService">
<summary> <summary>
微信支付 微信支付
@ -763,6 +816,11 @@
主键Id 主键Id
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.UpdateLiveHistoryContactsInput.Unread">
<summary>
修改消息数
</summary>
</member>
<member name="P:GDZZ.Application.AddLiveMessageInput.TenantId"> <member name="P:GDZZ.Application.AddLiveMessageInput.TenantId">
<summary> <summary>
租户Id 租户Id
@ -853,6 +911,21 @@
最后消息 最后消息
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.LiveFileOutput">
<summary>
聊天文件
</summary>
</member>
<member name="P:GDZZ.Application.LiveFileOutput.Id">
<summary>
文件ID
</summary>
</member>
<member name="P:GDZZ.Application.LiveFileOutput.FileUrl">
<summary>
文件名称
</summary>
</member>
<member name="T:GDZZ.Application.LiveHistoryContactsService"> <member name="T:GDZZ.Application.LiveHistoryContactsService">
<summary> <summary>
聊天服务 聊天服务
@ -864,6 +937,18 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.UPLive(GDZZ.Application.UpdateLiveHistoryContactsInput)">
<summary>
修改消息条数
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.DelLive(System.Int64)">
<summary>
删除联系人
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.List"> <member name="M:GDZZ.Application.LiveHistoryContactsService.List">
<summary> <summary>
获取联系人 获取联系人
@ -873,16 +958,31 @@
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.GetMessageLists"> <member name="M:GDZZ.Application.LiveHistoryContactsService.GetMessageLists">
<summary> <summary>
获取聊天信息列表 获取聊天详情
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.AddMessage(GDZZ.Application.AddLiveMessageInput)"> <member name="M:GDZZ.Application.LiveHistoryContactsService.AddMessage(GDZZ.Application.AddLiveMessageInput)">
<summary> <summary>
增加聊天历史任务列表 增加聊天详情
</summary> </summary>
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.UploadFileDefault(Microsoft.AspNetCore.Http.IFormFile)">
<summary>
上传文件
</summary>
<param name="file"></param>
<returns></returns>
</member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.UploadFile(Microsoft.AspNetCore.Http.IFormFile,System.String,GDZZ.Core.FileLocation)">
<summary>
上传文件
</summary>
<param name="file"></param>
<param name="pathType"></param>
<returns></returns>
</member>
</members> </members>
</doc> </doc>

@ -0,0 +1,109 @@
using Furion;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using GDZZ.Application.Enum;
using GDZZ.Core;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Help
{
/// <summary>
/// 系统缓存服务
/// </summary>
public class CacheService : ICacheService, IDynamicApiController, ITransient
{
private static ICache _redisCache = App.RootServices.GetService(typeof(RedisCache)) as ICache;
/// <summary>
///
/// </summary>
public CacheService() { }
#region 聊天服务
/// <summary>
/// 获取聊天列表
/// </summary>
/// <returns></returns>
[NonAction]
public async Task<List<LiveHistoryLists>> GetLiveHistoryService(long UserID)
{
string cacheKey = SystemConst.LIVE_HISTORYLIST + $"{UserID}";
return await _redisCache.GetAsync<List<LiveHistoryLists>>(cacheKey);
}
/// <summary>
/// 设置聊天列表
/// </summary>
/// <returns></returns>
[NonAction]
public async Task SetLiveHistoryService(long UserID, List<LiveHistoryLists> liveMessageLists)
{
string cacheKey = SystemConst.LIVE_HISTORYLIST + $"{UserID}";
await _redisCache.SetAsync(cacheKey, liveMessageLists, TimeSpan.FromHours(1));
}
/// <summary>
/// 删除聊天列表
/// </summary>
/// <returns></returns>
[NonAction]
public async Task DelLiveHistoryService(long UserID)
{
string cacheKey = SystemConst.LIVE_HISTORYLIST + $"{UserID}";
await _redisCache.DelAsync(cacheKey);
}
#endregion
#region 聊天详情
/// <summary>
/// 获取聊天列表
/// </summary>
/// <returns></returns>
[NonAction]
public async Task<List<LiveMessageList>> GetMessage(long UserID,long ChatUserID)
{
string cacheKey = SystemConst.LIVE_MESSAGE + $"{UserID}_{ChatUserID}";
return await _redisCache.GetAsync<List<LiveMessageList>>(cacheKey);
}
/// <summary>
/// 获取聊天列表
/// </summary>
/// <returns></returns>
[NonAction]
public async Task SetMessage(List<LiveMessageList> liveMessages,long UserID,long ChatUserID)
{
string cacheKey = SystemConst.LIVE_MESSAGE + $"{UserID}_{ChatUserID}";
await _redisCache.SetAsync(cacheKey, liveMessages, TimeSpan.FromHours(1));
}
/// <summary>
/// 获取聊天列表
/// </summary>
/// <returns></returns>
[NonAction]
public async Task DelMessage(long UserID, long ChatUserID)
{
string cacheKey = SystemConst.LIVE_MESSAGE + $"{UserID}_{ChatUserID}";
await _redisCache.DelAsync(cacheKey);
}
#endregion
}
}

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Help
{
public interface ICacheService
{
#region 聊天接口
Task DelLiveHistoryService(long UserID);
Task<List<LiveHistoryLists>> GetLiveHistoryService(long UserID);
Task SetLiveHistoryService(long UserID, List<LiveHistoryLists> liveMessageLists);
#endregion
#region 聊天详情接口
#endregion
}
}

@ -39,25 +39,7 @@ namespace GDZZ.Application.Service.LiveChat
/// <summary>
/// 发送消息
/// </summary>
/// <param name="message"></param>
/// <param name="userIds"></param>
/// <returns></returns>
[HttpPost("/LiveChat/PushMessage")]
public async Task PushMessages(List<long> userIds, string message)
{
var userList = this.sysOnlineUerRep.Where(m => userIds.Contains(m.UserId)).ToList();
if (userList.Any())
{
foreach (var item in userList)
{
await _chatHubContext.Clients.Client(item.ConnectionId).SendMessage("", item.Name, message);
}
}
}
} }
} }

@ -90,7 +90,7 @@ namespace GDZZ.Application
/// <summary> /// <summary>
/// 最新消息时间戳 /// 最新消息时间戳
/// </summary> /// </summary>
public string LastSendTime { get; set; } public long LastSendTime { get; set; }
/// <summary> /// <summary>
/// 最新消息内容 /// 最新消息内容
@ -111,7 +111,9 @@ namespace GDZZ.Application
public string Content { get; set; } public string Content { get; set; }
public long ToContactId { get; set; } public long ToContactId { get; set; }
public int FileSize { get; set; }
public string FileName { get; set; }
} }
} }

@ -64,6 +64,12 @@ namespace GDZZ.Application
[Required(ErrorMessage = "主键Id不能为空")] [Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; } public long Id { get; set; }
/// <summary>
/// 修改消息数
/// </summary>
public string Unread { get; set; }
} }
public class QueryeLiveHistoryContactsInput : DeleteLiveHistoryContactsInput public class QueryeLiveHistoryContactsInput : DeleteLiveHistoryContactsInput

@ -53,4 +53,20 @@ namespace GDZZ.Application
public string lastContent { get; set; } public string lastContent { get; set; }
} }
/// <summary>
/// 聊天文件
/// </summary>
public class LiveFileOutput
{
/// <summary>
/// 文件ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileUrl { get; set; }
}
} }

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Service.LiveHistoryContacts.Dto
{
public class LiveMessageInput
{
public string id { get; set; }
public string status { get; set; }
public string type { get; set; }
public long sendTime { get; set; }
public string content { get; set; }
public long toContactId { get; set; }
public Fromuser fromUser { get; set; }
}
public class Fromuser
{
public long id { get; set; }
public string displayName { get; set; }
public string avatar { get; set; }
}
}

@ -3,13 +3,26 @@ using Furion.DependencyInjection;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using GDZZ.Application.Entity; using GDZZ.Application.Entity;
using System.Collections.Generic; using System.Collections.Generic;
using K4os.Hash.xxHash; using K4os.Hash.xxHash;
using GDZZ.Core.Entity; using GDZZ.Core.Entity;
using Furion;
using GDZZ.Application.Help;
using Furion.LinqBuilder;
using System;
using static K4os.Compression.LZ4.Engine.Pubternal;
using Microsoft.AspNetCore.SignalR;
using GDZZ.Application.Service.LiveHistoryContacts.Dto;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using System.IO;
using Yitter.IdGenerator;
using Microsoft.Extensions.Options;
using ICacheService = GDZZ.Application.Help.ICacheService;
namespace GDZZ.Application namespace GDZZ.Application
{ {
@ -19,19 +32,37 @@ namespace GDZZ.Application
[ApiDescriptionSettings("Application", Name = "LiveHistoryContacts", Order = 1)] [ApiDescriptionSettings("Application", Name = "LiveHistoryContacts", Order = 1)]
public class LiveHistoryContactsService : ILiveHistoryContactsService, IDynamicApiController, ITransient public class LiveHistoryContactsService : ILiveHistoryContactsService, IDynamicApiController, ITransient
{ {
private readonly SqlSugarRepository<LiveHistoryContacts> _rep; private readonly SqlSugarRepository<LiveHistoryContacts> _rep; //聊天历史任务列表仓储
private readonly SqlSugarRepository<LiveMessage> liveMessageRep; private readonly SqlSugarRepository<LiveMessage> liveMessageRep; //消息仓储
private readonly SqlSugarRepository<LiveUserFriend> liveUserFriend; //好友表仓储 private readonly SqlSugarRepository<LiveUserFriend> liveUserFriend; //好友表仓储
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<OnlineUser> _sysOnlineUerRep; // 在线用户表仓储
private readonly ICacheService cacheService;
private readonly IHubContext<ChatHub, IChatClient> _chatHubContext;
private readonly UploadFileOptions _options;
public LiveHistoryContactsService(SqlSugarRepository<LiveHistoryContacts> rep, public LiveHistoryContactsService(SqlSugarRepository<LiveHistoryContacts> rep,
ICacheService cacheService,
IOptions<UploadFileOptions> options,
SqlSugarRepository<SysUser> _sysUserRep,
SqlSugarRepository<OnlineUser> sysOnlineUerRep,
SqlSugarRepository<LiveUserFriend> liveUserFriend, SqlSugarRepository<LiveUserFriend> liveUserFriend,
IHubContext<ChatHub, IChatClient> chatHubContext,
SqlSugarRepository<LiveMessage> liveMessageRep) SqlSugarRepository<LiveMessage> liveMessageRep)
{ {
_rep = rep; _rep = rep;
_options = options.Value;
this.cacheService = cacheService;
this._chatHubContext= chatHubContext;
this._sysOnlineUerRep = sysOnlineUerRep;
this.liveUserFriend = liveUserFriend; this.liveUserFriend = liveUserFriend;
this.liveMessageRep = liveMessageRep; this.liveMessageRep = liveMessageRep;
this._sysUserRep = _sysUserRep;
} }
#region 聊天列表
/// <summary> /// <summary>
/// 新增联系人 /// 新增联系人
/// </summary> /// </summary>
@ -39,10 +70,46 @@ namespace GDZZ.Application
[HttpPost("/LiveHistoryContacts/AddLive")] [HttpPost("/LiveHistoryContacts/AddLive")]
public async Task AddLive(AddLiveHistoryContactsInput input) public async Task AddLive(AddLiveHistoryContactsInput input)
{ {
var entity = input.Adapt<LiveHistoryContacts>(); var entity = input.Adapt<LiveHistoryContacts>();
await _rep.InsertAsync(entity); await _rep.InsertAsync(entity);
await this.cacheService.DelLiveHistoryService(UserManager.UserId);
} }
/// <summary>
/// 修改消息条数
/// </summary>
/// <returns></returns>
[HttpPut("/LiveHistoryContacts/UPLive")]
public async Task UPLive(UpdateLiveHistoryContactsInput input)
{
var entity = input.Adapt<LiveHistoryContacts>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
await this.cacheService.DelLiveHistoryService(UserManager.UserId);
}
/// <summary>
/// 删除联系人
/// </summary>
/// <returns></returns>
[HttpDelete("/LiveHistoryContacts/DelLive")]
public async Task DelLive(long ID)
{
var entity = await this.liveUserFriend.SingleAsync(x => x.Id == ID);
await _rep.DeleteAsync(entity);
await this.cacheService.DelLiveHistoryService(UserManager.UserId);
}
/// <summary> /// <summary>
/// 获取联系人 /// 获取联系人
/// </summary> /// </summary>
@ -51,37 +118,52 @@ namespace GDZZ.Application
[HttpGet("/LiveHistoryContacts/list")] [HttpGet("/LiveHistoryContacts/list")]
public async Task<List<LiveHistoryLists>> List() public async Task<List<LiveHistoryLists>> List()
{ {
List<LiveHistoryLists> historyLists= new List<LiveHistoryLists>();
var history = await this.cacheService.GetLiveHistoryService(UserManager.UserId);
if (!history.IsNullOrEmpty())
return history;
List<LiveHistoryLists> historyLists = new List<LiveHistoryLists>();
//获取好友列表 //获取好友列表
var friends = await this.liveUserFriend.Where(x => x.CreatedUserId == UserManager.UserId).ToListAsync(); var friends = await this.liveUserFriend.Where(x => x.CreatedUserId == UserManager.UserId).ToListAsync();
foreach (var item in friends) foreach (var item in friends)
{ {
var friend = await this._sysUserRep.SingleAsync(x => x.Id == item.FriendID);
if (friend == null) //获取用户信息
var sysUser = await this._sysUserRep.SingleAsync(x => x.Id == item.FriendID);
if (sysUser == null)
continue; continue;
historyLists.Add(new LiveHistoryLists() var liveHis = new LiveHistoryLists()
{ {
Avatar = friend.Avatar, Avatar = sysUser.Avatar,
DisplayName = friend.NickName, DisplayName = sysUser.NickName,
Id = item.FriendID, Id = item.FriendID,
Index = friend.Name.Substring(0, 1), Index = sysUser.Name.Substring(0, 1),
LastSendTime = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds(),
Unread = 0
};
//rm -rf mk dir ls install cd home //查询聊天记录
//rm -rf mk dir ls install cd home //ru-rf
}) ; var live = await this.liveMessageRep.Where(x => x.CreatedUserId == UserManager.UserId && x.OtherUserID == item.FriendID || (x.CreatedUserId == item.FriendID && x.OtherUserID == UserManager.UserId)).OrderByDescending(x =>x.CreatedTime).FirstAsync();
if (live != null)
{
liveHis.LastContent = live.Content;
liveHis.Type = live.Type;
} }
return historyLists; historyLists.Add(liveHis);
} }
await this.cacheService.SetLiveHistoryService(UserManager.UserId, historyLists);
return historyLists;
}
#endregion
#region 聊天详情 #region 聊天详情
/// <summary> /// <summary>
/// 获取聊天信息列表 /// 获取聊天详情
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet("/LiveHistoryContacts/GetMessageLists")] [HttpGet("/LiveHistoryContacts/GetMessageLists")]
@ -92,24 +174,98 @@ namespace GDZZ.Application
} }
/// <summary> /// <summary>
/// 增加聊天历史任务列表 /// 增加聊天详情
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("/LiveHistoryContacts/addMessage")] [HttpPost("/LiveHistoryContacts/addMessage")]
public async Task AddMessage(AddLiveMessageInput input) public async Task AddMessage(AddLiveMessageInput input)
{ {
var entity = input.Adapt<LiveMessage>(); var entity = input.Adapt<LiveMessage>();
var history = await this._rep.Where(x => (x.CreatedUserId == input.OtherUserID && x.UserID == UserManager.UserId) || (x.UserID == input.OtherUserID && x.CreatedUserId == UserManager.UserId)).SingleAsync(); var live = this.liveMessageRep.InsertReturnEntity(entity);
var user = await _sysOnlineUerRep.Where(m => m.UserId == entity.OtherUserID).OrderByDescending(x=>x.LastTime).FirstAsync();
var livemes = new LiveMessageInput()
{
id = live.Id.ToString(),
type = live.Type,
content = live.Content,
sendTime = new DateTimeOffset((DateTime)live.CreatedTime).ToUnixTimeSeconds(),
status = "succeed",
toContactId = entity.OtherUserID,
fromUser = new Fromuser()
{
avatar = this._sysUserRep.FirstOrDefaultAsync(x => x.Id == UserManager.UserId).Result.Avatar,
displayName = UserManager.Name,
id = UserManager.UserId
}
};
var livejson = livemes.ToJsonString();
await _chatHubContext.Clients.Client(user.ConnectionId).SendMessage(livejson, "SendMessage");
}
await this.liveMessageRep.InsertAsync(entity); /// <summary>
/// 上传文件
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost("/LiveHistoryContacts/upload")]
public async Task<LiveFileOutput> UploadFileDefault(IFormFile file)
{
// 可以读取系统配置来决定将文件存储到什么地方
return await UploadFile(file, _options.Default.path, FileLocation.LOCAL);
} }
/// <summary>
/// 上传文件
/// </summary>
/// <param name="file"></param>
/// <param name="pathType"></param>
/// <returns></returns>
private static async Task<LiveFileOutput> UploadFile(IFormFile file, string pathType, FileLocation fileLocation)
{
var fileSizeKb = (long)(file.Length / 1024.0); // 文件大小KB
var originalFilename = file.FileName; // 文件原始名称
var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀
#endregion // 先存库获取Id
var id = YitIdHelper.NextId();
var newFile = new SysFile
{
Id = id,
FileLocation = (int)FileLocation.LOCAL,
FileBucket = FileLocation.LOCAL.ToString(),
FileObjectName = $"{YitIdHelper.NextId()}{fileSuffix}",
FileOriginName = originalFilename,
FileSuffix = fileSuffix.TrimStart('.'),
FileSizeKb = fileSizeKb.ToString(),
FilePath = pathType
};
newFile = await App.GetService<ISqlSugarClient>().Insertable(newFile).ExecuteReturnEntityAsync();
var finalName = newFile.FileObjectName; // 生成文件的最终名称
if (fileLocation == FileLocation.LOCAL) // 本地存储
{
var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, pathType);
if (!Directory.Exists(filePath))
Directory.CreateDirectory(filePath);
using (var stream = File.Create(Path.Combine(filePath, finalName)))
{
await file.CopyToAsync(stream);
}
}
else if (fileLocation == FileLocation.ALIYUN) // 阿里云OSS
{
var filePath = pathType + finalName;
OSSClientUtil.DeletefileCode(filePath);
var stream = file.OpenReadStream();
OSSClientUtil.PushMedia(stream, filePath);
}
newFile.FileObjectName = finalName;
return new LiveFileOutput() { Id = finalName, FileUrl= "/"+pathType + "/"+ finalName }; // 返回文件唯一标识
}
#endregion
} }
} }

@ -8,7 +8,9 @@ namespace GDZZ.Core;
public class SqlSugarCache : ICacheService public class SqlSugarCache : ICacheService
{ {
private static ICache _cache = App.GetOptions<CacheOptions>().CacheType == CacheType.MemoryCache? App.RootServices.GetService(typeof(MemoryCache)) as ICache : App.RootServices.GetService(typeof(RedisCache)) as ICache; private static ICache _cache = App.GetOptions<CacheOptions>().CacheType == CacheType.MemoryCache
?App.RootServices.GetService(typeof(MemoryCache)) as ICache
:App.RootServices.GetService(typeof(RedisCache)) as ICache;
public void Add<TV>(string key, TV value) public void Add<TV>(string key, TV value)
{ {

@ -3510,6 +3510,11 @@
账号 账号
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Core.UserManager.TenantID">
<summary>
租户ID
</summary>
</member>
<member name="P:GDZZ.Core.UserManager.Name"> <member name="P:GDZZ.Core.UserManager.Name">
<summary> <summary>
昵称 昵称
@ -7063,14 +7068,6 @@
<param name="userIds"></param> <param name="userIds"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Core.Service.SysOnlineUserService.PushMessages(System.Collections.Generic.List{System.Int64},System.String)">
<summary>
发送消息
</summary>
<param name="notice"></param>
<param name="userIds"></param>
<returns></returns>
</member>
<member name="T:GDZZ.Core.Service.OrgInput"> <member name="T:GDZZ.Core.Service.OrgInput">
<summary> <summary>
组织机构参数 组织机构参数

@ -9,5 +9,5 @@ public interface IChatClient
Task AppendNotice(SysNotice notice); Task AppendNotice(SysNotice notice);
Task SendMessage(string handle, string user, string message); Task SendMessage(string handle, string message);
} }

@ -18,6 +18,13 @@ public static class UserManager
/// </summary> /// </summary>
public static string Account => App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; public static string Account => App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value;
/// <summary>
/// 租户ID
/// </summary>
public static string TenantID => App.User.FindFirst(ClaimConst.TENANT_ID)?.Value;
/// <summary> /// <summary>
/// 昵称 /// 昵称
/// </summary> /// </summary>

@ -52,7 +52,7 @@ public class SysOnlineUserService : ISysOnlineUserService, IDynamicApiController
[HttpPost("/sysOnlineUser/forceExist")] [HttpPost("/sysOnlineUser/forceExist")]
[NonValidation] [NonValidation]
public async Task ForceExist(OnlineUser user) { public async Task ForceExist(OnlineUser user) {
await _chatHubContext.Clients.Client(user.ConnectionId).ForceExist("7777777"); await _chatHubContext.Clients.Client(user.ConnectionId).ForceExist("111");
await _sysOnlineUerRep.DeleteAsync(user); await _sysOnlineUerRep.DeleteAsync(user);
} }
@ -80,25 +80,7 @@ public class SysOnlineUserService : ISysOnlineUserService, IDynamicApiController
/// <summary>
/// 发送消息
/// </summary>
/// <param name="notice"></param>
/// <param name="userIds"></param>
/// <returns></returns>
[NonAction]
public async Task PushMessages(List<long> userIds,string message)
{
var userList = _sysOnlineUerRep.Where(m => userIds.Contains(m.UserId)).ToList();
if (userList.Any())
{
foreach (var item in userList)
{
await _chatHubContext.Clients.Client(item.ConnectionId).SendMessage("", item.Name, message);
}
}
}

@ -266,6 +266,7 @@ public static class SqlSugarSetup
} }
if (attributes.Any(it => it is ColumnAttribute)) if (attributes.Any(it => it is ColumnAttribute))
{ {
//I love you Tpei
column.DbColumnName = (attributes.First(it => it is ColumnAttribute) as ColumnAttribute).Name; column.DbColumnName = (attributes.First(it => it is ColumnAttribute) as ColumnAttribute).Name;
} }
} }

@ -21,6 +21,8 @@ using Furion.Logging;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Microsoft.Extensions.FileProviders;
using System.IO;
namespace GDZZ.Web.Core; namespace GDZZ.Web.Core;
@ -66,7 +68,6 @@ public class Startup : AppStartup
// 配置远程请求 // 配置远程请求
services.AddRemoteRequest(option => services.AddRemoteRequest(option =>
{ {
@ -123,6 +124,8 @@ public class Startup : AppStartup
app.UseHsts(); app.UseHsts();
} }
// 添加状态码拦截中间件 // 添加状态码拦截中间件
app.UseUnifyResultStatusCodes(); app.UseUnifyResultStatusCodes();
@ -140,6 +143,8 @@ public class Startup : AppStartup
app.UseInject(string.Empty); app.UseInject(string.Empty);
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapHub<ChatHub>("/hubs/chathub"); endpoints.MapHub<ChatHub>("/hubs/chathub");

@ -3,5 +3,6 @@ using GDZZ.Core;
Serve.Run(RunOptions.Default.ConfigureBuilder(builder => { Serve.Run(RunOptions.Default.ConfigureBuilder(builder => {
builder.UseLoggingFile(); builder.UseLoggingFile();
})); }));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save