Commit 7662afc3 authored by 吴春's avatar 吴春

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 639e4a05 af6a7a77
......@@ -12,6 +12,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NPOI" Version="2.5.1" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="Spire.Doc" Version="8.12.14" />
</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 @@
"Microsoft.Extensions.Configuration.Json": "3.1.8",
"NPOI": "2.5.1",
"Newtonsoft.Json": "12.0.3",
"RabbitMQ.Client": "5.1.2",
"Spire.Doc": "8.12.14"
},
"runtime": {
......@@ -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": {
"dependencies": {
"Microsoft.NETCore.Platforms": "2.0.0",
......@@ -1272,6 +1281,13 @@
"path": "portable.bouncycastle/1.8.6",
"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": {
"type": "package",
"serviceable": true,
......
......@@ -14,6 +14,7 @@
"Microsoft.Extensions.Configuration.Json": "3.1.8",
"NPOI": "2.5.1",
"Newtonsoft.Json": "12.0.3",
"RabbitMQ.Client": "5.1.2",
"Spire.Doc": "8.12.14"
},
"runtime": {
......@@ -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": {
"dependencies": {
"Microsoft.NETCore.Platforms": "2.0.0",
......@@ -1272,6 +1281,13 @@
"path": "portable.bouncycastle/1.8.6",
"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": {
"type": "package",
"serviceable": true,
......
{
"ConnectionStrings": {
//"DefaultConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
//"DefaultConnection": "server=192.168.20.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
//"DefaultConnectionPName": "MySql.Data.MySqlClient",
//"FinanceConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=test_reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
//"FinanceConnection": "server=192.168.20.214;user id=reborn;password=Reborn@2018;database=test_reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
//"FinanceConnectionPName": "MySql.Data.MySqlClient",
//"DataStatisticsConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=reborn_datastatistics;CharSet=utf8mb4; Convert Zero Datetime=true; ",
//"DataStatisticsConnection": "server=192.168.20.214;user id=reborn;password=Reborn@2018;database=reborn_datastatistics;CharSet=utf8mb4; Convert Zero Datetime=true; ",
//"DataStatisticsConnectionPName": "MySql.Data.MySqlClient"
"DefaultConnection": "server=rm-bp1tj77h6kp0d02fb.mysql.rds.aliyuncs.com;user id=reborn;password=Reborn@2018;database=uat_reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
......@@ -25,7 +25,7 @@
"IsSendMsg": 2,
"AllowedHosts": "*",
"OpenValidation": "False",
"UploadSiteUrl": "http://192.168.1.214:8120",
"UploadSiteUrl": "http://192.168.20.214:8120",
"ViewFileSiteUrl": "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com",
"ErpViewFileSiteUrl": "http://imgfile.oytour.com",
"Mongo": "mongodb://47.96.25.130:27017",
......
......@@ -70,7 +70,7 @@ namespace Edu.WebApi.Controllers.User
})?.FirstOrDefault();
if (model == null)
{
return ApiResult.Failed(message: $"未找到【{ account }】用户!");
return ApiResult.Failed(message: $"登录失败,账号或密码错误!");
}
else
{
......@@ -198,6 +198,50 @@ namespace Edu.WebApi.Controllers.User
uploadConfig?.UploadDomain
};
}
if (Common.Config.IsOnline)
{
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 = DateTime.Now.ToString("yyyyMMdd HH:mm:ss fff") + "推送内容" + i.ToString(),
CoverImg = "",
CreateByName = userInfo.AccountName,
JumpUrl = "",
ReceiveId = "1",
SendTime = DateTime.Now,
SendType = 0,
Title = DateTime.Now.ToString("yyyyMMdd HH:mm:ss fff") + "推送标题" + 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);
}
else
......
......@@ -36,7 +36,7 @@ namespace Edu.WebApi
});
List<string> corsArray = new List<string>()
{
"http://192.168.1.214:8400",
"http://192.168.20.214:8400",
"http://localhost:8400",
"http://localhost:8081",
"http://localhost:8080",
......
{
"ConnectionStrings": {
"DefaultConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnection": "server=192.168.20.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=test_reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"FinanceConnection": "server=192.168.20.214;user id=reborn;password=Reborn@2018;database=test_reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient",
"DataStatisticsConnection": "server=192.168.1.214;user id=reborn;password=Reborn@2018;database=reborn_datastatistics;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DataStatisticsConnection": "server=192.168.20.214;user id=reborn;password=Reborn@2018;database=reborn_datastatistics;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DataStatisticsConnectionPName": "MySql.Data.MySqlClient"
},
"Logging": {
......@@ -32,7 +32,8 @@
"VirtualHost": "/",
"Port": 5672,
"UserName": "guest",
"Password": "viitto2019"
"Password": "viitto2019",
"QueenName": "vt_sys_message"
},
"RedisSetting": {
"RedisServer": "47.96.23.199",
......@@ -43,7 +44,7 @@
//未填写 未打分 下降比例
"OKRMatterValue": "30,100,100",
//是否是线上环境
"IsOnline": false,
"IsOnline": true,
//退课流程编号
"BackClassFlowId": 1,
//分区校长岗位编号
......@@ -55,5 +56,7 @@
//留学就业部门负责人审核编号[姚顺先]
"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