Compare commits

..

13 Commits

Author SHA1 Message Date
Argo-Lenovo e4b2f70ae3 feat: 增加任务日志滚动条样式 2022-01-29 18:39:54 +08:00
Argo-Lenovo 41b0dce852 feat: 任务日志增加最大数功能 2022-01-29 16:03:57 +08:00
Argo-Lenovo 188470bc1d feat: 增加任务日志功能 2022-01-29 15:26:44 +08:00
Argo-Lenovo 92e3aa4c35 feat: 实现缓存清楚逻辑 2022-01-29 14:34:00 +08:00
Argo-Tianyi 5e136d1815 fix: 修复 Client 工程编译报错问题 2022-01-28 12:24:49 +08:00
Argo-Tianyi 7506665052 feat: 登录首页增加切换功能 2022-01-27 16:00:21 +08:00
Argo-Tianyi fc2f0e84b2 feat: 增加 AdminLoginFooter 组件用于切换登录页 2022-01-27 15:43:29 +08:00
Argo-Tianyi 6ba2ef3a96 feat: 增加码云高仿登录界面 2022-01-27 15:14:09 +08:00
Argo-Tianyi 2674c6278d feat: 增加登录首页切换功能 2022-01-27 13:42:48 +08:00
Argo-Tianyi 6e881fbff4 feat: 登录首页配置增加顺序 2022-01-27 13:31:59 +08:00
Argo-Tianyi 135f0615f5 refactor: 改造登录首页组件 2022-01-27 13:31:37 +08:00
Argo-Tianyi a53c0cd791 feat: 增加更新 DisplayName 逻辑 2022-01-27 12:53:36 +08:00
Argo-Tianyi 71d5ff0a24 chore: 更新依赖包 2022-01-27 12:53:18 +08:00
26 changed files with 106 additions and 1326 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "src/vue/admin"]
path = src/vue/admin
url = https://gitee.com/zhangpeihang/vue-vben-admin.git

View File

@ -157,7 +157,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapClient.Web", "src\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootStarpAdmin.DataAccess.FreeSql", "src\blazor\admin\BootStarpAdmin.DataAccess.FreeSql\BootStarpAdmin.DataAccess.FreeSql.csproj", "{11122D97-B349-4A3E-B7DD-73B8B363C47C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootStarpAdmin.DataAccess.SqlSugar", "src\blazor\admin\BootStarpAdmin.DataAccess.SqlSugar\BootStarpAdmin.DataAccess.SqlSugar.csproj", "{1D20E6CF-9825-4CDE-B732-AE586BD1AABA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootStarpAdmin.DataAccess.SqlSugar", "src\blazor\admin\BootStarpAdmin.DataAccess.SqlSugar\BootStarpAdmin.DataAccess.SqlSugar.csproj", "{1D20E6CF-9825-4CDE-B732-AE586BD1AABA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapClient.Web.Core", "src\blazor\client\BootstrapClient.Web.Core\BootstrapClient.Web.Core.csproj", "{FFDF9FF9-0B29-47D3-AD42-53A476B570EC}"
EndProject
@ -165,12 +165,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapClient.DataAccess.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.Caching", "src\blazor\admin\BootstrapAdmin.Caching\BootstrapAdmin.Caching.csproj", "{ADD20515-1C1C-418B-84F6-8B05A7AA315B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vue", "vue", "{31F93CAE-7ADD-490F-A129-49D90FE4574A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{FED2B095-F0EA-4E52-A095-BD4C5AEA5C04}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootstrapAdmin.Api", "src\vue\api\BootstrapAdmin.Api\BootstrapAdmin.Api.csproj", "{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -257,10 +251,6 @@ Global
{ADD20515-1C1C-418B-84F6-8B05A7AA315B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADD20515-1C1C-418B-84F6-8B05A7AA315B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADD20515-1C1C-418B-84F6-8B05A7AA315B}.Release|Any CPU.Build.0 = Release|Any CPU
{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -303,9 +293,6 @@ Global
{FFDF9FF9-0B29-47D3-AD42-53A476B570EC} = {55A2459A-6BDE-4493-B2C0-5BE1673E99EE}
{CC3DF23A-2880-438F-BDEB-DB093E919ABA} = {55A2459A-6BDE-4493-B2C0-5BE1673E99EE}
{ADD20515-1C1C-418B-84F6-8B05A7AA315B} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
{31F93CAE-7ADD-490F-A129-49D90FE4574A} = {41B6D37A-5E5E-42B3-85E4-D81A81E3D757}
{FED2B095-F0EA-4E52-A095-BD4C5AEA5C04} = {31F93CAE-7ADD-490F-A129-49D90FE4574A}
{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C} = {FED2B095-F0EA-4E52-A095-BD4C5AEA5C04}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {221EAE38-5F75-4391-9A48-E462A9F3B8FC}

View File

@ -71,9 +71,9 @@ class DefaultCacheManager : ICacheManager
{
Cache.Remove(key);
}
else
else if (Cache is MemoryCache c)
{
//Cache.Compact(100);
c.Compact(100);
}
}
}

View File

@ -0,0 +1 @@
<BootstrapBlazor.Components.Console Items="@Messages" Height="280" ShowAutoScroll="true" />

View File

@ -0,0 +1,77 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using BootstrapAdmin.Web.Models;
using Longbow.Tasks;
namespace BootstrapAdmin.Web.Components;
/// <summary>
///
/// </summary>
public partial class TaskInfo : IDisposable
{
/// <summary>
///
/// </summary>
[Parameter]
[NotNull]
[EditorRequired]
public TasksModel? Model { get; set; }
private List<ConsoleMessageItem> Messages { get; } = new(24);
/// <summary>
///
/// </summary>
/// <param name="firstRender"></param>
/// <returns></returns>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var sche = TaskServicesManager.Get(Model.Name);
if (sche != null)
{
sche.Triggers.First().PulseCallback = async t => await DispatchMessage(t);
await DispatchMessage(sche.Triggers.First());
}
}
}
private async Task DispatchMessage(ITrigger trigger)
{
var message = $"Trigger({trigger.GetType().Name}) LastRuntime: {trigger.LastRuntime} Run({trigger.LastResult}) NextRuntime: {trigger.NextRuntime} Elapsed: {trigger.LastRunElapsedTime.TotalSeconds}";
Messages.Add(new ConsoleMessageItem()
{
Message = message
});
if (Messages.Count > 20)
{
Messages.RemoveAt(0);
}
await InvokeAsync(StateHasChanged);
}
private void Dispose(bool disposing)
{
if (disposing)
{
var sche = TaskServicesManager.Get(Model.Name);
if (sche != null)
{
sche.Triggers.First().PulseCallback = null;
}
}
}
/// <summary>
///
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}

View File

@ -2,6 +2,7 @@
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using BootstrapAdmin.Web.Components;
using BootstrapAdmin.Web.Core;
using BootstrapAdmin.Web.Extensions;
using BootstrapAdmin.Web.Models;
@ -32,6 +33,10 @@ public partial class Tasks
[NotNull]
private IDict? DictService { get; set; }
[Inject]
[NotNull]
private DialogService? DialogService { get; set; }
private bool IsDemo { get; set; }
/// <summary>
@ -157,9 +162,18 @@ public partial class Tasks
return Task.CompletedTask;
}
private static Task OnLog(TasksModel model)
private async Task OnLog(TasksModel model)
{
return Task.CompletedTask;
var option = new DialogOption()
{
Class = "modal-dialog-task",
Title = $"{model.Name} - 日志窗口(最新 20 条)",
Component = BootstrapDynamicComponent.CreateComponent<TaskInfo>(new Dictionary<string, object?>
{
[nameof(TaskInfo.Model)] = model
})
};
await DialogService.Show(option);
}
private static bool OnCheckTaskStatus(TasksModel model) => model.Status != SchedulerStatus.Disabled;

View File

@ -1,4 +1,4 @@
.layout.is-page .layout-side {
.layout.is-page .layout-side {
color: #3f4254;
background-color: #fff;
box-shadow: 0 0 28px 0 rgb(82 63 105 / 5%);
@ -26,3 +26,11 @@
background-color: #fff !important;
}
}
.modal-dialog-task ::-webkit-scrollbar-thumb {
background-color: #ffffff66;
}
.modal-dialog-task ::-webkit-scrollbar-thumb:hover {
background-color: #ffffffb3;
}

@ -1 +0,0 @@
Subproject commit dba7769cabd52a4bccd563e9430687c8b2457607

View File

@ -1,70 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
namespace BootstrapAdmin.Api.Authencation;
/// <summary>
///
/// </summary>
public static class BootstrapAdminJwtHandler
{
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <param name="configure"></param>
/// <returns></returns>
public static string CreateToken(string userName, Action<TokenValidateOption>? configure = null)
{
ClaimsIdentity claimsIdentity = new ClaimsIdentity("Bearer");
claimsIdentity.AddClaim(new Claim(ClaimTypes.Name, userName));
JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
TokenValidateOption tokenValidateOption = new TokenValidateOption();
configure?.Invoke(tokenValidateOption);
return jwtSecurityTokenHandler.CreateEncodedJwt(new SecurityTokenDescriptor
{
Issuer = tokenValidateOption.Issuer,
Audience = tokenValidateOption.Audience,
Subject = claimsIdentity,
Expires = DateTime.Now.AddMinutes(tokenValidateOption.Expires),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenValidateOption.SecurityKey)), "HS256")
});
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static string CreateRefershToken()
{
JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
TokenValidateOption tokenValidateOption = new TokenValidateOption();
return jwtSecurityTokenHandler.CreateEncodedJwt(new SecurityTokenDescriptor
{
Issuer = tokenValidateOption.Issuer,
Audience = tokenValidateOption.Audience,
Expires = DateTime.Now.AddMinutes(10),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenValidateOption.SecurityKey)), "HS256")
});
}
/// <summary>
///
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public static bool ValidateTokenExpires(string token)
{
JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
var parmeter = jwtSecurityTokenHandler.ReadJwtToken(token);
var value = parmeter.Claims.FirstOrDefault(s => s.Type == ClaimTypes.Expired);
return value!.Value != null;
}
}

View File

@ -1,32 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
namespace BootstrapAdmin.Api.Authencation;
/// <summary>
///
/// </summary>
public class TokenValidateOption
{
/// <summary>
///
/// </summary>
public string Issuer { get; set; } = "BA";
/// <summary>
///
/// </summary>
public string Audience { get; set; } = "api";
/// <summary>
///
/// </summary>
public int Expires { get; set; } = 5;
/// <summary>
///
/// </summary>
public string SecurityKey { get; set; } = "BootstrapAdmin-V1.1";
}

View File

@ -1,12 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
namespace BootstrapAdmin.Api;
/// <summary>
///
/// </summary>
public static class Authorization
{
}

View File

@ -1,33 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\blazor\admin\BootstrapAdmin.DataAccess.PetaPoco\BootstrapAdmin.DataAccess.PetaPoco.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>

View File

@ -1,58 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using BootstrapAdmin.Api.Authencation;
using BootstrapAdmin.Api.Extensions;
using BootstrapAdmin.Api.Models;
using BootstrapAdmin.Web.Core;
using Microsoft.AspNetCore.Mvc;
namespace BootstrapAdmin.Api.Controllers;
/// <summary>
///
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class AccountController : ControllerBase
{
private IUser UserService { get; }
/// <summary>
///
/// </summary>
/// <param name="userService"></param>
public AccountController(IUser userService) => UserService = userService;
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpPost]
public ActionResult<LoginResult> Post([FromServices] IConfiguration configuration, [FromBody] LoginUser user)
{
string? token = null;
string? refershtoken = null;
string? userName = user.UserName;
string? password = user.Password;
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password) && UserService.Authenticate(userName, password))
{
token = BootstrapAdminJwtHandler.CreateToken(userName, op =>
{
var tokenOption = configuration.GetOption(() => new TokenValidateOption());
op.Audience = tokenOption.Audience;
op.Expires = tokenOption.Expires;
op.Issuer = tokenOption.Issuer;
op.SecurityKey = tokenOption.SecurityKey;
});
refershtoken = BootstrapAdminJwtHandler.CreateRefershToken();
return new LoginResult { Code = "0", Message = "login successed!", Result = new Result { Token = token, RefershToken = refershtoken } };
}
else
{
return new LoginResult { Code = "0", Message = "login failed!", Result = new Result { Token = token, RefershToken = refershtoken } };
}
}
}

View File

@ -1,58 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using BootstrapAdmin.DataAccess.Models;
using BootstrapAdmin.Web.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace BootstrapAdmin.Api.Controllers
{
/// <summary>
/// 字典表维护控制器
/// </summary>
[Route("api/[controller]")]
[Authorize]
[ApiController]
public class DictsController : ControllerBase
{
private IDict DictService { get; }
/// <summary>
///
/// </summary>
/// <param name="dictService"></param>
public DictsController(IDict dictService) => DictService = dictService;
/// <summary>
/// 获取所有字典表数据方法
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult<List<Dict>> Get()
{
return DictService.GetAll();
}
/// <summary>
/// 保存字典方法
/// </summary>
/// <param name="value"></param>
[HttpPost]
public bool Post([FromBody] Dict value)
{
return true;
}
/// <summary>
/// 删除字典项方法
/// </summary>
/// <param name="value"></param>
[HttpDelete]
[Authorize(Roles = "Administrators")]
public bool Delete([FromBody] IEnumerable<string> value)
{
return true;
}
}
}

View File

@ -1,23 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using Bootstrap.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Collections.Generic;
namespace Bootstrap.Admin.Controllers.Api
{
/// <summary>
///
/// </summary>
[Route("api/[controller]")]
[Authorize]
[ApiController]
public class MenusController : ControllerBase
{
}
}

View File

@ -1,23 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Admin.Controllers.Api
{
/// <summary>
/// 角色维护控制器
/// </summary>
[Route("api/[controller]")]
[Authorize]
[ApiController]
public class RolesController : ControllerBase
{
}
}

View File

@ -1,49 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using BootstrapAdmin.DataAccess.Models;
using BootstrapAdmin.Web.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace BootstrapAdmin.Api.Controllers
{
/// <summary>
/// 用户控制器
/// </summary>
[Route("api/[controller]")]
[Authorize]
[ApiController]
public class UsersController : ControllerBase
{
private IUser UserService { get; }
/// <summary>
///
/// </summary>
/// <param name="userService"></param>
public UsersController(IUser userService) => UserService = userService;
/// <summary>
/// 调用获取所有用户信息 用户管理查询按钮
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Get()
{
return new JsonResult(new { Code = "0", Message = "login successed!", Result = new { roles = Array.Empty<string>() } }) ;
}
/// <summary>
/// api 握手协议
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpOptions]
public string? Options()
{
return null;
}
}
}

View File

@ -1,41 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
namespace BootstrapAdmin.Api.Extensions;
/// <summary>
///
/// </summary>
public static class ConfigurationExtension
{
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="configuration"></param>
/// <param name="valueFactory"></param>
/// <returns></returns>
public static T GetOption<T>(this IConfiguration configuration, Func<T> valueFactory) where T : class
{
T val = null;
Type typeFromHandle = typeof(T);
IConfigurationSection section = configuration.GetSection(typeFromHandle.Name);
if (!section.Exists())
{
section = configuration.GetSection(typeFromHandle.FullName);
}
if (section.Exists())
{
val = section.Get<T>();
}
if (val == null)
{
val = valueFactory();
}
return val;
}
}

View File

@ -1,54 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
using PetaPoco;
using PetaPoco.Providers;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
using BootstrapAdmin.Api.Authencation;
namespace Microsoft.Extensions.DependencyInjection;
/// <summary>
///
/// </summary>
public static class ServiceCollectionExtension
{
/// <summary>
///
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddBootstrapAdminService(this IServiceCollection services)
{
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, option =>
{
var tokenValidateOption = new TokenValidateOption();
option.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuer = true,//是否验证Issuer
ValidateAudience = true,//是否验证Audience
ValidateLifetime = true,//是否验证失效时间
ClockSkew = TimeSpan.Zero,
ValidateIssuerSigningKey = true,//是否验证SecurityKey
ValidAudience = tokenValidateOption.Audience,//Audience
ValidIssuer = tokenValidateOption.Issuer,//Issuer这两项和前面签发jwt的设置一致
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenValidateOption.SecurityKey)),//拿到SecurityKey
};
option.RequireHttpsMetadata = false;
});
services.AddPetaPocoDataAccessServices((provider, builder) =>
{
var configuration = provider.GetRequiredService<IConfiguration>();
var connString = configuration.GetConnectionString("bb");
builder.UsingProvider<SQLiteDatabaseProvider>()
.UsingConnectionString(connString);
});
return services;
}
}

View File

@ -1,33 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
namespace BootstrapAdmin.Api.Models;
/// <summary>
///
/// </summary>
public class LoginResult
{
/// <summary>
///
/// </summary>
public string? Code { get; set; }
/// <summary>
///
/// </summary>
public string? Message { get; set; }
/// <summary>
///
/// </summary>
public Result? Result { get; set; }
}
public class Result
{
public string? Token { get; set; }
public string? RefershToken { get; set; }
}

View File

@ -1,21 +0,0 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone
namespace BootstrapAdmin.Api.Models;
/// <summary>
///
/// </summary>
public class LoginUser
{
/// <summary>
///
/// </summary>
public string? UserName { get; set; }
/// <summary>
///
/// </summary>
public string? Password { get; set; }
}

View File

