Browse Source

还原代码

vue2 1.1.1
王军 5 years ago
parent
commit
b042c1f2fc
  1. 6
      content/aspnetcore/NuGet.Config
  2. 7
      content/aspnetcore/Zzz.sln
  3. 12
      content/aspnetcore/src/Zzz.Application.Contracts/Dic/IDataDicManager.cs
  4. 15
      content/aspnetcore/src/Zzz.Application.Contracts/Dic/IDicAppService.cs
  5. 4
      content/aspnetcore/src/Zzz.Application.Contracts/Jobs/CronType.cs
  6. 13
      content/aspnetcore/src/Zzz.Application.Contracts/Publics/IPublicApiAppService.cs
  7. 8
      content/aspnetcore/src/Zzz.Application.Contracts/Users/ILoginAppService.cs
  8. 6
      content/aspnetcore/src/Zzz.Application.Contracts/Zzz.Application.Contracts.csproj
  9. 30
      content/aspnetcore/src/Zzz.Application/Dic/DataDicManager.cs
  10. 6
      content/aspnetcore/src/Zzz.Application/Dic/DicAppService.cs
  11. 4
      content/aspnetcore/src/Zzz.Application/Jobs/TestJob.cs
  12. 20
      content/aspnetcore/src/Zzz.Application/Publics/PublicApiAppService.cs
  13. 2
      content/aspnetcore/src/Zzz.Application/Users/LoginAppService.cs
  14. 72
      content/aspnetcore/src/Zzz.Application/Zzz.Application.csproj
  15. 11
      content/aspnetcore/src/Zzz.Application/ZzzApplicationModule.cs
  16. 2
      content/aspnetcore/src/Zzz.DbMigrator/appsettings.json
  17. 2
      content/aspnetcore/src/Zzz.Domain.Shared/Zzz.Domain.Shared.csproj
  18. 6
      content/aspnetcore/src/Zzz.Domain.Shared/ZzzDomainSharedModule.cs
  19. 5
      content/aspnetcore/src/Zzz.Domain/Dic/DataDictionary.cs
  20. 5
      content/aspnetcore/src/Zzz.Domain/Dic/DataDictionaryDetail.cs
  21. 13
      content/aspnetcore/src/Zzz.Domain/Dic/MaxLengths/DataDictionaryMaxLength.cs
  22. 324
      content/aspnetcore/src/Zzz.Domain/IdentityServer/IdentityServerDataSeedContributor.cs
  23. 0
      content/aspnetcore/src/Zzz.Domain/Users/AppUser.cs
  24. 44
      content/aspnetcore/src/Zzz.Domain/Zzz.Domain.csproj
  25. 17
      content/aspnetcore/src/Zzz.Domain/ZzzDomainModule.cs
  26. 0
      content/aspnetcore/src/Zzz.EntityFrameworkCore/Repository/IUserDapperRepository.cs
  27. 0
      content/aspnetcore/src/Zzz.EntityFrameworkCore/Repository/UserDapperRepository.cs
  28. 2
      content/aspnetcore/src/Zzz.HttpApi.Client/Zzz.HttpApi.Client.csproj
  29. 2
      content/aspnetcore/src/Zzz.HttpApi.Client/ZzzHttpApiClientModule.cs
  30. 2
      content/aspnetcore/src/Zzz.HttpApi.Host/Controllers/HomeController.cs
  31. 9
      content/aspnetcore/src/Zzz.HttpApi.Host/Extensions/RecurringJobsExtensions.cs
  32. 5
      content/aspnetcore/src/Zzz.HttpApi.Host/Program.cs
  33. 17
      content/aspnetcore/src/Zzz.HttpApi.Host/Properties/launchSettings.json
  34. 8
      content/aspnetcore/src/Zzz.HttpApi.Host/Zzz.HttpApi.Host.csproj
  35. 267
      content/aspnetcore/src/Zzz.HttpApi.Host/ZzzHttpApiHostModule.cs
  36. 61
      content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.Ali.json
  37. 44
      content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.Development.json
  38. 61
      content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.Staging.json
  39. 43
      content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.json
  40. 39552
      content/aspnetcore/src/Zzz.PublicApi.Host/App_Data/logs/logs20210324.txt
  41. 49
      content/aspnetcore/src/Zzz.PublicApi.Host/Controllers/SampleController.cs
  42. 135
      content/aspnetcore/src/Zzz.PublicApi.Host/Extensions/SerilogToEsExtensions.cs
  43. 33
      content/aspnetcore/src/Zzz.PublicApi.Host/Program.cs
  44. 16
      content/aspnetcore/src/Zzz.PublicApi.Host/Properties/launchSettings.json
  45. 28
      content/aspnetcore/src/Zzz.PublicApi.Host/Startup.cs
  46. 42
      content/aspnetcore/src/Zzz.PublicApi.Host/Zzz.PublicApi.Host.csproj
  47. 14
      content/aspnetcore/src/Zzz.PublicApi.Host/ZzzPublicApiConsts.cs
  48. 90
      content/aspnetcore/src/Zzz.PublicApi.Host/ZzzPublicApiModule.cs
  49. 29
      content/aspnetcore/src/Zzz.PublicApi.Host/appsettings.Staging.json
  50. 29
      content/aspnetcore/src/Zzz.PublicApi.Host/appsettings.json
  51. 1
      content/aspnetcore/src/Zzz.PublicApi.Host/tempkey.jwk
  52. 44
      content/aspnetcore/test/Zzz.Application.Tests/Cache/CacheTests.cs
  53. 28
      content/aspnetcore/test/Zzz.Application.Tests/ConfigureOptions/ConfigureOptionTests.cs
  54. 35
      content/aspnetcore/test/Zzz.Application.Tests/Dics/DataDictionaryAppService_Tests.cs
  55. 32
      content/aspnetcore/test/Zzz.Application.Tests/Users/LoginAppServiceTests.cs
  56. 34
      content/aspnetcore/test/Zzz.Application.Tests/ZzzApplicationTestModule.cs
  57. 26
      content/aspnetcore/test/Zzz.Domain.Tests/Users/UserRepository_Tests.cs
  58. 4
      content/aspnetcore/test/Zzz.Domain.Tests/ZzzDomainTestModule.cs
  59. 8
      content/aspnetcore/test/Zzz.TestBase/Zzz.TestBase.csproj
  60. 9
      content/aspnetcore/test/Zzz.TestBase/ZzzTestBaseModule.cs
  61. 26
      content/aspnetcore/test/Zzz.TestBase/ZzzTestDataSeedContributor.cs

