Commit 725f1d87 authored by 黄奎's avatar 黄奎

页面修改

parent d489acd7
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NPOI" Version="2.5.1" /> <PackageReference Include="NPOI" Version="2.5.1" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="Spire.Doc" Version="8.12.14" /> <PackageReference Include="Spire.Doc" Version="8.12.14" />
</ItemGroup> </ItemGroup>
......
using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Message
{
/// <summary>
/// 消息发送
/// </summary>
public class MessageHelper
{
/// <summary>
/// 获取连接
/// </summary>
/// <param name="rabbitConfig">连接配置实体</param>
/// <returns></returns>
private static ConnectionFactory GetConnectionFactory(RabbitConfig rabbitConfig)
{
ConnectionFactory factory = new ConnectionFactory
{
HostName = rabbitConfig.HostName,
//默认端口
Port = rabbitConfig.Port,
UserName = rabbitConfig.UserName,
Password = rabbitConfig.Password,
};
return factory;
}
/// <summary>
/// 发送信息
/// </summary>
/// <param name="message"></param>
public static void SendMessage(PushMessageModel message)
{
Int32.TryParse(Common.Config.ReadConfigKey("RabbitMqConfig", subKey: "Port"), out int Port);
RabbitConfig rabbitConfig = new RabbitConfig()
{
HostName = Common.Config.ReadConfigKey("RabbitMqConfig", subKey: "HostName"),
Password = Common.Config.ReadConfigKey("RabbitMqConfig", subKey: "Password"),
Port = Port,
UserName = Common.Config.ReadConfigKey("RabbitMqConfig", subKey: "UserName"),
QueenName = Common.Config.ReadConfigKey("RabbitMqConfig", subKey: "QueenName"),
};
var obj = new
{
Id = 0,// 主键
message.Title,
message.Content,
message.CoverImg,
message.CategoryId,
message.Platform,
message.SendType,
message.SendTime,
message.ReceiveId,
message.JumpUrl,
message.CreateByName,
Status = 0,
CreateTime = DateTime.Now,
AppId = Common.Config.ReadConfigKey("PushAppId"),
};
using (IConnection conn = GetConnectionFactory(rabbitConfig).CreateConnection())
{
using (IModel channel = conn.CreateModel())
{
//在MQ上定义一个持久化队列,如果名称相同不会重复创建
channel.QueueDeclare(rabbitConfig.QueenName, true, false, false, null);
byte[] buffer = Encoding.UTF8.GetBytes(Common.Plugin.JsonHelper.Serialize(obj));
IBasicProperties properties = channel.CreateBasicProperties();
properties.DeliveryMode = 2;
channel.BasicPublish("", rabbitConfig.QueenName, properties, buffer);
}
}
}
/// <summary>
/// 批量推送
/// </summary>
/// <param name="msgList"></param>
public static void SendMessage(List<PushMessageModel> msgList)
{
foreach (var item in msgList)
{
SendMessage(item);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Message
{
/// <summary>
/// 消息推送实体
/// </summary>
public class PushMessageModel
{
/// <summary>
/// 推送标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 推送内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 封面图
/// </summary>
public string CoverImg { get; set; }
/// <summary>
/// 所属分类
/// </summary>
public int CategoryId { get; set; }
/// <summary>
/// 推送平台[1-手机端,2-Web端,3-短信,4-邮件]
/// </summary>
public int Platform { get; set; }
/// <summary>
/// 推送类型(0-立即推送,1-指定时间推送)
/// </summary>
public int SendType { get; set; }
/// <summary>
/// 推送时间
/// </summary>
public DateTime SendTime { get; set; }
/// <summary>
/// 接收人员
/// </summary>
public string ReceiveId { get; set; }
/// <summary>
/// 跳转地址
/// </summary>
public string JumpUrl { get; set; }
/// <summary>
/// 创建人姓名
/// </summary>
public string CreateByName { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Message
{
/// <summary>
/// 消息队列配置文件
/// </summary>
public class RabbitConfig
{
/// <summary>
/// 主机名:ip地址
/// </summary>
public string HostName { get; set; }
/// <summary>
/// 端口
/// </summary>
public int Port { get; set; }
/// <summary>
/// 用户名
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 密码
/// </summary>
public string Password { get; set; }
/// <summary>
/// 队列名称
/// </summary>
public string QueenName { get; set; }
}
}
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"Microsoft.Extensions.Configuration.Json": "3.1.8", "Microsoft.Extensions.Configuration.Json": "3.1.8",
"NPOI": "2.5.1", "NPOI": "2.5.1",
"Newtonsoft.Json": "12.0.3", "Newtonsoft.Json": "12.0.3",
"RabbitMQ.Client": "5.1.2",
"Spire.Doc": "8.12.14" "Spire.Doc": "8.12.14"
}, },
"runtime": { "runtime": {
...@@ -519,6 +520,14 @@ ...@@ -519,6 +520,14 @@
} }
} }
}, },
"RabbitMQ.Client/5.1.2": {
"runtime": {
"lib/netstandard2.0/RabbitMQ.Client.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.1.2.0"
}
}
},
"runtime.native.System/4.0.0": { "runtime.native.System/4.0.0": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Platforms": "2.0.0", "Microsoft.NETCore.Platforms": "2.0.0",
...@@ -1272,6 +1281,13 @@ ...@@ -1272,6 +1281,13 @@
"path": "portable.bouncycastle/1.8.6", "path": "portable.bouncycastle/1.8.6",
"hashPath": "portable.bouncycastle.1.8.6.nupkg.sha512" "hashPath": "portable.bouncycastle.1.8.6.nupkg.sha512"
}, },
"RabbitMQ.Client/5.1.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Xhj+un0pw4N7h37SZWptxl/NEv7f1RLHwZhXjqzkCm3w3IdbFJh+HjVyPaciD848BUYLGoEQzadx90nShsbs4Q==",
"path": "rabbitmq.client/5.1.2",
"hashPath": "rabbitmq.client.5.1.2.nupkg.sha512"
},
"runtime.native.System/4.0.0": { "runtime.native.System/4.0.0": {
"type": "package", "type": "package",
"serviceable": true, "serviceable": true,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"Microsoft.Extensions.Configuration.Json": "3.1.8", "Microsoft.Extensions.Configuration.Json": "3.1.8",
"NPOI": "2.5.1", "NPOI": "2.5.1",
"Newtonsoft.Json": "12.0.3", "Newtonsoft.Json": "12.0.3",
"RabbitMQ.Client": "5.1.2",
"Spire.Doc": "8.12.14" "Spire.Doc": "8.12.14"
}, },
"runtime": { "runtime": {
...@@ -519,6 +520,14 @@ ...@@ -519,6 +520,14 @@
} }
} }
}, },
"RabbitMQ.Client/5.1.2": {
"runtime": {
"lib/netstandard2.0/RabbitMQ.Client.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.1.2.0"
}
}
},
"runtime.native.System/4.0.0": { "runtime.native.System/4.0.0": {
"dependencies": { "dependencies": {
"Microsoft.NETCore.Platforms": "2.0.0", "Microsoft.NETCore.Platforms": "2.0.0",
...@@ -1272,6 +1281,13 @@ ...@@ -1272,6 +1281,13 @@
"path": "portable.bouncycastle/1.8.6", "path": "portable.bouncycastle/1.8.6",
"hashPath": "portable.bouncycastle.1.8.6.nupkg.sha512" "hashPath": "portable.bouncycastle.1.8.6.nupkg.sha512"
}, },
"RabbitMQ.Client/5.1.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Xhj+un0pw4N7h37SZWptxl/NEv7f1RLHwZhXjqzkCm3w3IdbFJh+HjVyPaciD848BUYLGoEQzadx90nShsbs4Q==",
"path": "rabbitmq.client/5.1.2",
"hashPath": "rabbitmq.client.5.1.2.nupkg.sha512"
},
"runtime.native.System/4.0.0": { "runtime.native.System/4.0.0": {
"type": "package", "type": "package",
"serviceable": true, "serviceable": true,
......
...@@ -70,7 +70,7 @@ namespace Edu.WebApi.Controllers.User ...@@ -70,7 +70,7 @@ namespace Edu.WebApi.Controllers.User
})?.FirstOrDefault(); })?.FirstOrDefault();
if (model == null) if (model == null)
{ {
return ApiResult.Failed(message: $"未找到【{ account }】用户!"); return ApiResult.Failed(message: $"登录失败,账号或密码错误!");
} }
else else
{ {
...@@ -112,12 +112,12 @@ namespace Edu.WebApi.Controllers.User ...@@ -112,12 +112,12 @@ namespace Edu.WebApi.Controllers.User
var actionList = menuModule.GetPostMenuFunctionListModule(model.Post_Id.ToString()); var actionList = menuModule.GetPostMenuFunctionListModule(model.Post_Id.ToString());
//上传配置 //上传配置
var uploadConfig = publicModule.GetFileStoreList(new Model.Public.RB_File_Store() { Group_Id = model.Group_Id, IsDefault = 1 })?.FirstOrDefault(); var uploadConfig = publicModule.GetFileStoreList(new Model.Public.RB_File_Store() { Group_Id = model.Group_Id, IsDefault = 1 })?.FirstOrDefault();
UserInfo obj = new UserInfo UserInfo obj = new UserInfo
{ {
Id = model.Id, Id = model.Id,
AccountId = model.AccountId, AccountId = model.AccountId,
UserMobile=model.Account, UserMobile = model.Account,
AccountType = model.AccountType, AccountType = model.AccountType,
Group_Id = model.Group_Id, Group_Id = model.Group_Id,
GroupName = model.GroupName, GroupName = model.GroupName,
...@@ -146,7 +146,7 @@ namespace Edu.WebApi.Controllers.User ...@@ -146,7 +146,7 @@ namespace Edu.WebApi.Controllers.User
uploadConfig?.SecretId, uploadConfig?.SecretId,
uploadConfig?.UploadDomain uploadConfig?.UploadDomain
}, },
StudyAbroadObj=publicModule.GetStudyAbroadListModule() StudyAbroadObj = publicModule.GetStudyAbroadListModule()
}; };
UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.Id, obj, Common.Config.JwtExpirTime); UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.Id, obj, Common.Config.JwtExpirTime);
return ApiResult.Success(data: obj); return ApiResult.Success(data: obj);
...@@ -198,6 +198,46 @@ namespace Edu.WebApi.Controllers.User ...@@ -198,6 +198,46 @@ namespace Edu.WebApi.Controllers.User
uploadConfig?.UploadDomain uploadConfig?.UploadDomain
}; };
} }
for (var i = 0; i < 10; i++)
{
Random rd = new Random();
int num = rd.Next(0, 1000);
Common.Message.PushMessageModel model = new Common.Message.PushMessageModel()
{
CategoryId = 0,
Content = "推送内容" + i.ToString(),
CoverImg = "",
CreateByName = userInfo.AccountName,
JumpUrl = "",
ReceiveId = "1",
SendTime = DateTime.Now,
SendType = 0,
Title = "推送标题" + i.ToString(),
};
//手机推送
if (num % 4 == 1)
{
model.Platform = 1;
}
//Web推送
else if (num % 4 == 2)
{
model.Platform = 2;
}
//短信推送
else if (num % 4 == 3)
{
model.Platform = 3;
model.ReceiveId = "13551126755";
}
//邮件推送
else
{
model.Platform = 4;
model.ReceiveId = "1006186972@qq.com";
}
Common.Message.MessageHelper.SendMessage(model);
}
return ApiResult.Success(data: userInfo); return ApiResult.Success(data: userInfo);
} }
else else
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
"VirtualHost": "/", "VirtualHost": "/",
"Port": 5672, "Port": 5672,
"UserName": "guest", "UserName": "guest",
"Password": "viitto2019" "Password": "viitto2019",
"QueenName": "vt_sys_message"
}, },
"RedisSetting": { "RedisSetting": {
"RedisServer": "47.96.23.199", "RedisServer": "47.96.23.199",
...@@ -55,5 +56,7 @@ ...@@ -55,5 +56,7 @@
//留学就业部门负责人审核编号[姚顺先] //留学就业部门负责人审核编号[姚顺先]
"StudyAbroadManagerId": 52, "StudyAbroadManagerId": 52,
//合同默认抬头 //合同默认抬头
"ContractDefaultTitle": "JH-DZ-CD-" "ContractDefaultTitle": "JH-DZ-CD-",
//消息推送AppId
"PushAppId": "JiaHeJiaoYu"
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment