Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
725f1d87
Commit
725f1d87
authored
3 years ago
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
d489acd7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
271 additions
and
6 deletions
+271
-6
Edu.Common.csproj
Edu.Common/Edu.Common.csproj
+1
-0
MessageHelper.cs
Edu.Common/Message/MessageHelper.cs
+89
-0
PushMessageModel.cs
Edu.Common/Message/PushMessageModel.cs
+62
-0
RabbitConfig.cs
Edu.Common/Message/RabbitConfig.cs
+38
-0
Edu.Common.deps.json
Edu.Common/bin/Debug/netcoreapp3.0/Edu.Common.deps.json
+16
-0
Edu.Common.deps.json
Edu.Common/bin/Release/netcoreapp3.0/Edu.Common.deps.json
+16
-0
LoginController.cs
Edu.WebApi/Controllers/User/LoginController.cs
+44
-4
appsettings.json
Edu.WebApi/appsettings.json
+5
-2
No files found.
Edu.Common/Edu.Common.csproj
View file @
725f1d87
...
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
Edu.Common/Message/MessageHelper.cs
0 → 100644
View file @
725f1d87
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
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Edu.Common/Message/PushMessageModel.cs
0 → 100644
View file @
725f1d87
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
;
}
}
}
This diff is collapsed.
Click to expand it.
Edu.Common/Message/RabbitConfig.cs
0 → 100644
View file @
725f1d87
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
;
}
}
}
This diff is collapsed.
Click to expand it.
Edu.Common/bin/Debug/netcoreapp3.0/Edu.Common.deps.json
View file @
725f1d87
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
Edu.Common/bin/Release/netcoreapp3.0/Edu.Common.deps.json
View file @
725f1d87
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
Edu.WebApi/Controllers/User/LoginController.cs
View file @
725f1d87
...
...
@@ -70,7 +70,7 @@ namespace Edu.WebApi.Controllers.User
})?.
FirstOrDefault
();
if
(
model
==
null
)
{
return
ApiResult
.
Failed
(
message
:
$"
未找到【
{
account
}
】用户
!"
);
return
ApiResult
.
Failed
(
message
:
$"
登录失败,账号或密码错误
!"
);
}
else
{
...
...
@@ -112,12 +112,12 @@ namespace Edu.WebApi.Controllers.User
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
();
UserInfo
obj
=
new
UserInfo
{
Id
=
model
.
Id
,
AccountId
=
model
.
AccountId
,
UserMobile
=
model
.
Account
,
UserMobile
=
model
.
Account
,
AccountType
=
model
.
AccountType
,
Group_Id
=
model
.
Group_Id
,
GroupName
=
model
.
GroupName
,
...
...
@@ -146,7 +146,7 @@ namespace Edu.WebApi.Controllers.User
uploadConfig
?.
SecretId
,
uploadConfig
?.
UploadDomain
},
StudyAbroadObj
=
publicModule
.
GetStudyAbroadListModule
()
StudyAbroadObj
=
publicModule
.
GetStudyAbroadListModule
()
};
UserReidsCache
.
UserInfoSet
(
Cache
.
CacheKey
.
User_Login_Key
+
model
.
Id
,
obj
,
Common
.
Config
.
JwtExpirTime
);
return
ApiResult
.
Success
(
data
:
obj
);
...
...
@@ -198,6 +198,46 @@ namespace Edu.WebApi.Controllers.User
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
);
}
else
...
...
This diff is collapsed.
Click to expand it.
Edu.WebApi/appsettings.json
View file @
725f1d87
...
...
@@ -32,7 +32,8 @@
"VirtualHost"
:
"/"
,
"Port"
:
5672
,
"UserName"
:
"guest"
,
"Password"
:
"viitto2019"
"Password"
:
"viitto2019"
,
"QueenName"
:
"vt_sys_message"
},
"RedisSetting"
:
{
"RedisServer"
:
"47.96.23.199"
,
...
...
@@ -55,5 +56,7 @@
//留学就业部门负责人审核编号
[
姚顺先
]
"StudyAbroadManagerId"
:
52
,
//合同默认抬头
"ContractDefaultTitle"
:
"JH-DZ-CD-"
"ContractDefaultTitle"
:
"JH-DZ-CD-"
,
//消息推送AppId
"PushAppId"
:
"JiaHeJiaoYu"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment