+
Skip to content

up 020424 #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,5 @@ src/applications/**/ServiceDependencies/
src/applications/Mixcore/wwwroot/portal-apps/
src/**/__pycache__/
src/**/logs/

src/**/mixcontent/
31 changes: 20 additions & 11 deletions src/applications/mixcore.gateway/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

using Microsoft.Extensions.DependencyInjection.Extensions;
using Mix.Constant.Constants;
using Mix.Database.Entities.Cms;
using Mix.Heart.Services;
using Mix.Lib.Helpers;
using Mix.Shared.Services;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
Expand All @@ -17,17 +19,23 @@
MixFileHelper.CopyFolder("../mixcore/mixcontent/shared", MixFolders.MixContentSharedFolder);
}

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
var builder = MixCmsHelper.CreateWebApplicationBuilder(args);
if (builder.Environment.IsDevelopment())
{
builder.AddServiceDefaults();
}

builder.WebHost.UseContentRoot(Directory.GetCurrentDirectory());
builder.Configuration.SetBasePath(builder.Environment.ContentRootPath)
.AddJsonFile("appsettings.json", true, false)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", true, true)
.AddJsonFile("ocelot.json", true, false)
.AddJsonFile($"ocelot.{builder.Environment.EnvironmentName}.json", true, true)
.AddJsonFile($"{MixFolders.AppConfigFolder}/ocelot.json", true, true)
.AddJsonFile($"{MixFolders.AppConfigFolder}/ocelot.{builder.Environment.EnvironmentName}.json", true, true)
.AddEnvironmentVariables();
builder.Services.AddOutputCache();
builder.Services.AddControllers();
builder.Services.AddMixServices(Assembly.GetExecutingAssembly(), builder.Configuration);
builder.Services.AddMixAuthorize<MixCmsContext>(builder.Configuration);
builder.Services.TryAddSingleton<MixEndpointService>();
builder.Services.AddOcelot(builder.Configuration);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
Expand All @@ -48,14 +56,16 @@
{
builder.Services.AddMixCors();
}
builder.Services.AddSwaggerGen();

var app = builder.Build();

Configure(app, builder.Environment, isInit);

app.UseOutputCache();
app.MapDefaultEndpoints();
if (app.Environment.IsDevelopment())
{
app.MapDefaultEndpoints();
}
app.Run();

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -65,6 +75,7 @@ static void Configure(WebApplication app, IWebHostEnvironment env, bool isInit)
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
app.UseHttpsRedirection();
}
//app.UseResponseCompression();
app.UseRouting();
Expand All @@ -77,11 +88,9 @@ static void Configure(WebApplication app, IWebHostEnvironment env, bool isInit)
app.UseMixCors();
}
// ref: app.UseMixAuth();
app.UseAuthentication();
app.UseAuthorization();
app.UseMixAuth();

app.UseSwagger();
app.UseSwaggerUI();
app.UseMixSwaggerApps(app.Environment.IsDevelopment(), Assembly.GetExecutingAssembly());
app.MapControllers();
app.UseOcelot().Wait();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

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

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

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

builder.Build().Run();
10 changes: 6 additions & 4 deletions src/applications/mixcore/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Mix.Heart.Extensions;
using Mix.Lib.Interfaces;
using Mix.Lib.Services;
using Mix.RepoDb.Interfaces;
using Mix.RepoDb.Repositories;
using Mix.Services.Databases.Lib.Interfaces;
using Mix.Shared.Services;
Expand All @@ -23,11 +24,12 @@ public class HomeController(
IMixMetadataService metadataService,
MixCacheService cacheService,
IMixTenantService tenantService,
IConfiguration configuration) : MvcBaseController(httpContextAccessor, ipSecurityConfigService, mixCmsService, translator, databaseService, uow, cacheService, tenantService, configuration)
IConfiguration configuration,
IMixDbDataService mixDbDataService) : MvcBaseController(httpContextAccessor, ipSecurityConfigService, mixCmsService, translator, databaseService, uow, cacheService, tenantService, configuration)
{
private readonly IMixMetadataService _metadataService = metadataService;
private readonly MixRepoDbRepository _repoDbRepository = repoDbRepository;

private readonly IMixDbDataService _mixDbDataService = mixDbDataService;
protected override void ValidateRequest()
{
base.ValidateRequest();
Expand Down Expand Up @@ -78,7 +80,7 @@ private async Task<PageContentViewModel> LoadPage(string seoName = null)

if (page != null)
{
await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
await page.LoadDataAsync(_mixDbDataService, _metadataService, new(Request)
{
SortBy = MixQueryColumnName.Priority
}, CacheService);
Expand Down Expand Up @@ -118,7 +120,7 @@ private async Task<IActionResult> LoadAlias(string seoName = null)
var page = await pageRepo.GetSingleAsync(m => m.Id == alias.SourceContentId);
if (page != null)
{
await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
await page.LoadDataAsync(_mixDbDataService, _metadataService, new(Request)
{
SortBy = MixQueryColumnName.Priority
}, CacheService);
Expand Down
13 changes: 7 additions & 6 deletions src/applications/mixcore/Controllers/PageContentApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Mix.Lib.Models.Common;
using Mix.Lib.Services;
using Mix.Mq.Lib.Models;
using Mix.RepoDb.Interfaces;
using Mix.RepoDb.Repositories;
using Mix.Services.Databases.Lib.Interfaces;
using Mix.Shared.Models;
Expand All @@ -14,8 +15,8 @@ namespace Mixcore.Controllers
[Route("api/v2/rest/mixcore/page-content")]
public sealed class PageContentApiController : MixQueryApiControllerBase<PageContentViewModel, MixCmsContext, MixPageContent, int>
{
private readonly MixRepoDbRepository _mixRepoDbRepository;
private readonly IMixMetadataService _metadataService;
private readonly IMixDbDataService _mixDbDataService;
public PageContentApiController(
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration,
Expand All @@ -24,21 +25,21 @@ public PageContentApiController(
MixIdentityService mixIdentityService,
UnitOfWorkInfo<MixCmsContext> uow,
IMemoryQueueService<MessageQueueModel> queueService,
MixRepoDbRepository mixRepoDbRepository,
IMixMetadataService metadataService,
IPortalHubClientService portalHub,
IMixTenantService mixTenantService)
: base(httpContextAccessor, configuration,
IMixTenantService mixTenantService,
IMixDbDataService mixDbDataService)
: base(httpContextAccessor, configuration,
cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService)
{
_mixRepoDbRepository = mixRepoDbRepository;
_metadataService = metadataService;
_mixDbDataService = mixDbDataService;
}

protected override async Task<PageContentViewModel> GetById(int id)
{
var result = await base.GetById(id);
await result.LoadDataAsync(_mixRepoDbRepository, _metadataService, new(), CacheService);
await result.LoadDataAsync(_mixDbDataService, _metadataService, new(), CacheService);
return result;
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/applications/mixcore/Controllers/PageController.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.RepoDb.Interfaces;
using Mix.RepoDb.Repositories;
using Mix.Services.Databases.Lib.Interfaces;
using Mix.Shared.Services;
Expand All @@ -13,20 +14,20 @@ public class PageController : MixControllerBase
protected readonly MixCmsContext CmsContext;
private readonly DatabaseService _databaseService;
private readonly MixCacheService _cacheService;
private readonly MixRepoDbRepository _repoDbRepository;
private readonly IMixMetadataService _metadataService;
private readonly IMixDbDataService _mixDbDataService;

public PageController(IHttpContextAccessor httpContextAccessor, IPSecurityConfigService ipSecurityConfigService, IMixCmsService mixCmsService, DatabaseService databaseService, MixCmsContext cmsContext, MixRepoDbRepository repoDbRepository, IMixMetadataService metadataService, MixCacheService cacheService, IMixTenantService tenantService,
IConfiguration configuration) :
public PageController(IHttpContextAccessor httpContextAccessor, IPSecurityConfigService ipSecurityConfigService, IMixCmsService mixCmsService, DatabaseService databaseService, MixCmsContext cmsContext, IMixMetadataService metadataService, MixCacheService cacheService, IMixTenantService tenantService,
IConfiguration configuration, IMixDbDataService mixDbDataService) :
base(httpContextAccessor, mixCmsService, ipSecurityConfigService, tenantService, configuration)
{
CmsContext = cmsContext;
Uow = new(CmsContext);
_databaseService = databaseService;
CmsContext = cmsContext;
_repoDbRepository = repoDbRepository;
_metadataService = metadataService;
_cacheService = cacheService;
_mixDbDataService = mixDbDataService;
}

protected override void ValidateRequest()
Expand Down Expand Up @@ -74,7 +75,7 @@ protected async Task<IActionResult> Page(int pageId, string keyword = null)
if (page == null)
return NotFound();

await page.LoadDataAsync(_repoDbRepository, _metadataService, new(Request)
await page.LoadDataAsync(_mixDbDataService, _metadataService, new(Request)
{
SortBy = MixQueryColumnName.Priority
}, _cacheService);
Expand Down
12 changes: 8 additions & 4 deletions src/applications/mixcore/Controllers/PostContentApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Mix.Lib.Models.Common;
using Mix.Lib.Services;
using Mix.Mq.Lib.Models;
using Mix.RepoDb.Interfaces;
using Mix.RepoDb.Repositories;
using Mix.Services.Databases.Lib.Interfaces;
using Mix.SignalR.Interfaces;
Expand All @@ -16,6 +17,7 @@ namespace Mixcore.Controllers
[Route("api/v2/rest/mixcore/post-content")]
public sealed class PostContentApiController : MixQueryApiControllerBase<PostContentViewModel, MixCmsContext, MixPostContent, int>
{
private readonly IMixDbDataService _mixDbDataService;
private readonly MixRepoDbRepository _repoDbRepository;
private readonly MixRepoDbRepository _mixRepoDbRepository;
private readonly IMixMetadataService _metadataService;
Expand All @@ -33,14 +35,16 @@ public PostContentApiController(
IMixMetadataService metadataService,
MixRepoDbRepository repoDbRepository,
IPortalHubClientService portalHub,
IMixTenantService mixTenantService)
IMixTenantService mixTenantService,
IMixDbDataService mixDbDataService)
: base(httpContextAccessor, configuration,
cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService)
{
_postService = postService;
_mixRepoDbRepository = mixRepoDbRepository;
_metadataService = metadataService;
_repoDbRepository = repoDbRepository;
_mixDbDataService = mixDbDataService;
}

[HttpPost("filter")]
Expand Down Expand Up @@ -69,7 +73,7 @@ public async Task<ActionResult<PagingResponseModel<PostContentViewModel>>> Filte
var result = await Repository.GetPagingAsync(searchRequest.Predicate, searchRequest.PagingData);
foreach (var item in result.Items)
{
await item.LoadAdditionalDataAsync(_repoDbRepository, _metadataService, CacheService);
await item.LoadAdditionalDataAsync(_mixDbDataService, _metadataService, CacheService);
}
return Ok(ParseSearchResult(req, result));
}
Expand All @@ -90,7 +94,7 @@ protected override async Task<PagingResponseModel<PostContentViewModel>> SearchH
var result = await _postService.SearchPosts(searchPostQuery, cancellationToken);
foreach (var item in result.Items)
{
await item.LoadAdditionalDataAsync(_mixRepoDbRepository, _metadataService, CacheService);
await item.LoadAdditionalDataAsync(_mixDbDataService, _metadataService, CacheService);
}

return RestApiService.ParseSearchResult(req, result);
Expand All @@ -99,7 +103,7 @@ protected override async Task<PagingResponseModel<PostContentViewModel>> SearchH
protected override async Task<PostContentViewModel> GetById(int id)
{
var result = await base.GetById(id);
await result.LoadAdditionalDataAsync(_mixRepoDbRepository, _metadataService, CacheService);
await result.LoadAdditionalDataAsync(_mixDbDataService, _metadataService, CacheService);
return result;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/applications/mixcore/Controllers/PostController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Mix.Database.Entities.MixDb;
using Mix.Database.Services;
using Mix.Lib.Interfaces;

using Mix.RepoDb.Interfaces;
using Mix.RepoDb.Repositories;
using Mix.Services.Databases.Lib.Interfaces;
using Mix.Shared.Services;
Expand All @@ -18,6 +18,7 @@ public class PostController : MixControllerBase
private readonly MixCacheService _cacheService;
private readonly MixRepoDbRepository _repoDbRepository;
private readonly IMixMetadataService _metadataService;
private readonly IMixDbDataService _mixDbDataService;
public PostController(
IHttpContextAccessor httpContextAccessor,
IPSecurityConfigService ipSecurityConfigService,
Expand All @@ -29,7 +30,8 @@ public PostController(
UnitOfWorkInfo<MixDbDbContext> dbUow,
MixCacheService cacheService,
IMixTenantService tenantService,
IConfiguration configuration)
IConfiguration configuration,
IMixDbDataService mixDbDataService)
: base(httpContextAccessor, mixCmsService, ipSecurityConfigService, tenantService, configuration)
{
CmsContext = cmsContext;
Expand All @@ -40,6 +42,7 @@ public PostController(
_metadataService = metadataService;
_repoDbRepository.SetDbConnection(dbUow);
_cacheService = cacheService;
_mixDbDataService = mixDbDataService;
}

protected override void ValidateRequest()
Expand Down Expand Up @@ -89,7 +92,7 @@ protected async Task<IActionResult> Post(int postId, string seoName = null)
{
return NotFound();
}
await post.LoadAdditionalDataAsync(_repoDbRepository, _metadataService, _cacheService);
await post.LoadAdditionalDataAsync(_mixDbDataService, _metadataService, _cacheService);

ViewData["Title"] = post.SeoTitle;
ViewData["Description"] = post.SeoDescription;
Expand Down
7 changes: 4 additions & 3 deletions src/applications/mixcore/Domain/StartupServices.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Mix.Lib.Publishers;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Mix.Lib.Publishers;
using Mix.Lib.Subscribers;
using Mix.Log.Lib.Publishers;
using Mix.Log.Lib.Subscribers;
using Mix.Quartz.Interfaces;
using Mix.Quartz.Services;
using Mix.RepoDb.Publishers;
using Mix.RepoDb.Subscribers;
Expand All @@ -28,12 +30,11 @@ public void AddServices(IServiceCollection services, IConfiguration configuratio
services.AddHostedService<MixDbCommandPublisher>();
services.AddHostedService<MixDbCommandSubscriber>();

services.AddHostedService<MixQuartzHostedService>();
services.AddMixQuartzServices(configuration);
services.AddHostedService<StorageBackgroundTaskSubscriber>();

if (!globalConfigs!.IsInit)
{
services.AddHostedService<MixLogPublisher>();
services.AddHostedService<MixLogSubscriber>();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Mix.Heart.Helpers;
using Mix.Lib.ViewModels.ReadOnly;
using Mix.RepoDb.Interfaces;
using Mix.RepoDb.Repositories;

namespace Mixcore.Domain.ViewModels
Expand Down Expand Up @@ -64,10 +65,9 @@ public T Property<T>(string fieldName)
#endregion

#region Private Methods
public async Task LoadAdditionalDataAsync(MixRepoDbRepository mixRepoDbRepository)
public async Task LoadAdditionalDataAsync(IMixDbDataService mixDbDataService)
{
mixRepoDbRepository.InitTableName(MixDatabaseName);
var obj = await mixRepoDbRepository.GetSingleByParentAsync(MixContentType.Page, Id);
var obj = await mixDbDataService.GetSingleByParent(MixDatabaseName, MixContentType.Post, Id, true);
ExtraData = obj != null ? ReflectionHelper.ParseObject(obj) : null;
}

Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载