You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
using BBWYB.Server.Business;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
using QYMessageCenter.Common.Extensions;
|
|
using QYMessageCenter.Common.Http;
|
|
using QYMessageCenter.Common.Log;
|
|
using QYMessageCenter.Common.Models;
|
|
using QYMessageCenter.Model.DB;
|
|
using QYMessageCenter.Model.DTO;
|
|
using System.Configuration;
|
|
using System.Threading.Channels;
|
|
using Yitter.IdGenerator;
|
|
|
|
namespace QYMessageCenter.Business
|
|
{
|
|
public class MessageBusiness : BaseBusiness, IDenpendency
|
|
{
|
|
private readonly string Key = "BC-652c4236c6ba4083b026e8cfa2e199b1";
|
|
|
|
public MessageBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, RestApiService restApiService) : base(fsql, nLogManager, idGenerator, restApiService)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送消息
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
public void Send(SendMessageRequest request)
|
|
{
|
|
var msg = request.Map<QYNotification>();
|
|
msg.Id = idGenerator.NewLong();
|
|
msg.CreateTime = DateTime.Now;
|
|
|
|
#region 调用goeasy
|
|
var goeasy_httpResult = restApiService.SendRequest("https://rest-hz.goeasy.io/", "v2/pubsub/publish", new
|
|
{
|
|
appkey = Key,
|
|
channel = request.Channel,
|
|
content = JsonConvert.SerializeObject(msg)
|
|
}, null, HttpMethod.Post);
|
|
|
|
if (goeasy_httpResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
throw new BusinessException($"消息发送失败 httpcode {goeasy_httpResult.StatusCode} conent {goeasy_httpResult.Content}");
|
|
#endregion
|
|
|
|
#region 保存入库
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|