6
content/aspnetcore/NuGet.Config

@ -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>

7
content/aspnetcore/Zzz.sln

@ -42,8 +42,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\Readme.md = ..\..\Readme.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zzz.PublicApi.Host", "src\Zzz.PublicApi.Host\Zzz.PublicApi.Host.csproj", "{AA3C1547-1A82-470E-9EB7-1C9E9AA50136}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -106,10 +104,6 @@ Global
{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.Build.0 = Release|Any CPU
{AA3C1547-1A82-470E-9EB7-1C9E9AA50136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA3C1547-1A82-470E-9EB7-1C9E9AA50136}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA3C1547-1A82-470E-9EB7-1C9E9AA50136}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA3C1547-1A82-470E-9EB7-1C9E9AA50136}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -129,7 +123,6 @@ Global
{E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{AA94D832-1CCC-4715-95A9-A483F23A1A5D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{AA3C1547-1A82-470E-9EB7-1C9E9AA50136} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

12
content/aspnetcore/src/Zzz.Application.Contracts/Dic/IDataDicManager.cs

@ -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);
}
}

15
content/aspnetcore/src/Zzz.Application.Contracts/Dic/IDicAppService.cs

@ -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);
}
}

4
content/aspnetcore/src/Zzz.Application/Jobs/Helpers/CronTypeHelper.cs → content/aspnetcore/src/Zzz.Application.Contracts/Jobs/CronType.cs

@ -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>
/// 周期性为分钟的任务

13
content/aspnetcore/src/Zzz.Application.Contracts/Publics/IPublicApiAppService.cs

@ -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);
}
}

8
content/aspnetcore/src/Zzz.Application.Contracts/Users/ILoginAppService.cs

@ -1,11 +1,13 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Zzz.DTOs.Public;
using Zzz.DTOs.Users;
namespace Zzz.Users
{
public interface ILoginAppService: IApplicationService
public interface ILoginAppService
{
Task<ApiResult> PostAsync(LoginInputDto input);
}

6
content/aspnetcore/src/Zzz.Application.Contracts/Zzz.Application.Contracts.csproj

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Zzz</RootNamespace>
</PropertyGroup>
@ -29,7 +29,7 @@
<PackageReference Include="Volo.Abp.PermissionManagement.Application.Contracts" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.TenantManagement.Application.Contracts" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.FeatureManagement.Application.Contracts" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" Version="$(AbpVersion)" />
</ItemGroup>
</Project>

30
content/aspnetcore/src/Zzz.Application/Dic/DataDicManager.cs

@ -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;
}
}
}

6
content/aspnetcore/src/Zzz.Application/Dic/DicAppService.cs

@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Localization;
using Swashbuckle.AspNetCore.Annotations;
using System;
@ -10,7 +9,6 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
@ -30,14 +28,12 @@ namespace Zzz.Dic
private readonly ICurrentUser _currentUser;
private readonly IGuidGenerator _guidGenerator;
private readonly IStringLocalizer<ZzzResource> _localizer;
public DicAppService(IRepository<DataDictionary, Guid> dataDictionaryRepository, ICurrentUser currentUser, IGuidGenerator guidGenerator, IStringLocalizer<ZzzResource> localizer)
{
_dataDictionaryRepository = dataDictionaryRepository;
_currentUser = currentUser;
_guidGenerator = guidGenerator;
_localizer = localizer;
}
[SwaggerOperation(summary: "获取字典列表", Tags = new[] { "字典" })]
@ -136,7 +132,5 @@ namespace Zzz.Dic
await _dataDictionaryRepository.UpdateAsync(entity);
return ApiResult.Ok();
}
}
}

4
content/aspnetcore/src/Zzz.Application/Jobs/TestJob.cs

@ -1,4 +1,8 @@
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Zzz.Jobs

20
content/aspnetcore/src/Zzz.Application/Publics/PublicApiAppService.cs

@ -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;
}
}
}

2
content/aspnetcore/src/Zzz.Application/Users/LoginAppService.cs

@ -23,7 +23,6 @@ namespace Zzz.Users
private readonly IdentityUserManager _userManager;
private readonly JwtOptions _jwtOptions;
private readonly Microsoft.AspNetCore.Identity.SignInManager<Volo.Abp.Identity.IdentityUser> _signInManager;
public LoginAppService(
IdentityUserManager userManager,
IOptionsSnapshot<JwtOptions> jwtOptions,
@ -39,6 +38,7 @@ namespace Zzz.Users
public async Task<ApiResult> PostAsync(LoginInputDto input)
{
var result = await _signInManager.PasswordSignInAsync(input.Name, input.Password, false, true);
if (!result.Succeeded) return ApiResult.Error();
var user = await _userManager.FindByNameAsync(input.Name);

72
content/aspnetcore/src/Zzz.Application/Zzz.Application.csproj

@ -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>

11
content/aspnetcore/src/Zzz.Application/ZzzApplicationModule.cs

@ -1,12 +1,7 @@
using Hangfire;
using Hangfire.Redis;
using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp.Account;
using Volo.Abp.Account;
using Volo.Abp.AutoMapper;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.BackgroundJobs.Hangfire;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Hangfire;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
@ -22,13 +17,13 @@ namespace Zzz
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpBackgroundJobsHangfireModule),
typeof(EasyAbp.Abp.SettingUi.SettingUiApplicationModule)
)]
public class ZzzApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<ZzzApplicationModule>();

2
content/aspnetcore/src/Zzz.DbMigrator/appsettings.json

@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"Default": "Data Source=mysql.platform.development.yhglobal.cn;Database=zzz.db;uid=root;pwd=mysql@dmin;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
"Default": "Data Source=mysql.Zzz.cn;Database=Zzz.db;uid=root;pwd=123456;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"IdentityServer": {
"Clients": {

2
content/aspnetcore/src/Zzz.Domain.Shared/Zzz.Domain.Shared.csproj

@ -3,7 +3,7 @@
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Zzz</RootNamespace>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>

6
content/aspnetcore/src/Zzz.Domain.Shared/ZzzDomainSharedModule.cs

@ -1,4 +1,5 @@
using Volo.Abp.AuditLogging;
using Zzz.Localization;
using Volo.Abp.AuditLogging;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
@ -11,7 +12,8 @@ using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;
using Zzz.Localization;
using Zzz.Options;
using Microsoft.Extensions.DependencyInjection;
namespace Zzz
{

5
content/aspnetcore/src/Zzz.Domain/Dic/Aggregates/DataDictionary.cs → content/aspnetcore/src/Zzz.Domain/Dic/DataDictionary.cs

@ -7,7 +7,6 @@ using System.Linq;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Data;
using System.ComponentModel.DataAnnotations;
using Zzz.Dic.MaxLengths;
namespace Zzz.Dic
{
@ -17,13 +16,13 @@ namespace Zzz.Dic
/// 名称
/// </summary>
[Required]
[MaxLength(DataDictionaryMaxLength.Name)]
[MaxLength(64)]
public virtual string Name { get; private set; }
/// <summary>
/// 描述
/// </summary>
[MaxLength(DataDictionaryMaxLength.Description)]
[MaxLength(256)]
public virtual string Description { get; set; }
[Required]

5
content/aspnetcore/src/Zzz.Domain/Dic/Aggregates/DataDictionaryDetail.cs → content/aspnetcore/src/Zzz.Domain/Dic/DataDictionaryDetail.cs

@ -6,7 +6,6 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Zzz.Dic.MaxLengths;
namespace Zzz.Dic
{
@ -16,14 +15,14 @@ namespace Zzz.Dic
/// 名称
/// </summary>
[Required]
[MaxLength(DataDictionaryMaxLength.Label)]
[MaxLength(64)]
public virtual string Label { get; protected set; }
/// <summary>
/// 名称
/// </summary>
[Required]
[MaxLength(DataDictionaryMaxLength.Value)]
[MaxLength(64)]
public virtual string Value { get; protected set; }
[Required]

13
content/aspnetcore/src/Zzz.Domain/Dic/MaxLengths/DataDictionaryMaxLength.cs

@ -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;
}
}

324
content/aspnetcore/src/Zzz.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

@ -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);
// }
//}
}

0
content/aspnetcore/src/Zzz.Domain/Users/Aggregates/AppUser.cs → content/aspnetcore/src/Zzz.Domain/Users/AppUser.cs

44
content/aspnetcore/src/Zzz.Domain/Zzz.Domain.csproj

@ -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>

17
content/aspnetcore/src/Zzz.Domain/ZzzDomainModule.cs

@ -1,8 +1,9 @@
using Microsoft.Extensions.Caching.Distributed;
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Zzz.MultiTenancy;
using Volo.Abp.AuditLogging;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Caching;
using Volo.Abp.Emailing;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
using Volo.Abp.IdentityServer;
@ -12,7 +13,6 @@ using Volo.Abp.PermissionManagement.Identity;
using Volo.Abp.PermissionManagement.IdentityServer;
using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement;
using Zzz.MultiTenancy;
namespace Zzz
{
@ -27,8 +27,8 @@ namespace Zzz
typeof(AbpPermissionManagementDomainIdentityServerModule),
typeof(AbpSettingManagementDomainModule),
typeof(AbpTenantManagementDomainModule),
typeof(EasyAbp.Abp.SettingUi.SettingUiDomainModule),
typeof(AbpCachingModule)
typeof(AbpEmailingModule),
typeof(EasyAbp.Abp.SettingUi.SettingUiDomainModule)
)]
public class ZzzDomainModule : AbpModule
{
@ -39,11 +39,6 @@ namespace Zzz
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
// 设置全局默认缓存时间
//Configure<AbpDistributedCacheOptions>(option =>
//{
// option.GlobalCacheEntryOptions.SetSlidingExpiration(TimeSpan.FromSeconds(7200));
//});
}
}
}

0
content/aspnetcore/src/Zzz.EntityFrameworkCore/Repository/Users/IUserDapperRepository.cs → content/aspnetcore/src/Zzz.EntityFrameworkCore/Repository/IUserDapperRepository.cs

0
content/aspnetcore/src/Zzz.EntityFrameworkCore/Repository/Users/UserDapperRepository.cs → content/aspnetcore/src/Zzz.EntityFrameworkCore/Repository/UserDapperRepository.cs

