WXWork7 1.0.9
dotnet add package WXWork7 --version 1.0.9
NuGet\Install-Package WXWork7 -Version 1.0.9
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WXWork7" Version="1.0.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WXWork7" Version="1.0.9" />
<PackageReference Include="WXWork7" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WXWork7 --version 1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WXWork7, 1.0.9"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WXWork7@1.0.9
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WXWork7&version=1.0.9
#tool nuget:?package=WXWork7&version=1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WXWork7 & WXWork7.Account
一、WXWork7
基于.Net7的企业微信Api
- Program.cs
builder.Services.AddHttpClient();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddMemoryCache();
builder.Services.AddWXWork();
- appsettings.json
"WXWork":
{
"AgentId": 应用Id,
"CorpId": "企业Id",
"Secret": "企业密钥"
}
3.使用示例
public async Task OnGetAsync([FromServices] WXWork q)
{
await q.SendTextMessageAsync( "ZhangSan", "1432");
}
二、WXWork7.Account
添加了企业微信OAuth授权登录逻辑和简单的用户、角色管理模块
- Program.cs
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(option =>
{
option.LoginPath = new PathString("/account/login");
option.AccessDeniedPath = new PathString("/account/denied");
});
builder.Services.AddAuthorization(options =>
{
//options.AddPolicy(ERole.Admin.ToString(), policy => policy.RequireRole(ERole.Admin.ToString(), ERole.SystemAdmin.ToString()));
//options.AddPolicy(ERole.SystemAdmin.ToString(), policy => policy.RequireRole(ERole.SystemAdmin.ToString()));
//options.AddPolicy(ERole.Report.ToString(), policy => policy.RequireRole(ERole.Report.ToString(), ERole.Admin.ToString(), ERole.SystemAdmin.ToString()));
});
builder.Services.AddWXWorkWithAccount(connectionString);
...
app.UseAuthentication();
app.UseAuthorization();
- appsettings.json
"WXWork":
{
"AgentId": 应用Id,
"CorpId": "企业Id",
"Secret": "企业密钥"
},
"WXWork.Account": {
"Roles": [ "角色A", "角色B", "角色C" ],
"Ext": "用户扩展属性的文字说明"
}
3._Layout.cshtml
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/User/Index">用户</a>
</li>
4.Table Users
/****** Object: Table [dbo].[Users] Script Date: 2023/12/10 15:16:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
[UserId] [nvarchar](128) NOT NULL,
[TrueName] [nvarchar](128) NOT NULL,
[Roles] [nvarchar](max) NULL,
[Ext] [nvarchar](max) NULL,
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
(
[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
三、WXWork7.Third.Auth
企业微信服务商登录授权
- Program.cs
builder.Services.AddWXWork3rdAuth();
- 其它网站使用登录授权 见Demo.Auth3rd 的Login和Callback页
另外,还改造了Demo的_Layout.cshtml、_LoginPartial.cshtml、Error.cshtml等页面。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on WXWork7:
Package | Downloads |
---|---|
WXWork7.Account
基于ASP.Net7的用企业微信Api以及OAuth和User页面 |
GitHub repositories
This package is not used by any popular GitHub repositories.