@ -24,6 +24,8 @@ public class SystemOtherConfigService : ApplicationService
private const string PaymentQrChannelWechat = "wechat" ;
private const string BrandLogoChannelPortal = "portal" ;
private const string BrandLogoChannelSite = "site" ;
private const string BrandLogoChannelFavicon = "favicon" ;
private const string BrandLogoChannelMascot = "mascot" ;
private ISystemOtherConfigRepository SystemOtherConfigRepository = >
LazyServiceProvider . GetRequiredService < ISystemOtherConfigRepository > ( ) ;
@ -197,22 +199,18 @@ public class SystemOtherConfigService : ApplicationService
}
/// <summary>
/// 获取品牌 Logo( 系统顶栏 / 官网 )。未配置时对应 URL 为空(前端回退本地默认图)。匿名可读,供官网使用 。
/// 获取品牌 Logo( 系统顶栏 / 官网 / 网站标签 / 启动页吉祥物 )。未配置时对应 URL 为空(前端回退本地默认图)。匿名可读。
/// </summary>
[AllowAnonymous]
[HttpGet("/system/other-config/brand-logo")]
public async Task < BrandLogoOutput > GetBrandLogoAsync ( )
{
var entity = await SystemOtherConfigRepository . GetByConfigCodeAsync ( SystemOtherConfigCodes . BrandLogo ) ;
return new BrandLogoOutput
{
PortalUrl = FileStorage . GetPublicUrl ( entity ? . AppKey ) ,
SiteUrl = FileStorage . GetPublicUrl ( entity ? . Remark )
} ;
return MapBrandLogoOutput ( entity ) ;
}
/// <summary>
/// 上传并替换品牌 Logo。Channel=portal|site ;返回最新可访问 URL。
/// 上传并替换品牌 Logo。Channel=portal|site|favicon|mascot; 返回最新可访问 URL。
/// </summary>
/// <param name="input">入参:渠道 + 图片文件。</param>
[HttpPost("/system/other-config/brand-logo/upload")]
@ -220,9 +218,13 @@ public class SystemOtherConfigService : ApplicationService
public async Task < BrandLogoOutput > UploadBrandLogoAsync ( [ FromForm ] BrandLogoUploadInput input )
{
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 ) ;
@ -231,19 +233,34 @@ public class SystemOtherConfigService : ApplicationService
{
entity . AppKey = key ;
}
else
else if ( channel = = BrandLogoChannelSite )
{
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 ) ;
return new BrandLogoOutput
{
PortalUrl = FileStorage . GetPublicUrl ( entity . AppKey ) ,
SiteUrl = FileStorage . GetPublicUrl ( entity . Remark )
} ;
return MapBrandLogoOutput ( entity ) ;
}
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 ( )
{
var entity = await SystemOtherConfigRepository . GetByConfigCodeAsync ( SystemOtherConfigCodes . PaymentReceiveQr ) ;
@ -291,8 +308,7 @@ public class SystemOtherConfigService : ApplicationService
deleted . ConfigName = "品牌 Logo" ;
deleted . Enabled = true ;
deleted . TimeoutSeconds = 30 ;
deleted . BaseUrl = null ;
deleted . AppSecret = null ;
// 保留 AppKey/Remark/BaseUrl/AppSecret 中的 Logo object key, 避免恢复时丢图
await SystemOtherConfigRepository . UpdateAsync ( deleted ) ;
return deleted ;
}