Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 committed Jan 8, 2025
1 parent b044b70 commit 36d4349
Show file tree
Hide file tree
Showing 96 changed files with 4,274 additions and 184 deletions.
11 changes: 11 additions & 0 deletions Masa.Alert.sln
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Alert.EntityFrameworkC
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Alert.EntityFrameworkCore.PostgreSql", "src\Infrastructure\Masa.Alert.EntityFrameworkCore.PostgreSql\Masa.Alert.EntityFrameworkCore.PostgreSql.csproj", "{27A5AB4D-4447-47B0-9A44-E6511F58AA68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Alert.Web.Admin.Wasm", "src\Web\Masa.Alert.Web.Admin.Wasm\Masa.Alert.Web.Admin.Wasm.csproj", "{DA768DA7-4D8A-467A-909B-13B43D0316D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -242,6 +244,14 @@ Global
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|Any CPU.Build.0 = Release|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|x86.ActiveCfg = Release|Any CPU
{27A5AB4D-4447-47B0-9A44-E6511F58AA68}.Release|x86.Build.0 = Release|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Debug|x86.Build.0 = Debug|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Release|Any CPU.Build.0 = Release|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Release|x86.ActiveCfg = Release|Any CPU
{DA768DA7-4D8A-467A-909B-13B43D0316D9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -274,6 +284,7 @@ Global
{AFF871EB-653E-460D-9A64-C1944E8F76B3} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
{4557C624-8748-44FC-9795-7E0A9E7E4CF7} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
{27A5AB4D-4447-47B0-9A44-E6511F58AA68} = {4660010F-BB9B-4C8E-B4F7-34AF77080EA0}
{DA768DA7-4D8A-467A-909B-13B43D0316D9} = {F3986DD3-0372-4929-B72A-09D93196541E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B83BA2BA-19E5-41FB-A92A-16A03DA229E4}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
<None Include="src\Web\Masa.Alert.Web.Admin\Pages\AlarmRules\Modules\MCol.razor" />
<None Include="src\Web\Masa.Alert.Web.Admin\RedirectToLogin.razor" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Masa.Alert.ApiGateways.Caller
public class AlertApiOptions
{
public string AppId { get; set; } = string.Empty;
public string ServiceBaseAddress { get; set; } = string.Empty;
public string AuthorityEndpoint { get; set; } = string.Empty;

public string ClientId { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Masa.Alert.ApiGateways.Caller;

public class AlertCaller : DaprCallerBase
public class AlertCaller : StackHttpClientCaller
{
private AlarmRuleService? _alarmRuleService;
private AlarmHistoryService? _alarmHistoryService;
Expand All @@ -11,20 +11,16 @@ public class AlertCaller : DaprCallerBase
public AlarmHistoryService AlarmHistoryService => _alarmHistoryService ??= new(Caller);
public AlarmRuleRecordService AlarmRuleRecordService => _alarmRuleRecordService ??= new(Caller);
public WebHookService WebHookService => _webHookService ??= new(Caller);
protected override string AppId { get; set; } = App.APP;
protected override string BaseAddress { get; set; }

public AlertCaller(AlertApiOptions options)
{
AppId = options.AppId;
BaseAddress = options.ServiceBaseAddress;
}

protected override void UseDaprPost(MasaDaprClientBuilder masaDaprClientBuilder)
protected override void UseHttpClientPost(MasaHttpClientBuilder masaHttpClientBuilder)
{
masaDaprClientBuilder.UseAuthentication(serviceProvider => new AuthenticationService(
serviceProvider.GetRequiredService<TokenProvider>(),
serviceProvider.GetRequiredService<JwtTokenValidator>(),
serviceProvider.GetRequiredService<IMultiEnvironmentContext>()
));
base.UseDaprPost(masaDaprClientBuilder);
masaHttpClientBuilder.UseI18n();
base.UseHttpClientPost(masaHttpClientBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ public static IServiceCollection AddAlertApiGateways(this IServiceCollection ser
var options = new AlertApiOptions();
configure.Invoke(options);
services.AddSingleton(options);
services.AddStackCaller(Assembly.Load("Masa.Alert.ApiGateways.Caller"), jwtTokenValidatorOptions =>
{
jwtTokenValidatorOptions.AuthorityEndpoint = options.AuthorityEndpoint;
}, clientRefreshTokenOptions =>
{
clientRefreshTokenOptions.ClientId = options.ClientId;
clientRefreshTokenOptions.ClientSecret = options.ClientSecret;
});
services.AddStackCaller(Assembly.Load("Masa.Alert.ApiGateways.Caller"));
return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Masa.Contrib.StackSdks.Caller" Version="$(MasaStackSdksPackageVersion)" />
<PackageReference Include="Masa.Contrib.Service.Caller.DaprClient" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Caller.Wasm" Version="$(MasaStackSdksPackageVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global using Masa.Contrib.Service.Caller.DaprClient;
global using Masa.Contrib.Service.Caller.HttpClient;
global using Microsoft.Extensions.DependencyInjection;
global using System.Reflection;
global using Masa.BuildingBlocks.Service.Caller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Alert.Application.Contracts.AlarmHistories.Dtos;

public class GetAlarmHistoryInputDto : PaginatedOptionsDto<GetAlarmHistoryInputDto>
public class GetAlarmHistoryInputDto : PaginatedOptionsDto
{
public string Filter { get; set; } = default!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Alert.Application.Contracts.AlarmRules.Dtos;

public class GetAlarmRuleInputDto : PaginatedOptionsDto<GetAlarmRuleInputDto>
public class GetAlarmRuleInputDto : PaginatedOptionsDto
{
public string Filter { get; set; } = default!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Alert.Application.Contracts.AlarmRules.Dtos;

public class GetAlarmRuleRecordInputDto : PaginatedOptionsDto<GetAlarmRuleRecordInputDto>
public class GetAlarmRuleRecordInputDto : PaginatedOptionsDto
{
public Guid AlarmHistoryId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Alert.Application.Contracts.WebHooks.Dtos;

public class GetWebHookInputDto : PaginatedOptionsDto<GetWebHookInputDto>
public class GetWebHookInputDto : PaginatedOptionsDto
{
public string Filter { get; set; } = default!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<ProjectReference Include="..\..\Application\Masa.Alert.Application.Contracts\Masa.Alert.Application.Contracts.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Alert.Infrastructure.Ddd.Application.Contracts\Masa.Alert.Infrastructure.Ddd.Application.Contracts.csproj" />
<!--<ProjectReference Include="..\..\Infrastructure\Masa.Alert.Infrastructure.Ddd.Application.Contracts\Masa.Alert.Infrastructure.Ddd.Application.Contracts.csproj" />-->
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,6 @@ public static bool IsAssignableToGenericType(Type givenType, Type genericType)
return IsAssignableToGenericType(givenTypeInfo.BaseType, genericType);
}

//TODO: Summary
public static List<Type> GetImplementedGenericTypes(Type givenType, Type genericType)
{
var result = new List<Type>();
AddImplementedGenericTypes(result, givenType, genericType);
return result;
}

private static void AddImplementedGenericTypes(List<Type> result, Type givenType, Type genericType)
{
var givenTypeInfo = givenType.GetTypeInfo();

if (givenTypeInfo.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
{
result.TryAdd(givenType);
}

foreach (var interfaceType in givenTypeInfo.GetInterfaces())
{
if (interfaceType.GetTypeInfo().IsGenericType && interfaceType.GetGenericTypeDefinition() == genericType)
{
result.TryAdd(interfaceType);
}
}

if (givenTypeInfo.BaseType == null)
{
return;
}

AddImplementedGenericTypes(result, givenTypeInfo.BaseType, genericType);
}

/// <summary>
/// Tries to gets an of attribute defined for a class member and it's declaring type including inherited attributes.
/// Returns default value if it's not declared at all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Masa.Utils.Extensions.DotNet" Version="$(MasaFrameworkPackageVersion)" />
<!--<PackageReference Include="Masa.Utils.Extensions.DotNet" Version="$(MasaFrameworkPackageVersion)" />-->
<PackageReference Include="Masa.Utils.Extensions.Validations.FluentValidation" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<!--<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />-->
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Masa.Alert.Infrastructure.Ddd.Application.Contracts.Dtos;

public class PaginatedOptionsDto<T> : FromUri<T>
public class PaginatedOptionsDto
{
public int Page { get; set; } = 1;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Util.Reflection" Version="1.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
global using System.Collections.Concurrent;
global using System.Reflection;
global using Microsoft.AspNetCore.Http;
global using Microsoft.Extensions.Primitives;
global using Util.Reflection.Expressions;
global using Util.Reflection.Expressions.Abstractions;
global using Microsoft.Extensions.Primitives;
2 changes: 1 addition & 1 deletion src/Web/Masa.Alert.Web.Admin.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

builder.Services.AddAlertApiGateways(option =>
{
option.AppId = masaStackConfig.GetServiceId(MasaStackProject.Alert);
option.ServiceBaseAddress = masaStackConfig.GetAlertServiceDomain();
option.AuthorityEndpoint = masaOpenIdConnectOptions.Authority;
option.ClientId = masaOpenIdConnectOptions.ClientId;
option.ClientSecret = masaOpenIdConnectOptions.ClientSecret;
Expand Down
22 changes: 22 additions & 0 deletions src/Web/Masa.Alert.Web.Admin.Wasm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS publish
WORKDIR /src
COPY . .
ENV CSPROJ="src/Web/Masa.Alert.Web.Admin.Wasm/Masa.Alert.Web.Admin.Wasm.csproj"
RUN dotnet nuget add source http://devops.lonsid.cn:8080/nuget
RUN dotnet restore $CSPROJ && dotnet publish $CSPROJ -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=publish /app/publish .
# ENV ASPNETCORE_URLS=https://0.0.0.0:443
# EXPOSE 80
# EXPOSE 443
# ENTRYPOINT ["dotnet", "Masa.Auth.Web.Admin.Wasm.dll"]

FROM nginx:1.21.1
WORKDIR /usr/share/nginx/html
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY --from=front-base /app /usr/share/nginx/html
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["nginx","-g","daemon off;"]
22 changes: 22 additions & 0 deletions src/Web/Masa.Alert.Web.Admin.Wasm/Masa.Alert.Web.Admin.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.*" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Masa.Contrib.Data.Mapping.Mapster" Version="$(MasaFrameworkPackageVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Masa.Alert.Web.Admin\Masa.Alert.Web.Admin.csproj" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions src/Web/Masa.Alert.Web.Admin.Wasm/Masa.Alert.Web.Admin.Wasm.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Alert.Web.Admin.Wasm", "Masa.Alert.Web.Admin.Wasm.csproj", "{1AD05086-726D-4E25-984C-DCEF654A40AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1AD05086-726D-4E25-984C-DCEF654A40AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AD05086-726D-4E25-984C-DCEF654A40AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AD05086-726D-4E25-984C-DCEF654A40AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AD05086-726D-4E25-984C-DCEF654A40AB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AFEE560D-924B-4E8D-865E-D982AFCF8116}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 36d4349

Please sign in to comment.