2
content/aspnetcore/src/Zzz.HttpApi.Client/Zzz.HttpApi.Client.csproj

@ -3,7 +3,7 @@
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Zzz</RootNamespace>
</PropertyGroup>

2
content/aspnetcore/src/Zzz.HttpApi.Client/ZzzHttpApiClientModule.cs

@ -18,7 +18,7 @@ namespace Zzz
)]
public class ZzzHttpApiClientModule : AbpModule
{
public const string RemoteServiceName = "Zzz";
public const string RemoteServiceName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{

2
content/aspnetcore/src/Zzz.HttpApi.Host/Controllers/HomeController.cs

@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Users;
using Zzz.Dic;
namespace Zzz.Controllers
{
public class HomeController : AbpController
{
public ActionResult Index()
{
return Redirect("~/swagger/index.html");

9
content/aspnetcore/src/Zzz.HttpApi.Host/Extensions/RecurringJobsExtensions.cs

@ -1,7 +1,10 @@
using Hangfire;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Zzz.Jobs;
using Microsoft.Extensions.DependencyInjection;
namespace Zzz.Extensions
{
@ -9,8 +12,8 @@ namespace Zzz.Extensions
{
public static void CreateRecurringJob(this IServiceProvider service)
{
var job = service.GetService<TestJob>();
RecurringJob.AddOrUpdate("测试Job", () => job.ExecuteAsync(), CronTypeHelper.Minute(1));
//var job = service.GetService<TestJob>();
//RecurringJob.AddOrUpdate("测试Job", () => job.ExecuteAsync(), CronType.Minute(1));
}
}
}

5
content/aspnetcore/src/Zzz.HttpApi.Host/Program.cs

@ -1,6 +1,5 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
@ -31,10 +30,6 @@ namespace Zzz
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, builder) => {
// 配置nacos
builder.AddNacosConfiguration(builder.Build().GetSection("NacosConfig"));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

17
content/aspnetcore/src/Zzz.HttpApi.Host/Properties/launchSettings.json

@ -1,5 +1,20 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5010/",
"sslPort": 44359
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Zzz.HttpApi.Host": {
"commandName": "Project",
"launchBrowser": false,
@ -7,7 +22,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:50000/"
"applicationUrl": "http://localhost:5010/"
}
}
}

8
content/aspnetcore/src/Zzz.HttpApi.Host/Zzz.HttpApi.Host.csproj

@ -25,12 +25,8 @@
</PropertyGroup>
<ItemGroup>
<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" />
<PackageReference Include="Hangfire.Redis.StackExchange.StrongName" Version="1.7.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.*" />
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="$(AbpVersion)" />

267
content/aspnetcore/src/Zzz.HttpApi.Host/ZzzHttpApiHostModule.cs

@ -1,45 +1,47 @@
using Hangfire;
using Hangfire.Redis;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Zzz.EntityFrameworkCore;
using Zzz.MultiTenancy;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Microsoft.OpenApi.Models;
using Serilog;
using Swashbuckle.AspNetCore.SwaggerUI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Volo.Abp;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Auditing;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Hangfire;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
using Volo.Abp.Swashbuckle;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem;
using Zzz.EntityFrameworkCore;
using Zzz.Options;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Serilog;
using Zzz.Extensions;
using Hangfire;
using Hangfire.Redis;
using Zzz.Extensions.Filters;
using Zzz.Options;
using Volo.Abp.Auditing;
using Volo.Abp.BackgroundJobs;
using Swashbuckle.AspNetCore.SwaggerUI;
using Volo.Abp.Json;
using Volo.Abp.Settings;
namespace Zzz
{
@ -53,8 +55,7 @@ namespace Zzz
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule),
typeof(AbpHangfireModule)
typeof(AbpSwashbuckleModule)
)]
public class ZzzHttpApiHostModule : AbpModule
{
@ -62,7 +63,6 @@ namespace Zzz
public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
{
// 应用程序初始化的时候注册hangfire
var app = context.GetApplicationBuilder();
app.ApplicationServices.GetService<ISettingDefinitionManager>().Get(LocalizationSettingNames.DefaultLanguage).DefaultValue = "zh-Hans";
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
@ -75,6 +75,8 @@ namespace Zzz
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
ConfigureJson();
ConfigureOptions(context);
ConfigureBundles();
ConfigureUrls(configuration);
@ -86,75 +88,15 @@ namespace Zzz
ConfigureSwaggerServices(context);
ConfigureAbpExcepotions(context);
ConfigureCache(context.Services);
ConfigureAuditLog();
ConfigureHangfire(context.Services);
ConfigureAuditLog();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{
app.UseErrorPage();
}
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseJwtTokenMiddleware();
//if (MultiTenancyConsts.IsEnabled)
//{
// app.UseMultiTenancy();
//}
//app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Zzz API");
c.DefaultModelExpandDepth(-2);
c.DocExpansion(DocExpansion.None);
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseSerilogRequestLogging(opts =>
{
opts.EnrichDiagnosticContext = SerilogToEsExtensions.EnrichFromRequest;
});
app.UseConfiguredEndpoints();
}
#region 私有方法
/// <summary>
/// 配置options
/// </summary>
/// <param name="context"></param>
private void ConfigureOptions(ServiceConfigurationContext context)
private void ConfigureJson()
{
context.Services.Configure<JwtOptions>(context.Services.GetConfiguration().GetSection("Jwt"));
// 时间格式化
Configure<AbpJsonOptions>(options => options.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss");
}
/// <summary>
/// 审计日志
/// </summary>
private void ConfigureAuditLog()
{
Configure<AbpAuditingOptions>(options =>
@ -163,10 +105,6 @@ namespace Zzz
});
}
/// <summary>
/// Redis缓存
/// </summary>
/// <param name="services"></param>
private void ConfigureCache(IServiceCollection services)
{
var redisConnectionString = services.GetConfiguration().GetSection("Cache:Redis:ConnectionString").Value;
@ -177,11 +115,30 @@ namespace Zzz
});
}
/// <summary>
/// 异常处理
/// 注入Hangfire服务
/// </summary>
/// <param name="context"></param>
/// <param name="services"></param>
private void ConfigureHangfire(IServiceCollection services)
{
Configure<AbpBackgroundJobOptions>(options =>
{
options.IsJobExecutionEnabled = false;
});
var redisConnectionString = services.GetConfiguration().GetSection("Cache:Redis:ConnectionString").Value;
var redisDatabaseId = Convert.ToInt32(services.GetConfiguration().GetSection("Cache:Redis:DatabaseId").Value);
// 启用Hangfire 并使用Redis作为持久化
services.AddHangfire(config =>
{
config.UseRedisStorage(redisConnectionString, new RedisStorageOptions { Db = redisDatabaseId });
});
JobStorage.Current = new RedisStorage(redisConnectionString, new RedisStorageOptions { Db = redisDatabaseId });
}
private void ConfigureAbpExcepotions(ServiceConfigurationContext context)
{
// dev环境显示异常具体信息
@ -194,7 +151,18 @@ namespace Zzz
}
}
private void ConfigureOptions(ServiceConfigurationContext context)
{
//var configuration = context.Services.GetConfiguration();
//Configure<JwtOptions>(options =>
//{
// options.Audience = configuration.GetValue<string>("Jwt:Audience");
// options.Issuer = configuration.GetValue<string>("Jwt:Audience");
// options.SecurityKey = configuration.GetValue<string>("Jwt:SecurityKey");
// options.ExpirationTime = configuration.GetValue<int>("Jwt:ExpirationTime");
//});
context.Services.Configure<JwtOptions>(context.Services.GetConfiguration().GetSection("Jwt"));
}
private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
@ -206,7 +174,6 @@ namespace Zzz
});
}
private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
@ -215,21 +182,30 @@ namespace Zzz
});
}
/// <summary>
/// 配置虚拟文件系统
/// </summary>
/// <param name="context"></param>
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
var hostingEnvironment = context.Services.GetHostingEnvironment();
if (hostingEnvironment.IsDevelopment())
{
options.FileSets.AddEmbedded<ZzzHttpApiHostModule>();
});
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPhysical<ZzzDomainSharedModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}Zzz.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<ZzzDomainModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}Zzz.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<ZzzApplicationContractsModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}Zzz.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<ZzzApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}Zzz.Application"));
});
}
}
/// <summary>
/// 映射Controller
/// </summary>
private void ConfigureConventionalControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
@ -238,11 +214,6 @@ namespace Zzz
});
}
/// <summary>
/// 配置JWT
/// </summary>
/// <param name="context"></param>
/// <param name="configuration"></param>
private void ConfigureJwtAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication(options =>
@ -267,17 +238,13 @@ namespace Zzz
});
}
/// <summary>
/// 配置SwaggerUI
/// </summary>
/// <param name="context"></param>
private static void ConfigureSwaggerServices(ServiceConfigurationContext context)
{
context.Services.AddSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Zzz API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.EnableAnnotations();// 启用注解
// 加载xml文件,不然不会显示备注
@ -305,7 +272,7 @@ namespace Zzz
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer"
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer"
}
},
new List<string>()
@ -314,9 +281,6 @@ namespace Zzz
});
}
/// <summary>
///配置本地化
/// </summary>
private void ConfigureLocalization()
{
Configure<AbpLocalizationOptions>(options =>
@ -326,11 +290,6 @@ namespace Zzz
});
}
/// <summary>
/// 配置跨域
/// </summary>
/// <param name="context"></param>
/// <param name="configuration"></param>
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddCors(options =>
@ -354,32 +313,58 @@ namespace Zzz
}
/// <summary>
/// 配置Hangfire服务
/// </summary>
/// <param name="services"></param>
private void ConfigureHangfire(IServiceCollection services)
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
Configure<AbpBackgroundJobOptions>(options =>
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
options.IsJobExecutionEnabled = false;
});
app.UseDeveloperExceptionPage();
}
var redisConnectionString = services.GetConfiguration().GetSection("Cache:Redis:ConnectionString").Value;
var redisDatabaseId = Convert.ToInt32(services.GetConfiguration().GetSection("Cache:Redis:DatabaseId").Value);
app.UseAbpRequestLocalization();
// 启用Hangfire 并使用Redis作为持久化
services.AddHangfire(config =>
if (!env.IsDevelopment())
{
config.UseRedisStorage(redisConnectionString, new RedisStorageOptions { Db = redisDatabaseId });
});
app.UseErrorPage();
}
JobStorage.Current = new RedisStorage(redisConnectionString, new RedisStorageOptions { Db = redisDatabaseId });
}
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseJwtTokenMiddleware();
//if (MultiTenancyConsts.IsEnabled)
//{
// app.UseMultiTenancy();
//}
//app.UseIdentityServer();
app.UseAuthorization();
#endregion
app.UseSwagger();
app.UseAbpSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Zzz API");
c.DefaultModelExpandDepth(-2);
c.DocExpansion(DocExpansion.None);
});
app.UseAuditing();
//app.UseAbpSerilogEnrichers();
app.UseSerilogRequestLogging(opts =>
{
opts.EnrichDiagnosticContext = SerilogToEsExtensions.EnrichFromRequest;
});
app.UseConfiguredEndpoints();
}
}
}

61
content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.Ali.json

@ -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"
}
}
}

44
content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.Development.json

@ -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"
}
}
}

61
content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.Staging.json

@ -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"
}
}
}

43
content/aspnetcore/src/Zzz.HttpApi.Host/appsettings.json

@ -16,46 +16,5 @@
"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"
}
}
}
}

39552
content/aspnetcore/src/Zzz.PublicApi.Host/App_Data/logs/logs20210324.txt

File diff suppressed because it is too large

49
content/aspnetcore/src/Zzz.PublicApi.Host/Controllers/SampleController.cs

@ -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权限通过");
}
}
}

135
content/aspnetcore/src/Zzz.PublicApi.Host/Extensions/SerilogToEsExtensions.cs

@ -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}";
}
}
}

33
content/aspnetcore/src/Zzz.PublicApi.Host/Program.cs

@ -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();
}
}

16
content/aspnetcore/src/Zzz.PublicApi.Host/Properties/launchSettings.json

@ -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"
}
}
}
}

28
content/aspnetcore/src/Zzz.PublicApi.Host/Startup.cs

@ -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();
}
}
}

42
content/aspnetcore/src/Zzz.PublicApi.Host/Zzz.PublicApi.Host.csproj

@ -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>

14
content/aspnetcore/src/Zzz.PublicApi.Host/ZzzPublicApiConsts.cs

