Skip to content

Commit

Permalink
Merge pull request #729 from mixcore/featues/update-mix-mq
Browse files Browse the repository at this point in the history
update mix mq
  • Loading branch information
nhathoang989 authored Jan 20, 2024
2 parents 53b7ef2 + fbde647 commit 1e54ea1
Show file tree
Hide file tree
Showing 208 changed files with 5,157 additions and 1,314 deletions.
14 changes: 7 additions & 7 deletions src/Mixcore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mix-message-queue", "mix-me
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mix-auth-service", "mix-auth-service", "{EC933357-1D95-4CDD-B290-7A5984FC1AA2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mix.auth.service", "services\mix-auth-service\mix.auth.service\mix.auth.service.csproj", "{D503F737-90E6-438F-ACB2-1074CACEE407}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mix.mq.server", "services\mix-message-queue\mix.mq.server\mix.mq.server.csproj", "{7C5101F3-E3E6-42DB-8585-D08C2BE5E30C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mix.auth.api", "services\mix-auth-service\mix.auth.api\mix.auth.api.csproj", "{9C04921A-38D5-4EC9-8FF5-0E0D74681049}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -279,14 +279,14 @@ Global
{F5D4C70F-DD2E-4EC9-A191-56A717B1B5EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5D4C70F-DD2E-4EC9-A191-56A717B1B5EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5D4C70F-DD2E-4EC9-A191-56A717B1B5EE}.Release|Any CPU.Build.0 = Release|Any CPU
{D503F737-90E6-438F-ACB2-1074CACEE407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D503F737-90E6-438F-ACB2-1074CACEE407}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D503F737-90E6-438F-ACB2-1074CACEE407}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D503F737-90E6-438F-ACB2-1074CACEE407}.Release|Any CPU.Build.0 = Release|Any CPU
{7C5101F3-E3E6-42DB-8585-D08C2BE5E30C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C5101F3-E3E6-42DB-8585-D08C2BE5E30C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C5101F3-E3E6-42DB-8585-D08C2BE5E30C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C5101F3-E3E6-42DB-8585-D08C2BE5E30C}.Release|Any CPU.Build.0 = Release|Any CPU
{9C04921A-38D5-4EC9-8FF5-0E0D74681049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C04921A-38D5-4EC9-8FF5-0E0D74681049}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C04921A-38D5-4EC9-8FF5-0E0D74681049}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C04921A-38D5-4EC9-8FF5-0E0D74681049}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -350,8 +350,8 @@ Global
{F5D4C70F-DD2E-4EC9-A191-56A717B1B5EE} = {B4C40E02-E06A-4359-BDC5-349E103366AD}
{C93898B7-2001-4C29-9BBE-33A2E61C350A} = {C0A05428-767E-46C5-A31F-0D220E41F7C5}
{EC933357-1D95-4CDD-B290-7A5984FC1AA2} = {C0A05428-767E-46C5-A31F-0D220E41F7C5}
{D503F737-90E6-438F-ACB2-1074CACEE407} = {EC933357-1D95-4CDD-B290-7A5984FC1AA2}
{7C5101F3-E3E6-42DB-8585-D08C2BE5E30C} = {C93898B7-2001-4C29-9BBE-33A2E61C350A}
{9C04921A-38D5-4EC9-8FF5-0E0D74681049} = {EC933357-1D95-4CDD-B290-7A5984FC1AA2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0143C230-7F40-44B2-8BA3-EF5B92D55848}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

var mixcore = builder.AddProject<Projects.mixcore>("mixcore");

builder.AddProject<Projects.mixcore_gateway>("mixcore.gateway")
.WithReference(mixcore)
;
var mixmq = builder.AddProject<Projects.mix_mq_server>("mix.mq.server");

builder.AddProject<Projects.mix_mq_server>("mix.mq.server");
var mixcore = builder.AddProject<Projects.mixcore>("mixcore");

builder.AddProject<Projects.mix_auth_service>("mix.auth.service");
builder.AddProject<Projects.mix_auth_api>("mix.auth.api");
builder.AddProject<Projects.mixcore_gateway>("mixcore.gateway");

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15173",
"applicationUrl": "https://localhost:15173",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,11 +9,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="8.0.0-preview.1.23557.2" />
<PackageReference Include="Aspire.Hosting" Version="8.0.0-preview.2.23619.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\services\mix-auth-service\mix.auth.service\mix.auth.service.csproj" />
<ProjectReference Include="..\..\..\services\mix-message-queue\mix.mq.server\mix.mq.server.csproj" />
<ProjectReference Include="..\..\..\services\mix-auth-service\mix.auth.api\mix.auth.api.csproj" />
<ProjectReference Include="..\..\mixcore.gateway\mixcore.gateway.csproj" />
<ProjectReference Include="..\..\mixcore\mixcore.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicati
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
.AddCheck("self", () => HealthCheckResult.Healthy(), new[] { "live" });

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Grafana.OpenTelemetry" Version="0.7.0-beta.2" />
<PackageReference Include="Grafana.OpenTelemetry.Base" Version="0.7.0-beta.2" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.1.23557.2" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.2.23619.3" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.7.0-rc.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.2" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.3" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="8.0.0" />
</ItemGroup>