@ -1,65 +0,0 @@
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Configure the service container.
builder.Services.AddControllers();
builder.Services.AddRouting(s => s.LowercaseUrls = true);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "BootstrapAdmin API"
});
//Set the comments path for the swagger json and ui.
//var xmlPath = Path.Combine(AppContext.BaseDirectory, "Bootstrap.Admin.xml");
//options.IncludeXmlComments(xmlPath);
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Name = "Authorization",
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Description = "JWT Authorization header using the Bearer scheme."
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[]{ }
}
});
});
builder.Services.AddBootstrapAdminService();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(option =>
{
option.DocumentTitle = "BootstrapAdmin API V1";
});
}
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -1,31 +0,0 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:11008",
"sslPort": 0
}
},
"profiles": {
"BootstrapAdmin.Api": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5046",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -1,350 +0,0 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Longbow.Tasks": "Error"
},
"LgbFile": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Error"
},
"FileName": "Error\\Log.log"
}
},
"SimulateUserName": "",
"AutoGenerateDatabase": true,
"BootstrapAdminAuthenticationOptions": {
"KeyPath": "..\\..\\keys"
},
"DB": [
{
"Enabled": false,
"ProviderName": "SqlServer",
"SqlFolder": "..\\..\\..\\db\\SqlServer",
"ConnectionStrings": {
"ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa"
}
},
{
"Enabled": true,
"ProviderName": "Sqlite",
"SqlFolder": "..\\..\\..\\db\\SQLite",
"ConnectionStrings": {
"ba": "Data Source=BootstrapAdmin.db;"
}
},
{
"Enabled": false,
"ProviderName": "MySql",
"SqlFolder": "..\\..\\..\\db\\MySQL",
"ConnectionStrings": {
"ba": "Server=localhost;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;"
}
},
{
"Enabled": false,
"ProviderName": "Oracle",
"ConnectionStrings": {
"ba": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXXXXX)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));User Id=XX;Password=XX"
}
},
{
"Enabled": false,
"ProviderName": "Npgsql",
"ConnectionStrings": {
"ba": "Server=localhost;Database=BootstrapAdmin;User ID=argozhang;Password=argo@163.com;"
}
},
{
"Enabled": false,
"Widget": "Bootstrap.DataAccess.MongoDB",
"ProviderName": "MongoDB",
"SqlFolder": "..\\..\\..\\db\\MongoDB",
"ConnectionStrings": {
"ba": "mongodb://localhost:27017/BootstrapAdmin"
}
}
],
"SwaggerPathBase": "",
"GiteeHealthChecks": "true",
"AllowOrigins": "http://localhost:49185",
"HealthsCloudUrl": "https://client.blazor.zone/api/Interface/Healths",
"FileStorageOptions": {
"Enabled": true,
"Folder": "TaskStorage",
"Secure": false
},
"GiteeOptions": {
"Enabled": true,
"ClientId": "9bfe9b95d813ca7d613b110a54eda28bf227154b314c95f0c69e7680d64525e1",
"ClientSecret": "3427f2d901ba9afc76c1842a7303b2d67f8e098e71acc15051f89fe6f3d265db",
"CallbackPath": "/signin-gitee",
"HomePath": "/Admin/Profiles",
"Scope": [ "user_info", "projects" ],
"Roles": [ "Administrators" ],
"App": "Demo",
"StarredUrl": "https://gitee.com/api/v5/user/starred/LongbowEnterprise/BootstrapAdmin"
},
"GitHubOptions": {
"Enabled": true,
"ClientId": "ec53ecfe238558a0423b",
"ClientSecret": "ffa759ca599df941b869efecb5e750bc1b27334e",
"CallbackPath": "/signin-github",
"HomePath": "/Admin/Profiles",
"Scope": [ "user_info", "repo" ],
"Roles": [ "Administrators" ],
"App": "Demo",
"StarredUrl": "https://api.github.com/user/starred/ArgoZhang/BootstrapAdmin"
},
"WeChatOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<secret>",
"CallbackPath": "/signin-weixin",
"HomePath": "/Admin/Profiles",
"Scope": [ "snsapi_login" ],
"Roles": [ "Administrators" ],
"App": "Demo"
},
"TencentOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>",
"CallbackPath": "/signin-tencent",
"HomePath": "/Admin/Profiles",
"Scope": [ "get_user_info" ],
"Roles": [ "Administrators" ],
"App": "Demo"
},
"SMSOptions": {
"CompanyCode": "<CompanyCode>",
"MD5Key": "MD5Key",
"Roles": [ "Administrators" ],
"HomePath": "/Admin/Profiles",
"App": "Demo"
},
"AlipayOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>",
"CallbackPath": "/signin-alipay",
"HomePath": "/Admin/Profiles",
"SignKey": "",
"Scope": [ "auth_user" ],
"Roles": [ "Administrators" ],
"App": "Demo"
},
"TencentSMSOptions": {
"AppId": "<TencentAppId>",
"AppKey": "<TencentAppKey>",
"TplId": 0,
"Sign": "<TencentSign>",
"Roles": [ "Default" ],
"HomePath": "/Admin/Profiles",
"App": "Demo",
"Debug": true
},
"AppMenus": [
"首页",
"测试页面",
"关于",
"返回码云",
"多级菜单",
"第二层",
"第三层",
"第四层"
],
"LongbowCache": {
"Enabled": true,
"CorsItems": [
{
"Enabled": true,
"Key": "ba",
"Url": "CacheList.axd",
"Desc": "后台管理数据缓存接口",
"Self": true
},
{
"Enabled": true,
"Key": "App",
"Url": "http://localhost:49185/CacheList.axd",
"Desc": "测试系统",
"Self": false
}
],
"CacheItems": [
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByUserName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "指定用户角色数据缓存"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByUrl",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过菜单获得角色数据"
},
{
"Enabled": true,
"Key": "AppHelper-RetrieveAppsByUserName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "指定用户授权应用数据缓存"
},
{
"Enabled": true,
"Key": "BootstrapUser-RetrieveUsersByName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "登录用户数据"
},
{
"Enabled": true,
"Key": "BootstrapDict-RetrieveDicts",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有字典数据缓存"
},
{
"Enabled": true,
"Key": "BootstrapMenu-RetrieveMenus",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "用户所有菜单数据缓存"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroupsByUserName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "指定用户组数据缓存"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveUsers",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有用户数据"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveUsersByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有用户数据"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveUsersByGroupId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过部门ID获得所有用户数据"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveNewUsers",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "新用户数据"
},
{
"Enabled": true,
"Key": "MenuHelper-RetrieveMenusByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有菜单数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRoles",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有角色数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByUserId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过用户ID获得所有角色数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByMenuId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过菜单ID获得所有角色数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByGroupId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过部门ID获得所有角色数据"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroups",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有部门数据"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroupsByUserId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过用户ID获得所有部门数据"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroupsByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有部门数据"
},
{
"Enabled": true,
"Key": "AppHelper-RetrieveAppsByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有应用程序数据"
},
{
"Enabled": true,
"Key": "DictHelper-RetrieveDictsCategory",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "字典分类数据"
},
{
"Enabled": true,
"Key": "ExceptionHelper-RetrieveExceptions",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "程序异常数据"
},
{
"Enabled": true,
"Key": "MessageHelper-RetrieveMessages",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "站内消息数据"
},
{
"Enabled": true,
"Key": "TaskHelper-RetrieveTasks",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有任务数据"
}
]
}
}