@ -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";
}
}

90
content/aspnetcore/src/Zzz.PublicApi.Host/ZzzPublicApiModule.cs

@ -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" });
});
}
}
}

29
content/aspnetcore/src/Zzz.PublicApi.Host/appsettings.Staging.json

@ -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/"
}
}
}

29
content/aspnetcore/src/Zzz.PublicApi.Host/appsettings.json

@ -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
content/aspnetcore/src/Zzz.PublicApi.Host/tempkey.jwk

@ -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"}

44
content/aspnetcore/test/Zzz.Application.Tests/Cache/CacheTests.cs

@ -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; }
}
}

28
content/aspnetcore/test/Zzz.Application.Tests/ConfigureOptions/ConfigureOptionTests.cs

@ -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();
}
}
}

35
content/aspnetcore/test/Zzz.Application.Tests/Dics/DataDictionaryAppService_Tests.cs

@ -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);
}
}
}

32
content/aspnetcore/test/Zzz.Application.Tests/Users/LoginAppServiceTests.cs

@ -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.);
}
}
}

34
content/aspnetcore/test/Zzz.Application.Tests/ZzzApplicationTestModule.cs

@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.BackgroundJobs.Hangfire;
using Volo.Abp.Hangfire;
using Volo.Abp.Modularity;
using Zzz.Options;
@ -13,10 +12,39 @@ namespace Zzz
{
[DependsOn(
typeof(ZzzApplicationModule),
typeof(ZzzDomainTestModule)
typeof(ZzzDomainTestModule),
typeof(ZzzApplicationContractsModule),
typeof(AbpBackgroundJobsHangfireModule)
)]
public class ZzzApplicationTestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
ConfigureHangfire(context.Services);
}
/// <summary>
/// 注入Hangfire服务
/// </summary>
/// <param name="services"></param>
private void ConfigureHangfire(IServiceCollection services)
{
Configure<AbpBackgroundJobOptions>(options =>
{
options.IsJobExecutionEnabled = false;
});
var redisConnectionString = services.GetConfiguration().GetSection("Cache:Redis:ConnectionString").Value;
var redisDatabaseId = Convert.ToInt32(services.GetConfiguration().GetSection("Cache:Redis:DatabaseId").Value);
// 启用Hangfire 并使用Redis作为持久化
services.AddHangfire(config =>
{
config.UseRedisStorage(redisConnectionString, new RedisStorageOptions { Db = redisDatabaseId });
});
JobStorage.Current = new RedisStorage(redisConnectionString, new RedisStorageOptions { Db = redisDatabaseId });
}
}
}

