Skip to content

Commit

Permalink
240125
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynab committed Jan 25, 2024
1 parent c8ee50f commit fbaabc3
Show file tree
Hide file tree
Showing 27 changed files with 137 additions and 105 deletions.
4 changes: 2 additions & 2 deletions console/YANLib.Benchmarks/YANLib.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
34 changes: 17 additions & 17 deletions host/YANLib.HttpApi.Host/YANLib.HttpApi.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\..\common.props" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>YANLib</RootNamespace>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<UserSecretsId>YANLib-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
Expand All @@ -14,34 +14,34 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="7.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="7.1.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="6.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
<PackageReference Include="DotNetCore.CAP" Version="6.2.1" />
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="6.2.1" />
<PackageReference Include="DotNetCore.CAP.Kafka" Version="6.2.1" />
<PackageReference Include="DotNetCore.CAP.MongoDB" Version="6.2.1" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="6.2.1" />
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.25.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.14">
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.25.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.26" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.26">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="7.4.2" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.4.2" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="7.4.2" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="7.4.2" />
<PackageReference Include="Volo.Abp.EventBus.Azure" Version="7.4.2" />
<PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="7.4.2" />
<PackageReference Include="Volo.Abp.Http.Client" Version="7.4.2" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="7.4.2" />
<PackageReference Include="Volo.Abp.Autofac" Version="6.0.3" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="6.0.3" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="6.0.3" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="6.0.3" />
<PackageReference Include="Volo.Abp.EventBus.Azure" Version="6.0.3" />
<PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="6.0.3" />
<PackageReference Include="Volo.Abp.Http.Client" Version="6.0.3" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="6.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions host/YANLib.HttpApi.Host/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"Sample": "yanlib_sample_index_dev"
},
"Url": "http://192.168.1.8:9200/",
"Username": "yanlib_index",
"Password": "yanlibindex123"
"Username": "elastic",
"Password": "admin123"
},
"RemoteServices": {
"TestApi": {
Expand Down Expand Up @@ -113,7 +113,7 @@
"Name": "Elasticsearch",
"Args": {
"nodeUris": "http://192.168.1.8:9200",
"connectionGlobalHeaders": "Authorization=Basic eWFubGliX2xvZ3M6eWFubGlibG9nczEyMw==",
"connectionGlobalHeaders": "Authorization=Basic ZWxhc3RpYzphZG1pbjEyMw==",
"indexFormat": "log-dev-yanlib-{0:yyyy.MM.dd}",
"autoRegisterTemplate": true,
"autoRegisterTemplateVersion": "ESv8"
Expand Down
6 changes: 3 additions & 3 deletions host/YANLib.HttpApi.Host/appsettings.Production.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"Sample": "yanlib_sample_index_prod"
},
"Url": "http://elasticsearch:9200/",
"Username": "yanlib_index",
"Password": "yanlibindex123"
"Username": "elastic",
"Password": "admin123"
},
"RemoteServices": {
"TestApi": {
Expand Down Expand Up @@ -113,7 +113,7 @@
"Name": "Elasticsearch",
"Args": {
"nodeUris": "http://elasticsearch:9200",
"connectionGlobalHeaders": "Authorization=Basic eWFubGliX2xvZ3M6eWFubGlibG9nczEyMw==",
"connectionGlobalHeaders": "Authorization=Basic ZWxhc3RpYzphZG1pbjEyMw==",
"indexFormat": "log-prod-yanlib-{0:yyyy.MM.dd}",
"autoRegisterTemplate": true,
"autoRegisterTemplateVersion": "ESv8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,5 @@ namespace YANLib.Permissions;

public class YANLibPermissionDefinitionProvider : PermissionDefinitionProvider
{
public override void Define(IPermissionDefinitionContext context)
{
var myGroup = context.AddGroup(YANLibPermissions.GroupName);
//Define your own permissions here. Example:
//myGroup.AddPermission(YANLibPermissions.MyPermission1, L("Permission:MyPermission1"));
}

private static LocalizableString L(string name) => Create<YANLibResource>(name);
public override void Define(IPermissionDefinitionContext context) => context.AddGroup(YANLibPermissions.GroupName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
public static class YANLibPermissions
{
public const string GroupName = "YANLib";

//Add your own permission names. Example:
//public const string MyPermission1 = GroupName + ".MyPermission1";
}
13 changes: 9 additions & 4 deletions src/YANLib.Application.Contracts/Requests/CertificateRequest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
namespace YANLib.Requests;
using System.ComponentModel.DataAnnotations;

namespace YANLib.Requests;

public sealed class CertificateRequest
{
public required string Id { get; set; }
[Required]
public string Id { get; set; }

public required string Name { get; set; }
[Required]
public string Name { get; set; }

public double? GPA { get; set; }

public required string DeveloperId { get; set; }
[Required]
public string DeveloperId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace YANLib.Requests.Developer;

public sealed class DeveloperCreateRequest
{
public required string Name { get; set; }
[Required]
public string Name { get; set; }

public string Phone { get; set; }

public required string IdCard { get; set; }
[Required]
public string IdCard { get; set; }

public required int DeveloperTypeCode { get; set; }
[Required]
public int DeveloperTypeCode { get; set; }

public List<Certificate> Certificates { get; set; }

public sealed class Certificate
{
public required string Name { get; set; }
[Required]
public string Name { get; set; }

public double? GPA { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace YANLib.Requests.Developer;

Expand All @@ -14,7 +15,8 @@ public sealed class DeveloperUpdateRequest

public sealed class Certificate
{
public required string Name { get; set; }
[Required]
public string Name { get; set; }

public double? GPA { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
namespace YANLib.Requests.DeveloperType;
using System.ComponentModel.DataAnnotations;

namespace YANLib.Requests.DeveloperType;

public sealed class DeveloperTypeCreateRequest
{
public required int Code { get; set; }
[Required]
public int Code { get; set; }

public required string Name { get; set; }
[Required]
public string Name { get; set; }

public bool IsActive { get; set; } = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<Import Project="..\..\common.props" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>YANLib</RootNamespace>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NEST" Version="7.17.5" />
<PackageReference Include="Volo.Abp.Authorization" Version="7.4.2" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="7.4.2" />
<PackageReference Include="Volo.Abp.Authorization" Version="6.0.3" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="6.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public DeveloperTypeRedisService(ILogger<DeveloperTypeRedisService> logger, IRed
catch (Exception ex)
{
_logger.LogError(ex, "GetDeveloperTypeRedisService-Exception: {Group} - {Key}", group, key);

throw;
}
}
Expand Down Expand Up @@ -82,6 +83,7 @@ await WhenAll(keys.Select(async k =>
catch (Exception ex)
{
_logger.LogError(ex, "GetBulkDeveloperTypeRedisService-Exception: {Group} - {Keys}", group, string.Join(", ", keys));

throw;
}
}
Expand Down Expand Up @@ -122,6 +124,7 @@ await WhenAll((await _database.HashGetAllAsync(group.ToLowerInvariant())).Where(
catch (Exception ex)
{
_logger.LogError(ex, "GetAllDeveloperTypeRedisService-Exception: {Group}", group);

throw;
}
}
Expand All @@ -132,13 +135,14 @@ public async ValueTask<bool> Set(string group, string key, DeveloperTypeRedisDto

try
{
return group.IsWhiteSpaceOrNull() || key.IsWhiteSpaceOrNull() || value is null
return group.IsWhiteSpaceOrNull() || key.IsWhiteSpaceOrNull() || value.IsNull()
? throw new BusinessException(BAD_REQUEST)
: await _database.HashSetAsync((RedisKey)group.ToLowerInvariant(), (RedisValue)key.ToLowerInvariant(), jsonVal);
}
catch (Exception ex)
{
_logger.LogError(ex, "SetDeveloperTypeRedisService-Exception: {Group} - {Key} - {Value}", group, key, jsonVal);

throw;
}
}
Expand All @@ -159,6 +163,7 @@ public async ValueTask<bool> SetBulk(string group, IDictionary<string, Developer
catch (Exception ex)
{
_logger.LogError(ex, "SetBulkDeveloperTypeRedisService-Exception: {Group} - {Fields}", group, fields.Serialize());

throw;
}
}
Expand All @@ -172,6 +177,7 @@ public async ValueTask<bool> Delete(string group, string key)
catch (Exception ex)
{
_logger.LogError(ex, "DeleteDeveloperTypeRedisService-Exception: {Group} - {Key}", group, key);

throw;
}
}
Expand Down Expand Up @@ -207,6 +213,7 @@ await WhenAll(keys.Where(k => k.IsNotWhiteSpaceAndNull()).Select(async k =>
catch (Exception ex)
{
_logger.LogError(ex, "DeleteBulkDeveloperTypeRedisService-Exception: {Group} - {Keys}", group, string.Join(", ", keys));

throw;
}
}
Expand All @@ -227,6 +234,7 @@ public async ValueTask<bool> DeleteAll(string group)
catch (Exception ex)
{
_logger.LogError(ex, "DeleteAllDeveloperTypeRedisService-Exception: {Group}", group);

throw;
}
}
Expand All @@ -237,7 +245,7 @@ public async ValueTask<bool> DeleteAll(string group)
{
var redisRslt = await GetGroupKeys(groupPreffix);

if (redisRslt is not null)
if (redisRslt.IsNotNull())
{
var keys = (RedisKey[])redisRslt!;
var rslts = new Dictionary<string, IDictionary<string, DeveloperTypeRedisDto?>?>();
Expand Down Expand Up @@ -284,7 +292,7 @@ public async ValueTask<bool> DeleteGroup(string groupPreffix)
{
var redisRslt = await GetGroupKeys(groupPreffix);

if (redisRslt is not null)
if (redisRslt.IsNotNull())
{
var keys = (RedisKey[])redisRslt!;

Expand Down
4 changes: 2 additions & 2 deletions src/YANLib.Application.Redis/YANLib.Application.Redis.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StackExchange.Redis" Version="2.7.4" />
<PackageReference Include="StackExchange.Redis" Version="2.7.17" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions src/YANLib.Application/EsServices/DeveloperEsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async ValueTask<DeveloperIndex> Get(string id)
catch (Exception ex)
{
_logger.LogError(ex, "GetDeveloperEsService-Exception: {Id}", id);

throw;
}
}
Expand All @@ -41,11 +42,12 @@ public async ValueTask<bool> Set(DeveloperIndex data)

try
{
return await _elasticClient.IndexDocumentAsync(data) is not null;
return (await _elasticClient.IndexDocumentAsync(data)).IsNotNull();
}
catch (Exception ex)
{
_logger.LogError(ex, "SetDeveloperEsService-Exception: {Data}", data.Serialize());

throw;
}
}
Expand All @@ -69,11 +71,12 @@ public async ValueTask<bool> SetBulk(List<DeveloperIndex> datas)
_ = reqs.Index<DeveloperIndex>(x => x.Document(data).Index(index));
}

return await _elasticClient.BulkAsync(reqs) is not null;
return (await _elasticClient.BulkAsync(reqs)).IsNotNull();
}
catch (Exception ex)
{
_logger.LogError(ex, "SetBulkDeveloperEsService-Exception: {Datas}", datas.Serialize());

throw;
}
}
Expand All @@ -89,6 +92,7 @@ public async ValueTask<bool> DeleteAll()
catch (Exception ex)
{
_logger.LogError(ex, "DeleteAllDeveloperEsService-Exception");

throw;
}
}
Expand Down
Loading

0 comments on commit fbaabc3

Please sign in to comment.