61 changed files with 804 additions and 40615 deletions
@ -1,10 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<config> |
|||
<add key="yhglobal" value="https://proget.yhglobal.cn/nuget/default/" /> |
|||
</config> |
|||
|
|||
<packageSources> |
|||
<add key="yhglobal" value="https://proget.yhglobal.cn/nuget/default/" /> |
|||
<!--<add key="BlazoriseMyGet" value="https://www.myget.org/F/blazorise/api/v3/index.json" />--> |
|||
</packageSources> |
|||
</configuration> |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Zzz.Dic |
|||
{ |
|||
public interface IDataDicManager |
|||
{ |
|||
Task<string> FindAsync(string name, string label); |
|||
} |
|||
} |
|||
@ -1,25 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Zzz.DTOs.Dic; |
|||
using Zzz.DTOs.Public; |
|||
|
|||
namespace Zzz.Dic |
|||
{ |
|||
public interface IDicAppService: IApplicationService |
|||
public interface IDicAppService |
|||
{ |
|||
Task<ApiResult> CreateAsync(CreateDataDictionaryDto input); |
|||
|
|||
Task<ApiResult> UpdateAsync(UpdataDataDictionaryDto input); |
|||
|
|||
Task<ApiResult> GetListAsync(string name, int skipCount = 0, int maxResultCount = 10); |
|||
|
|||
Task<ApiResult> GetListDetailAsync(Guid id); |
|||
|
|||
Task<ApiResult> CreateDetailAsync(CreateDataDictionaryDetailDto input); |
|||
|
|||
Task<ApiResult> UpdateDetailAsync(UpdataDataDictionaryDetailDto input); |
|||
|
|||
Task<ApiResult> DeleteAsync(Guid id, Guid? itemId); |
|||
} |
|||
} |
|||
|
|||
@ -1,12 +1,14 @@ |
|||
using Hangfire; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Zzz.Jobs |
|||
{ |
|||
/// <summary>
|
|||
/// Cron类型
|
|||
/// </summary>
|
|||
public static class CronTypeHelper |
|||
public static class CronType |
|||
{ |
|||
/// <summary>
|
|||
/// 周期性为分钟的任务
|
|||
@ -1,13 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Zzz.Publics |
|||
{ |
|||
public interface IPublicApiAppService : IApplicationService |
|||
{ |
|||
Task<string> TestAsync(string msg); |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Zzz.Dic |
|||
{ |
|||
public class DataDicManager : IDataDicManager |
|||
{ |
|||
private readonly IRepository<DataDictionary, Guid> _dataDictionaryRepository; |
|||
|
|||
public DataDicManager(IRepository<DataDictionary, Guid> dataDictionaryRepository) |
|||
{ |
|||
_dataDictionaryRepository = dataDictionaryRepository; |
|||
} |
|||
|
|||
public async Task<string> FindAsync(string name, string label) |
|||
{ |
|||
Check.NotNullOrEmpty(name, nameof(name)); |
|||
Check.NotNullOrEmpty(label, nameof(label)); |
|||
var entity = await _dataDictionaryRepository.Include(e => e.DataDictionaryDetails).Where(e => e.Name == name.Trim()).FirstOrDefaultAsync(); |
|||
if (entity == null) throw new BusinessException("Dic is Null"); |
|||
var entityDetail= entity.DataDictionaryDetails.Find(e => e.Label == label.Trim()); |
|||
if(entityDetail==null) throw new BusinessException("DicDetail is Null"); |
|||
return entityDetail.Value; |
|||
} |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Zzz.Publics |
|||
{ |
|||
[RemoteService] |
|||
public class PublicApiAppService : ApplicationService, IPublicApiAppService |
|||
{ |
|||
public async Task<string> TestAsync(string msg) |
|||
{ |
|||
await Task.CompletedTask; |
|||
return msg; |
|||
} |
|||
} |
|||
} |
|||
@ -1,39 +1,41 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
<RootNamespace>Zzz</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
|||
<OutputPath>bin\Debug\net5.0\</OutputPath> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<OutputPath>bin\Debug\net5.0\</OutputPath> |
|||
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Zzz.Domain\Zzz.Domain.csproj" /> |
|||
<ProjectReference Include="..\Zzz.Application.Contracts\Zzz.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\Zzz.EntityFrameworkCore\Zzz.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Hangfire.Redis.StackExchange.StrongName" Version="1.7.0" /> |
|||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" /> |
|||
<PackageReference Include="EasyAbp.Abp.SettingUi.Application" Version="1.3.1" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" /> |
|||
<PackageReference Include="Volo.Abp.Account.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Identity.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" Version="$(AbpVersion)" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
<RootNamespace>Zzz</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
|||
<OutputPath>bin\Debug\net5.0\</OutputPath> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<OutputPath>bin\Debug\net5.0\</OutputPath> |
|||
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Zzz.Domain\Zzz.Domain.csproj" /> |
|||
<ProjectReference Include="..\Zzz.Application.Contracts\Zzz.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\Zzz.EntityFrameworkCore\Zzz.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
|
|||
<PackageReference Include="EasyAbp.Abp.SettingUi.Application" Version="1.3.1" /> |
|||
|
|||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" /> |
|||
|
|||
<PackageReference Include="Volo.Abp.Account.Application" Version="$(AbpVersion)" /> |
|||
|
|||
|
|||
<PackageReference Include="Volo.Abp.Identity.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="$(AbpVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
|||
@ -1,13 +0,0 @@ |
|||
namespace Zzz.Dic.MaxLengths |
|||
{ |
|||
public class DataDictionaryMaxLength |
|||
{ |
|||
public const int Name = 64; |
|||
|
|||
public const int Description = 256; |
|||
|
|||
public const int Label = 64; |
|||
|
|||
public const int Value = 64; |
|||
} |
|||
} |
|||
@ -0,0 +1,324 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using IdentityServer4.Models; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
using Volo.Abp.IdentityServer.ApiScopes; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.IdentityServer.IdentityResources; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; |
|||
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; |
|||
using Client = Volo.Abp.IdentityServer.Clients.Client; |
|||
|
|||
namespace Zzz.IdentityServer |
|||
{ |
|||
//public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency
|
|||
//{
|
|||
// private readonly IApiResourceRepository _apiResourceRepository;
|
|||
// private readonly IApiScopeRepository _apiScopeRepository;
|
|||
// private readonly IClientRepository _clientRepository;
|
|||
// private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder;
|
|||
// private readonly IGuidGenerator _guidGenerator;
|
|||
// private readonly IPermissionDataSeeder _permissionDataSeeder;
|
|||
// private readonly IConfiguration _configuration;
|
|||
// private readonly ICurrentTenant _currentTenant;
|
|||
|
|||
// public IdentityServerDataSeedContributor(
|
|||
// IClientRepository clientRepository,
|
|||
// IApiResourceRepository apiResourceRepository,
|
|||
// IApiScopeRepository apiScopeRepository,
|
|||
// IIdentityResourceDataSeeder identityResourceDataSeeder,
|
|||
// IGuidGenerator guidGenerator,
|
|||
// IPermissionDataSeeder permissionDataSeeder,
|
|||
// IConfiguration configuration,
|
|||
// ICurrentTenant currentTenant)
|
|||
// {
|
|||
// _clientRepository = clientRepository;
|
|||
// _apiResourceRepository = apiResourceRepository;
|
|||
// _apiScopeRepository = apiScopeRepository;
|
|||
// _identityResourceDataSeeder = identityResourceDataSeeder;
|
|||
// _guidGenerator = guidGenerator;
|
|||
// _permissionDataSeeder = permissionDataSeeder;
|
|||
// _configuration = configuration;
|
|||
// _currentTenant = currentTenant;
|
|||
// }
|
|||
|
|||
// [UnitOfWork]
|
|||
// public virtual async Task SeedAsync(DataSeedContext context)
|
|||
// {
|
|||
// using (_currentTenant.Change(context?.TenantId))
|
|||
// {
|
|||
// await _identityResourceDataSeeder.CreateStandardResourcesAsync();
|
|||
// await CreateApiResourcesAsync();
|
|||
// await CreateApiScopesAsync();
|
|||
// await CreateClientsAsync();
|
|||
// }
|
|||
// }
|
|||
|
|||
// private async Task CreateApiScopesAsync()
|
|||
// {
|
|||
// await CreateApiScopeAsync("Zzz");
|
|||
// }
|
|||
|
|||
// private async Task CreateApiResourcesAsync()
|
|||
// {
|
|||
// var commonApiUserClaims = new[]
|
|||
// {
|
|||
// "email",
|
|||
// "email_verified",
|
|||
// "name",
|
|||
// "phone_number",
|
|||
// "phone_number_verified",
|
|||
// "role"
|
|||
// };
|
|||
|
|||
// await CreateApiResourceAsync("Zzz", commonApiUserClaims);
|
|||
// }
|
|||
|
|||
// private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims)
|
|||
// {
|
|||
// var apiResource = await _apiResourceRepository.FindByNameAsync(name);
|
|||
// if (apiResource == null)
|
|||
// {
|
|||
// apiResource = await _apiResourceRepository.InsertAsync(
|
|||
// new ApiResource(
|
|||
// _guidGenerator.Create(),
|
|||
// name,
|
|||
// name + " API"
|
|||
// ),
|
|||
// autoSave: true
|
|||
// );
|
|||
// }
|
|||
|
|||
// foreach (var claim in claims)
|
|||
// {
|
|||
// if (apiResource.FindClaim(claim) == null)
|
|||
// {
|
|||
// apiResource.AddUserClaim(claim);
|
|||
// }
|
|||
// }
|
|||
|
|||
// return await _apiResourceRepository.UpdateAsync(apiResource);
|
|||
// }
|
|||
|
|||
// private async Task<ApiScope> CreateApiScopeAsync(string name)
|
|||
// {
|
|||
// var apiScope = await _apiScopeRepository.GetByNameAsync(name);
|
|||
// if (apiScope == null)
|
|||
// {
|
|||
// apiScope = await _apiScopeRepository.InsertAsync(
|
|||
// new ApiScope(
|
|||
// _guidGenerator.Create(),
|
|||
// name,
|
|||
// name + " API"
|
|||
// ),
|
|||
// autoSave: true
|
|||
// );
|
|||
// }
|
|||
|
|||
// return apiScope;
|
|||
// }
|
|||
|
|||
// private async Task CreateClientsAsync()
|
|||
// {
|
|||
// var commonScopes = new[]
|
|||
// {
|
|||
// "email",
|
|||
// "openid",
|
|||
// "profile",
|
|||
// "role",
|
|||
// "phone",
|
|||
// "address",
|
|||
// "Zzz"
|
|||
// };
|
|||
|
|||
// var configurationSection = _configuration.GetSection("IdentityServer:Clients");
|
|||
|
|||
// //Web Client
|
|||
// var webClientId = configurationSection["Zzz_Web:ClientId"];
|
|||
// if (!webClientId.IsNullOrWhiteSpace())
|
|||
// {
|
|||
// var webClientRootUrl = configurationSection["Zzz_Web:RootUrl"].EnsureEndsWith('/');
|
|||
|
|||
// /* Zzz_Web client is only needed if you created a tiered
|
|||
// * solution. Otherwise, you can delete this client. */
|
|||
|
|||
// await CreateClientAsync(
|
|||
// name: webClientId,
|
|||
// scopes: commonScopes,
|
|||
// grantTypes: new[] { "hybrid" },
|
|||
// secret: (configurationSection["Zzz_Web:ClientSecret"] ?? "1q2w3e*").Sha256(),
|
|||
// redirectUri: $"{webClientRootUrl}signin-oidc",
|
|||
// postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc",
|
|||
// frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout",
|
|||
// corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
|
|||
// );
|
|||
// }
|
|||
|
|||
// //Console Test / Angular Client
|
|||
// var consoleAndAngularClientId = configurationSection["Zzz_App:ClientId"];
|
|||
// if (!consoleAndAngularClientId.IsNullOrWhiteSpace())
|
|||
// {
|
|||
// var webClientRootUrl = configurationSection["Zzz_App:RootUrl"]?.TrimEnd('/');
|
|||
|
|||
// await CreateClientAsync(
|
|||
// name: consoleAndAngularClientId,
|
|||
// scopes: commonScopes,
|
|||
// grantTypes: new[] { "password", "client_credentials", "authorization_code" },
|
|||
// secret: (configurationSection["Zzz_App:ClientSecret"] ?? "1q2w3e*").Sha256(),
|
|||
// requireClientSecret: false,
|
|||
// redirectUri: webClientRootUrl,
|
|||
// postLogoutRedirectUri: webClientRootUrl,
|
|||
// corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
|
|||
// );
|
|||
// }
|
|||
|
|||
// // Blazor Client
|
|||
// var blazorClientId = configurationSection["Zzz_Blazor:ClientId"];
|
|||
// if (!blazorClientId.IsNullOrWhiteSpace())
|
|||
// {
|
|||
// var blazorRootUrl = configurationSection["Zzz_Blazor:RootUrl"].TrimEnd('/');
|
|||
|
|||
// await CreateClientAsync(
|
|||
// name: blazorClientId,
|
|||
// scopes: commonScopes,
|
|||
// grantTypes: new[] { "authorization_code" },
|
|||
// secret: configurationSection["Zzz_Blazor:ClientSecret"]?.Sha256(),
|
|||
// requireClientSecret: false,
|
|||
// redirectUri: $"{blazorRootUrl}/authentication/login-callback",
|
|||
// postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback",
|
|||
// corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") }
|
|||
// );
|
|||
// }
|
|||
|
|||
// // Swagger Client
|
|||
// var swaggerClientId = configurationSection["Zzz_Swagger:ClientId"];
|
|||
// if (!swaggerClientId.IsNullOrWhiteSpace())
|
|||
// {
|
|||
// var swaggerRootUrl = configurationSection["Zzz_Swagger:RootUrl"].TrimEnd('/');
|
|||
|
|||
// await CreateClientAsync(
|
|||
// name: swaggerClientId,
|
|||
// scopes: commonScopes,
|
|||
// grantTypes: new[] { "authorization_code" },
|
|||
// secret: configurationSection["Zzz_Swagger:ClientSecret"]?.Sha256(),
|
|||
// requireClientSecret: false,
|
|||
// redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
|
|||
// corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") }
|
|||
// );
|
|||
// }
|
|||
// }
|
|||
|
|||
// private async Task<Client> CreateClientAsync(
|
|||
// string name,
|
|||
// IEnumerable<string> scopes,
|
|||
// IEnumerable<string> grantTypes,
|
|||
// string secret = null,
|
|||
// string redirectUri = null,
|
|||
// string postLogoutRedirectUri = null,
|
|||
// string frontChannelLogoutUri = null,
|
|||
// bool requireClientSecret = true,
|
|||
// bool requirePkce = false,
|
|||
// IEnumerable<string> permissions = null,
|
|||
// IEnumerable<string> corsOrigins = null)
|
|||
// {
|
|||
// var client = await _clientRepository.FindByClientIdAsync(name);
|
|||
// if (client == null)
|
|||
// {
|
|||
// client = await _clientRepository.InsertAsync(
|
|||
// new Client(
|
|||
// _guidGenerator.Create(),
|
|||
// name
|
|||
// )
|
|||
// {
|
|||
// ClientName = name,
|
|||
// ProtocolType = "oidc",
|
|||
// Description = name,
|
|||
// AlwaysIncludeUserClaimsInIdToken = true,
|
|||
// AllowOfflineAccess = true,
|
|||
// AbsoluteRefreshTokenLifetime = 31536000, //365 days
|
|||
// AccessTokenLifetime = 31536000, //365 days
|
|||
// AuthorizationCodeLifetime = 300,
|
|||
// IdentityTokenLifetime = 300,
|
|||
// RequireConsent = false,
|
|||
// FrontChannelLogoutUri = frontChannelLogoutUri,
|
|||
// RequireClientSecret = requireClientSecret,
|
|||
// RequirePkce = requirePkce
|
|||
// },
|
|||
// autoSave: true
|
|||
// );
|
|||
// }
|
|||
|
|||
// foreach (var scope in scopes)
|
|||
// {
|
|||
// if (client.FindScope(scope) == null)
|
|||
// {
|
|||
// client.AddScope(scope);
|
|||
// }
|
|||
// }
|
|||
|
|||
// foreach (var grantType in grantTypes)
|
|||
// {
|
|||
// if (client.FindGrantType(grantType) == null)
|
|||
// {
|
|||
// client.AddGrantType(grantType);
|
|||
// }
|
|||
// }
|
|||
|
|||
// if (!secret.IsNullOrEmpty())
|
|||
// {
|
|||
// if (client.FindSecret(secret) == null)
|
|||
// {
|
|||
// client.AddSecret(secret);
|
|||
// }
|
|||
// }
|
|||
|
|||
// if (redirectUri != null)
|
|||
// {
|
|||
// if (client.FindRedirectUri(redirectUri) == null)
|
|||
// {
|
|||
// client.AddRedirectUri(redirectUri);
|
|||
// }
|
|||
// }
|
|||
|
|||
// if (postLogoutRedirectUri != null)
|
|||
// {
|
|||
// if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null)
|
|||
// {
|
|||
// client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
|
|||
// }
|
|||
// }
|
|||
|
|||
// if (permissions != null)
|
|||
// {
|
|||
// await _permissionDataSeeder.SeedAsync(
|
|||
// ClientPermissionValueProvider.ProviderName,
|
|||
// name,
|
|||
// permissions,
|
|||
// null
|
|||
// );
|
|||
// }
|
|||
|
|||
// if (corsOrigins != null)
|
|||
// {
|
|||
// foreach (var origin in corsOrigins)
|
|||
// {
|
|||
// if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null)
|
|||
// {
|
|||
// client.AddCorsOrigin(origin);
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
|
|||
// return await _clientRepository.UpdateAsync(client);
|
|||
// }
|
|||
//}
|
|||
} |
|||
@ -1,29 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\common.props" /> |
|||
<Import Project="..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
<RootNamespace>Zzz</RootNamespace> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
<RootNamespace>Zzz</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Zzz.Domain.Shared\Zzz.Domain.Shared.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Zzz.Domain.Shared\Zzz.Domain.Shared.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="EasyAbp.Abp.SettingUi.Domain" Version="1.3.1" /> |
|||
<PackageReference Include="Volo.Abp.Emailing" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Identity.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="EasyAbp.Abp.SettingUi.Domain" Version="1.3.1" /> |
|||
<PackageReference Include="Volo.Abp.Emailing" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Identity.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="$(AbpVersion)" /> |
|||
|
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
|||
@ -1,61 +0,0 @@ |
|||
{ |
|||
"App": { |
|||
"SelfUrl": "https://localhost:44363", |
|||
"CorsOrigins": "https://*.Zzz.com,http://localhost:8083,http://localhost:8081,https://localhost:44307," |
|||
}, |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "MY2bTgp2iaHUEp66" |
|||
}, |
|||
"Settings": { |
|||
"Abp.Mailing.Smtp.Host": "127.0.0.1", |
|||
"Abp.Mailing.Smtp.Port": "25", |
|||
"Abp.Mailing.Smtp.UserName": "", |
|||
"Abp.Mailing.Smtp.Password": "", |
|||
"Abp.Mailing.Smtp.Domain": "", |
|||
"Abp.Mailing.Smtp.EnableSsl": "false", |
|||
"Abp.Mailing.Smtp.UseDefaultCredentials": "true", |
|||
"Abp.Mailing.DefaultFromAddress": "noreply@abp.io", |
|||
"Abp.Mailing.DefaultFromDisplayName": "ABP application" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"Microsoft": "Information", |
|||
"Microsoft.AspNetCore": "Information", |
|||
"System": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information", |
|||
"Microsoft.AspNetCore.Routing": "Information", |
|||
"Microsoft.AspNetCore.Hosting.Diagnostics": "Error" |
|||
} |
|||
} |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=mysql.development.cn;Database=zzz.db;uid=root;pwd=mysql@;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
}, |
|||
"Cache": { |
|||
"Redis": { |
|||
"ConnectionString": "redis.cn,password=OD5VbzIuAWsHOZV5ncYx9xaDsAMsKXn7", |
|||
"DatabaseId": 231 |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "https://localhost:44363", |
|||
"RequireHttpsMetadata": "false" |
|||
}, |
|||
"Jwt": { |
|||
"Audience": "http://localhost:5010", //客户端标识 |
|||
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", |
|||
"Issuer": "Zzz", //签发者 |
|||
"ExpirationTime": 2 //过期时间 hour |
|||
}, |
|||
"LogToElasticSearch": { |
|||
"Enabled": "true", |
|||
"ElasticSearch": { |
|||
"Url": "http://es.cn", |
|||
"IndexFormat": "Zzz.admin.api.dev-{0:yyyy.MM.dd}", |
|||
"UserName": "Zzz", |
|||
"Password": "TCYobkZxWu0ELYZY" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
{ |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"Microsoft": "Information", |
|||
"Microsoft.AspNetCore": "Information", |
|||
"System": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information", |
|||
"Microsoft.AspNetCore.Routing": "Information", |
|||
"Microsoft.AspNetCore.Hosting.Diagnostics": "Error" |
|||
} |
|||
} |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=mysql.development.yhglobal.cn;Database=zzz.db;uid=root;pwd=mysql@dmin;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
}, |
|||
"Cache": { |
|||
"Redis": { |
|||
"ConnectionString": "redis.development.yhglobal.cn,password=OD5VbzIuAWsHOZV5ncYx9xaDsAMsKXn7", |
|||
"DatabaseId": 205 |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "https://localhost:44363", |
|||
"RequireHttpsMetadata": "false" |
|||
}, |
|||
"Jwt": { |
|||
"Audience": "http://localhost:5010", //客户端标识 |
|||
//"SecurityKey": "dzehzRz9a8+8TAGbqKHP9ITdRmZdOpJWQRsFb8oz50A=", |
|||
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", |
|||
"Issuer": "Zzz", //签发者 |
|||
"ExpirationTime": 2 //过期时间 hour |
|||
}, |
|||
"LogToElasticSearch": { |
|||
"Enabled": "true", |
|||
"ElasticSearch": { |
|||
"Url": "http://es.platform.Zzz.cn", |
|||
"IndexFormat": "Zzz.api.dev-{0:yyyy.MM.dd}", |
|||
"UserName": "Zzz", |
|||
"Password": "TCYobkZxWu0ELYZY" |
|||
} |
|||
} |
|||
} |
|||
@ -1,61 +0,0 @@ |
|||
{ |
|||
"App": { |
|||
"SelfUrl": "https://localhost:44363", |
|||
"CorsOrigins": "https://*.Zzz.com,http://localhost:8083,http://localhost:8081,https://localhost:44307," |
|||
}, |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "MY2bTgp2iaHUEp66" |
|||
}, |
|||
"Settings": { |
|||
"Abp.Mailing.Smtp.Host": "127.0.0.1", |
|||
"Abp.Mailing.Smtp.Port": "25", |
|||
"Abp.Mailing.Smtp.UserName": "", |
|||
"Abp.Mailing.Smtp.Password": "", |
|||
"Abp.Mailing.Smtp.Domain": "", |
|||
"Abp.Mailing.Smtp.EnableSsl": "false", |
|||
"Abp.Mailing.Smtp.UseDefaultCredentials": "true", |
|||
"Abp.Mailing.DefaultFromAddress": "noreply@abp.io", |
|||
"Abp.Mailing.DefaultFromDisplayName": "ABP application" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"Microsoft": "Information", |
|||
"Microsoft.AspNetCore": "Information", |
|||
"System": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information", |
|||
"Microsoft.AspNetCore.Routing": "Information", |
|||
"Microsoft.AspNetCore.Hosting.Diagnostics": "Error" |
|||
} |
|||
} |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=mysql.development.cn;Database=zzz.db;uid=root;pwd=mysql@;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
}, |
|||
"Cache": { |
|||
"Redis": { |
|||
"ConnectionString": "redis.cn,password=OD5VbzIuAWsHOZV5ncYx9xaDsAMsKXn7", |
|||
"DatabaseId": 231 |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "https://localhost:44363", |
|||
"RequireHttpsMetadata": "false" |
|||
}, |
|||
"Jwt": { |
|||
"Audience": "http://localhost:5010", //客户端标识 |
|||
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", |
|||
"Issuer": "Zzz", //签发者 |
|||
"ExpirationTime": 2 //过期时间 hour |
|||
}, |
|||
"LogToElasticSearch": { |
|||
"Enabled": "true", |
|||
"ElasticSearch": { |
|||
"Url": "http://es.cn", |
|||
"IndexFormat": "Zzz.admin.api.dev-{0:yyyy.MM.dd}", |
|||
"UserName": "Zzz", |
|||
"Password": "TCYobkZxWu0ELYZY" |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,49 +0,0 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Configuration; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Zzz.Dic; |
|||
using Zzz.Publics; |
|||
|
|||
namespace Zzz.PublicApi.Host.Controllers |
|||
{ |
|||
[Route("api/[controller]")]
|
|||
[ApiController] |
|||
public class SampleController : AbpController |
|||
{ |
|||
private readonly IConfiguration _configuration; |
|||
private readonly IPublicApiAppService _publicApiAppService; |
|||
public SampleController( |
|||
IConfiguration configuration, |
|||
IPublicApiAppService publicApiAppService) |
|||
{ |
|||
_configuration = configuration; |
|||
_publicApiAppService = publicApiAppService; |
|||
} |
|||
|
|||
[HttpGet("config")] |
|||
public async Task<IActionResult> GetConfig() |
|||
{ |
|||
var test = await _publicApiAppService.TestAsync("测试"); |
|||
var result = _configuration.GetSection("Logging:LogLevel:Default").Value; |
|||
return Ok(result + test); |
|||
} |
|||
|
|||
[HttpGet("write")] |
|||
[Authorize(Policy = ZzzPublicApiConsts.Policy_Write)] |
|||
public async Task<IActionResult> WriteAsync() |
|||
{ |
|||
await Task.CompletedTask; |
|||
return Ok("Write权限通过"); |
|||
} |
|||
|
|||
[HttpGet("read")] |
|||
[Authorize(Policy = ZzzPublicApiConsts.Policy_Read)] |
|||
public async Task<IActionResult> ReadAsync() |
|||
{ |
|||
await Task.CompletedTask; |
|||
return Ok("Read权限通过"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,135 +0,0 @@ |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Serilog; |
|||
using Serilog.Exceptions; |
|||
using Serilog.Exceptions.Core; |
|||
using Serilog.Sinks.Elasticsearch; |
|||
using System; |
|||
using System.IO; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Zzz.Extensions |
|||
{ |
|||
public static class SerilogToEsExtensions |
|||
{ |
|||
|
|||
public static void SetSerilogConfiguration(LoggerConfiguration loggerConfiguration, IConfiguration configuration) |
|||
{ |
|||
// 默认读取 configuration 中 "Serilog" 节点下的配置
|
|||
loggerConfiguration.ReadFrom.Configuration(configuration) |
|||
.Enrich.WithExceptionDetails() |
|||
.Enrich.WithExceptionDetails(new DestructuringOptionsBuilder() |
|||
.WithDefaultDestructurers() |
|||
) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Console() |
|||
.WriteTo.File("App_Data/logs/logs.txt", rollingInterval: RollingInterval.Day); |
|||
|
|||
var writeToElasticSearch = configuration.GetValue("LogToElasticSearch:Enabled", false); |
|||
|
|||
// LogToElasticSearch:Enabled = true 才输出至ES
|
|||
if (!writeToElasticSearch) |
|||
return; |
|||
|
|||
var applicationName = "Zzz.HttpApi.Host"; |
|||
|
|||
var esUrl = configuration["LogToElasticSearch:ElasticSearch:Url"]; |
|||
// 需要设置ES URL
|
|||
if (string.IsNullOrEmpty(esUrl)) |
|||
return; |
|||
|
|||
|
|||
var indexFormat = configuration["LogToElasticSearch:ElasticSearch:IndexFormat"]; |
|||
|
|||
// 需要设置ES URL
|
|||
if (string.IsNullOrEmpty(indexFormat)) |
|||
return; |
|||
|
|||
var esUserName = configuration["LogToElasticSearch:ElasticSearch:UserName"]; |
|||
var esPassword = configuration["LogToElasticSearch:ElasticSearch:Password"]; |
|||
|
|||
loggerConfiguration.Enrich.FromLogContext().Enrich.WithExceptionDetails().WriteTo.Elasticsearch(BuildElasticSearchSinkOptions(esUrl, indexFormat, esUserName, esPassword)); |
|||
loggerConfiguration.Enrich.WithProperty("Application", applicationName); |
|||
} |
|||
|
|||
// 创建Es连接
|
|||
private static ElasticsearchSinkOptions BuildElasticSearchSinkOptions( |
|||
string url, |
|||
string indexFormat, |
|||
string userName, |
|||
string password) |
|||
{ |
|||
if (string.IsNullOrEmpty(userName)) |
|||
{ |
|||
return new ElasticsearchSinkOptions(new Uri(url)) |
|||
{ |
|||
AutoRegisterTemplate = true, |
|||
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7, |
|||
IndexFormat = indexFormat |
|||
}; |
|||
} |
|||
|
|||
return new ElasticsearchSinkOptions(new Uri(url)) |
|||
{ |
|||
AutoRegisterTemplate = true, |
|||
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7, |
|||
IndexFormat = indexFormat, |
|||
ModifyConnectionSettings = x => x.BasicAuthentication(userName, password) |
|||
}; |
|||
} |
|||
|
|||
public static void EnrichFromRequest(IDiagnosticContext diagnosticContext, HttpContext httpContext) |
|||
{ |
|||
var request = httpContext.Request; |
|||
|
|||
// 为每个请求都设置通用的属性
|
|||
diagnosticContext.Set("Host", request.Host); |
|||
diagnosticContext.Set("Protocol", request.Protocol); |
|||
diagnosticContext.Set("Scheme", request.Scheme); |
|||
diagnosticContext.Set("RemoteIpAddress", httpContext.Connection.RemoteIpAddress); |
|||
// 如果要记录 Request Body 或 Response Body
|
|||
// 参考 https://stackoverflow.com/questions/60076922/serilog-logging-web-api-methods-adding-context-properties-inside-middleware
|
|||
string requestBody = ReadRequestBody(httpContext.Request).Result; |
|||
if (!string.IsNullOrEmpty(requestBody)) |
|||
{ |
|||
diagnosticContext.Set("RequestBody", requestBody); |
|||
} |
|||
|
|||
// string responseBody = ReadResponseBody(httpContext.Response).Result;
|
|||
// if (!string.IsNullOrEmpty(responseBody))
|
|||
// {
|
|||
// diagnosticContext.Set("ResponseBody", requestBody);
|
|||
// }
|
|||
|
|||
if (request.QueryString.HasValue) |
|||
{ |
|||
diagnosticContext.Set("QueryString", request.QueryString.Value); |
|||
} |
|||
|
|||
} |
|||
|
|||
private static async Task<string> ReadRequestBody(HttpRequest request) |
|||
{ |
|||
HttpRequestRewindExtensions.EnableBuffering(request); |
|||
|
|||
var body = request.Body; |
|||
var buffer = new byte[Convert.ToInt32(request.ContentLength)]; |
|||
await request.Body.ReadAsync(buffer, 0, buffer.Length); |
|||
string requestBody = Encoding.UTF8.GetString(buffer); |
|||
body.Seek(0, SeekOrigin.Begin); |
|||
request.Body = body; |
|||
|
|||
return $"{requestBody}"; |
|||
} |
|||
|
|||
private static async Task<string> ReadResponseBody(HttpResponse response) |
|||
{ |
|||
response.Body.Seek(0, SeekOrigin.Begin); |
|||
string responseBody = await new StreamReader(response.Body).ReadToEndAsync(); |
|||
response.Body.Seek(0, SeekOrigin.Begin); |
|||
|
|||
return $"{responseBody}"; |
|||
} |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Zzz.Extensions; |
|||
|
|||
namespace Zzz.PublicApi.Host |
|||
{ |
|||
public class Program |
|||
{ |
|||
public static void Main(string[] args) |
|||
{ |
|||
CreateHostBuilder(args).Build().Run(); |
|||
} |
|||
|
|||
public static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.ConfigureAppConfiguration((context, builder) => { |
|||
// ÅäÖÃnacos
|
|||
builder.AddNacosConfiguration(builder.Build().GetSection("NacosConfig")); |
|||
}) |
|||
.UseSerilog((context, loggerConfiguration) => |
|||
{ |
|||
SerilogToEsExtensions.SetSerilogConfiguration( |
|||
loggerConfiguration, |
|||
context.Configuration); |
|||
}).UseAutofac(); |
|||
} |
|||
} |
|||
@ -1,16 +0,0 @@ |
|||
{ |
|||
"$schema": "http://json.schemastore.org/launchsettings.json", |
|||
|
|||
"profiles": { |
|||
"Zzz.PublicApi.Host": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": "true", |
|||
"launchBrowser": true, |
|||
"launchUrl": "swagger", |
|||
"applicationUrl": "http://localhost:50001", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.OpenApi.Models; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Zzz.PublicApi.Host |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<ZzzPublicApiModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<Import Project="..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="App_Data\**" /> |
|||
<Content Remove="App_Data\**" /> |
|||
<EmbeddedResource Remove="App_Data\**" /> |
|||
<None Remove="App_Data\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="$(AbpVersion)" /> |
|||
|
|||
|
|||
<PackageReference Include="Serilog" Version="2.10.0" /> |
|||
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" /> |
|||
<PackageReference Include="Serilog.Exceptions" Version="5.7.0" /> |
|||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /> |
|||
|
|||
|
|||
<PackageReference Include="nacos-sdk-csharp" Version="1.0.0" /> |
|||
<PackageReference Include="nacos-sdk-csharp.AspNetCore" Version="1.0.0" /> |
|||
<PackageReference Include="nacos-sdk-csharp.Extensions.Configuration" Version="1.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Zzz.HttpApi.Client\Zzz.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -1,14 +0,0 @@ |
|||
namespace Zzz.PublicApi.Host |
|||
{ |
|||
public class ZzzPublicApiConsts |
|||
{ |
|||
public const string Policy_Read = "Policy_Read"; |
|||
|
|||
public const string Policy_Write = "Policy_Write"; |
|||
|
|||
|
|||
public const string Scope_Read = "ZzzPublicApi.Read"; |
|||
|
|||
public const string Scope_Write = "ZzzPublicApi.Write"; |
|||
} |
|||
} |
|||
@ -1,90 +0,0 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.IdentityModel.Logging; |
|||
using Microsoft.OpenApi.Models; |
|||
using Serilog; |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
using Zzz.Extensions; |
|||
using Zzz.PublicApi.Host; |
|||
|
|||
namespace Zzz.PublicApi |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreMvcModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(ZzzHttpApiClientModule) |
|||
)] |
|||
public class ZzzPublicApiModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
ConfigureSwagger(context); |
|||
ConfigureAuthentication(context); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
var env = context.GetEnvironment(); |
|||
if (env.IsDevelopment()) |
|||
{ |
|||
app.UseDeveloperExceptionPage(); |
|||
app.UseSwagger(); |
|||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Zzz.PublicApi.Host v1")); |
|||
} |
|||
|
|||
app.UseAuthentication(); |
|||
app.UseRouting(); |
|||
app.UseAuthorization(); |
|||
app.UseSerilogRequestLogging(opts => |
|||
{ |
|||
opts.EnrichDiagnosticContext = SerilogToEsExtensions.EnrichFromRequest; |
|||
}); |
|||
app.UseConfiguredEndpoints(); |
|||
} |
|||
|
|||
private void ConfigureAuthentication(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
IdentityModelEventSource.ShowPII = true; |
|||
context.Services.AddAuthentication("Bearer") |
|||
.AddJwtBearer("Bearer", options => |
|||
{ |
|||
//token颁发者
|
|||
options.Authority = configuration["AuthServer:Authority"]; |
|||
options.Audience = configuration["AuthServer:ApiName"]; |
|||
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); |
|||
}); |
|||
|
|||
context.Services.AddAuthorization(options => |
|||
{ |
|||
// 为了掩饰 分读写权限
|
|||
options.AddPolicy(ZzzPublicApiConsts.Policy_Read, builder => |
|||
builder.RequireScope(new string[] { |
|||
ZzzPublicApiConsts.Scope_Read }) |
|||
); |
|||
|
|||
options.AddPolicy(ZzzPublicApiConsts.Policy_Write, builder => |
|||
builder.RequireScope(new string[] { |
|||
ZzzPublicApiConsts.Scope_Write }) |
|||
); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSwagger(ServiceConfigurationContext context) |
|||
{ |
|||
var services = context.Services; |
|||
|
|||
services.AddSwaggerGen(c => |
|||
{ |
|||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Zzz.PublicApi.Host", Version = "v1" }); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*", |
|||
"LogToElasticSearch": { |
|||
"Enabled": "true", |
|||
"ElasticSearch": { |
|||
"Url": "http://es.platform.cn", |
|||
"IndexFormat": "Zzz.public.api.dev-{0:yyyy.MM.dd}", |
|||
"UserName": "erp", |
|||
"Password": "TCYobkZxWu0ELYZY" |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://sts.vnext.identity.development.cn", |
|||
"RequireHttpsMetadata": "false", |
|||
"ApiName": "ZzzPublicApi" |
|||
}, |
|||
"RemoteServices": { |
|||
"Zzz": { |
|||
"BaseUrl": "http://localhost:50000/" |
|||
} |
|||
} |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*", |
|||
"LogToElasticSearch": { |
|||
"Enabled": "true", |
|||
"ElasticSearch": { |
|||
"Url": "http://es.platform.cn", |
|||
"IndexFormat": "Zzz.public.api.dev-{0:yyyy.MM.dd}", |
|||
"UserName": "erp", |
|||
"Password": "TCYobkZxWu0ELYZY" |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://sts.vnext.identity.development.cn", |
|||
"RequireHttpsMetadata": "false", |
|||
"ApiName": "ZzzPublicApi" |
|||
}, |
|||
"RemoteServices": { |
|||
"Zzz": { |
|||
"BaseUrl": "http://localhost:50000/" |
|||
} |
|||
} |
|||
} |
|||
@ -1 +0,0 @@ |
|||
{"alg":"RS256","d":"lNH0OzXPRnDsV767u7a3LZCHUTUVfyvDOPqKBWjVKs03hHvpbPm6xxyJxR_2MDUFaDxHmVKjXZxOPZFuAiKbKWXNsjmpirtF2U42TjjnCvEb2Nb-G6SIC_JeaNo8kV3OUE4UzFWw_rpTF6CKpGdOhCVDAPdyGU-9GM7h6bcFLg3jbThUC7CrYSl57bQswUhiXwYxiA20dXkwh0sDSIMXlZOfurWz8w0etYQq1LTSIlhpZ021x4csQyTQM2X0rFVZnS8f75oDyYBI0E9xU9ogC9LpaxrPBnxNhqXQ8LnTgK_5Nmi3m-GLKxC6ImGxItQlV7pf5iP8E1lEQ3U63dvabQ","dp":"LbtXHqBYBs3VapOkZIrXAJrNux9fAqrq_2FDjiHxL76uXlTk2rq0Em-aVkQv9M-QzzaJNR-r1fSIscibQvS1VhWMha3-vR04pAy7KvA1T9bfZa7QWiAN-Po1IDH7hPe1U9Du2prJ9XPjaHLDffvI_bMfFdSdxZeaghivyh92K6U","dq":"pHr9BRS6ArlmPqSwmw2eQhcVsDAfOu22WEK7wD26wDRG4riV4uJticVQOHCpwTn0-5kCcp2LfBhX0uanFTh5dGT62B1Ib6DKpjT39hcSF1V1-GJl0fyrmvXku7cyeRTqooLCHrXovZ4EV0uDRAeAkZ03BCpTW5MxGqKA7doWWOE","e":"AQAB","kid":"9F6E0CA233DC806A58A0821E58521B17","kty":"RSA","n":"pEaiCVTAe6F6hBpi6ozmA3let7sBJwGcKoo1Vm0t1EvqiMLsBuU1lB9pVUzxPb8zFpAKpgrgpA58u7Pv0erZ_9_zRYAQ2jxglp9bPJmTtga2cY-emPzl_0cDgsTTYiTh4c9btgB2eYgLAyaAeM9K82vblTs-0HPK7o7zQJvX6-iv_-B8XY7DLOHwAp_Ua_DiAwx4sarULRpCPULD2HHtFl990NpunCj1Bo1kcZcF9SKQxM9KM2UEd5P6GbQJjkU549tO2kK22oHNJz1krbDyfLC0G8VWFN6Z-fb44hoerHpILyQvdpCTdarJG3JUlkhsCLx8FAYqz5cuQ5KhQ8YWiQ","p":"1mrTYqHNXPY5XlbKtUyn-GoMDLGdzGNxCuIzfUMOIhACSh-h7gsvv5msOiPKZLiRB0b1Qu_v_H2KGNu4Rb209jMbyYrLfo1rh4QIfetFx3K-oJ86Evs0EZXQf-RgY2WdPVJar1YgBKYqM-gLJh4XGnwdBxBdqgU0AfaVkiwuEBs","q":"xCJwPOWJ6NaHwEGBc7tncSghuFUIUu8psDlUc-78ClrOi_WII7y0Q0-kLB_COdmlxhVOO58bLDZZL8PBFH4q_Mm9qFHVSBxLJ97AoQxVxed31Eqq6SG_3iv4LqKI6EKk9nLLBKh3L1sn0nafHORfNp4vtCNJSZatkCbh5I0GRis","qi":"ud4nssqZ00XTbkObwyoWEHMzgYQifdBInXk_j6KRaKt_fPYzxVWnHoVAaLSgKJTU1aqxiJHd3Mb5sCvM_W-MocKAeWxeGij0R-kv16El8eTNgsukcr3mdAOeaUsZlVuXOeO9ol-e6VOTIziIqLJmTjflruh0ZskDUw0AJ8xVIro"} |
|||
@ -0,0 +1,44 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Xunit; |
|||
using Shouldly; |
|||
|
|||
namespace Zzz.Cache |
|||
{ |
|||
public class CacheTests : ZzzApplicationTestBase |
|||
{ |
|||
ICacheManger cacheManger; |
|||
public CacheTests() |
|||
{ |
|||
cacheManger = GetRequiredService<ICacheManger>(); |
|||
} |
|||
|
|||
[Fact] |
|||
async Task Shuold_Set_OK() |
|||
{ |
|||
await cacheManger.SetAsync("test5", "value5"); |
|||
var result = await cacheManger.GetAsync("test5"); |
|||
result.ShouldBe("value"); |
|||
} |
|||
|
|||
[Fact] |
|||
async Task Shuold_SetObject_Ok() |
|||
{ |
|||
var info = new RedisTestDto() { Id = 1, Name = "wangjun" }; |
|||
await cacheManger.SetAsync<RedisTestDto>(nameof(RedisTestDto), info); |
|||
var result = await cacheManger.GetAsync<RedisTestDto>(nameof(RedisTestDto)); |
|||
result.Id.ShouldBe(1); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class RedisTestDto |
|||
{ |
|||
public int Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Zzz.Options; |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Zzz.ConfigureOptions |
|||
{ |
|||
public class ConfigureOptionTests : ZzzApplicationTestBase |
|||
{ |
|||
private readonly JwtOptions jwtOptions; |
|||
public ConfigureOptionTests() |
|||
{ |
|||
jwtOptions = GetRequiredService<IOptions<JwtOptions>>().Value; |
|||
} |
|||
|
|||
[Fact] |
|||
void Get_Options() |
|||
{ |
|||
jwtOptions.Audience.ShouldNotBeNull(); |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,35 +0,0 @@ |
|||
using Shouldly; |
|||
using System.Threading.Tasks; |
|||
using Xunit; |
|||
using Zzz.Dic; |
|||
using Zzz.DTOs.Dic; |
|||
|
|||
namespace Zzz.Dics |
|||
{ |
|||
public class DataDictionaryAppService_Tests: ZzzApplicationTestBase |
|||
{ |
|||
private readonly IDicAppService _dicAppService; |
|||
|
|||
public DataDictionaryAppService_Tests() |
|||
{ |
|||
_dicAppService = GetRequiredService<IDicAppService>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Shuold_Get_List_Of_Dics() |
|||
{ |
|||
var result = await _dicAppService.GetListAsync("Group"); |
|||
result.Code.ShouldBe(200); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Create_Dic() |
|||
{ |
|||
var dic = new CreateDataDictionaryDto() { Name = "Group01", Description = "单元测试01" }; |
|||
|
|||
var result = await _dicAppService.CreateAsync(dic); |
|||
|
|||
result.Code.ShouldBe(200); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Zzz.DTOs.Users; |
|||
using Xunit; |
|||
using Xunit.Abstractions; |
|||
using Shouldly; |
|||
namespace Zzz.Users |
|||
{ |
|||
public class LoginAppServiceTests : ZzzApplicationTestBase |
|||
{ |
|||
private readonly ILoginAppService _loginAppService; |
|||
|
|||
public LoginAppServiceTests() |
|||
{ |
|||
_loginAppService = GetRequiredService<ILoginAppService>(); |
|||
|
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Shuold_Login_Success() |
|||
{ |
|||
var loginInfo = new LoginInputDto() { Name = "admin@abp.io", Password = "1q2w3E*" }; |
|||
var result = await _loginAppService.PostAsync(loginInfo); |
|||
result.Code.ShouldBe((int)DTOs.Public.ApiCodeEnum.成功); |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Xunit; |
|||
using Zzz.Repository; |
|||
using Shouldly; |
|||
|
|||
namespace Zzz.Users |
|||
{ |
|||
public class UserRepository_Tests: ZzzDomainTestBase |
|||
{ |
|||
private readonly IUserDapperRepository _userDapperRepository; |
|||
public UserRepository_Tests() |
|||
{ |
|||
_userDapperRepository = GetService<IUserDapperRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Shuold_Get_User_Return_Ok() |
|||
{ |
|||
await WithUnitOfWorkAsync(async () => |
|||
{ |
|||
var result = await _userDapperRepository.GetAllUserNameListAsync(); |
|||
result.Count.ShouldBe(1); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,36 +1,16 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Identity; |
|||
using Zzz.Dic; |
|||
using Zzz.Users; |
|||
|
|||
namespace Zzz |
|||
{ |
|||
public class ZzzTestDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IRepository<DataDictionary> _dataDictionaryRepository; |
|||
|
|||
public ZzzTestDataSeedContributor( |
|||
IRepository<DataDictionary> dataDictionaryRepository) |
|||
{ |
|||
_dataDictionaryRepository = dataDictionaryRepository; |
|||
} |
|||
|
|||
public async Task SeedAsync(DataSeedContext context) |
|||
public Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
/* Seed additional test data... */ |
|||
await InitDicDataAsync(); |
|||
} |
|||
|
|||
|
|||
private async Task InitDicDataAsync() |
|||
{ |
|||
var dic = new DataDictionary(Guid.NewGuid(), "Group", null, "单元测试"); |
|||
dic.AddDataDictionaryDetail(new DataDictionaryDetail(Guid.NewGuid(), "Test", "007", 1)); |
|||
await _dataDictionaryRepository.InsertAsync(dic); |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue