64 changed files with 40486 additions and 929 deletions
@ -0,0 +1,20 @@ |
|||||
|
@ECHO off |
||||
|
cls |
||||
|
|
||||
|
ECHO Deleting all BIN and OBJ folders... |
||||
|
ECHO. |
||||
|
|
||||
|
FOR /d /r . %%d in (bin,obj) DO ( |
||||
|
IF EXIST "%%d" ( |
||||
|
ECHO %%d | FIND /I "\node_modules\" > Nul && ( |
||||
|
ECHO.Skipping: %%d |
||||
|
) || ( |
||||
|
ECHO.Deleting: %%d |
||||
|
rd /s/q "%%d" |
||||
|
) |
||||
|
) |
||||
|
) |
||||
|
|
||||
|
ECHO. |
||||
|
ECHO.BIN and OBJ folders have been successfully deleted. Press any key to exit. |
||||
|
pause > nul |
||||
@ -1,6 +1,10 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<configuration> |
<configuration> |
||||
|
<config> |
||||
|
<add key="yhglobal" value="https://proget.yhglobal.cn/nuget/default/" /> |
||||
|
</config> |
||||
|
|
||||
<packageSources> |
<packageSources> |
||||
<!--<add key="BlazoriseMyGet" value="https://www.myget.org/F/blazorise/api/v3/index.json" />--> |
<add key="yhglobal" value="https://proget.yhglobal.cn/nuget/default/" /> |
||||
</packageSources> |
</packageSources> |
||||
</configuration> |
</configuration> |
||||
@ -1,47 +0,0 @@ |
|||||
using Microsoft.Extensions.Caching.Distributed; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
|
|
||||
namespace Zzz.Cache |
|
||||
{ |
|
||||
public interface ICacheManger : ITransientDependency |
|
||||
{ |
|
||||
|
|
||||
|
|
||||
Task<string> GetAsync(string key); |
|
||||
|
|
||||
|
|
||||
Task<T> GetAsync<T>(string key); |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 设置缓存
|
|
||||
/// </summary>
|
|
||||
/// <param name="key"></param>
|
|
||||
/// <param name="value"></param>
|
|
||||
/// <param name="expiratioTime">秒</param>
|
|
||||
/// <returns></returns>
|
|
||||
Task SetAsync(string key, string value, int expiratioTime = 7200); |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 设置缓存
|
|
||||
/// </summary>
|
|
||||
/// <param name="key"></param>
|
|
||||
/// <param name="value"></param>
|
|
||||
/// <param name="expiratioTime">秒</param>
|
|
||||
/// <returns></returns>
|
|
||||
Task SetAsync<T>(string key, T value, int expiratioTime = 7200); |
|
||||
|
|
||||
|
|
||||
|
|
||||
Task SetOptionsAsync(string key, string value, DistributedCacheEntryOptions options = null); |
|
||||
|
|
||||
|
|
||||
Task SetOptionsAsync<T>(string key, T value, DistributedCacheEntryOptions options = null); |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +0,0 @@ |
|||||
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,16 +1,25 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
using Zzz.DTOs.Dic; |
using Zzz.DTOs.Dic; |
||||
using Zzz.DTOs.Public; |
using Zzz.DTOs.Public; |
||||
|
|
||||
namespace Zzz.Dic |
namespace Zzz.Dic |
||||
{ |
{ |
||||
public interface IDicAppService |
public interface IDicAppService: IApplicationService |
||||
{ |
{ |
||||
Task<ApiResult> CreateAsync(CreateDataDictionaryDto input); |
Task<ApiResult> CreateAsync(CreateDataDictionaryDto input); |
||||
|
|
||||
Task<ApiResult> UpdateAsync(UpdataDataDictionaryDto 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); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,13 @@ |
|||||
|
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); |
||||
|
} |
||||
|
} |
||||
@ -1,61 +0,0 @@ |
|||||
using Microsoft.Extensions.Caching.Distributed; |
|
||||
using Newtonsoft.Json; |
|
||||
using System; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp; |
|
||||
|
|
||||
namespace Zzz.Cache |
|
||||
{ |
|
||||
public class CacheManger: ICacheManger |
|
||||
{ |
|
||||
private readonly IDistributedCache _cache; |
|
||||
|
|
||||
public CacheManger(IDistributedCache cache) |
|
||||
{ |
|
||||
_cache = cache; |
|
||||
} |
|
||||
|
|
||||
public async Task<string> GetAsync(string key) |
|
||||
{ |
|
||||
Check.NotNullOrEmpty(key, nameof(key)); |
|
||||
return Encoding.UTF8.GetString(await _cache.GetAsync(key)); |
|
||||
} |
|
||||
|
|
||||
public async Task<T> GetAsync<T>(string key) |
|
||||
{ |
|
||||
Check.NotNullOrEmpty(key, nameof(key)); |
|
||||
return JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(await _cache.GetAsync(key))); |
|
||||
} |
|
||||
|
|
||||
public async Task SetAsync(string key, string value, int expiratioTime = 7200) |
|
||||
{ |
|
||||
Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
Check.NotNullOrWhiteSpace(value, nameof(value)); |
|
||||
var options = new DistributedCacheEntryOptions() { AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(expiratioTime) }; |
|
||||
await _cache.SetAsync(key, Encoding.UTF8.GetBytes(value),options); |
|
||||
} |
|
||||
|
|
||||
public async Task SetAsync<T>(string key, T value, int expiratioTime = 7200) |
|
||||
{ |
|
||||
Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
var options = new DistributedCacheEntryOptions() { AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(expiratioTime) }; |
|
||||
await _cache.SetAsync(key, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), options); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public async Task SetOptionsAsync(string key, string value, DistributedCacheEntryOptions options = null) |
|
||||
{ |
|
||||
Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
Check.NotNullOrWhiteSpace(value, nameof(value)); |
|
||||
await _cache.SetAsync(key, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), options); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
public async Task SetOptionsAsync<T>(string key, T value, DistributedCacheEntryOptions options = null) |
|
||||
{ |
|
||||
Check.NotNullOrWhiteSpace(key, nameof(key)); |
|
||||
await _cache.SetAsync(key, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), options); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,30 +0,0 @@ |
|||||
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,14 +1,12 @@ |
|||||
using Hangfire; |
using Hangfire; |
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
|
|
||||
namespace Zzz.Jobs |
namespace Zzz.Jobs |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Cron类型
|
/// Cron类型
|
||||
/// </summary>
|
/// </summary>
|
||||
public static class CronType |
public static class CronTypeHelper |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 周期性为分钟的任务
|
/// 周期性为分钟的任务
|
||||
@ -0,0 +1,20 @@ |
|||||
|
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,41 +1,39 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\common.props" /> |
<Import Project="..\..\common.props" /> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net5.0</TargetFramework> |
<TargetFramework>net5.0</TargetFramework> |
||||
<RootNamespace>Zzz</RootNamespace> |
<RootNamespace>Zzz</RootNamespace> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
||||
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
||||
<OutputPath>bin\Debug\net5.0\</OutputPath> |
<OutputPath>bin\Debug\net5.0\</OutputPath> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
||||
<OutputPath>bin\Debug\net5.0\</OutputPath> |
<OutputPath>bin\Debug\net5.0\</OutputPath> |
||||
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
<DocumentationFile>bin\Debug\net5.0\Zzz.Application.xml</DocumentationFile> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\Zzz.Domain\Zzz.Domain.csproj" /> |
<ProjectReference Include="..\Zzz.Domain\Zzz.Domain.csproj" /> |
||||
<ProjectReference Include="..\Zzz.Application.Contracts\Zzz.Application.Contracts.csproj" /> |
<ProjectReference Include="..\Zzz.Application.Contracts\Zzz.Application.Contracts.csproj" /> |
||||
<ProjectReference Include="..\Zzz.EntityFrameworkCore\Zzz.EntityFrameworkCore.csproj" /> |
<ProjectReference Include="..\Zzz.EntityFrameworkCore\Zzz.EntityFrameworkCore.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
|
<PackageReference Include="Hangfire.Redis.StackExchange.StrongName" Version="1.7.0" /> |
||||
<PackageReference Include="EasyAbp.Abp.SettingUi.Application" Version="1.3.1" /> |
<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="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" /> |
||||
|
<PackageReference Include="Volo.Abp.Account.Application" Version="$(AbpVersion)" /> |
||||
<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.Identity.Application" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="$(AbpVersion)" /> |
</ItemGroup> |
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="$(AbpVersion)" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,13 @@ |
|||||
|
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; |
||||
|
} |
||||
|
} |
||||
@ -1,324 +0,0 @@ |
|||||
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"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\common.props" /> |
<Import Project="..\..\common.props" /> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net5.0</TargetFramework> |
<TargetFramework>net5.0</TargetFramework> |
||||
<RootNamespace>Zzz</RootNamespace> |
<RootNamespace>Zzz</RootNamespace> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\Zzz.Domain.Shared\Zzz.Domain.Shared.csproj" /> |
<ProjectReference Include="..\Zzz.Domain.Shared\Zzz.Domain.Shared.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="EasyAbp.Abp.SettingUi.Domain" Version="1.3.1" /> |
<PackageReference Include="EasyAbp.Abp.SettingUi.Domain" Version="1.3.1" /> |
||||
<PackageReference Include="Volo.Abp.Emailing" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.Emailing" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.Identity.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.Identity.Domain" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="$(AbpVersion)" /> |
||||
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="$(AbpVersion)" /> |
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="$(AbpVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,17 @@ |
|||||
|
{ |
||||
|
"NacosConfig": { |
||||
|
"Listeners": [ |
||||
|
{ |
||||
|
"Optional": false, |
||||
|
"DataId": "Zzz", |
||||
|
"Group": "Ali" |
||||
|
} |
||||
|
], |
||||
|
"Optional": false, |
||||
|
"Tenant": "erp", |
||||
|
"ServerAddresses": [ "http://nacos.zzz.cn/" ], |
||||
|
"UserName": "erp.app", |
||||
|
"Password": "Yh@1234" |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,44 +0,0 @@ |
|||||
{ |
|
||||
"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.Zzz.cn;Database=Zzz.db;uid=root;pwd=123456;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|
||||
}, |
|
||||
"Cache": { |
|
||||
"Redis": { |
|
||||
"ConnectionString": "redis.Zzz.cn,password=OD5VbzIuAWsHOZV5ncYx9xaDsAMsKXn7", |
|
||||
"DatabaseId": 1 |
|
||||
} |
|
||||
}, |
|
||||
"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" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,17 @@ |
|||||
|
{ |
||||
|
"NacosConfig": { |
||||
|
"Listeners": [ |
||||
|
{ |
||||
|
"Optional": false, |
||||
|
"DataId": "Zzz", |
||||
|
"Group": "Staging" |
||||
|
} |
||||
|
], |
||||
|
"Optional": false, |
||||
|
"Tenant": "erp", |
||||
|
"ServerAddresses": [ "http://nacos.zzz.cn/" ], |
||||
|
"UserName": "erp.app", |
||||
|
"Password": "Yh@1234" |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,20 +1,17 @@ |
|||||
{ |
{ |
||||
"App": { |
"NacosConfig": { |
||||
"SelfUrl": "https://localhost:44363", |
"Listeners": [ |
||||
"CorsOrigins": "https://*.Zzz.com,http://localhost:8083,http://localhost:8081,https://localhost:44307," |
{ |
||||
}, |
"Optional": false, |
||||
"StringEncryption": { |
"DataId": "Zzz", |
||||
"DefaultPassPhrase": "MY2bTgp2iaHUEp66" |
"Group": "Development" |
||||
}, |
} |
||||
"Settings": { |
], |
||||
"Abp.Mailing.Smtp.Host": "127.0.0.1", |
"Optional": false, |
||||
"Abp.Mailing.Smtp.Port": "25", |
"Tenant": "erp", |
||||
"Abp.Mailing.Smtp.UserName": "", |
"ServerAddresses": [ "http://nacos.zzz.cn/" ], |
||||
"Abp.Mailing.Smtp.Password": "", |
"UserName": "erp.app", |
||||
"Abp.Mailing.Smtp.Domain": "", |
"Password": "Yh@1234" |
||||
"Abp.Mailing.Smtp.EnableSsl": "false", |
|
||||
"Abp.Mailing.Smtp.UseDefaultCredentials": "true", |
|
||||
"Abp.Mailing.DefaultFromAddress": "noreply@abp.io", |
|
||||
"Abp.Mailing.DefaultFromDisplayName": "ABP application" |
|
||||
} |
} |
||||
|
|
||||
} |
} |
||||
|
|||||
File diff suppressed because it is too large
@ -0,0 +1,49 @@ |
|||||
|
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权限通过"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,135 @@ |
|||||
|
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}"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
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(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"$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" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
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(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
<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> |
||||
@ -0,0 +1,14 @@ |
|||||
|
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"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,90 @@ |
|||||
|
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" }); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Warning", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"NacosConfig": { |
||||
|
"Listeners": [ |
||||
|
{ |
||||
|
"Optional": false, |
||||
|
"DataId": "ZzzPublicApiHost", |
||||
|
"Group": "Development" |
||||
|
} |
||||
|
], |
||||
|
"Optional": false, |
||||
|
"Tenant": "erp", |
||||
|
"ServerAddresses": [ "http://nacos.platform.yhglobal.cn/" ], |
||||
|
"UserName": "erp.app", |
||||
|
"Password": "Yh@1234" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
{"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"} |
||||
@ -1,44 +0,0 @@ |
|||||
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; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,28 +0,0 @@ |
|||||
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(); |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,35 @@ |
|||||
|
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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,32 +0,0 @@ |
|||||
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.成功); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,26 @@ |
|||||
|
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,16 +1,36 @@ |
|||||
using System.Threading.Tasks; |
using System; |
||||
|
using System.Threading.Tasks; |
||||
using Volo.Abp.Data; |
using Volo.Abp.Data; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Zzz.Dic; |
||||
|
using Zzz.Users; |
||||
|
|
||||
namespace Zzz |
namespace Zzz |
||||
{ |
{ |
||||
public class ZzzTestDataSeedContributor : IDataSeedContributor, ITransientDependency |
public class ZzzTestDataSeedContributor : IDataSeedContributor, ITransientDependency |
||||
{ |
{ |
||||
public Task SeedAsync(DataSeedContext context) |
private readonly IRepository<DataDictionary> _dataDictionaryRepository; |
||||
|
|
||||
|
public ZzzTestDataSeedContributor( |
||||
|
IRepository<DataDictionary> dataDictionaryRepository) |
||||
|
{ |
||||
|
_dataDictionaryRepository = dataDictionaryRepository; |
||||
|
} |
||||
|
|
||||
|
public async Task SeedAsync(DataSeedContext context) |
||||
{ |
{ |
||||
/* Seed additional test data... */ |
/* Seed additional test data... */ |
||||
|
await InitDicDataAsync(); |
||||
|
} |
||||
|
|
||||
|
|
||||
return Task.CompletedTask; |
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); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue