This commit is contained in:
2023-05-31 10:19:05 +08:00
parent 1b65a7a9e5
commit 9c621c75cd
238 changed files with 9905 additions and 4034 deletions

View File

@@ -37,4 +37,5 @@ public class MessageListOutput
/// 是否已读(0-未读1-已读).
/// </summary>
public int? isRead { get; set; }
public int? flowType { get; set; }
}

View File

@@ -65,4 +65,6 @@ public class MessageEntity : CLDEntityBase
/// </summary>
[SugarColumn(ColumnName = "F_FILES")]
public string Files { get; set; }
[SugarColumn(ColumnName = "F_FLOWTYPE")]
public int? FlowType { get; set; }
}

View File

@@ -15,5 +15,5 @@ public interface IMessageService
/// <param name="title"></param>
/// <param name="bodyText"></param>
/// <returns></returns>
Task SentMessage(List<string> toUserIds, string title, string bodyText = null, Dictionary<string, object> bodyDic = null);
Task SentMessage(List<string> toUserIds, string title, string bodyText = null, Dictionary<string, object> bodyDic = null, int type = 2, string flowType = "1");
}

View File

@@ -6,5 +6,7 @@ public interface ISendMessageService
{
Task<string> SendMessage(MessageSendModel messageSendModel, Dictionary<string, object> bodyDic);
Task SendMessageDefult(string enCode, List<string> toUser, string taskName, Dictionary<string, object> bodyDic);
Task SendMessageDefult(string enCode, List<string> toUser, string creatorUser, string flowName, Dictionary<string, object> bodyDic);
Task SendMessageDelegate(string delegateType, string ToUserId, string flowName);
Task SendMessageSystem(string enCode);
}

View File