View File

@ -1,350 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"LgbFile": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Error"
},
"FileName": "Error\\Log.log"
},
"Cloud": {
"LogLevel": {
"Default": "Error"
},
"Url": "https://client.blazor.zone/api/Interface/Log"
}
},
"ConnectionStrings": {
"ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa",
"bb": "Data Source=BootstrapAdmin.db;"
},
"AutoGenerateDatabase": false,
"DB": [
{
"Enabled": false,
"ProviderName": "SqlServer",
"ConnectionStrings": {
"ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa"
}
},
{
"Enabled": true,
"ProviderName": "Sqlite",
"ConnectionStrings": {
"ba": "Data Source=BootstrapAdmin.db;"
}
},
{
"Enabled": false,
"ProviderName": "MySql",
"ConnectionStrings": {
"ba": "Server=localhost;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;"
}
},
{
"Enabled": false,
"ProviderName": "Npgsql",
"ConnectionStrings": {
"ba": "Server=localhost;Database=BootstrapAdmin;User ID=argozhang;Password=argo@163.com;"
}
},
{
"Enabled": false,
"Widget": "Bootstrap.DataAccess.MongoDB",
"ProviderName": "MongoDB",
"ConnectionStrings": {
"ba": "mongodb://localhost:27017/BootstrapAdmin"
}
}
],
"AppId": "BA",
"UseHttps": true,
"SwaggerPathBase": "",
"AllowOrigins": "http://localhost,http://admin.blazor.zone",
"HealthsCloudUrl": "https://client.blazor.zone/api/Interface/Healths",
"GiteeHealthChecks": false,
"Sentry": {
"Dsn": "https://70bdfff562e84fa7b9a43d65924ab9ad@sentry.io/1469396"
},
"BootstrapBlazorOptions": {
"DefaultCultureInfo": "zh-CN"
},
"Exceptionless": {
"ApiKey": "AgQlY1MRWpX5qOF2edpK2IZYBhgPYImhr4UnZdAT"
},
"TokenValidateOption": {
"Issuer": "BA",
"Audience": "api",
"Expires": 5,
"SecurityKey": "BootstrapAdmin-V1.1"
},
"TaskServicesOptions": {
"ShutdownTimeout": "00:00:05"
},
"FileStorageOptions": {
"Enabled": true,
"Folder": "TaskStorage",
"Secure": true
},
"GiteeOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>",
"CallbackPath": "/signin-gitee",
"HomePath": "/Home/Index",
"Scope": [ "user_info", "projects" ],
"Roles": [ "Default" ],
"App": "Demo"
},
"GitHubOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>",
"CallbackPath": "/signin-github",
"HomePath": "/Home/Index",
"Scope": [ "user_info", "repo" ],
"Roles": [ "Default" ],
"App": "Demo"
},
"WeChatOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<secret>",
"CallbackPath": "/signin-weixin",
"HomePath": "/Admin/Profiles",
"Scope": [ "snsapi_login" ],
"Roles": [ "Default" ],
"App": "Demo"
},
"TencentOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>",
"CallbackPath": "/signin-tencent",
"HomePath": "/Admin/Profiles",
"Scope": [ "get_user_info" ],
"Roles": [ "Administrators" ],
"App": "Demo"
},
"AlipayOptions": {
"Enabled": true,
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>",
"CallbackPath": "/signin-alipay",
"HomePath": "/Admin/Profiles",
"SignKey": "",
"Scope": [ "auth_user" ],
"Roles": [ "Administrators" ],
"App": "Demo"
},
"SMSOptions": {
"CompanyCode": "<CompanyCode>",
"MD5Key": "MD5Key",
"Roles": [ "Default" ],
"HomePath": "/Home/Index",
"App": "Demo"
},
"TencentSMSOptions": {
"AppId": "<TencentAppId>",
"AppKey": "<TencentAppKey>",
"TplId": 0,
"Sign": "<TencentSign>",
"Roles": [ "Default" ],
"HomePath": "/Admin/Profiles",
"App": "Demo"
},
"LongbowCache": {
"Enabled": true,
"CorsItems": [
{
"Enabled": true,
"Key": "ba",
"Url": "CacheList.axd",
"Desc": "后台管理数据缓存接口",
"Self": true
},
{
"Enabled": true,
"Key": "App",
"Url": "../Client/CacheList.axd",
"Desc": "测试系统",
"Self": false
}
],
"CacheItems": [
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByUserName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "指定用户角色数据缓存"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByUrl",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过菜单获得角色数据"
},
{
"Enabled": true,
"Key": "AppHelper-RetrieveAppsByUserName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "指定用户授权应用数据缓存"
},
{
"Enabled": true,
"Key": "BootstrapUser-RetrieveUsersByName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "登录用户数据"
},
{
"Enabled": true,
"Key": "BootstrapDict-RetrieveDicts",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有字典数据缓存"
},
{
"Enabled": true,
"Key": "BootstrapMenu-RetrieveMenus",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "用户所有菜单数据缓存"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroupsByUserName",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "指定用户组数据缓存"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveUsers",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有用户数据"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveUsersByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有用户数据"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveUsersByGroupId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过部门ID获得所有用户数据"
},
{
"Enabled": true,
"Key": "UserHelper-RetrieveNewUsers",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "新用户数据"
},
{
"Enabled": true,
"Key": "MenuHelper-RetrieveMenusByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有菜单数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRoles",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有角色数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByUserId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过用户ID获得所有角色数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByMenuId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过菜单ID获得所有角色数据"
},
{
"Enabled": true,
"Key": "RoleHelper-RetrieveRolesByGroupId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过部门ID获得所有角色数据"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroups",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有部门数据"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroupsByUserId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过用户ID获得所有部门数据"
},
{
"Enabled": true,
"Key": "GroupHelper-RetrieveGroupsByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有部门数据"
},
{
"Enabled": true,
"Key": "AppHelper-RetrieveAppsByRoleId",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "通过角色ID获得所有应用程序数据"
},
{
"Enabled": true,
"Key": "DictHelper-RetrieveDictsCategory",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "字典分类数据"
},
{
"Enabled": true,
"Key": "ExceptionHelper-RetrieveExceptions",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "程序异常数据"
},
{
"Enabled": true,
"Key": "MessageHelper-RetrieveMessages",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "站内消息数据"
},
{
"Enabled": true,
"Key": "TaskHelper-RetrieveTasks",
"Interval": 600000,
"SlidingExpiration": true,
"Desc": "所有任务数据"
}
]
}
}