</Project>
148 changes: 82 additions & 66 deletions src/applications/mixcore/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Mix.Database.Services;
using Mix.Heart.Exceptions;
using Mix.Heart.Extensions;
using Mix.Lib.Interfaces;
using Mix.Lib.Services;
Expand Down Expand Up @@ -66,86 +67,101 @@ public async Task<IActionResult> Index()

private async Task<PageContentViewModel> LoadPage(string seoName = null)
{
var pageRepo = PageContentViewModel.GetRepository(Uow, CacheService);
Expression<Func<MixPageContent, bool>> predicate = p => p.MixTenantId == CurrentTenant.Id
&& p.Specificulture == Culture;
predicate = predicate.AndAlsoIf(string.IsNullOrEmpty(seoName), m => m.Type == MixPageType.Home);
predicate = predicate.AndAlsoIf(!string.IsNullOrEmpty(seoName), m => m.SeoName == seoName);
var page = await pageRepo.GetFirstAsync(predicate);

if (page != null)
try
{
await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
var pageRepo = PageContentViewModel.GetRepository(Uow, CacheService);
Expression<Func<MixPageContent, bool>> predicate = p => p.MixTenantId == CurrentTenant.Id
&& p.Specificulture == Culture;
predicate = predicate.AndAlsoIf(string.IsNullOrEmpty(seoName), m => m.Type == MixPageType.Home);
predicate = predicate.AndAlsoIf(!string.IsNullOrEmpty(seoName), m => m.SeoName == seoName);
var page = await pageRepo.GetFirstAsync(predicate);

if (page != null)
{
SortBy = MixQueryColumnName.Priority
}, CacheService);
await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
{
SortBy = MixQueryColumnName.Priority
}, CacheService);

ViewData["Tenant"] = CurrentTenant;
ViewData["Title"] = page.SeoTitle;
ViewData["Description"] = page.SeoDescription;
ViewData["Keywords"] = page.SeoKeywords;
ViewData["Image"] = page.Image;
ViewData["Layout"] = page.Layout?.FilePath;
ViewData["BodyClass"] = page.ClassName;
ViewData["ViewMode"] = MixMvcViewMode.Page;
ViewData["Keyword"] = page.SeoKeywords;
ViewData["Tenant"] = CurrentTenant;
ViewData["Title"] = page.SeoTitle;
ViewData["Description"] = page.SeoDescription;
ViewData["Keywords"] = page.SeoKeywords;
ViewData["Image"] = page.Image;
ViewData["Layout"] = page.Layout?.FilePath;
ViewData["BodyClass"] = page.ClassName;
ViewData["ViewMode"] = MixMvcViewMode.Page;
ViewData["Keyword"] = page.SeoKeywords;

ViewData["ViewMode"] = MixMvcViewMode.Page;
}

