fix: 官网封面图响应加长期 Cache-Control,并合并 CoverImage 迁移脚本。
All checks were successful
Build and Deploy / deploy (push) Successful in 1m19s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m19s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ef3a3abb9f
commit
caca756c94
@ -1,4 +1,5 @@
|
|||||||
-- 服务渠道:黑名单分区 + 独立计重(应付);订单/揽收件重尺应付计费重。
|
-- 服务渠道:黑名单分区 + 独立计重(应付);订单/揽收件重尺应付计费重。
|
||||||
|
-- 销售产品:官网线路封面图 CoverImage。
|
||||||
-- 可重复执行。不改 ChargeableWeight 语义(仍为应收计费重)。
|
-- 可重复执行。不改 ChargeableWeight 语义(仍为应收计费重)。
|
||||||
|
|
||||||
SET @db := DATABASE();
|
SET @db := DATABASE();
|
||||||
@ -87,3 +88,20 @@ SET @sql := IF(
|
|||||||
PREPARE stmt FROM @sql;
|
PREPARE stmt FROM @sql;
|
||||||
EXECUTE stmt;
|
EXECUTE stmt;
|
||||||
DEALLOCATE PREPARE stmt;
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
-- t_sales_product.CoverImage(官网线路封面图 object key)
|
||||||
|
SET @exists := (
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = @db
|
||||||
|
AND TABLE_NAME = 't_sales_product'
|
||||||
|
AND COLUMN_NAME = 'CoverImage'
|
||||||
|
);
|
||||||
|
SET @sql := IF(
|
||||||
|
@exists = 0,
|
||||||
|
'ALTER TABLE `t_sales_product` ADD COLUMN `CoverImage` VARCHAR(512) NULL COMMENT ''官网线路封面图 object key'' AFTER `ProductDescription`',
|
||||||
|
'SELECT ''t_sales_product.CoverImage already exists'' AS info'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|||||||
@ -1,20 +0,0 @@
|
|||||||
-- 销售产品:官网线路封面图(产品配置可上传;门户精选线路卡片背景)
|
|
||||||
-- 可重复执行
|
|
||||||
|
|
||||||
SET @db := DATABASE();
|
|
||||||
|
|
||||||
SET @exists := (
|
|
||||||
SELECT COUNT(1)
|
|
||||||
FROM information_schema.COLUMNS
|
|
||||||
WHERE TABLE_SCHEMA = @db
|
|
||||||
AND TABLE_NAME = 't_sales_product'
|
|
||||||
AND COLUMN_NAME = 'CoverImage'
|
|
||||||
);
|
|
||||||
SET @sql := IF(
|
|
||||||
@exists = 0,
|
|
||||||
'ALTER TABLE `t_sales_product` ADD COLUMN `CoverImage` VARCHAR(512) NULL COMMENT ''官网线路封面图 object key'' AFTER `ProductDescription`',
|
|
||||||
'SELECT ''t_sales_product.CoverImage already exists'' AS info'
|
|
||||||
);
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
@ -63,23 +63,33 @@ public partial class SalesProductService : ApplicationService
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 按 object key 输出销售产品封面图字节(同源代理,避免浏览器直连 COS)。官网匿名可读。
|
/// 按 object key 输出销售产品封面图字节(同源代理,避免浏览器直连 COS)。官网匿名可读。
|
||||||
|
/// URL 带 v= 缓存戳时浏览器可长期缓存,刷新精选封面走磁盘缓存。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">入参:uploads/sales-product-cover/... object key。</param>
|
/// <param name="key">入参:uploads/sales-product-cover/... object key。</param>
|
||||||
/// <param name="v">缓存戳,可选。</param>
|
/// <param name="v">缓存戳,可选。</param>
|
||||||
/// <param name="cancellationToken">取消令牌。</param>
|
/// <param name="cancellationToken">取消令牌。</param>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpGet("/channel/sales-product/cover/file")]
|
[HttpGet("/channel/sales-product/cover/file")]
|
||||||
public Task<FileContentResult> GetCoverImageFileAsync(
|
public async Task<FileContentResult> GetCoverImageFileAsync(
|
||||||
[FromQuery] string key,
|
[FromQuery] string key,
|
||||||
[FromQuery] string? v = null,
|
[FromQuery] string? v = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
_ = v;
|
_ = v;
|
||||||
return OmsManagedImageHelper.StreamByKeyAsync(
|
var result = await OmsManagedImageHelper.StreamByKeyAsync(
|
||||||
FileStorage,
|
FileStorage,
|
||||||
key,
|
key,
|
||||||
cancellationToken,
|
cancellationToken,
|
||||||
OmsManagedImageHelper.SalesProductCoverKeyPrefix);
|
OmsManagedImageHelper.SalesProductCoverKeyPrefix);
|
||||||
|
|
||||||
|
// v= 随 object key 文件名变化;允许浏览器长期缓存,加速官网刷新
|
||||||
|
var http = LazyServiceProvider.GetRequiredService<IHttpContextAccessor>().HttpContext;
|
||||||
|
if (http != null)
|
||||||
|
{
|
||||||
|
http.Response.Headers["Cache-Control"] = "public, max-age=31536000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user