@@ -95,7 +95,7 @@ public class MessageAccountService : IDynamicApiController, ITransient
[HttpPost("")]
public async Task Create([FromBody] MessageAccountListOutput input)
{
if (await _repository.IsAnyAsync(x => (x.EnCode == input.enCode) && x.DeleteMark == null))
if (await _repository.IsAnyAsync(x => (x.EnCode == input.enCode) && x.Type == input.type && x.DeleteMark == null))
throw Oops.Oh(ErrorCode.COM1004);
var entity = input.Adapt<MessageAccountEntity>();
var isOk = await _repository.AsInsertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
@@ -112,7 +112,7 @@ public class MessageAccountService : IDynamicApiController, ITransient
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] MessageAccountListOutput input)
{
if (await _repository.IsAnyAsync(x => x.Id != id && (x.EnCode == input.enCode) && x.DeleteMark == null))
if (await _repository.IsAnyAsync(x => x.Id != id && (x.EnCode == input.enCode) && x.Type == input.type && x.DeleteMark == null))
throw Oops.Oh(ErrorCode.COM1004);
if ((await _repository.AsSugarClient().Queryable<MessageSendTemplateEntity>().AnyAsync(x => x.AccountConfigId == id && x.DeleteMark == null)) && input.enabledMark == 0)
throw Oops.Oh(ErrorCode.D7013);
@@ -153,6 +153,8 @@ public class MessageAccountService : IDynamicApiController, ITransient
entity.FullName = string.Format("{0}副本{1}", entity.FullName, random);
entity.EnCode = string.Format("{0}{1}", entity.EnCode, random);
entity.EnabledMark = 0;
entity.LastModifyTime = null;
entity.LastModifyUserId = null;
if (entity.Type == "7")
{
entity.AppKey = string.Format("{0}{1}", entity.AppKey, random);

View File

@@ -119,7 +119,8 @@ public class MessageService : IMessageService, IDynamicApiController, ITransient
releaseUser = SqlFunc.MergeString(c.RealName, "/", c.Account),
title = a.Title,
type = a.Type,
isRead = b.IsRead
isRead = b.IsRead,
flowType=a.FlowType
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<MessageListOutput>.SqlSugarPageResult(list);
}
@@ -297,7 +298,7 @@ public class MessageService : IMessageService, IDynamicApiController, ITransient
{
try
{
_repository.AsSugarClient().Insertable(receiveEntityList).ExecuteCommandAsync();
_repository.AsSugarClient().Insertable(receiveEntityList).ExecuteCommand();
return _repository.AsInsertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteCommand();
}
@@ -317,7 +318,7 @@ public class MessageService : IMessageService, IDynamicApiController, ITransient
{
try
{
_repository.AsSugarClient().Insertable(receiveEntityList).ExecuteCommandAsync();
_repository.AsSugarClient().Insertable(receiveEntityList).ExecuteCommand();
return _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommand();
}
catch (Exception)
@@ -405,7 +406,7 @@ public class MessageService : IMessageService, IDynamicApiController, ITransient
/// <param name="title">标题.</param>
/// <param name="bodyText">内容.</param>
[NonAction]
public async Task SentMessage(List<string> toUserIds, string title, string bodyText = null, Dictionary<string, object> bodyDic = null)
public async Task SentMessage(List<string> toUserIds, string title, string bodyText = null, Dictionary<string, object> bodyDic = null, int type = 2, string flowType = "1")
{
try
{
@@ -413,9 +414,10 @@ public class MessageService : IMessageService, IDynamicApiController, ITransient
entity.Id = SnowflakeIdHelper.NextId();
entity.Title = title;
entity.BodyText = bodyText;
entity.Type = 2;
entity.Type = type;
entity.LastModifyTime = DateTime.Now;
entity.LastModifyUserId = _userManager.UserId;
entity.FlowType = flowType.ParseToInt();
List<MessageReceiveEntity> receiveEntityList = toUserIds
.Select(x => new MessageReceiveEntity()
{
@@ -432,7 +434,7 @@ public class MessageService : IMessageService, IDynamicApiController, ITransient
{
var userId = item.Replace("-delegate", string.Empty);
// 消息推送 - 指定用户
await _imHandler.SendMessageToUserAsync(string.Format("{0}-{1}", _userManager.TenantId, item), new { method = "messagePush", messageType = 2, userId = _userManager.UserId, toUserId = toUserIds, title = entity.Title, unreadNoticeCount = 1, id = entity.Id }.ToJsonString());
await _imHandler.SendMessageToUserAsync(string.Format("{0}-{1}", _userManager.TenantId, userId), new { method = "messagePush", messageType = 2, userId = _userManager.UserId, toUserId = toUserIds, title = entity.Title, unreadNoticeCount = 1, id = entity.Id }.ToJsonString());
}
}
}

View File

@@ -194,6 +194,8 @@ public class MessageTemplateService : IDynamicApiController, ITransient
entity.Id = SnowflakeIdHelper.NextId();
entity.EnabledMark = 0;
entity.TemplateType = "0";
entity.LastModifyTime = null;
entity.LastModifyUserId = null;
if (entity.FullName.Length >= 50 || entity.EnCode.Length >= 50)
throw Oops.Oh(ErrorCode.COM1009);
var templateParamList = await _repository.AsSugarClient().Queryable<MessageTemplateParamEntity>().Where(x => x.TemplateId == id && x.DeleteMark == null).ToListAsync();

View File

@@ -106,7 +106,7 @@ public class SendMessageService : ISendMessageService, IDynamicApiController, IT
{
fullName = b.FullName,
type = a.MessageType,
}).ToListAsync();
}).Distinct().ToListAsync();
}
return PageResult<SendMessageListOutput>.SqlSugarPageResult(list);
}
@@ -115,10 +115,8 @@ public class SendMessageService : ISendMessageService, IDynamicApiController, IT
public async Task<dynamic> GetSendList([FromQuery] MessageTemplateQuery input)
{
var list = await _repository.AsSugarClient().Queryable<MessageSendEntity>()
.Where(a => a.DeleteMark == null)
.Where(a => a.DeleteMark == null && a.EnabledMark == 1 && a.TemplateType == "0")
.WhereIF(input.messageSource.IsNotEmptyOrNull(), a => a.MessageSource == input.messageSource)
.WhereIF(input.templateType.IsNotEmptyOrNull(), a => a.TemplateType == input.templateType)
.WhereIF(input.enabledMark.IsNotEmptyOrNull(), a => a.EnabledMark == input.enabledMark)
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
.OrderBy(a => a.SortCode)
.OrderBy(a => a.CreatorTime, OrderByType.Desc)
@@ -251,6 +249,10 @@ public class SendMessageService : ISendMessageService, IDynamicApiController, IT
entity.FullName = string.Format("{0}副本{1}", entity.FullName, random);
entity.EnCode = string.Format("{0}{1}", entity.EnCode, random);
entity.Id = SnowflakeIdHelper.NextId();
entity.EnabledMark = 0;
entity.TemplateType = "0";
entity.LastModifyTime = null;
entity.LastModifyUserId = null;
if (entity.FullName.Length >= 50 || entity.EnCode.Length >= 50)
throw Oops.Oh(ErrorCode.COM1009);
var sendTemplateList = await _repository.AsSugarClient().Queryable<MessageSendTemplateEntity>().Where(x => x.SendConfigId == id && x.DeleteMark == null).ToListAsync();
@@ -460,11 +462,11 @@ public class SendMessageService : ISendMessageService, IDynamicApiController, IT
return errorList.Any() ? string.Join(",", errorList) : string.Empty;
}
public async Task SendMessageDefult(string enCode,List<string> toUser, string taskName, Dictionary<string, object> bodyDic)
public async Task SendMessageDefult(string enCode, List<string> toUser,string creatorUser, string flowName, Dictionary<string, object> bodyDic)
{
var msgTemplateEntity= await _repository.AsSugarClient().Queryable<MessageTemplateEntity>().FirstAsync(x => x.EnCode == enCode && x.TemplateType=="1" && x.DeleteMark == null);
msgTemplateEntity.Title= msgTemplateEntity.Title.Replace("@流程发起人@流程名称", taskName);
msgTemplateEntity.Content = msgTemplateEntity.Content.Replace("@流程发起人@流程名称", taskName);
msgTemplateEntity.Title = msgTemplateEntity.Title.Replace("@流程发起人", creatorUser).Replace("@流程名称", flowName);
msgTemplateEntity.Content = msgTemplateEntity.Content.Replace("@流程发起人", creatorUser).Replace("@流程名称", flowName);
await _messageService.SentMessage(toUser, msgTemplateEntity.Title, msgTemplateEntity.Content, bodyDic);
#region
foreach (var item in toUser)
@@ -482,6 +484,21 @@ public class SendMessageService : ISendMessageService, IDynamicApiController, IT
}
#endregion
}
public async Task SendMessageDelegate(string delegateType, string ToUserId, string flowName)
{
var title = string.Format("{0}已{1}您的{2}流程!", _userManager.User.RealName, delegateType, flowName);
var parameter = new { type = "1" };
var bodyDic = new Dictionary<string, object>();
bodyDic.Add(ToUserId, parameter);
await _messageService.SentMessage(new List<string>() { ToUserId }, title, null, bodyDic, 2, "2");
}
public async Task SendMessageSystem(string enCode)
{
var msgTemplateEntity = await _repository.AsSugarClient().Queryable<MessageTemplateEntity>().FirstAsync(x => x.EnCode == enCode && x.TemplateType == "1" && x.DeleteMark == null);
var bodyDic = new Dictionary<string, object>();
bodyDic.Add(_userManager.UserId, msgTemplateEntity.Content);
await _messageService.SentMessage(new List<string>() { _userManager.UserId }, msgTemplateEntity.Title, msgTemplateEntity.Content, bodyDic, 3);
}
#endregion
#region PrivateMethod
@@ -680,9 +697,13 @@ public class SendMessageService : ISendMessageService, IDynamicApiController, IT
if (text.IsNotEmptyOrNull())
{
// 默认站内信
if (paramDic.ContainsKey("@taskFullName"))
if (paramDic.ContainsKey("@flowFullName"))
{
text = text.Replace("@流程发起人@流程名称", paramDic["@taskFullName"]);
text = text.Replace("@流程名称", paramDic["@flowFullName"]);
}
if (paramDic.ContainsKey("@launchUserName"))
{
text = text.Replace("@流程发起人", paramDic["@launchUserName"]);
}
foreach (var item in paramDic.Keys)
{

View File

@@ -8,6 +8,7 @@ using JNPF.Common.Security;
using JNPF.DataEncryption;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.DatabaseAccessor.SqlSugar.Models;
using JNPF.FriendlyException;
using JNPF.Logging.Attributes;
using JNPF.Message.Entitys.Entity;
@@ -92,9 +93,15 @@ public class ShortLinkService : IShortLinkService, IDynamicApiController, ITrans
options = JNPFTenantExtensions.GetLinkToCustom(tenantId, result.data.linkList);
}
}
if (!"default".Equals(tenantId) && _tenant.MultiTenancyType.Equals("COLUMN"))
{
_sqlSugarClient.QueryFilter.AddTableFilter<ITenantFilter>(it => it.TenantId == tenantId);
}
else
{
_sqlSugarClient.AddConnection(JNPFTenantExtensions.GetConfig(options));
_sqlSugarClient.ChangeDatabase(tenantId);
}
}
var entity = await _sqlSugarClient.Queryable<MessageShortLinkEntity>().SingleAsync(x => x.ShortLink == shortLink && x.DeleteMark == null);