mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.1 KiB
62 lines
2.1 KiB
using System;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Caching.Distributed;
|
|
using Volo.Abp.AspNetCore.Mvc;
|
|
using Volo.Abp.Caching;
|
|
using Volo.CmsKit.GlobalResources;
|
|
using Volo.CmsKit.Public.GlobalResources;
|
|
|
|
namespace Volo.CmsKit.Public.Web.Controllers;
|
|
|
|
[Route("cms-kit/global-resources")]
|
|
public class CmsKitPublicGlobalResourcesController: AbpController
|
|
{
|
|
private readonly IGlobalResourcePublicAppService _globalResourcePublicAppService;
|
|
private readonly IDistributedCache<GlobalResourceDto> _resourceCache;
|
|
|
|
public CmsKitPublicGlobalResourcesController(
|
|
IGlobalResourcePublicAppService globalResourcePublicAppService,
|
|
IDistributedCache<GlobalResourceDto> resourceCache)
|
|
{
|
|
_globalResourcePublicAppService = globalResourcePublicAppService;
|
|
_resourceCache = resourceCache;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("style")]
|
|
public virtual async Task<IActionResult> GetGlobalStyleAsync()
|
|
{
|
|
var style = await _resourceCache.GetOrAddAsync(
|
|
GlobalResourceConsts.GlobalStyleName, //Cache key
|
|
async () => await _globalResourcePublicAppService.GetGlobalStyleAsync(),
|
|
() => new DistributedCacheEntryOptions
|
|
{
|
|
AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(2)
|
|
}
|
|
);
|
|
|
|
return new FileContentResult(
|
|
Encoding.ASCII.GetBytes(style.Value),
|
|
"text/css");
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("script")]
|
|
public virtual async Task<IActionResult> GetGlobalScriptAsync()
|
|
{
|
|
var script = await _resourceCache.GetOrAddAsync(
|
|
GlobalResourceConsts.GlobalScriptName, //Cache key
|
|
async () => await _globalResourcePublicAppService.GetGlobalScriptAsync(),
|
|
() => new DistributedCacheEntryOptions
|
|
{
|
|
AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(2)
|
|
}
|
|
);
|
|
|
|
return new FileContentResult(
|
|
Encoding.ASCII.GetBytes(script.Value),
|
|
"application/javascript");
|
|
}
|
|
}
|