ViewData["ViewMode"] = MixMvcViewMode.Page;
return page;
}
catch (Exception ex)
{
throw new MixException(MixErrorStatus.Badrequest, ex);
}
return page;
}
private async Task<IActionResult> LoadAlias(string seoName = null)
{
var alias = await MixUrlAliasViewModel.GetRepository(Uow, CacheService).GetSingleAsync(m => m.MixTenantId == CurrentTenant.Id && m.Alias == seoName);
if (alias != null)
try
{
switch (alias.Type)
var alias = await MixUrlAliasViewModel.GetRepository(Uow, CacheService).GetSingleAsync(m => m.MixTenantId == CurrentTenant.Id && m.Alias == seoName);
if (alias != null)
{
case MixUrlAliasType.Page:
var pageRepo = PageContentViewModel.GetRepository(Uow, CacheService);
pageRepo.CacheService = CacheService;
var page = await pageRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (page != null)
{
await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
switch (alias.Type)
{
case MixUrlAliasType.Page:
var pageRepo = PageContentViewModel.GetRepository(Uow, CacheService);
pageRepo.CacheService = CacheService;
var page = await pageRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (page != null)
{
SortBy = MixQueryColumnName.Priority
}, CacheService);
ViewData["Tenant"] = CurrentTenant;
ViewData["Title"] = page.SeoTitle;
ViewData["Description"] = page.SeoDescription;
ViewData["Keywords"] = page.SeoKeywords;
ViewData["Image"] = page.Image;
ViewData["Layout"] = page.Layout?.FilePath;
ViewData["BodyClass"] = page.ClassName;
ViewData["ViewMode"] = MixMvcViewMode.Page;
ViewData["Keyword"] = page.SeoKeywords;
await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
{
SortBy = MixQueryColumnName.Priority
}, CacheService);
ViewData["Tenant"] = CurrentTenant;
ViewData["Title"] = page.SeoTitle;
ViewData["Description"] = page.SeoDescription;
ViewData["Keywords"] = page.SeoKeywords;
ViewData["Image"] = page.Image;
ViewData["Layout"] = page.Layout?.FilePath;
ViewData["BodyClass"] = page.ClassName;
ViewData["ViewMode"] = MixMvcViewMode.Page;
ViewData["Keyword"] = page.SeoKeywords;

ViewData["ViewMode"] = MixMvcViewMode.Page;
return View("Page", page);
}
break;
case MixUrlAliasType.Post:
var postRepo = PostContentViewModel.GetRepository(Uow, CacheService);
postRepo.CacheService = CacheService;
var post = await postRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (post != null)
return View("Post", post);
break;
case MixUrlAliasType.Module:
break;
case MixUrlAliasType.ModuleData:
break;
case MixUrlAliasType.MixApplication:
var appRepo = ApplicationViewModel.GetRepository(Uow, CacheService);
appRepo.CacheService = CacheService;
var app = await appRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (app != null)
return View("App", app);
break;
ViewData["ViewMode"] = MixMvcViewMode.Page;
return View("Page", page);
}
break;
case MixUrlAliasType.Post:
var postRepo = PostContentViewModel.GetRepository(Uow, CacheService);
postRepo.CacheService = CacheService;
var post = await postRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (post != null)
return View("Post", post);
break;
case MixUrlAliasType.Module:
break;
case MixUrlAliasType.ModuleData:
break;
case MixUrlAliasType.MixApplication:
var appRepo = ApplicationViewModel.GetRepository(Uow, CacheService);
appRepo.CacheService = CacheService;
var app = await appRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (app != null)
return View("App", app);
break;
}
}
return NotFound();
}
catch (Exception ex)
{
throw new MixException(MixErrorStatus.Badrequest, ex);
}
return NotFound();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ModuleDataController(IHttpContextAccessor httpContextAccessor,
TranslatorService translator,
MixIdentityService mixIdentityService,
UnitOfWorkInfo<MixCmsContext> uow,
IQueueService<MessageQueueModel> queueService,
IMemoryQueueService<MessageQueueModel> queueService,
IPortalHubClientService portalHub,
IMixTenantService mixTenantService)
: base(httpContextAccessor, configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PageContentApiController(
TranslatorService translator,
MixIdentityService mixIdentityService,
UnitOfWorkInfo<MixCmsContext> uow,
IQueueService<MessageQueueModel> queueService,
IMemoryQueueService<MessageQueueModel> queueService,
MixRepoDbRepository mixRepoDbRepository,
IMixMetadataService metadataService,
IPortalHubClientService portalHub,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public PostContentApiController(
TranslatorService translator,
MixIdentityService mixIdentityService,
UnitOfWorkInfo<MixCmsContext> uow,
IQueueService<MessageQueueModel> queueService,
IMemoryQueueService<MessageQueueModel> queueService,
MixcorePostService postService,
MixRepoDbRepository mixRepoDbRepository,
IMixMetadataService metadataService,
Expand Down
8 changes: 4 additions & 4 deletions src/applications/mixcore/Controllers/SecurityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public IActionResult Index(string page)
public ActionResult<JObject> ExternalLogin([FromForm] string returnUrl, [FromForm] MixExternalLoginProviders provider)
{
// Request a redirect to the external login provider.
returnUrl ??= _mixEndpointService.DefaultDomain;
returnUrl = returnUrl.Contains(_mixEndpointService.DefaultDomain) || returnUrl.StartsWith("http")
returnUrl ??= _mixEndpointService.Mixcore;
returnUrl = returnUrl.Contains(_mixEndpointService.Mixcore) || returnUrl.StartsWith("http")
? returnUrl
: $"{_mixEndpointService.DefaultDomain.TrimEnd('/')}/{returnUrl.TrimStart('/')}";
var redirectUrl = $"/security/external-login-result?returnUrl={returnUrl}";
: $"{_mixEndpointService.Mixcore.TrimEnd('/')}/{returnUrl.TrimStart('/')}";
var redirectUrl = $"{_mixEndpointService.Mixcore}/security/external-login-result";
var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider.ToString(), redirectUrl);
return new ChallengeResult(provider.ToString(), properties);
}
Expand Down
Loading

0 comments on commit 1e54ea1

Please sign in to comment.