feat: 品牌 Logo 增加 mascot 渠道(启动页吉祥物)
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
8c1b7c0140
commit
af9532f5df
@ -14,4 +14,14 @@ public class BrandLogoOutput
|
|||||||
/// 官网 Logo 可访问 URL;未配置时为空。
|
/// 官网 Logo 可访问 URL;未配置时为空。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SiteUrl { get; set; } = string.Empty;
|
public string SiteUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网站标签(favicon)可访问 URL;未配置时为空。
|
||||||
|
/// </summary>
|
||||||
|
public string FaviconUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启动页 / 空态吉祥物可访问 URL;未配置时为空。
|
||||||
|
/// </summary>
|
||||||
|
public string MascotUrl { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace Oms.Application.Dtos.System;
|
|||||||
public class BrandLogoUploadInput
|
public class BrandLogoUploadInput
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 渠道:portal(系统顶栏)/ site(官网)。
|
/// 渠道:portal(系统顶栏)/ site(官网)/ favicon(网站标签)/ mascot(启动页吉祥物)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Channel { get; set; } = string.Empty;
|
public string Channel { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,8 @@ public class SystemOtherConfigService : ApplicationService
|
|||||||
private const string PaymentQrChannelWechat = "wechat";
|
private const string PaymentQrChannelWechat = "wechat";
|
||||||
private const string BrandLogoChannelPortal = "portal";
|
private const string BrandLogoChannelPortal = "portal";
|
||||||
private const string BrandLogoChannelSite = "site";
|
private const string BrandLogoChannelSite = "site";
|
||||||
|
private const string BrandLogoChannelFavicon = "favicon";
|
||||||
|
private const string BrandLogoChannelMascot = "mascot";
|
||||||
|
|
||||||
private ISystemOtherConfigRepository SystemOtherConfigRepository =>
|
private ISystemOtherConfigRepository SystemOtherConfigRepository =>
|
||||||
LazyServiceProvider.GetRequiredService<ISystemOtherConfigRepository>();
|
LazyServiceProvider.GetRequiredService<ISystemOtherConfigRepository>();
|
||||||
@ -197,22 +199,18 @@ public class SystemOtherConfigService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取品牌 Logo(系统顶栏 / 官网)。未配置时对应 URL 为空(前端回退本地默认图)。匿名可读,供官网使用。
|
/// 获取品牌 Logo(系统顶栏 / 官网 / 网站标签 / 启动页吉祥物)。未配置时对应 URL 为空(前端回退本地默认图)。匿名可读。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpGet("/system/other-config/brand-logo")]
|
[HttpGet("/system/other-config/brand-logo")]
|
||||||
public async Task<BrandLogoOutput> GetBrandLogoAsync()
|
public async Task<BrandLogoOutput> GetBrandLogoAsync()
|
||||||
{
|
{
|
||||||
var entity = await SystemOtherConfigRepository.GetByConfigCodeAsync(SystemOtherConfigCodes.BrandLogo);
|
var entity = await SystemOtherConfigRepository.GetByConfigCodeAsync(SystemOtherConfigCodes.BrandLogo);
|
||||||
return new BrandLogoOutput
|
return MapBrandLogoOutput(entity);
|
||||||
{
|
|
||||||
PortalUrl = FileStorage.GetPublicUrl(entity?.AppKey),
|
|
||||||
SiteUrl = FileStorage.GetPublicUrl(entity?.Remark)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传并替换品牌 Logo。Channel=portal|site;返回最新可访问 URL。
|
/// 上传并替换品牌 Logo。Channel=portal|site|favicon|mascot;返回最新可访问 URL。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input">入参:渠道 + 图片文件。</param>
|
/// <param name="input">入参:渠道 + 图片文件。</param>
|
||||||
[HttpPost("/system/other-config/brand-logo/upload")]
|
[HttpPost("/system/other-config/brand-logo/upload")]
|
||||||
@ -220,9 +218,13 @@ public class SystemOtherConfigService : ApplicationService
|
|||||||
public async Task<BrandLogoOutput> UploadBrandLogoAsync([FromForm] BrandLogoUploadInput input)
|
public async Task<BrandLogoOutput> UploadBrandLogoAsync([FromForm] BrandLogoUploadInput input)
|
||||||
{
|
{
|
||||||
var channel = (input.Channel ?? string.Empty).Trim().ToLowerInvariant();
|
var channel = (input.Channel ?? string.Empty).Trim().ToLowerInvariant();
|
||||||
if (channel is not (BrandLogoChannelPortal or BrandLogoChannelSite))
|
if (channel is not (
|
||||||
|
BrandLogoChannelPortal
|
||||||
|
or BrandLogoChannelSite
|
||||||
|
or BrandLogoChannelFavicon
|
||||||
|
or BrandLogoChannelMascot))
|
||||||
{
|
{
|
||||||
throw new BusinessException("渠道仅支持 portal 或 site");
|
throw new BusinessException("渠道仅支持 portal、site、favicon 或 mascot");
|
||||||
}
|
}
|
||||||
|
|
||||||
var key = await OmsFileUploadHelper.SaveBrandLogoAsync(input.File, FileStorage);
|
var key = await OmsFileUploadHelper.SaveBrandLogoAsync(input.File, FileStorage);
|
||||||
@ -231,19 +233,34 @@ public class SystemOtherConfigService : ApplicationService
|
|||||||
{
|
{
|
||||||
entity.AppKey = key;
|
entity.AppKey = key;
|
||||||
}
|
}
|
||||||
else
|
else if (channel == BrandLogoChannelSite)
|
||||||
{
|
{
|
||||||
entity.Remark = key;
|
entity.Remark = key;
|
||||||
}
|
}
|
||||||
|
else if (channel == BrandLogoChannelFavicon)
|
||||||
|
{
|
||||||
|
// BaseUrl 复用为 favicon object key(非网关地址)
|
||||||
|
entity.BaseUrl = key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// AppSecret 复用为启动页吉祥物 object key(非密钥)
|
||||||
|
entity.AppSecret = key;
|
||||||
|
}
|
||||||
|
|
||||||
await SystemOtherConfigRepository.UpdateAsync(entity);
|
await SystemOtherConfigRepository.UpdateAsync(entity);
|
||||||
return new BrandLogoOutput
|
return MapBrandLogoOutput(entity);
|
||||||
{
|
|
||||||
PortalUrl = FileStorage.GetPublicUrl(entity.AppKey),
|
|
||||||
SiteUrl = FileStorage.GetPublicUrl(entity.Remark)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BrandLogoOutput MapBrandLogoOutput(SystemOtherConfig? entity) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
PortalUrl = FileStorage.GetPublicUrl(entity?.AppKey),
|
||||||
|
SiteUrl = FileStorage.GetPublicUrl(entity?.Remark),
|
||||||
|
FaviconUrl = FileStorage.GetPublicUrl(entity?.BaseUrl),
|
||||||
|
MascotUrl = FileStorage.GetPublicUrl(entity?.AppSecret)
|
||||||
|
};
|
||||||
|
|
||||||
private async Task<SystemOtherConfig> EnsurePaymentReceiveQrConfigAsync()
|
private async Task<SystemOtherConfig> EnsurePaymentReceiveQrConfigAsync()
|
||||||
{
|
{
|
||||||
var entity = await SystemOtherConfigRepository.GetByConfigCodeAsync(SystemOtherConfigCodes.PaymentReceiveQr);
|
var entity = await SystemOtherConfigRepository.GetByConfigCodeAsync(SystemOtherConfigCodes.PaymentReceiveQr);
|
||||||
@ -291,8 +308,7 @@ public class SystemOtherConfigService : ApplicationService
|
|||||||
deleted.ConfigName = "品牌 Logo";
|
deleted.ConfigName = "品牌 Logo";
|
||||||
deleted.Enabled = true;
|
deleted.Enabled = true;
|
||||||
deleted.TimeoutSeconds = 30;
|
deleted.TimeoutSeconds = 30;
|
||||||
deleted.BaseUrl = null;
|
// 保留 AppKey/Remark/BaseUrl/AppSecret 中的 Logo object key,避免恢复时丢图
|
||||||
deleted.AppSecret = null;
|
|
||||||
await SystemOtherConfigRepository.UpdateAsync(deleted);
|
await SystemOtherConfigRepository.UpdateAsync(deleted);
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public static class SystemOtherConfigCodes
|
|||||||
public const string PaymentReceiveQr = "payment_receive_qr";
|
public const string PaymentReceiveQr = "payment_receive_qr";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 品牌 Logo(AppKey=系统顶栏 Logo object key,Remark=官网 Logo object key)。
|
/// 品牌 Logo(AppKey=系统顶栏,Remark=官网,BaseUrl=favicon,AppSecret=启动页吉祥物;均为 object key)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string BrandLogo = "brand_logo";
|
public const string BrandLogo = "brand_logo";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user