26
content/aspnetcore/test/Zzz.Domain.Tests/Users/UserRepository_Tests.cs

@ -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);
});
}
}
}

4
content/aspnetcore/test/Zzz.Domain.Tests/ZzzDomainTestModule.cs

@ -1,5 +1,5 @@
using Volo.Abp.Modularity;
using Zzz.EntityFrameworkCore;
using Zzz.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace Zzz
{

8
content/aspnetcore/test/Zzz.TestBase/Zzz.TestBase.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
@ -7,10 +7,6 @@
<RootNamespace>Zzz</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Include="..\..\src\Zzz.HttpApi.Host\appsettings.json" Link="appsettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.TestBase" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpVersion)" />
@ -27,6 +23,4 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project>

9
content/aspnetcore/test/Zzz.TestBase/ZzzTestBaseModule.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp;
using Volo.Abp.Authorization;
using Volo.Abp.Autofac;
@ -7,7 +8,6 @@ using Volo.Abp.Data;
using Volo.Abp.IdentityServer;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
using Zzz.Options;
namespace Zzz
{
@ -39,7 +39,6 @@ namespace Zzz
options.IsJobExecutionEnabled = false;
});
ConfigureOptions(context);
context.Services.AddAlwaysAllowAuthorization();
}
@ -62,11 +61,5 @@ namespace Zzz
}
});
}
private void ConfigureOptions(ServiceConfigurationContext context)
{
context.Services.Configure<JwtOptions>(context.Services.GetConfiguration().GetSection("Jwt"));
}
}
}

26
content/aspnetcore/test/Zzz.TestBase/ZzzTestDataSeedContributor.cs

@ -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…
Cancel
Save