Commit d75c03414606da84df19df12f8ed0a832cbba553
1 parent
94c284c5
2026-10-21泰鄂代码优化
Showing
162 changed files
with
5056 additions
and
773 deletions
Too many changes.
To preserve performance only 100 of 162 files are displayed.
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore.Authentication.OAuth/AuthticationErrCodeModel.cs
| @@ -20,7 +20,7 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth | @@ -20,7 +20,7 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth | ||
| 20 | if (model.error != null) | 20 | if (model.error != null) |
| 21 | { | 21 | { |
| 22 | 22 | ||
| 23 | - throw new Exception($"第三方授权返回错误,错误码:【{model.error}】,错误详情:【{model.error_description}】"); | 23 | + throw new Exception($"Third-party authorization failed. Code: [{model.error}]. Details: [{model.error_description}]"); |
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore.Authentication.OAuth/OAuthAuthenticationHandler.cs
| @@ -54,7 +54,7 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth | @@ -54,7 +54,7 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth | ||
| 54 | var content = await response.Content.ReadAsStringAsync(); | 54 | var content = await response.Content.ReadAsStringAsync(); |
| 55 | if (!response.IsSuccessStatusCode) | 55 | if (!response.IsSuccessStatusCode) |
| 56 | { | 56 | { |
| 57 | - throw new Exception($"授权服务器请求错误,请求地址:{queryUrl},错误信息:{content}"); | 57 | + throw new Exception($"Authorization server request failed. URL: {queryUrl}. Error: {content}"); |
| 58 | } | 58 | } |
| 59 | VerifyErrResponse(content); | 59 | VerifyErrResponse(content); |
| 60 | var model = Newtonsoft.Json.JsonConvert.DeserializeObject<HttpModel>(content); | 60 | var model = Newtonsoft.Json.JsonConvert.DeserializeObject<HttpModel>(content); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs
| @@ -109,7 +109,7 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter | @@ -109,7 +109,7 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter | ||
| 109 | // 非友好异常也必须带上 errors,避免前端 errors:null 无提示 | 109 | // 非友好异常也必须带上 errors,避免前端 errors:null 无提示 |
| 110 | var baseEx = exception.GetBaseException(); | 110 | var baseEx = exception.GetBaseException(); |
| 111 | errors = string.IsNullOrWhiteSpace(baseEx.Message) | 111 | errors = string.IsNullOrWhiteSpace(baseEx.Message) |
| 112 | - ? "服务器内部错误" | 112 | + ? "Internal server error" |
| 113 | : baseEx.Message; | 113 | : baseEx.Message; |
| 114 | statusCode = StatusCodes.Status500InternalServerError; | 114 | statusCode = StatusCodes.Status500InternalServerError; |
| 115 | } | 115 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Providers/RESTfulResultProvider.cs
| @@ -77,7 +77,7 @@ public class RESTfulResultProvider : IUnifyResultProvider,ITransientDependency | @@ -77,7 +77,7 @@ public class RESTfulResultProvider : IUnifyResultProvider,ITransientDependency | ||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /// <summary> | 79 | /// <summary> |
| 80 | - /// 验证失败/业务异常返回值 | 80 | + /// 验证失败/Business error.返回值 |
| 81 | /// </summary> | 81 | /// </summary> |
| 82 | /// <param name="context"></param> | 82 | /// <param name="context"></param> |
| 83 | /// <param name="metadata"></param> | 83 | /// <param name="metadata"></param> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/DateHelper.cs
| @@ -16,7 +16,7 @@ namespace Yi.Framework.Core.Helper | @@ -16,7 +16,7 @@ namespace Yi.Framework.Core.Helper | ||
| 16 | public static string TimeSubTract(DateTime time1, DateTime time2) | 16 | public static string TimeSubTract(DateTime time1, DateTime time2) |
| 17 | { | 17 | { |
| 18 | TimeSpan subTract = time1.Subtract(time2); | 18 | TimeSpan subTract = time1.Subtract(time2); |
| 19 | - return $"{subTract.Days} 天 {subTract.Hours} 时 {subTract.Minutes} 分 "; | 19 | + return $"{subTract.Days} days. {subTract.Hours} 时 {subTract.Minutes} 分 "; |
| 20 | } | 20 | } |
| 21 | /// <summary> | 21 | /// <summary> |
| 22 | /// 时间戳转本地时间-时间戳精确到秒 | 22 | /// 时间戳转本地时间-时间戳精确到秒 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/DateTimeHelper.cs
| @@ -85,7 +85,7 @@ namespace Yi.Framework.Core.Helper | @@ -85,7 +85,7 @@ namespace Yi.Framework.Core.Helper | ||
| 85 | string sMilliSecond = milliSecond < 10 ? "0" + milliSecond : "" + milliSecond;//毫秒 | 85 | string sMilliSecond = milliSecond < 10 ? "0" + milliSecond : "" + milliSecond;//毫秒 |
| 86 | sMilliSecond = milliSecond < 100 ? "0" + sMilliSecond : "" + sMilliSecond; | 86 | sMilliSecond = milliSecond < 100 ? "0" + sMilliSecond : "" + sMilliSecond; |
| 87 | 87 | ||
| 88 | - return string.Format("{0} 天 {1} 小时 {2} 分 {3} 秒", sDay, sHour, sMinute, sSecond); | 88 | + return string.Format("{0} days. {1} 小时 {2} 分 {3} 秒", sDay, sHour, sMinute, sSecond); |
| 89 | } | 89 | } |
| 90 | #endregion | 90 | #endregion |
| 91 | 91 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/MD5Hepler.cs
| @@ -86,7 +86,7 @@ namespace Yi.Framework.Core.Helper | @@ -86,7 +86,7 @@ namespace Yi.Framework.Core.Helper | ||
| 86 | } | 86 | } |
| 87 | catch | 87 | catch |
| 88 | { | 88 | { |
| 89 | - throw new Exception($"错误的 password 字符串:【{password}】"); | 89 | + throw new Exception($"Invalid password string: [{password}]"); |
| 90 | } | 90 | } |
| 91 | return pwd; | 91 | return pwd; |
| 92 | } | 92 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.Core/Helper/RSAFileHelper.cs
| @@ -24,7 +24,7 @@ namespace Yi.Framework.Core.Helper | @@ -24,7 +24,7 @@ namespace Yi.Framework.Core.Helper | ||
| 24 | string rootPath = Directory.GetCurrentDirectory(); | 24 | string rootPath = Directory.GetCurrentDirectory(); |
| 25 | string filePath = Path.Combine(rootPath, fileName); | 25 | string filePath = Path.Combine(rootPath, fileName); |
| 26 | if (!File.Exists(filePath)) | 26 | if (!File.Exists(filePath)) |
| 27 | - throw new Exception("文件不存在"); | 27 | + throw new Exception("File does not exist."); |
| 28 | string key = File.ReadAllText(filePath); | 28 | string key = File.ReadAllText(filePath); |
| 29 | var rsa = RSA.Create(); | 29 | var rsa = RSA.Create(); |
| 30 | rsa.ImportFromPem(key.AsSpan()); | 30 | rsa.ImportFromPem(key.AsSpan()); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCacheCrudAppService.cs
| @@ -99,7 +99,7 @@ namespace Yi.Framework.Ddd.Application | @@ -99,7 +99,7 @@ namespace Yi.Framework.Ddd.Application | ||
| 99 | // 建议实现两种缓存策略: | 99 | // 建议实现两种缓存策略: |
| 100 | // 1. 全表缓存: 适用于数据量小且变动不频繁的场景 | 100 | // 1. 全表缓存: 适用于数据量小且变动不频繁的场景 |
| 101 | // 2. 按需缓存: 仅缓存常用数据,适用于大数据量场景 | 101 | // 2. 按需缓存: 仅缓存常用数据,适用于大数据量场景 |
| 102 | - throw new NotImplementedException("请实现具体的缓存查询策略"); | 102 | + throw new NotImplementedException("Implement a concrete cache query strategy."); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /// <summary> | 105 | /// <summary> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCrudAppService.cs
| @@ -259,7 +259,7 @@ namespace Yi.Framework.Ddd.Application | @@ -259,7 +259,7 @@ namespace Yi.Framework.Ddd.Application | ||
| 259 | /// </summary> | 259 | /// </summary> |
| 260 | public virtual Task PostImportExcelAsync(List<TCreateInput> input) | 260 | public virtual Task PostImportExcelAsync(List<TCreateInput> input) |
| 261 | { | 261 | { |
| 262 | - throw new NotImplementedException("请在实现类中重写此方法以支持Excel导入"); | 262 | + throw new NotImplementedException("Override this method in the implementation class to support Excel import."); |
| 263 | } | 263 | } |
| 264 | } | 264 | } |
| 265 | } | 265 | } |
| 266 | \ No newline at end of file | 266 | \ No newline at end of file |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/Repositories/SqlSugarRepository.cs
| @@ -395,7 +395,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories | @@ -395,7 +395,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories | ||
| 395 | catch (VersionExceptions ex) | 395 | catch (VersionExceptions ex) |
| 396 | { | 396 | { |
| 397 | throw new AbpDbConcurrencyException( | 397 | throw new AbpDbConcurrencyException( |
| 398 | - $"{ex.Message}[更新失败:ConcurrencyStamp不是最新版本],entityInfo:{updateObj}", ex); | 398 | + $"{ex.Message}[Update failed: ConcurrencyStamp is not the latest version], entityInfo: {updateObj}", ex); |
| 399 | } | 399 | } |
| 400 | } | 400 | } |
| 401 | } | 401 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/SqlSugarDbContextFactory.cs
| @@ -184,7 +184,7 @@ namespace Yi.Framework.SqlSugarCore | @@ -184,7 +184,7 @@ namespace Yi.Framework.SqlSugarCore | ||
| 184 | // 验证数据库类型配置 | 184 | // 验证数据库类型配置 |
| 185 | if (dbConnOptions.DbType is null) | 185 | if (dbConnOptions.DbType is null) |
| 186 | { | 186 | { |
| 187 | - throw new ArgumentException("未配置数据库类型(DbType)"); | 187 | + throw new ArgumentException("Database type (DbType) is not configured."); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | // 配置读写分离 | 190 | // 配置读写分离 |
| @@ -193,7 +193,7 @@ namespace Yi.Framework.SqlSugarCore | @@ -193,7 +193,7 @@ namespace Yi.Framework.SqlSugarCore | ||
| 193 | { | 193 | { |
| 194 | if (dbConnOptions.ReadUrl is null) | 194 | if (dbConnOptions.ReadUrl is null) |
| 195 | { | 195 | { |
| 196 | - throw new ArgumentException("启用读写分离但未配置读库连接字符串"); | 196 | + throw new ArgumentException("Read/write splitting is enabled but read database connection string is not configured."); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | slaveConfigs.AddRange(dbConnOptions.ReadUrl.Select(url => | 199 | slaveConfigs.AddRange(dbConnOptions.ReadUrl.Select(url => |
| @@ -327,7 +327,7 @@ namespace Yi.Framework.SqlSugarCore | @@ -327,7 +327,7 @@ namespace Yi.Framework.SqlSugarCore | ||
| 327 | break; | 327 | break; |
| 328 | 328 | ||
| 329 | default: | 329 | default: |
| 330 | - throw new NotImplementedException($"数据库类型 {DbConnectionOptions.DbType} 的备份操作尚未实现"); | 330 | + throw new NotImplementedException($"Backup is not implemented for database type {DbConnectionOptions.DbType}."); |
| 331 | } | 331 | } |
| 332 | } | 332 | } |
| 333 | } | 333 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/TenantConfigurationWrapper.cs
| @@ -51,7 +51,7 @@ public class TenantConfigurationWrapper : ITransientDependency | @@ -51,7 +51,7 @@ public class TenantConfigurationWrapper : ITransientDependency | ||
| 51 | var config = await TenantStoreService.FindAsync(CurrentTenantService.Id.Value); | 51 | var config = await TenantStoreService.FindAsync(CurrentTenantService.Id.Value); |
| 52 | if (config == null) | 52 | if (config == null) |
| 53 | { | 53 | { |
| 54 | - throw new ApplicationException($"未找到租户信息,租户Id:{CurrentTenantService.Id}"); | 54 | + throw new ApplicationException($"Tenant information not found. Tenant Id: {CurrentTenantService.Id}"); |
| 55 | } | 55 | } |
| 56 | return config; | 56 | return config; |
| 57 | } | 57 | } |
| @@ -62,7 +62,7 @@ public class TenantConfigurationWrapper : ITransientDependency | @@ -62,7 +62,7 @@ public class TenantConfigurationWrapper : ITransientDependency | ||
| 62 | var config = await TenantStoreService.FindAsync(CurrentTenantService.Name); | 62 | var config = await TenantStoreService.FindAsync(CurrentTenantService.Name); |
| 63 | if (config == null) | 63 | if (config == null) |
| 64 | { | 64 | { |
| 65 | - throw new ApplicationException($"未找到租户信息,租户名称:{CurrentTenantService.Name}"); | 65 | + throw new ApplicationException($"Tenant information not found. Tenant name: {CurrentTenantService.Name}"); |
| 66 | } | 66 | } |
| 67 | return config; | 67 | return config; |
| 68 | } | 68 | } |
| @@ -78,7 +78,7 @@ public class TenantConfigurationWrapper : ITransientDependency | @@ -78,7 +78,7 @@ public class TenantConfigurationWrapper : ITransientDependency | ||
| 78 | { | 78 | { |
| 79 | if (string.IsNullOrWhiteSpace(DbConnectionOptions.Url)) | 79 | if (string.IsNullOrWhiteSpace(DbConnectionOptions.Url)) |
| 80 | { | 80 | { |
| 81 | - throw new ApplicationException("未配置主库连接字符串 DbConnOptions.Url"); | 81 | + throw new ApplicationException("Host database connection string DbConnOptions.Url is not configured."); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | return new TenantConfiguration | 84 | return new TenantConfiguration |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerCheckExpiredOutputDto.cs
| @@ -31,6 +31,6 @@ public class LabelAlertTimerCheckExpiredOutputDto | @@ -31,6 +31,6 @@ public class LabelAlertTimerCheckExpiredOutputDto | ||
| 31 | 31 | ||
| 32 | public string? FormattedExpiresAt { get; set; } | 32 | public string? FormattedExpiresAt { get; set; } |
| 33 | 33 | ||
| 34 | - /// <summary>固定文案:亲爱的{userName},您的{labelName}标签已过期,请及时处理</summary> | 34 | + /// <summary>固定文案:Hi {userName}, your {labelName} label has expired. Please take action.</summary> |
| 35 | public string? ExpiredMessageTemplate { get; set; } | 35 | public string? ExpiredMessageTemplate { get; set; } |
| 36 | } | 36 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerListItemDto.cs
| @@ -53,6 +53,6 @@ public class LabelAlertTimerListItemDto | @@ -53,6 +53,6 @@ public class LabelAlertTimerListItemDto | ||
| 53 | 53 | ||
| 54 | public string? PrintedByUserName { get; set; } | 54 | public string? PrintedByUserName { get; set; } |
| 55 | 55 | ||
| 56 | - /// <summary>固定文案:亲爱的{userName},您的{labelName}标签已过期,请及时处理</summary> | 56 | + /// <summary>固定文案:Hi {userName}, your {labelName} label has expired. Please take action.</summary> |
| 57 | public string ExpiredMessageTemplate { get; set; } = string.Empty; | 57 | public string ExpiredMessageTemplate { get; set; } = string.Empty; |
| 58 | } | 58 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsTemplatePrintStatGetListInputVo.cs
| @@ -16,7 +16,7 @@ public class ReportsTemplatePrintStatGetListInputVo : PagedAndSortedResultReques | @@ -16,7 +16,7 @@ public class ReportsTemplatePrintStatGetListInputVo : PagedAndSortedResultReques | ||
| 16 | /// <summary>门店(<c>location.Id</c>)</summary> | 16 | /// <summary>门店(<c>location.Id</c>)</summary> |
| 17 | public string? LocationId { get; set; } | 17 | public string? LocationId { get; set; } |
| 18 | 18 | ||
| 19 | - /// <summary>统计开始日期(含);未传时与 <see cref="EndDate"/> 组成默认近 30 天</summary> | 19 | + /// <summary>统计开始日期(含);未传时与 <see cref="EndDate"/> 组成默认近 30 days.</summary> |
| 20 | public DateTime? StartDate { get; set; } | 20 | public DateTime? StartDate { get; set; } |
| 21 | 21 | ||
| 22 | /// <summary>统计结束日期(含);未传时默认为今天</summary> | 22 | /// <summary>统计结束日期(含);未传时默认为今天</summary> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/UsAppProductCategoryNodeDto.cs
| @@ -5,10 +5,10 @@ namespace FoodLabeling.Application.Contracts.Dtos.UsAppLabeling; | @@ -5,10 +5,10 @@ namespace FoodLabeling.Application.Contracts.Dtos.UsAppLabeling; | ||
| 5 | /// </summary> | 5 | /// </summary> |
| 6 | public class UsAppProductCategoryNodeDto | 6 | public class UsAppProductCategoryNodeDto |
| 7 | { | 7 | { |
| 8 | - /// <summary>产品分类Id;当产品未归类或分类不存在时为空</summary> | 8 | + /// <summary>产品分类Id;当产品未归类或Category not found.时为空</summary> |
| 9 | public string? CategoryId { get; set; } | 9 | public string? CategoryId { get; set; } |
| 10 | 10 | ||
| 11 | - /// <summary>产品分类图片地址;当产品未归类或分类不存在时为空</summary> | 11 | + /// <summary>产品分类图片地址;当产品未归类或Category not found.时为空</summary> |
| 12 | public string? CategoryPhotoUrl { get; set; } | 12 | public string? CategoryPhotoUrl { get; set; } |
| 13 | 13 | ||
| 14 | /// <summary>分类显示名;空为「无」</summary> | 14 | /// <summary>分类显示名;空为「无」</summary> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAuthSessionAppService.cs
| @@ -21,7 +21,7 @@ public interface IAuthSessionAppService : IApplicationService | @@ -21,7 +21,7 @@ public interface IAuthSessionAppService : IApplicationService | ||
| 21 | /// </remarks> | 21 | /// </remarks> |
| 22 | /// <returns>用户简要信息、权限码与菜单树</returns> | 22 | /// <returns>用户简要信息、权限码与菜单树</returns> |
| 23 | /// <response code="200">成功</response> | 23 | /// <response code="200">成功</response> |
| 24 | - /// <response code="401">未登录或令牌无效</response> | 24 | + /// <response code="401">You are not signed in.或令牌无效</response> |
| 25 | /// <response code="500">服务器错误</response> | 25 | /// <response code="500">服务器错误</response> |
| 26 | Task<CurrentUserMenuPermissionsOutputDto> GetMyMenusAsync(); | 26 | Task<CurrentUserMenuPermissionsOutputDto> GetMyMenusAsync(); |
| 27 | 27 | ||
| @@ -29,7 +29,7 @@ public interface IAuthSessionAppService : IApplicationService | @@ -29,7 +29,7 @@ public interface IAuthSessionAppService : IApplicationService | ||
| 29 | /// 退出登录:清除服务端用户信息缓存(JWT 仍由前端丢弃) | 29 | /// 退出登录:清除服务端用户信息缓存(JWT 仍由前端丢弃) |
| 30 | /// </summary> | 30 | /// </summary> |
| 31 | /// <remarks> | 31 | /// <remarks> |
| 32 | - /// 与框架 <c>AccountService.PostLogout</c> 一致;未登录时返回 <c>false</c>。 | 32 | + /// 与框架 <c>AccountService.PostLogout</c> 一致;You are not signed in.时返回 <c>false</c>。 |
| 33 | /// </remarks> | 33 | /// </remarks> |
| 34 | /// <returns>是否执行了缓存清理(已登录为 true)</returns> | 34 | /// <returns>是否执行了缓存清理(已登录为 true)</returns> |
| 35 | /// <response code="200">成功</response> | 35 | /// <response code="200">成功</response> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IReportsAppService.cs
| @@ -58,7 +58,7 @@ public interface IReportsAppService : IApplicationService | @@ -58,7 +58,7 @@ public interface IReportsAppService : IApplicationService | ||
| 58 | /// | 58 | /// |
| 59 | /// 参数说明: | 59 | /// 参数说明: |
| 60 | /// - SkipCount / MaxResultCount: 分页(SkipCount 为 1-based 页码约定,与项目其它列表一致) | 60 | /// - SkipCount / MaxResultCount: 分页(SkipCount 为 1-based 页码约定,与项目其它列表一致) |
| 61 | - /// - StartDate / EndDate: 统计区间(含起止日;默认近 30 天至今天) | 61 | + /// - StartDate / EndDate: 统计区间(含起止日;默认近 30 days.至今天) |
| 62 | /// - PartnerId / GroupId / LocationId: 组织范围筛选 | 62 | /// - PartnerId / GroupId / LocationId: 组织范围筛选 |
| 63 | /// - Keyword: 模板名称模糊匹配 | 63 | /// - Keyword: 模板名称模糊匹配 |
| 64 | /// - Sorting: 可选 <c>PrintedCount desc</c>(默认按打印数降序) | 64 | /// - Sorting: 可选 <c>PrintedCount desc</c>(默认按打印数降序) |
| @@ -66,7 +66,7 @@ public interface IReportsAppService : IApplicationService | @@ -66,7 +66,7 @@ public interface IReportsAppService : IApplicationService | ||
| 66 | /// <param name="input">分页与筛选条件</param> | 66 | /// <param name="input">分页与筛选条件</param> |
| 67 | /// <returns>各模板打印数量列表</returns> | 67 | /// <returns>各模板打印数量列表</returns> |
| 68 | /// <response code="200">成功返回分页统计</response> | 68 | /// <response code="200">成功返回分页统计</response> |
| 69 | - /// <response code="400">入参无效或未登录</response> | 69 | + /// <response code="400">入参无效或You are not signed in.</response> |
| 70 | /// <response code="500">服务器错误</response> | 70 | /// <response code="500">服务器错误</response> |
| 71 | Task<PagedResultWithPageDto<ReportsTemplatePrintStatListItemDto>> GetTemplatePrintStatListAsync( | 71 | Task<PagedResultWithPageDto<ReportsTemplatePrintStatListItemDto>> GetTemplatePrintStatListAsync( |
| 72 | ReportsTemplatePrintStatGetListInputVo input); | 72 | ReportsTemplatePrintStatGetListInputVo input); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IUsAppAuthAppService.cs
| @@ -45,7 +45,7 @@ public interface IUsAppAuthAppService : IApplicationService | @@ -45,7 +45,7 @@ public interface IUsAppAuthAppService : IApplicationService | ||
| 45 | /// </summary> | 45 | /// </summary> |
| 46 | /// <returns>资料 DTO</returns> | 46 | /// <returns>资料 DTO</returns> |
| 47 | /// <response code="200">成功</response> | 47 | /// <response code="200">成功</response> |
| 48 | - /// <response code="400">未登录或用户不存在</response> | 48 | + /// <response code="400">You are not signed in.或User not found.</response> |
| 49 | /// <response code="500">服务器错误</response> | 49 | /// <response code="500">服务器错误</response> |
| 50 | Task<UsAppMyProfileOutputDto> GetMyProfileAsync(); | 50 | Task<UsAppMyProfileOutputDto> GetMyProfileAsync(); |
| 51 | 51 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Json/StringOrFirstArrayItemJsonConverter.cs
| @@ -33,7 +33,7 @@ public sealed class StringOrFirstArrayItemJsonConverter : JsonConverter<string?> | @@ -33,7 +33,7 @@ public sealed class StringOrFirstArrayItemJsonConverter : JsonConverter<string?> | ||
| 33 | 33 | ||
| 34 | if (reader.TokenType != JsonTokenType.String) | 34 | if (reader.TokenType != JsonTokenType.String) |
| 35 | { | 35 | { |
| 36 | - throw new JsonException("partnerId 数组元素必须是字符串"); | 36 | + throw new JsonException("partnerId array elements must be strings."); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | var item = reader.GetString()?.Trim(); | 39 | var item = reader.GetString()?.Trim(); |
| @@ -46,7 +46,7 @@ public sealed class StringOrFirstArrayItemJsonConverter : JsonConverter<string?> | @@ -46,7 +46,7 @@ public sealed class StringOrFirstArrayItemJsonConverter : JsonConverter<string?> | ||
| 46 | return first; | 46 | return first; |
| 47 | } | 47 | } |
| 48 | default: | 48 | default: |
| 49 | - throw new JsonException($"无法将 JSON token {reader.TokenType} 转为字符串(partnerId)"); | 49 | + throw new JsonException($"Cannot convert JSON token {reader.TokenType} to string (partnerId)."); |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | 52 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
| @@ -25,6 +25,8 @@ public class FoodLabelingApplicationModule : AbpModule | @@ -25,6 +25,8 @@ public class FoodLabelingApplicationModule : AbpModule | ||
| 25 | context.Services.GetConfiguration().GetSection(FoodLabelingBatchImportOptions.SectionName)); | 25 | context.Services.GetConfiguration().GetSection(FoodLabelingBatchImportOptions.SectionName)); |
| 26 | Configure<FoodLabelingAppUpdateOptions>( | 26 | Configure<FoodLabelingAppUpdateOptions>( |
| 27 | context.Services.GetConfiguration().GetSection(FoodLabelingAppUpdateOptions.SectionName)); | 27 | context.Services.GetConfiguration().GetSection(FoodLabelingAppUpdateOptions.SectionName)); |
| 28 | + Configure<FoodLabelingPictureOptions>( | ||
| 29 | + context.Services.GetConfiguration().GetSection(FoodLabelingPictureOptions.SectionName)); | ||
| 28 | 30 | ||
| 29 | // 任意业务写接口成功后刷新系统编辑时间戳,供 my-menus.lastUpdated 使用 | 31 | // 任意业务写接口成功后刷新系统编辑时间戳,供 my-menus.lastUpdated 使用 |
| 30 | Configure<MvcOptions>(options => | 32 | Configure<MvcOptions>(options => |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AllScopeBindingHelper.cs
| @@ -574,7 +574,7 @@ public static class AllScopeBindingHelper | @@ -574,7 +574,7 @@ public static class AllScopeBindingHelper | ||
| 574 | 574 | ||
| 575 | if (availabilityType != ScopeAll && availabilityType != ScopeSpecified) | 575 | if (availabilityType != ScopeAll && availabilityType != ScopeSpecified) |
| 576 | { | 576 | { |
| 577 | - throw new UserFriendlyException("门店可用范围不合法(ALL/SPECIFIED)"); | 577 | + throw new UserFriendlyException("Invalid location availability scope (ALL/SPECIFIED)."); |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | var locationSpecified = string.Equals(availabilityType, ScopeSpecified, StringComparison.OrdinalIgnoreCase); | 580 | var locationSpecified = string.Equals(availabilityType, ScopeSpecified, StringComparison.OrdinalIgnoreCase); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AuthScopeQueryHelper.cs
| @@ -19,7 +19,7 @@ public static class AuthScopeQueryHelper | @@ -19,7 +19,7 @@ public static class AuthScopeQueryHelper | ||
| 19 | { | 19 | { |
| 20 | if (!currentUser.Id.HasValue) | 20 | if (!currentUser.Id.HasValue) |
| 21 | { | 21 | { |
| 22 | - throw new UserFriendlyException("用户未登录"); | 22 | + throw new UserFriendlyException("You are not signed in."); |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | 25 | ||
| @@ -52,7 +52,7 @@ public static class AuthScopeQueryHelper | @@ -52,7 +52,7 @@ public static class AuthScopeQueryHelper | ||
| 52 | { | 52 | { |
| 53 | EnsureLoggedIn(currentUser); | 53 | EnsureLoggedIn(currentUser); |
| 54 | 54 | ||
| 55 | - var pid = RequireNonEmpty(partnerId, "公司标识不能为空"); | 55 | + var pid = RequireNonEmpty(partnerId, "Company identifier is required."); |
| 56 | await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid); | 56 | await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid); |
| 57 | 57 | ||
| 58 | var listScope = await GroupListScopeHelper.ResolveAsync(currentUser, dbContext); | 58 | var listScope = await GroupListScopeHelper.ResolveAsync(currentUser, dbContext); |
| @@ -80,15 +80,15 @@ public static class AuthScopeQueryHelper | @@ -80,15 +80,15 @@ public static class AuthScopeQueryHelper | ||
| 80 | { | 80 | { |
| 81 | EnsureLoggedIn(currentUser); | 81 | EnsureLoggedIn(currentUser); |
| 82 | 82 | ||
| 83 | - var pid = RequireNonEmpty(partnerId, "公司标识不能为空"); | ||
| 84 | - var gid = RequireNonEmpty(groupId, "区域标识不能为空"); | 83 | + var pid = RequireNonEmpty(partnerId, "Company identifier is required."); |
| 84 | + var gid = RequireNonEmpty(groupId, "Region identifier is required."); | ||
| 85 | await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid); | 85 | await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid); |
| 86 | 86 | ||
| 87 | var group = await dbContext.SqlSugarClient.Queryable<FlGroupDbEntity>() | 87 | var group = await dbContext.SqlSugarClient.Queryable<FlGroupDbEntity>() |
| 88 | .FirstAsync(g => !g.IsDeleted && g.Id == gid && g.PartnerId == pid); | 88 | .FirstAsync(g => !g.IsDeleted && g.Id == gid && g.PartnerId == pid); |
| 89 | if (group is null) | 89 | if (group is null) |
| 90 | { | 90 | { |
| 91 | - throw new UserFriendlyException("区域不存在或不属于所选公司"); | 91 | + throw new UserFriendlyException("Region not found or does not belong to the selected company."); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | var groupScope = await GroupListScopeHelper.ResolveAsync(currentUser, dbContext); | 94 | var groupScope = await GroupListScopeHelper.ResolveAsync(currentUser, dbContext); |
| @@ -98,12 +98,12 @@ public static class AuthScopeQueryHelper | @@ -98,12 +98,12 @@ public static class AuthScopeQueryHelper | ||
| 98 | var allowedGroup = groupScope.AllowedGroupIds; | 98 | var allowedGroup = groupScope.AllowedGroupIds; |
| 99 | if (allowedPartner.Count > 0 && !allowedPartner.Contains(pid, StringComparer.OrdinalIgnoreCase)) | 99 | if (allowedPartner.Count > 0 && !allowedPartner.Contains(pid, StringComparer.OrdinalIgnoreCase)) |
| 100 | { | 100 | { |
| 101 | - throw new UserFriendlyException("无权查看该区域"); | 101 | + throw new UserFriendlyException("You do not have permission to view this region."); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | if (allowedGroup.Count > 0 && !allowedGroup.Contains(gid, StringComparer.OrdinalIgnoreCase)) | 104 | if (allowedGroup.Count > 0 && !allowedGroup.Contains(gid, StringComparer.OrdinalIgnoreCase)) |
| 105 | { | 105 | { |
| 106 | - throw new UserFriendlyException("无权查看该区域"); | 106 | + throw new UserFriendlyException("You do not have permission to view this region."); |
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| @@ -111,7 +111,7 @@ public static class AuthScopeQueryHelper | @@ -111,7 +111,7 @@ public static class AuthScopeQueryHelper | ||
| 111 | .FirstAsync(p => !p.IsDeleted && p.Id == pid); | 111 | .FirstAsync(p => !p.IsDeleted && p.Id == pid); |
| 112 | if (partner is null) | 112 | if (partner is null) |
| 113 | { | 113 | { |
| 114 | - throw new UserFriendlyException("公司不存在"); | 114 | + throw new UserFriendlyException("Company not found."); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | var partnerKeys = new List<string> { partner.Id, partner.PartnerName ?? string.Empty } | 117 | var partnerKeys = new List<string> { partner.Id, partner.PartnerName ?? string.Empty } |
| @@ -263,7 +263,7 @@ public static class AuthScopeQueryHelper | @@ -263,7 +263,7 @@ public static class AuthScopeQueryHelper | ||
| 263 | 263 | ||
| 264 | if (!scope.AllowedPartnerIds.Contains(partnerId)) | 264 | if (!scope.AllowedPartnerIds.Contains(partnerId)) |
| 265 | { | 265 | { |
| 266 | - throw new UserFriendlyException("无权查看该公司"); | 266 | + throw new UserFriendlyException("You do not have permission to view this company."); |
| 267 | } | 267 | } |
| 268 | } | 268 | } |
| 269 | 269 | ||
| @@ -288,13 +288,13 @@ public static class AuthScopeQueryHelper | @@ -288,13 +288,13 @@ public static class AuthScopeQueryHelper | ||
| 288 | ISqlSugarDbContext dbContext, | 288 | ISqlSugarDbContext dbContext, |
| 289 | AuthScopeSelectLocationInputVo input) | 289 | AuthScopeSelectLocationInputVo input) |
| 290 | { | 290 | { |
| 291 | - var pid = RequireNonEmpty(input.PartnerId, "请选择公司"); | 291 | + var pid = RequireNonEmpty(input.PartnerId, "Select a company."); |
| 292 | var gid = RequireNonEmpty(input.GroupId, "请选择区域"); | 292 | var gid = RequireNonEmpty(input.GroupId, "请选择区域"); |
| 293 | - var lid = RequireNonEmpty(input.LocationId, "请选择门店"); | 293 | + var lid = RequireNonEmpty(input.LocationId, "Select a location."); |
| 294 | 294 | ||
| 295 | if (!Guid.TryParse(lid, out var locationGuid)) | 295 | if (!Guid.TryParse(lid, out var locationGuid)) |
| 296 | { | 296 | { |
| 297 | - throw new UserFriendlyException("无效的门店标识"); | 297 | + throw new UserFriendlyException("Invalid location identifier."); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid); | 300 | await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid); |
| @@ -303,21 +303,21 @@ public static class AuthScopeQueryHelper | @@ -303,21 +303,21 @@ public static class AuthScopeQueryHelper | ||
| 303 | .FirstAsync(g => !g.IsDeleted && g.Id == gid && g.PartnerId == pid); | 303 | .FirstAsync(g => !g.IsDeleted && g.Id == gid && g.PartnerId == pid); |
| 304 | if (group is null) | 304 | if (group is null) |
| 305 | { | 305 | { |
| 306 | - throw new UserFriendlyException("区域不存在或不属于所选公司"); | 306 | + throw new UserFriendlyException("Region not found or does not belong to the selected company."); |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | var partner = await dbContext.SqlSugarClient.Queryable<FlPartnerDbEntity>() | 309 | var partner = await dbContext.SqlSugarClient.Queryable<FlPartnerDbEntity>() |
| 310 | .FirstAsync(p => !p.IsDeleted && p.Id == pid); | 310 | .FirstAsync(p => !p.IsDeleted && p.Id == pid); |
| 311 | if (partner is null) | 311 | if (partner is null) |
| 312 | { | 312 | { |
| 313 | - throw new UserFriendlyException("公司不存在"); | 313 | + throw new UserFriendlyException("Company not found."); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | var loc = await dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() | 316 | var loc = await dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() |
| 317 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); | 317 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); |
| 318 | if (loc is null) | 318 | if (loc is null) |
| 319 | { | 319 | { |
| 320 | - throw new UserFriendlyException("门店不存在或已删除"); | 320 | + throw new UserFriendlyException("Location not found or removed."); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | var partnerKeys = new List<string> { partner.Id, partner.PartnerName ?? string.Empty } | 323 | var partnerKeys = new List<string> { partner.Id, partner.PartnerName ?? string.Empty } |
| @@ -331,7 +331,7 @@ public static class AuthScopeQueryHelper | @@ -331,7 +331,7 @@ public static class AuthScopeQueryHelper | ||
| 331 | if (!partnerKeys.Contains(locPartner, StringComparer.Ordinal) || | 331 | if (!partnerKeys.Contains(locPartner, StringComparer.Ordinal) || |
| 332 | !string.Equals(locGroup, groupName, StringComparison.Ordinal)) | 332 | !string.Equals(locGroup, groupName, StringComparison.Ordinal)) |
| 333 | { | 333 | { |
| 334 | - throw new UserFriendlyException("门店与所选公司/区域不匹配"); | 334 | + throw new UserFriendlyException("Location does not match the selected company/region."); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | return new AuthScopeSelectLocationOutputDto | 337 | return new AuthScopeSelectLocationOutputDto |
| @@ -359,14 +359,14 @@ public static class AuthScopeQueryHelper | @@ -359,14 +359,14 @@ public static class AuthScopeQueryHelper | ||
| 359 | { | 359 | { |
| 360 | if (!Guid.TryParse(locationId.Trim(), out var locationGuid)) | 360 | if (!Guid.TryParse(locationId.Trim(), out var locationGuid)) |
| 361 | { | 361 | { |
| 362 | - throw new UserFriendlyException("无效的门店标识"); | 362 | + throw new UserFriendlyException("Invalid location identifier."); |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | var loc = await dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() | 365 | var loc = await dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() |
| 366 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); | 366 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); |
| 367 | if (loc is null) | 367 | if (loc is null) |
| 368 | { | 368 | { |
| 369 | - throw new UserFriendlyException("门店不存在或已删除"); | 369 | + throw new UserFriendlyException("Location not found or removed."); |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | var pid = (partnerId ?? string.Empty).Trim(); | 372 | var pid = (partnerId ?? string.Empty).Trim(); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/BoundLabelBindingHelper.cs
| @@ -63,7 +63,7 @@ public static class BoundLabelBindingHelper | @@ -63,7 +63,7 @@ public static class BoundLabelBindingHelper | ||
| 63 | } | 63 | } |
| 64 | catch (Exception ex) when (throwIfMissing) | 64 | catch (Exception ex) when (throwIfMissing) |
| 65 | { | 65 | { |
| 66 | - throw new UserFriendlyException($"绑定标签表未初始化,请执行 fl_bound_label.sql:{ex.Message}"); | 66 | + throw new UserFriendlyException($"Bound label table is not initialized. Run fl_bound_label.sql: {ex.Message}"); |
| 67 | } | 67 | } |
| 68 | catch | 68 | catch |
| 69 | { | 69 | { |
| @@ -78,7 +78,7 @@ public static class BoundLabelBindingHelper | @@ -78,7 +78,7 @@ public static class BoundLabelBindingHelper | ||
| 78 | 78 | ||
| 79 | if (throwIfMissing) | 79 | if (throwIfMissing) |
| 80 | { | 80 | { |
| 81 | - throw new UserFriendlyException("绑定标签表未初始化,请执行 fl_bound_label.sql"); | 81 | + throw new UserFriendlyException("Bound label table is not initialized. Run fl_bound_label.sql."); |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | 84 | ||
| @@ -331,7 +331,7 @@ public static class BoundLabelBindingHelper | @@ -331,7 +331,7 @@ public static class BoundLabelBindingHelper | ||
| 331 | { | 331 | { |
| 332 | if (throwIfMissing) | 332 | if (throwIfMissing) |
| 333 | { | 333 | { |
| 334 | - throw new UserFriendlyException($"绑定标签不存在:{token}"); | 334 | + throw new UserFriendlyException($"Bound label not found: {token}"); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | continue; | 337 | continue; |
| @@ -374,7 +374,7 @@ public static class BoundLabelBindingHelper | @@ -374,7 +374,7 @@ public static class BoundLabelBindingHelper | ||
| 374 | { | 374 | { |
| 375 | if (throwIfMissing) | 375 | if (throwIfMissing) |
| 376 | { | 376 | { |
| 377 | - throw new UserFriendlyException($"绑定培训文件不存在:{token}"); | 377 | + throw new UserFriendlyException($"Bound training file not found: {token}"); |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | continue; | 380 | continue; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/CategoryAppearanceStorageHelper.cs
| @@ -36,7 +36,7 @@ public static class CategoryAppearanceStorageHelper | @@ -36,7 +36,7 @@ public static class CategoryAppearanceStorageHelper | ||
| 36 | } | 36 | } |
| 37 | catch (JsonException) | 37 | catch (JsonException) |
| 38 | { | 38 | { |
| 39 | - throw new UserFriendlyException("按钮外观格式不正确,须为合法 JSON(或兼容旧的 TEXT/COLOR/IMAGE)"); | 39 | + throw new UserFriendlyException("Invalid button appearance format; must be valid JSON (or legacy TEXT/COLOR/IMAGE)."); |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | 42 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/FoodLabelingPictureRoot.cs
0 → 100644
| 1 | +using System.Runtime.InteropServices; | ||
| 2 | + | ||
| 3 | +namespace FoodLabeling.Application.Helpers; | ||
| 4 | + | ||
| 5 | +/// <summary>解析图片物理根目录:优先配置,Linux 用 <c>/www/wwwroot/picture/...</c>,Windows 回落到 wwwroot/picture。</summary> | ||
| 6 | +public static class FoodLabelingPictureRoot | ||
| 7 | +{ | ||
| 8 | + public const string LinuxSharedRoot = "/www/wwwroot/picture"; | ||
| 9 | + public const string RequestPath = "/picture"; | ||
| 10 | + | ||
| 11 | + public static string Resolve(string? configuredRoot, string contentRootPath, string? webRootPath) | ||
| 12 | + { | ||
| 13 | + var configured = (configuredRoot ?? string.Empty).Trim(); | ||
| 14 | + if (!string.IsNullOrWhiteSpace(configured) && CanUseConfiguredPath(configured)) | ||
| 15 | + { | ||
| 16 | + Directory.CreateDirectory(configured); | ||
| 17 | + return configured; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || Directory.Exists("/www/wwwroot")) | ||
| 21 | + { | ||
| 22 | + var linux = string.IsNullOrWhiteSpace(configured) | ||
| 23 | + ? Path.Combine(LinuxSharedRoot, "local") | ||
| 24 | + : configured; | ||
| 25 | + Directory.CreateDirectory(linux); | ||
| 26 | + return linux; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + var localBase = !string.IsNullOrWhiteSpace(webRootPath) | ||
| 30 | + ? webRootPath | ||
| 31 | + : Path.Combine(contentRootPath, "wwwroot"); | ||
| 32 | + var local = Path.Combine(localBase, "picture"); | ||
| 33 | + Directory.CreateDirectory(local); | ||
| 34 | + return local; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + private static bool CanUseConfiguredPath(string path) | ||
| 38 | + { | ||
| 39 | + var unix = path.Replace('\\', '/'); | ||
| 40 | + var isLinuxWww = unix.StartsWith("/www/wwwroot/", StringComparison.OrdinalIgnoreCase); | ||
| 41 | + if (isLinuxWww && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !Directory.Exists("/www/wwwroot")) | ||
| 42 | + { | ||
| 43 | + return false; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + return true; | ||
| 47 | + } | ||
| 48 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/GroupListScopeHelper.cs
| @@ -43,6 +43,13 @@ public static class GroupListScopeHelper | @@ -43,6 +43,13 @@ public static class GroupListScopeHelper | ||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | var db = dbContext.SqlSugarClient; | 45 | var db = dbContext.SqlSugarClient; |
| 46 | + var allScopePartnerIds = await LocationScopeBindingHelper.LoadLocationAllPartnerIdsAsync( | ||
| 47 | + db, currentUser.Id.Value); | ||
| 48 | + if (allScopePartnerIds.Count > 0) | ||
| 49 | + { | ||
| 50 | + return new GroupListScope { AllowedPartnerIds = allScopePartnerIds }; | ||
| 51 | + } | ||
| 52 | + | ||
| 46 | var locationIds = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync( | 53 | var locationIds = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync( |
| 47 | db, currentUser.Id.Value); | 54 | db, currentUser.Id.Value); |
| 48 | if (locationIds.Count == 0) | 55 | if (locationIds.Count == 0) |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerDisplayHelper.cs
| @@ -6,7 +6,7 @@ namespace FoodLabeling.Application.Helpers; | @@ -6,7 +6,7 @@ namespace FoodLabeling.Application.Helpers; | ||
| 6 | /// <summary>告警计时器展示字段(格式化过期时刻、弹窗文案、状态)</summary> | 6 | /// <summary>告警计时器展示字段(格式化过期时刻、弹窗文案、状态)</summary> |
| 7 | public static class LabelAlertTimerDisplayHelper | 7 | public static class LabelAlertTimerDisplayHelper |
| 8 | { | 8 | { |
| 9 | - public const string ExpiredMessageTemplate = "亲爱的{userName},您的{labelName}标签已过期,请及时处理"; | 9 | + public const string ExpiredMessageTemplate = "Hi {userName}, your {labelName} label has expired. Please take action."; |
| 10 | 10 | ||
| 11 | public const string StatusRunning = "running"; | 11 | public const string StatusRunning = "running"; |
| 12 | 12 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelBatchTemplateDefaultsHelper.cs
| @@ -222,7 +222,7 @@ public static class LabelBatchTemplateDefaultsHelper | @@ -222,7 +222,7 @@ public static class LabelBatchTemplateDefaultsHelper | ||
| 222 | if (!duplicateCheckSet.Add(key)) | 222 | if (!duplicateCheckSet.Add(key)) |
| 223 | { | 223 | { |
| 224 | throw new UserFriendlyException( | 224 | throw new UserFriendlyException( |
| 225 | - $"模板默认值绑定重复:产品[{row.ProductId}]与标签类型[{row.LabelTypeId}]只能存在一条"); | 225 | + $"Duplicate template default binding: product [{row.ProductId}] and label type [{row.LabelTypeId}] may only have one binding."); |
| 226 | } | 226 | } |
| 227 | } | 227 | } |
| 228 | 228 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
| @@ -132,7 +132,7 @@ public static class LabelEntityPartnerScopeHelper | @@ -132,7 +132,7 @@ public static class LabelEntityPartnerScopeHelper | ||
| 132 | if (string.Equals(partnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) | 132 | if (string.Equals(partnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) |
| 133 | && normalizedPartnerIds.Count == 0) | 133 | && normalizedPartnerIds.Count == 0) |
| 134 | { | 134 | { |
| 135 | - throw new UserFriendlyException("指定适用 Company 时,partnerIds/companyIds 不能为空"); | 135 | + throw new UserFriendlyException("When specifying applicable Company, partnerIds/companyIds is required."); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if (normalizedPartnerIds.Count > 0) | 138 | if (normalizedPartnerIds.Count > 0) |
| @@ -192,7 +192,7 @@ public static class LabelEntityPartnerScopeHelper | @@ -192,7 +192,7 @@ public static class LabelEntityPartnerScopeHelper | ||
| 192 | if (needsPartnerRows && !hasTable) | 192 | if (needsPartnerRows && !hasTable) |
| 193 | { | 193 | { |
| 194 | throw new UserFriendlyException( | 194 | throw new UserFriendlyException( |
| 195 | - "Company 适用范围关联表尚未就绪,请联系管理员执行数据库迁移(fl_label_entity_partner_scope.sql 或 fl_product_category_partner_scope.sql)后重试"); | 195 | + "Company scope association table is not ready. Ask an administrator to run fl_label_entity_partner_scope.sql or fl_product_category_partner_scope.sql, then retry."); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | if (hasTable) | 198 | if (hasTable) |
| @@ -595,7 +595,7 @@ public static class LabelEntityPartnerScopeHelper | @@ -595,7 +595,7 @@ public static class LabelEntityPartnerScopeHelper | ||
| 595 | { | 595 | { |
| 596 | if (type != ScopeAll && type != ScopeSpecified) | 596 | if (type != ScopeAll && type != ScopeSpecified) |
| 597 | { | 597 | { |
| 598 | - throw new UserFriendlyException("适用 Company 范围不合法(ALL/SPECIFIED)"); | 598 | + throw new UserFriendlyException("Invalid applicable Company scope (ALL/SPECIFIED)."); |
| 599 | } | 599 | } |
| 600 | } | 600 | } |
| 601 | 601 | ||
| @@ -617,7 +617,7 @@ public static class LabelEntityPartnerScopeHelper | @@ -617,7 +617,7 @@ public static class LabelEntityPartnerScopeHelper | ||
| 617 | .CountAsync(); | 617 | .CountAsync(); |
| 618 | if (count != partnerIds.Count) | 618 | if (count != partnerIds.Count) |
| 619 | { | 619 | { |
| 620 | - throw new UserFriendlyException("存在无效的 Company(partnerIds/companyIds),请刷新后重试"); | 620 | + throw new UserFriendlyException("Invalid Company (partnerIds/companyIds). Refresh and try again."); |
| 621 | } | 621 | } |
| 622 | } | 622 | } |
| 623 | 623 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelRegionScopeHelper.cs
| @@ -104,13 +104,13 @@ public static class LabelRegionScopeHelper | @@ -104,13 +104,13 @@ public static class LabelRegionScopeHelper | ||
| 104 | 104 | ||
| 105 | if (type != AppliedRegionAll && type != AppliedRegionSpecified) | 105 | if (type != AppliedRegionAll && type != AppliedRegionSpecified) |
| 106 | { | 106 | { |
| 107 | - throw new UserFriendlyException("适用 Region 范围不合法(ALL/SPECIFIED)"); | 107 | + throw new UserFriendlyException("Invalid applicable Region scope (ALL/SPECIFIED)."); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | if (mergedRegionIds.Count == 0 && explicitLocationIds.Count == 0 | 110 | if (mergedRegionIds.Count == 0 && explicitLocationIds.Count == 0 |
| 111 | && !string.Equals(type, AppliedRegionAll, StringComparison.OrdinalIgnoreCase)) | 111 | && !string.Equals(type, AppliedRegionAll, StringComparison.OrdinalIgnoreCase)) |
| 112 | { | 112 | { |
| 113 | - throw new UserFriendlyException("请指定 Region(regionIds)和/或门店(locationIds)"); | 113 | + throw new UserFriendlyException("Specify Region (regionIds) and/or location(s) (locationIds)."); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | if (mergedRegionIds.Count > 0) | 116 | if (mergedRegionIds.Count > 0) |
| @@ -196,7 +196,7 @@ public static class LabelRegionScopeHelper | @@ -196,7 +196,7 @@ public static class LabelRegionScopeHelper | ||
| 196 | { | 196 | { |
| 197 | if (allLocationsInRegions.Count == 0) | 197 | if (allLocationsInRegions.Count == 0) |
| 198 | { | 198 | { |
| 199 | - throw new UserFriendlyException("指定 Region 下未匹配到有效门店,请检查 Region 或 locationIds"); | 199 | + throw new UserFriendlyException("No valid locations matched under the specified Region. Check Region or locationIds."); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | return new LabelRegionScopeSaveResult | 202 | return new LabelRegionScopeSaveResult |
| @@ -212,7 +212,7 @@ public static class LabelRegionScopeHelper | @@ -212,7 +212,7 @@ public static class LabelRegionScopeHelper | ||
| 212 | db, resolvedPartnerContext, mergedRegionIds, explicitLocationIds); | 212 | db, resolvedPartnerContext, mergedRegionIds, explicitLocationIds); |
| 213 | if (mergedLocations.Count == 0) | 213 | if (mergedLocations.Count == 0) |
| 214 | { | 214 | { |
| 215 | - throw new UserFriendlyException("指定 Region 下未匹配到有效门店,请检查 Region 或 locationIds"); | 215 | + throw new UserFriendlyException("No valid locations matched under the specified Region. Check Region or locationIds."); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | var invalid = explicitLocationIds | 218 | var invalid = explicitLocationIds |
| @@ -220,7 +220,7 @@ public static class LabelRegionScopeHelper | @@ -220,7 +220,7 @@ public static class LabelRegionScopeHelper | ||
| 220 | .ToList(); | 220 | .ToList(); |
| 221 | if (invalid.Count > 0) | 221 | if (invalid.Count > 0) |
| 222 | { | 222 | { |
| 223 | - throw new UserFriendlyException("所选门店必须属于所选 Region"); | 223 | + throw new UserFriendlyException("Selected locations must belong to the selected Region."); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | return new LabelRegionScopeSaveResult | 226 | return new LabelRegionScopeSaveResult |
| @@ -691,7 +691,7 @@ public static class LabelRegionScopeHelper | @@ -691,7 +691,7 @@ public static class LabelRegionScopeHelper | ||
| 691 | var groupIds = await ResolveGroupIdsForLocationAsync(db, locationId); | 691 | var groupIds = await ResolveGroupIdsForLocationAsync(db, locationId); |
| 692 | if (!await LabelAppliesToLocationAsync(db, label, locationId, groupIds)) | 692 | if (!await LabelAppliesToLocationAsync(db, label, locationId, groupIds)) |
| 693 | { | 693 | { |
| 694 | - throw new UserFriendlyException("??????????????? Region"); | 694 | + throw new UserFriendlyException("This label does not apply to the location's Region."); |
| 695 | } | 695 | } |
| 696 | } | 696 | } |
| 697 | 697 | ||
| @@ -929,7 +929,7 @@ public static class LabelRegionScopeHelper | @@ -929,7 +929,7 @@ public static class LabelRegionScopeHelper | ||
| 929 | .CountAsync(); | 929 | .CountAsync(); |
| 930 | if (count != ids.Count) | 930 | if (count != ids.Count) |
| 931 | { | 931 | { |
| 932 | - throw new UserFriendlyException("存在无效的 Region Id,请刷新后重试"); | 932 | + throw new UserFriendlyException("Invalid Region Id(s). Refresh and try again."); |
| 933 | } | 933 | } |
| 934 | } | 934 | } |
| 935 | } | 935 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelReportDateRangeHelper.cs
| @@ -34,7 +34,7 @@ public static class LabelReportDateRangeHelper | @@ -34,7 +34,7 @@ public static class LabelReportDateRangeHelper | ||
| 34 | case "custom": | 34 | case "custom": |
| 35 | if (!startDate.HasValue || !endDate.HasValue) | 35 | if (!startDate.HasValue || !endDate.HasValue) |
| 36 | { | 36 | { |
| 37 | - throw new UserFriendlyException("自定义日期须同时传入 startDate 与 endDate"); | 37 | + throw new UserFriendlyException("For custom dates, pass both startDate and endDate."); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | startDay = startDate.Value.Date; | 40 | startDay = startDate.Value.Date; |
| @@ -42,7 +42,7 @@ public static class LabelReportDateRangeHelper | @@ -42,7 +42,7 @@ public static class LabelReportDateRangeHelper | ||
| 42 | endExcl = endDay.AddDays(1); | 42 | endExcl = endDay.AddDays(1); |
| 43 | if (startDay > endDay) | 43 | if (startDay > endDay) |
| 44 | { | 44 | { |
| 45 | - throw new UserFriendlyException("开始日期不能晚于结束日期"); | 45 | + throw new UserFriendlyException("Start date cannot be after end date."); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | break; | 48 | break; |
| @@ -60,7 +60,7 @@ public static class LabelReportDateRangeHelper | @@ -60,7 +60,7 @@ public static class LabelReportDateRangeHelper | ||
| 60 | var dayCount = Math.Max(1, (int)Math.Ceiling((endExcl - startDay).TotalDays)); | 60 | var dayCount = Math.Max(1, (int)Math.Ceiling((endExcl - startDay).TotalDays)); |
| 61 | if (dayCount > MaxRangeDays) | 61 | if (dayCount > MaxRangeDays) |
| 62 | { | 62 | { |
| 63 | - throw new UserFriendlyException($"统计区间不能超过 {MaxRangeDays} 天"); | 63 | + throw new UserFriendlyException($"Statistics range cannot exceed {MaxRangeDays} days."); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | return new LabelReportResolvedRange | 66 | return new LabelReportResolvedRange |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplatePrintOrientationHelper.cs
| @@ -38,6 +38,6 @@ public static class LabelTemplatePrintOrientationHelper | @@ -38,6 +38,6 @@ public static class LabelTemplatePrintOrientationHelper | ||
| 38 | return; | 38 | return; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | - throw new UserFriendlyException("printOrientation 仅支持 vertical 或 horizontal"); | 41 | + throw new UserFriendlyException("printOrientation supports only vertical or horizontal."); |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
| @@ -132,17 +132,17 @@ public static class LabelTemplateScopeHelper | @@ -132,17 +132,17 @@ public static class LabelTemplateScopeHelper | ||
| 132 | 132 | ||
| 133 | if (string.Equals(partnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && partnerIds.Count == 0) | 133 | if (string.Equals(partnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && partnerIds.Count == 0) |
| 134 | { | 134 | { |
| 135 | - throw new UserFriendlyException("指定适用 Company 时,partnerIds/companyIds 不能为空"); | 135 | + throw new UserFriendlyException("When specifying applicable Company, partnerIds/companyIds is required."); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if (string.Equals(regionType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && regionIds.Count == 0) | 138 | if (string.Equals(regionType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && regionIds.Count == 0) |
| 139 | { | 139 | { |
| 140 | - throw new UserFriendlyException("指定适用 Region 时,regionIds/groupIds 不能为空"); | 140 | + throw new UserFriendlyException("When specifying applicable Region, regionIds/groupIds is required."); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | if (string.Equals(locationType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && locationIds.Count == 0) | 143 | if (string.Equals(locationType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && locationIds.Count == 0) |
| 144 | { | 144 | { |
| 145 | - throw new UserFriendlyException("指定适用门店时,locationIds/appliedLocationIds 不能为空"); | 145 | + throw new UserFriendlyException("When specifying applicable locations, locationIds/appliedLocationIds is required."); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | if (partnerIds.Count > 0) | 148 | if (partnerIds.Count > 0) |
| @@ -175,7 +175,7 @@ public static class LabelTemplateScopeHelper | @@ -175,7 +175,7 @@ public static class LabelTemplateScopeHelper | ||
| 175 | string.Equals(locationType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) ? locationIds : null); | 175 | string.Equals(locationType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) ? locationIds : null); |
| 176 | if (merged.Count == 0) | 176 | if (merged.Count == 0) |
| 177 | { | 177 | { |
| 178 | - throw new UserFriendlyException("指定适用范围后至少需要匹配到一个有效门店"); | 178 | + throw new UserFriendlyException("After specifying scope, at least one valid location must match."); |
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
| @@ -209,7 +209,7 @@ public static class LabelTemplateScopeHelper | @@ -209,7 +209,7 @@ public static class LabelTemplateScopeHelper | ||
| 209 | if (needsPartnerRows && !hasPartnerTable) | 209 | if (needsPartnerRows && !hasPartnerTable) |
| 210 | { | 210 | { |
| 211 | throw new UserFriendlyException( | 211 | throw new UserFriendlyException( |
| 212 | - "Company 适用范围关联表尚未就绪,请联系管理员执行数据库迁移(fl_label_template_scope.sql)后重试"); | 212 | + "Company scope association table is not ready. Ask an administrator to run fl_label_template_scope.sql, then retry."); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | if (hasPartnerTable) | 215 | if (hasPartnerTable) |
| @@ -602,7 +602,7 @@ public static class LabelTemplateScopeHelper | @@ -602,7 +602,7 @@ public static class LabelTemplateScopeHelper | ||
| 602 | { | 602 | { |
| 603 | if (type != ScopeAll && type != ScopeSpecified) | 603 | if (type != ScopeAll && type != ScopeSpecified) |
| 604 | { | 604 | { |
| 605 | - throw new UserFriendlyException($"适用{label}范围不合法(ALL/SPECIFIED)"); | 605 | + throw new UserFriendlyException($"Invalid applicable {label} scope (ALL/SPECIFIED)."); |
| 606 | } | 606 | } |
| 607 | } | 607 | } |
| 608 | 608 | ||
| @@ -672,7 +672,7 @@ public static class LabelTemplateScopeHelper | @@ -672,7 +672,7 @@ public static class LabelTemplateScopeHelper | ||
| 672 | .CountAsync(); | 672 | .CountAsync(); |
| 673 | if (count != partnerIds.Count) | 673 | if (count != partnerIds.Count) |
| 674 | { | 674 | { |
| 675 | - throw new UserFriendlyException("存在无效的 Company(partnerIds/companyIds),请刷新后重试"); | 675 | + throw new UserFriendlyException("Invalid Company (partnerIds/companyIds). Refresh and try again."); |
| 676 | } | 676 | } |
| 677 | } | 677 | } |
| 678 | 678 | ||
| @@ -689,7 +689,7 @@ public static class LabelTemplateScopeHelper | @@ -689,7 +689,7 @@ public static class LabelTemplateScopeHelper | ||
| 689 | .CountAsync(); | 689 | .CountAsync(); |
| 690 | if (count != ids.Count) | 690 | if (count != ids.Count) |
| 691 | { | 691 | { |
| 692 | - throw new UserFriendlyException("存在无效的 Region(regionIds/groupIds),请刷新后重试"); | 692 | + throw new UserFriendlyException("Invalid Region (regionIds/groupIds). Refresh and try again."); |
| 693 | } | 693 | } |
| 694 | } | 694 | } |
| 695 | 695 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationBatchExcelHelper.cs
| @@ -73,7 +73,7 @@ public static class LocationBatchExcelHelper | @@ -73,7 +73,7 @@ public static class LocationBatchExcelHelper | ||
| 73 | parseErrors.Add(new LocationBatchImportErrorDto | 73 | parseErrors.Add(new LocationBatchImportErrorDto |
| 74 | { | 74 | { |
| 75 | RowNumber = 0, | 75 | RowNumber = 0, |
| 76 | - Message = "Excel 中无工作表" | 76 | + Message = "The Excel file has no worksheets." |
| 77 | }); | 77 | }); |
| 78 | return result; | 78 | return result; |
| 79 | } | 79 | } |
| @@ -81,7 +81,7 @@ public static class LocationBatchExcelHelper | @@ -81,7 +81,7 @@ public static class LocationBatchExcelHelper | ||
| 81 | var headerRow = ws.Row(1); | 81 | var headerRow = ws.Row(1); |
| 82 | if (!headerRow.CellsUsed().Any()) | 82 | if (!headerRow.CellsUsed().Any()) |
| 83 | { | 83 | { |
| 84 | - parseErrors.Add(new LocationBatchImportErrorDto { RowNumber = 1, Message = "表头为空" }); | 84 | + parseErrors.Add(new LocationBatchImportErrorDto { RowNumber = 1, Message = "Header row is empty." }); |
| 85 | return result; | 85 | return result; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -91,7 +91,7 @@ public static class LocationBatchExcelHelper | @@ -91,7 +91,7 @@ public static class LocationBatchExcelHelper | ||
| 91 | parseErrors.Add(new LocationBatchImportErrorDto | 91 | parseErrors.Add(new LocationBatchImportErrorDto |
| 92 | { | 92 | { |
| 93 | RowNumber = 1, | 93 | RowNumber = 1, |
| 94 | - Message = "未找到「Location ID」列(或同义表头),请使用官方模板" | 94 | + Message = "Location ID column was not found (or equivalent header). Use the official template." |
| 95 | }); | 95 | }); |
| 96 | return result; | 96 | return result; |
| 97 | } | 97 | } |
| @@ -105,7 +105,7 @@ public static class LocationBatchExcelHelper | @@ -105,7 +105,7 @@ public static class LocationBatchExcelHelper | ||
| 105 | parseErrors.Add(new LocationBatchImportErrorDto | 105 | parseErrors.Add(new LocationBatchImportErrorDto |
| 106 | { | 106 | { |
| 107 | RowNumber = rowNum, | 107 | RowNumber = rowNum, |
| 108 | - Message = $"已超过单次导入上限 {maxRows} 行,后续行已忽略" | 108 | + Message = $"Import exceeds the limit of {maxRows} rows; remaining rows were skipped." |
| 109 | }); | 109 | }); |
| 110 | break; | 110 | break; |
| 111 | } | 111 | } |
| @@ -117,7 +117,7 @@ public static class LocationBatchExcelHelper | @@ -117,7 +117,7 @@ public static class LocationBatchExcelHelper | ||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | dataRowCount++; | 119 | dataRowCount++; |
| 120 | - var errPrefix = $"第 {rowNum} 行"; | 120 | + var errPrefix = $"Row {rowNum}"; |
| 121 | try | 121 | try |
| 122 | { | 122 | { |
| 123 | var input = BuildCreateInputFromRow(colMap, ws, rowNum, out var rowErrs); | 123 | var input = BuildCreateInputFromRow(colMap, ws, rowNum, out var rowErrs); |
| @@ -257,12 +257,12 @@ public static class LocationBatchExcelHelper | @@ -257,12 +257,12 @@ public static class LocationBatchExcelHelper | ||
| 257 | 257 | ||
| 258 | if (string.IsNullOrWhiteSpace(locationCode)) | 258 | if (string.IsNullOrWhiteSpace(locationCode)) |
| 259 | { | 259 | { |
| 260 | - errors.Add("Location ID 不能为空"); | 260 | + errors.Add("Location ID is required."); |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | if (string.IsNullOrWhiteSpace(locationName)) | 263 | if (string.IsNullOrWhiteSpace(locationName)) |
| 264 | { | 264 | { |
| 265 | - errors.Add("Location Name 不能为空"); | 265 | + errors.Add("Location Name is required."); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | decimal? lat = null; | 268 | decimal? lat = null; |
| @@ -270,7 +270,7 @@ public static class LocationBatchExcelHelper | @@ -270,7 +270,7 @@ public static class LocationBatchExcelHelper | ||
| 270 | { | 270 | { |
| 271 | if (!decimal.TryParse(latStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var latVal)) | 271 | if (!decimal.TryParse(latStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var latVal)) |
| 272 | { | 272 | { |
| 273 | - errors.Add("Latitude 格式不正确"); | 273 | + errors.Add("Latitude format is invalid."); |
| 274 | } | 274 | } |
| 275 | else | 275 | else |
| 276 | { | 276 | { |
| @@ -283,7 +283,7 @@ public static class LocationBatchExcelHelper | @@ -283,7 +283,7 @@ public static class LocationBatchExcelHelper | ||
| 283 | { | 283 | { |
| 284 | if (!decimal.TryParse(lngStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var lngVal)) | 284 | if (!decimal.TryParse(lngStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var lngVal)) |
| 285 | { | 285 | { |
| 286 | - errors.Add("Longitude 格式不正确"); | 286 | + errors.Add("Longitude format is invalid."); |
| 287 | } | 287 | } |
| 288 | else | 288 | else |
| 289 | { | 289 | { |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationRegionScopeHelper.cs
| @@ -21,6 +21,11 @@ public static class LocationRegionScopeHelper | @@ -21,6 +21,11 @@ public static class LocationRegionScopeHelper | ||
| 21 | 21 | ||
| 22 | public IReadOnlyList<(string Partner, string GroupName)> RegionKeys { get; init; } = | 22 | public IReadOnlyList<(string Partner, string GroupName)> RegionKeys { get; init; } = |
| 23 | Array.Empty<(string, string)>(); | 23 | Array.Empty<(string, string)>(); |
| 24 | + | ||
| 25 | + /// <summary> | ||
| 26 | + /// Location=ALL 时按 Company 匹配 <c>location.Partner</c>(Id 或名称),不依赖 Region 名是否已对齐。 | ||
| 27 | + /// </summary> | ||
| 28 | + public IReadOnlyList<string> PartnerKeys { get; init; } = Array.Empty<string>(); | ||
| 24 | } | 29 | } |
| 25 | 30 | ||
| 26 | /// <summary> | 31 | /// <summary> |
| @@ -42,6 +47,12 @@ public static class LocationRegionScopeHelper | @@ -42,6 +47,12 @@ public static class LocationRegionScopeHelper | ||
| 42 | } | 47 | } |
| 43 | 48 | ||
| 44 | var db = dbContext.SqlSugarClient; | 49 | var db = dbContext.SqlSugarClient; |
| 50 | + var allScopePartnerIds = await LocationScopeBindingHelper.LoadLocationAllPartnerIdsAsync( | ||
| 51 | + db, currentUser.Id.Value); | ||
| 52 | + if (allScopePartnerIds.Count > 0) | ||
| 53 | + { | ||
| 54 | + return await ResolveLocationListScopeFromPartnerIdsAsync(db, allScopePartnerIds); | ||
| 55 | + } | ||
| 45 | 56 | ||
| 46 | if (await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser)) | 57 | if (await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser)) |
| 47 | { | 58 | { |
| @@ -49,10 +60,11 @@ public static class LocationRegionScopeHelper | @@ -49,10 +60,11 @@ public static class LocationRegionScopeHelper | ||
| 49 | } | 60 | } |
| 50 | 61 | ||
| 51 | var userId = currentUser.Id.Value.ToString(); | 62 | var userId = currentUser.Id.Value.ToString(); |
| 63 | + var userIdLower = TeamMemberListScopeHelper.UserKey(currentUser.Id.Value); | ||
| 52 | var rows = await db.Queryable<UserLocationDbEntity>() | 64 | var rows = await db.Queryable<UserLocationDbEntity>() |
| 53 | .InnerJoin<LocationAggregateRoot>((ul, loc) => | 65 | .InnerJoin<LocationAggregateRoot>((ul, loc) => |
| 54 | !loc.IsDeleted && ul.LocationId == loc.Id.ToString()) | 66 | !loc.IsDeleted && ul.LocationId == loc.Id.ToString()) |
| 55 | - .Where(ul => !ul.IsDeleted && ul.UserId == userId) | 67 | + .Where(ul => !ul.IsDeleted && (ul.UserId == userId || ul.UserId == userIdLower)) |
| 56 | .Select((ul, loc) => new { loc.Partner, loc.GroupName }) | 68 | .Select((ul, loc) => new { loc.Partner, loc.GroupName }) |
| 57 | .ToListAsync(); | 69 | .ToListAsync(); |
| 58 | 70 | ||
| @@ -76,6 +88,13 @@ public static class LocationRegionScopeHelper | @@ -76,6 +88,13 @@ public static class LocationRegionScopeHelper | ||
| 76 | } | 88 | } |
| 77 | 89 | ||
| 78 | var partnerIds = await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(db, locationIds); | 90 | var partnerIds = await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(db, locationIds); |
| 91 | + return await ResolveLocationListScopeFromPartnerIdsAsync(db, partnerIds); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + private static async Task<LocationListScopeFilter> ResolveLocationListScopeFromPartnerIdsAsync( | ||
| 95 | + ISqlSugarClient db, | ||
| 96 | + IReadOnlyList<string> partnerIds) | ||
| 97 | + { | ||
| 79 | if (partnerIds.Count == 0) | 98 | if (partnerIds.Count == 0) |
| 80 | { | 99 | { |
| 81 | return new LocationListScopeFilter(); | 100 | return new LocationListScopeFilter(); |
| @@ -91,6 +110,28 @@ public static class LocationRegionScopeHelper | @@ -91,6 +110,28 @@ public static class LocationRegionScopeHelper | ||
| 91 | .Select(g => new { g.PartnerId, g.GroupName }) | 110 | .Select(g => new { g.PartnerId, g.GroupName }) |
| 92 | .ToListAsync(); | 111 | .ToListAsync(); |
| 93 | 112 | ||
| 113 | + var partnerKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase); | ||
| 114 | + foreach (var partner in partners) | ||
| 115 | + { | ||
| 116 | + if (!string.IsNullOrWhiteSpace(partner.Id)) | ||
| 117 | + { | ||
| 118 | + partnerKeys.Add(partner.Id.Trim()); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + if (!string.IsNullOrWhiteSpace(partner.PartnerName)) | ||
| 122 | + { | ||
| 123 | + partnerKeys.Add(partner.PartnerName.Trim()); | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + foreach (var pid in partnerIds) | ||
| 128 | + { | ||
| 129 | + if (!string.IsNullOrWhiteSpace(pid)) | ||
| 130 | + { | ||
| 131 | + partnerKeys.Add(pid.Trim()); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + | ||
| 94 | var keys = new HashSet<(string Partner, string GroupName)>(); | 135 | var keys = new HashSet<(string Partner, string GroupName)>(); |
| 95 | foreach (var group in groups) | 136 | foreach (var group in groups) |
| 96 | { | 137 | { |
| @@ -115,7 +156,11 @@ public static class LocationRegionScopeHelper | @@ -115,7 +156,11 @@ public static class LocationRegionScopeHelper | ||
| 115 | } | 156 | } |
| 116 | } | 157 | } |
| 117 | 158 | ||
| 118 | - return new LocationListScopeFilter { RegionKeys = keys.ToList() }; | 159 | + return new LocationListScopeFilter |
| 160 | + { | ||
| 161 | + PartnerKeys = partnerKeys.ToList(), | ||
| 162 | + RegionKeys = keys.ToList() | ||
| 163 | + }; | ||
| 119 | } | 164 | } |
| 120 | 165 | ||
| 121 | /// <summary> | 166 | /// <summary> |
| @@ -130,6 +175,12 @@ public static class LocationRegionScopeHelper | @@ -130,6 +175,12 @@ public static class LocationRegionScopeHelper | ||
| 130 | return query; | 175 | return query; |
| 131 | } | 176 | } |
| 132 | 177 | ||
| 178 | + if (scope.PartnerKeys.Count > 0) | ||
| 179 | + { | ||
| 180 | + var partnerKeys = scope.PartnerKeys.ToList(); | ||
| 181 | + return query.Where(x => partnerKeys.Contains(x.Partner!)); | ||
| 182 | + } | ||
| 183 | + | ||
| 133 | if (scope.RegionKeys.Count == 0) | 184 | if (scope.RegionKeys.Count == 0) |
| 134 | { | 185 | { |
| 135 | return query.Where(_ => false); | 186 | return query.Where(_ => false); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
| @@ -71,6 +71,23 @@ public static class LocationScopeBindingHelper | @@ -71,6 +71,23 @@ public static class LocationScopeBindingHelper | ||
| 71 | ICurrentUser? currentUser) | 71 | ICurrentUser? currentUser) |
| 72 | { | 72 | { |
| 73 | var locationIds = await ResolveBoundLocationIdsForUserAsync(db, userId); | 73 | var locationIds = await ResolveBoundLocationIdsForUserAsync(db, userId); |
| 74 | + var allScopePartnerIds = await LoadLocationAllPartnerIdsAsync(db, userId); | ||
| 75 | + if (allScopePartnerIds.Count > 0) | ||
| 76 | + { | ||
| 77 | + var fromAll = await ResolveLocationIdsFromPartnerIdsAsync(db, allScopePartnerIds); | ||
| 78 | + if (fromAll.Count > 0) | ||
| 79 | + { | ||
| 80 | + return fromAll | ||
| 81 | + .Select(TeamMemberListScopeHelper.NormalizeScopeKey) | ||
| 82 | + .Where(x => !string.IsNullOrEmpty(x)) | ||
| 83 | + .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| 84 | + .OrderBy(x => x, StringComparer.Ordinal) | ||
| 85 | + .ToList(); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + return locationIds; | ||
| 89 | + } | ||
| 90 | + | ||
| 74 | if (locationIds.Count == 0) | 91 | if (locationIds.Count == 0) |
| 75 | { | 92 | { |
| 76 | return locationIds; | 93 | return locationIds; |
| @@ -348,7 +365,8 @@ public static class LocationScopeBindingHelper | @@ -348,7 +365,8 @@ public static class LocationScopeBindingHelper | ||
| 348 | ISqlSugarClient db, | 365 | ISqlSugarClient db, |
| 349 | IReadOnlyList<string>? partnerIds, | 366 | IReadOnlyList<string>? partnerIds, |
| 350 | IReadOnlyList<string>? regionIds, | 367 | IReadOnlyList<string>? regionIds, |
| 351 | - IReadOnlyList<string>? locationIds) | 368 | + IReadOnlyList<string>? locationIds, |
| 369 | + bool allowEmptyAll = false) | ||
| 352 | { | 370 | { |
| 353 | var normalizedPartners = NormalizeIds(partnerIds); | 371 | var normalizedPartners = NormalizeIds(partnerIds); |
| 354 | var locationHasAll = ContainsAllScopeSentinel(locationIds); | 372 | var locationHasAll = ContainsAllScopeSentinel(locationIds); |
| @@ -362,13 +380,14 @@ public static class LocationScopeBindingHelper | @@ -362,13 +380,14 @@ public static class LocationScopeBindingHelper | ||
| 362 | var expanded = await ExpandScopedAllLocationsForSaveAsync( | 380 | var expanded = await ExpandScopedAllLocationsForSaveAsync( |
| 363 | db, | 381 | db, |
| 364 | normalizedPartners.Count > 0 ? normalizedPartners : null, | 382 | normalizedPartners.Count > 0 ? normalizedPartners : null, |
| 365 | - concreteRegions.Count > 0 ? concreteRegions : null); | 383 | + concreteRegions.Count > 0 ? concreteRegions : null, |
| 384 | + allowEmptyAll); | ||
| 366 | if (expanded is not null) | 385 | if (expanded is not null) |
| 367 | { | 386 | { |
| 368 | return expanded; | 387 | return expanded; |
| 369 | } | 388 | } |
| 370 | 389 | ||
| 371 | - throw new UserFriendlyException("选择全部门店时需指定 Company(partnerId / partnerIds)或 Region"); | 390 | + throw new UserFriendlyException("When selecting all locations, specify Company (partnerId / partnerIds) or Region."); |
| 372 | } | 391 | } |
| 373 | 392 | ||
| 374 | // 2. 具体门店 +(无区域 / 区域为 ALL)→ 只绑这些门店,避免 regionIds=ALL 盖掉单店 | 393 | // 2. 具体门店 +(无区域 / 区域为 ALL)→ 只绑这些门店,避免 regionIds=ALL 盖掉单店 |
| @@ -382,7 +401,7 @@ public static class LocationScopeBindingHelper | @@ -382,7 +401,7 @@ public static class LocationScopeBindingHelper | ||
| 382 | { | 401 | { |
| 383 | if (normalizedPartners.Count == 0) | 402 | if (normalizedPartners.Count == 0) |
| 384 | { | 403 | { |
| 385 | - throw new UserFriendlyException("选择全部 Region 时需指定 Company(partnerId / partnerIds)"); | 404 | + throw new UserFriendlyException("When selecting all Regions, specify Company (partnerId / partnerIds)."); |
| 386 | } | 405 | } |
| 387 | 406 | ||
| 388 | return await AllScopeBindingHelper.ResolveAllLocationIdsAsync(db, normalizedPartners, null); | 407 | return await AllScopeBindingHelper.ResolveAllLocationIdsAsync(db, normalizedPartners, null); |
| @@ -446,7 +465,7 @@ public static class LocationScopeBindingHelper | @@ -446,7 +465,7 @@ public static class LocationScopeBindingHelper | ||
| 446 | || (ContainsAllScopeSentinel(regionIds) | 465 | || (ContainsAllScopeSentinel(regionIds) |
| 447 | && FilterConcreteScopeIds(locationIds).Count == 0)) | 466 | && FilterConcreteScopeIds(locationIds).Count == 0)) |
| 448 | { | 467 | { |
| 449 | - throw new UserFriendlyException("门店范围含 ALL 哨兵时应归档为 ALL,不应进入 SPECIFIED 落库校验"); | 468 | + throw new UserFriendlyException("When location scope includes the ALL sentinel, persist as ALL; do not run SPECIFIED persistence validation."); |
| 450 | } | 469 | } |
| 451 | 470 | ||
| 452 | var concreteRegions = FilterConcreteScopeIds(regionIds); | 471 | var concreteRegions = FilterConcreteScopeIds(regionIds); |
| @@ -466,7 +485,7 @@ public static class LocationScopeBindingHelper | @@ -466,7 +485,7 @@ public static class LocationScopeBindingHelper | ||
| 466 | concreteLocations); | 485 | concreteLocations); |
| 467 | if (merged.Count == 0) | 486 | if (merged.Count == 0) |
| 468 | { | 487 | { |
| 469 | - throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店"); | 488 | + throw new UserFriendlyException("When specifying applicable regions or locations, at least one valid location must match."); |
| 470 | } | 489 | } |
| 471 | 490 | ||
| 472 | await ValidateLocationIdsExistAsync(db, merged); | 491 | await ValidateLocationIdsExistAsync(db, merged); |
| @@ -479,7 +498,8 @@ public static class LocationScopeBindingHelper | @@ -479,7 +498,8 @@ public static class LocationScopeBindingHelper | ||
| 479 | public static async Task<List<string>?> ExpandScopedAllLocationsForSaveAsync( | 498 | public static async Task<List<string>?> ExpandScopedAllLocationsForSaveAsync( |
| 480 | ISqlSugarClient db, | 499 | ISqlSugarClient db, |
| 481 | IReadOnlyList<string>? partnerIds, | 500 | IReadOnlyList<string>? partnerIds, |
| 482 | - IReadOnlyList<string>? regionIds) | 501 | + IReadOnlyList<string>? regionIds, |
| 502 | + bool allowEmpty = false) | ||
| 483 | { | 503 | { |
| 484 | var concreteRegions = FilterConcreteScopeIds(regionIds); | 504 | var concreteRegions = FilterConcreteScopeIds(regionIds); |
| 485 | if (concreteRegions.Count > 0) | 505 | if (concreteRegions.Count > 0) |
| @@ -496,7 +516,12 @@ public static class LocationScopeBindingHelper | @@ -496,7 +516,12 @@ public static class LocationScopeBindingHelper | ||
| 496 | 516 | ||
| 497 | if (fromRegions.Count == 0) | 517 | if (fromRegions.Count == 0) |
| 498 | { | 518 | { |
| 499 | - throw new UserFriendlyException("指定 Region 下未匹配到有效门店"); | 519 | + if (allowEmpty) |
| 520 | + { | ||
| 521 | + return fromRegions; | ||
| 522 | + } | ||
| 523 | + | ||
| 524 | + throw new UserFriendlyException("No valid locations matched under the specified Region."); | ||
| 500 | } | 525 | } |
| 501 | 526 | ||
| 502 | await ValidateLocationIdsExistAsync(db, fromRegions); | 527 | await ValidateLocationIdsExistAsync(db, fromRegions); |
| @@ -509,7 +534,12 @@ public static class LocationScopeBindingHelper | @@ -509,7 +534,12 @@ public static class LocationScopeBindingHelper | ||
| 509 | var fromPartners = await ResolveLocationIdsFromPartnerIdsAsync(db, concretePartners); | 534 | var fromPartners = await ResolveLocationIdsFromPartnerIdsAsync(db, concretePartners); |
| 510 | if (fromPartners.Count == 0) | 535 | if (fromPartners.Count == 0) |
| 511 | { | 536 | { |
| 512 | - throw new UserFriendlyException("指定 Company 下未匹配到有效门店"); | 537 | + if (allowEmpty) |
| 538 | + { | ||
| 539 | + return fromPartners; | ||
| 540 | + } | ||
| 541 | + | ||
| 542 | + throw new UserFriendlyException("No valid locations matched under the specified Company."); | ||
| 513 | } | 543 | } |
| 514 | 544 | ||
| 515 | await ValidateLocationIdsExistAsync(db, fromPartners); | 545 | await ValidateLocationIdsExistAsync(db, fromPartners); |
| @@ -605,7 +635,7 @@ public static class LocationScopeBindingHelper | @@ -605,7 +635,7 @@ public static class LocationScopeBindingHelper | ||
| 605 | } | 635 | } |
| 606 | 636 | ||
| 607 | var locIds = await db.Queryable<LocationAggregateRoot>() | 637 | var locIds = await db.Queryable<LocationAggregateRoot>() |
| 608 | - .Where(x => !x.IsDeleted && x.Partner == pName) | 638 | + .Where(x => !x.IsDeleted && (x.Partner == pName || x.Partner == pid)) |
| 609 | .Select(x => SqlFunc.ToString(x.Id)) | 639 | .Select(x => SqlFunc.ToString(x.Id)) |
| 610 | .ToListAsync(); | 640 | .ToListAsync(); |
| 611 | foreach (var lid in locIds.Where(x => !string.IsNullOrWhiteSpace(x))) | 641 | foreach (var lid in locIds.Where(x => !string.IsNullOrWhiteSpace(x))) |
| @@ -772,7 +802,7 @@ public static class LocationScopeBindingHelper | @@ -772,7 +802,7 @@ public static class LocationScopeBindingHelper | ||
| 772 | { | 802 | { |
| 773 | if (!Guid.TryParse(id, out _)) | 803 | if (!Guid.TryParse(id, out _)) |
| 774 | { | 804 | { |
| 775 | - throw new UserFriendlyException("门店Id格式不正确"); | 805 | + throw new UserFriendlyException("Invalid locationId format."); |
| 776 | } | 806 | } |
| 777 | } | 807 | } |
| 778 | 808 | ||
| @@ -782,7 +812,7 @@ public static class LocationScopeBindingHelper | @@ -782,7 +812,7 @@ public static class LocationScopeBindingHelper | ||
| 782 | .CountAsync(); | 812 | .CountAsync(); |
| 783 | if (existCount != ids.Count) | 813 | if (existCount != ids.Count) |
| 784 | { | 814 | { |
| 785 | - throw new UserFriendlyException("门店不存在"); | 815 | + throw new UserFriendlyException("Location not found."); |
| 786 | } | 816 | } |
| 787 | } | 817 | } |
| 788 | 818 | ||
| @@ -879,6 +909,133 @@ public static class LocationScopeBindingHelper | @@ -879,6 +909,133 @@ public static class LocationScopeBindingHelper | ||
| 879 | } | 909 | } |
| 880 | 910 | ||
| 881 | /// <summary> | 911 | /// <summary> |
| 912 | + /// 新建门店后:给 Location=ALL 且 Company 匹配的成员补 <c>userlocation</c>。 | ||
| 913 | + /// </summary> | ||
| 914 | + public static async Task BindLocationAllScopeUsersToNewLocationAsync( | ||
| 915 | + ISqlSugarClient db, | ||
| 916 | + IGuidGenerator guidGenerator, | ||
| 917 | + string locationId, | ||
| 918 | + string? locationPartnerField, | ||
| 919 | + string? creatorId) | ||
| 920 | + { | ||
| 921 | + if (string.IsNullOrWhiteSpace(locationId) || !Guid.TryParse(locationId, out _)) | ||
| 922 | + { | ||
| 923 | + return; | ||
| 924 | + } | ||
| 925 | + | ||
| 926 | + var partnerIds = await ResolvePartnerIdsFromLocationIdsAsync(db, new List<string> { locationId }); | ||
| 927 | + if (partnerIds.Count == 0) | ||
| 928 | + { | ||
| 929 | + partnerIds = await ResolvePartnerIdsFromPartnerNamesAsync(db, locationPartnerField); | ||
| 930 | + } | ||
| 931 | + | ||
| 932 | + if (partnerIds.Count == 0) | ||
| 933 | + { | ||
| 934 | + return; | ||
| 935 | + } | ||
| 936 | + | ||
| 937 | + var partnerSet = new HashSet<string>( | ||
| 938 | + partnerIds.Select(id => Guid.TryParse(id, out var g) ? g.ToString("D") : id.Trim()), | ||
| 939 | + StringComparer.OrdinalIgnoreCase); | ||
| 940 | + var scopes = await db.Queryable<FlTeamMemberScopeDbEntity>().ToListAsync(); | ||
| 941 | + scopes = scopes | ||
| 942 | + .Where(x => AllScopeBindingHelper.IsDeclaredAll(x.AppliedLocationType)) | ||
| 943 | + .ToList(); | ||
| 944 | + if (scopes.Count == 0) | ||
| 945 | + { | ||
| 946 | + return; | ||
| 947 | + } | ||
| 948 | + | ||
| 949 | + var userGuids = scopes | ||
| 950 | + .Select(x => Guid.TryParse(x.UserId, out var id) ? id : Guid.Empty) | ||
| 951 | + .Where(x => x != Guid.Empty) | ||
| 952 | + .Distinct() | ||
| 953 | + .ToList(); | ||
| 954 | + var activeUsers = userGuids.Count == 0 | ||
| 955 | + ? new List<Guid>() | ||
| 956 | + : await db.Queryable<UserAggregateRoot>() | ||
| 957 | + .Where(u => !u.IsDeleted && userGuids.Contains(u.Id)) | ||
| 958 | + .Select(u => u.Id) | ||
| 959 | + .ToListAsync(); | ||
| 960 | + var activeSet = activeUsers.ToHashSet(); | ||
| 961 | + | ||
| 962 | + foreach (var scope in scopes) | ||
| 963 | + { | ||
| 964 | + if (!Guid.TryParse(scope.UserId, out var userId) || !activeSet.Contains(userId)) | ||
| 965 | + { | ||
| 966 | + continue; | ||
| 967 | + } | ||
| 968 | + | ||
| 969 | + var scopePartners = SplitPartnerIds(scope.PartnerIds); | ||
| 970 | + if (scopePartners.Count == 0 | ||
| 971 | + || !scopePartners.Any(id => | ||
| 972 | + partnerSet.Contains(id) | ||
| 973 | + || (Guid.TryParse(id, out var g) && partnerSet.Contains(g.ToString("D"))))) | ||
| 974 | + { | ||
| 975 | + continue; | ||
| 976 | + } | ||
| 977 | + | ||
| 978 | + await AppendUserLocationBindingsAsync( | ||
| 979 | + db, guidGenerator, userId, new List<string> { locationId }, creatorId); | ||
| 980 | + } | ||
| 981 | + } | ||
| 982 | + | ||
| 983 | + public static async Task EnsurePartnerIdsExistAsync(ISqlSugarClient db, IReadOnlyList<string> partnerIds) | ||
| 984 | + { | ||
| 985 | + var ids = NormalizeIds(partnerIds); | ||
| 986 | + if (ids.Count == 0) | ||
| 987 | + { | ||
| 988 | + throw new UserFriendlyException("When selecting all locations, specify Company (partnerId / partnerIds)."); | ||
| 989 | + } | ||
| 990 | + | ||
| 991 | + var existing = await db.Queryable<FlPartnerDbEntity>() | ||
| 992 | + .Where(x => !x.IsDeleted && ids.Contains(x.Id)) | ||
| 993 | + .Select(x => x.Id) | ||
| 994 | + .ToListAsync(); | ||
| 995 | + if (existing.Count != ids.Count) | ||
| 996 | + { | ||
| 997 | + throw new UserFriendlyException("The specified Company does not exist or was removed."); | ||
| 998 | + } | ||
| 999 | + } | ||
| 1000 | + | ||
| 1001 | + public static List<string> SplitPartnerIds(string? raw) | ||
| 1002 | + { | ||
| 1003 | + if (string.IsNullOrWhiteSpace(raw)) | ||
| 1004 | + { | ||
| 1005 | + return new List<string>(); | ||
| 1006 | + } | ||
| 1007 | + | ||
| 1008 | + return raw.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) | ||
| 1009 | + .Where(x => Guid.TryParse(x, out _)) | ||
| 1010 | + .Select(x => Guid.Parse(x).ToString("D")) | ||
| 1011 | + .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| 1012 | + .ToList(); | ||
| 1013 | + } | ||
| 1014 | + | ||
| 1015 | + public static string? JoinPartnerIds(IReadOnlyList<string>? partnerIds) | ||
| 1016 | + { | ||
| 1017 | + var ids = NormalizeIds(partnerIds) | ||
| 1018 | + .Select(x => Guid.TryParse(x, out var g) ? g.ToString("D") : x) | ||
| 1019 | + .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| 1020 | + .ToList(); | ||
| 1021 | + return ids.Count == 0 ? null : string.Join(',', ids); | ||
| 1022 | + } | ||
| 1023 | + | ||
| 1024 | + public static async Task<List<string>> LoadLocationAllPartnerIdsAsync(ISqlSugarClient db, Guid userId) | ||
| 1025 | + { | ||
| 1026 | + var userIdD = userId.ToString("D"); | ||
| 1027 | + var userIdLower = TeamMemberListScopeHelper.UserKey(userId); | ||
| 1028 | + var row = await db.Queryable<FlTeamMemberScopeDbEntity>() | ||
| 1029 | + .FirstAsync(x => x.UserId == userIdD || x.UserId == userIdLower); | ||
| 1030 | + if (row is null || !AllScopeBindingHelper.IsDeclaredAll(row.AppliedLocationType)) | ||
| 1031 | + { | ||
| 1032 | + return new List<string>(); | ||
| 1033 | + } | ||
| 1034 | + | ||
| 1035 | + return SplitPartnerIds(row.PartnerIds); | ||
| 1036 | + } | ||
| 1037 | + | ||
| 1038 | + /// <summary> | ||
| 882 | /// 追加 <c>userlocation</c> 绑定(幂等;仅插入当前用户尚未绑定的门店)。 | 1039 | /// 追加 <c>userlocation</c> 绑定(幂等;仅插入当前用户尚未绑定的门店)。 |
| 883 | /// </summary> | 1040 | /// </summary> |
| 884 | public static async Task<int> AppendUserLocationBindingsAsync( | 1041 | public static async Task<int> AppendUserLocationBindingsAsync( |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PartnerScopeHelper.cs
| @@ -39,6 +39,13 @@ public static class PartnerScopeHelper | @@ -39,6 +39,13 @@ public static class PartnerScopeHelper | ||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | var db = dbContext.SqlSugarClient; | 41 | var db = dbContext.SqlSugarClient; |
| 42 | + var allScopePartnerIds = await LocationScopeBindingHelper.LoadLocationAllPartnerIdsAsync( | ||
| 43 | + db, currentUser.Id.Value); | ||
| 44 | + if (allScopePartnerIds.Count > 0) | ||
| 45 | + { | ||
| 46 | + return new PartnerScopeFilter { AllowedPartnerIds = allScopePartnerIds }; | ||
| 47 | + } | ||
| 48 | + | ||
| 42 | var locationIds = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync( | 49 | var locationIds = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync( |
| 43 | db, currentUser.Id.Value); | 50 | db, currentUser.Id.Value); |
| 44 | if (locationIds.Count == 0) | 51 | if (locationIds.Count == 0) |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ProductBatchExcelHelper.cs
| @@ -62,14 +62,14 @@ public static class ProductBatchExcelHelper | @@ -62,14 +62,14 @@ public static class ProductBatchExcelHelper | ||
| 62 | ?? wb.Worksheets.FirstOrDefault(); | 62 | ?? wb.Worksheets.FirstOrDefault(); |
| 63 | if (ws is null) | 63 | if (ws is null) |
| 64 | { | 64 | { |
| 65 | - parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 0, Message = "Excel 中无工作表" }); | 65 | + parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 0, Message = "The Excel file has no worksheets." }); |
| 66 | return result; | 66 | return result; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | var headerRow = ws.Row(1); | 69 | var headerRow = ws.Row(1); |
| 70 | if (!headerRow.CellsUsed().Any()) | 70 | if (!headerRow.CellsUsed().Any()) |
| 71 | { | 71 | { |
| 72 | - parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 1, Message = "表头为空" }); | 72 | + parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 1, Message = "Header row is empty." }); |
| 73 | return result; | 73 | return result; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| @@ -79,7 +79,7 @@ public static class ProductBatchExcelHelper | @@ -79,7 +79,7 @@ public static class ProductBatchExcelHelper | ||
| 79 | parseErrors.Add(new ProductBatchImportErrorDto | 79 | parseErrors.Add(new ProductBatchImportErrorDto |
| 80 | { | 80 | { |
| 81 | RowNumber = 1, | 81 | RowNumber = 1, |
| 82 | - Message = "未找到「Product」与「Product Category」列(或同义表头),请使用官方模板" | 82 | + Message = "Product and Product Category columns were not found (or equivalent headers). Use the official template." |
| 83 | }); | 83 | }); |
| 84 | return result; | 84 | return result; |
| 85 | } | 85 | } |
| @@ -93,7 +93,7 @@ public static class ProductBatchExcelHelper | @@ -93,7 +93,7 @@ public static class ProductBatchExcelHelper | ||
| 93 | parseErrors.Add(new ProductBatchImportErrorDto | 93 | parseErrors.Add(new ProductBatchImportErrorDto |
| 94 | { | 94 | { |
| 95 | RowNumber = rowNum, | 95 | RowNumber = rowNum, |
| 96 | - Message = $"已超过单次导入上限 {maxRows} 行,后续行已忽略" | 96 | + Message = $"Import exceeds the limit of {maxRows} rows; remaining rows were skipped." |
| 97 | }); | 97 | }); |
| 98 | break; | 98 | break; |
| 99 | } | 99 | } |
| @@ -114,16 +114,16 @@ public static class ProductBatchExcelHelper | @@ -114,16 +114,16 @@ public static class ProductBatchExcelHelper | ||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | dataRowCount++; | 116 | dataRowCount++; |
| 117 | - var errPrefix = $"第 {rowNum} 行"; | 117 | + var errPrefix = $"Row {rowNum}"; |
| 118 | var rowErrs = new List<string>(); | 118 | var rowErrs = new List<string>(); |
| 119 | if (string.IsNullOrWhiteSpace(productName)) | 119 | if (string.IsNullOrWhiteSpace(productName)) |
| 120 | { | 120 | { |
| 121 | - rowErrs.Add("Product 不能为空"); | 121 | + rowErrs.Add("Product is required."); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | if (string.IsNullOrWhiteSpace(categoryName)) | 124 | if (string.IsNullOrWhiteSpace(categoryName)) |
| 125 | { | 125 | { |
| 126 | - rowErrs.Add("Product Category 不能为空"); | 126 | + rowErrs.Add("Product Category is required."); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | if (rowErrs.Count > 0) | 129 | if (rowErrs.Count > 0) |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TeamMemberBatchExcelHelper.cs
| @@ -80,7 +80,7 @@ public static class TeamMemberBatchExcelHelper | @@ -80,7 +80,7 @@ public static class TeamMemberBatchExcelHelper | ||
| 80 | parseErrors.Add(new TeamMemberBatchImportErrorDto | 80 | parseErrors.Add(new TeamMemberBatchImportErrorDto |
| 81 | { | 81 | { |
| 82 | RowNumber = 0, | 82 | RowNumber = 0, |
| 83 | - Message = "未配置默认导入密码 FoodLabeling:BatchImport:TeamMemberImportDefaultPassword" | 83 | + Message = "Default import password is not configured (FoodLabeling:BatchImport:TeamMemberImportDefaultPassword)." |
| 84 | }); | 84 | }); |
| 85 | return result; | 85 | return result; |
| 86 | } | 86 | } |
| @@ -89,14 +89,14 @@ public static class TeamMemberBatchExcelHelper | @@ -89,14 +89,14 @@ public static class TeamMemberBatchExcelHelper | ||
| 89 | var ws = wb.Worksheets.FirstOrDefault(); | 89 | var ws = wb.Worksheets.FirstOrDefault(); |
| 90 | if (ws is null) | 90 | if (ws is null) |
| 91 | { | 91 | { |
| 92 | - parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 0, Message = "Excel 中无工作表" }); | 92 | + parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 0, Message = "The Excel file has no worksheets." }); |
| 93 | return result; | 93 | return result; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | var headerRow = ws.Row(1); | 96 | var headerRow = ws.Row(1); |
| 97 | if (!headerRow.CellsUsed().Any()) | 97 | if (!headerRow.CellsUsed().Any()) |
| 98 | { | 98 | { |
| 99 | - parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 1, Message = "表头为空" }); | 99 | + parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 1, Message = "Header row is empty." }); |
| 100 | return result; | 100 | return result; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| @@ -106,7 +106,7 @@ public static class TeamMemberBatchExcelHelper | @@ -106,7 +106,7 @@ public static class TeamMemberBatchExcelHelper | ||
| 106 | parseErrors.Add(new TeamMemberBatchImportErrorDto | 106 | parseErrors.Add(new TeamMemberBatchImportErrorDto |
| 107 | { | 107 | { |
| 108 | RowNumber = 1, | 108 | RowNumber = 1, |
| 109 | - Message = "未找到「Name」与「Email」列(或同义表头),请使用官方模板" | 109 | + Message = "Name and Email columns were not found (or equivalent headers). Use the official template." |
| 110 | }); | 110 | }); |
| 111 | return result; | 111 | return result; |
| 112 | } | 112 | } |
| @@ -120,7 +120,7 @@ public static class TeamMemberBatchExcelHelper | @@ -120,7 +120,7 @@ public static class TeamMemberBatchExcelHelper | ||
| 120 | parseErrors.Add(new TeamMemberBatchImportErrorDto | 120 | parseErrors.Add(new TeamMemberBatchImportErrorDto |
| 121 | { | 121 | { |
| 122 | RowNumber = rowNum, | 122 | RowNumber = rowNum, |
| 123 | - Message = $"已超过单次导入上限 {maxRows} 行,后续行已忽略" | 123 | + Message = $"Import exceeds the limit of {maxRows} rows; remaining rows were skipped." |
| 124 | }); | 124 | }); |
| 125 | break; | 125 | break; |
| 126 | } | 126 | } |
| @@ -133,7 +133,7 @@ public static class TeamMemberBatchExcelHelper | @@ -133,7 +133,7 @@ public static class TeamMemberBatchExcelHelper | ||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | dataRowCount++; | 135 | dataRowCount++; |
| 136 | - var errPrefix = $"第 {rowNum} 行"; | 136 | + var errPrefix = $"Row {rowNum}"; |
| 137 | try | 137 | try |
| 138 | { | 138 | { |
| 139 | var input = BuildCreateInputFromRow( | 139 | var input = BuildCreateInputFromRow( |
| @@ -280,12 +280,12 @@ public static class TeamMemberBatchExcelHelper | @@ -280,12 +280,12 @@ public static class TeamMemberBatchExcelHelper | ||
| 280 | 280 | ||
| 281 | if (string.IsNullOrWhiteSpace(fullName)) | 281 | if (string.IsNullOrWhiteSpace(fullName)) |
| 282 | { | 282 | { |
| 283 | - errors.Add("Name 不能为空"); | 283 | + errors.Add("Name is required."); |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | if (string.IsNullOrWhiteSpace(email)) | 286 | if (string.IsNullOrWhiteSpace(email)) |
| 287 | { | 287 | { |
| 288 | - errors.Add("Email 不能为空"); | 288 | + errors.Add("Email is required."); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | var login = string.IsNullOrWhiteSpace(userName) ? email.Trim() : userName.Trim(); | 291 | var login = string.IsNullOrWhiteSpace(userName) ? email.Trim() : userName.Trim(); |
| @@ -293,13 +293,13 @@ public static class TeamMemberBatchExcelHelper | @@ -293,13 +293,13 @@ public static class TeamMemberBatchExcelHelper | ||
| 293 | 293 | ||
| 294 | if (string.IsNullOrWhiteSpace(login)) | 294 | if (string.IsNullOrWhiteSpace(login)) |
| 295 | { | 295 | { |
| 296 | - errors.Add("登录账号不能为空(可填 UserName 列,否则使用 Email)"); | 296 | + errors.Add("Login account is required (fill UserName, or Email will be used)."); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | var pwd = string.IsNullOrWhiteSpace(password) ? defaultPassword : password.Trim(); | 299 | var pwd = string.IsNullOrWhiteSpace(password) ? defaultPassword : password.Trim(); |
| 300 | if (string.IsNullOrWhiteSpace(pwd)) | 300 | if (string.IsNullOrWhiteSpace(pwd)) |
| 301 | { | 301 | { |
| 302 | - errors.Add("Password 不能为空且未配置默认密码"); | 302 | + errors.Add("Password is required and no default password is configured."); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | long? phone = null; | 305 | long? phone = null; |
| @@ -308,7 +308,7 @@ public static class TeamMemberBatchExcelHelper | @@ -308,7 +308,7 @@ public static class TeamMemberBatchExcelHelper | ||
| 308 | if (!long.TryParse(RegexDigitsOnly(phoneStr), NumberStyles.Integer, CultureInfo.InvariantCulture, | 308 | if (!long.TryParse(RegexDigitsOnly(phoneStr), NumberStyles.Integer, CultureInfo.InvariantCulture, |
| 309 | out var p)) | 309 | out var p)) |
| 310 | { | 310 | { |
| 311 | - errors.Add("Phone 格式不正确(需为数字)"); | 311 | + errors.Add("Phone format is invalid (digits only)."); |
| 312 | } | 312 | } |
| 313 | else | 313 | else |
| 314 | { | 314 | { |
| @@ -323,11 +323,11 @@ public static class TeamMemberBatchExcelHelper | @@ -323,11 +323,11 @@ public static class TeamMemberBatchExcelHelper | ||
| 323 | } | 323 | } |
| 324 | else if (string.IsNullOrWhiteSpace(roleName)) | 324 | else if (string.IsNullOrWhiteSpace(roleName)) |
| 325 | { | 325 | { |
| 326 | - errors.Add("Role Name 不能为空(或填写有效的 Role Id Guid)"); | 326 | + errors.Add("Role Name is required (or provide a valid Role Id Guid)."); |
| 327 | } | 327 | } |
| 328 | else if (!roleNameToId.TryGetValue(NormalizeRoleKey(roleName), out var rid)) | 328 | else if (!roleNameToId.TryGetValue(NormalizeRoleKey(roleName), out var rid)) |
| 329 | { | 329 | { |
| 330 | - errors.Add($"未找到角色「{roleName.Trim()}」,请与系统角色名称一致"); | 330 | + errors.Add($"Role \"{roleName.Trim()}\" was not found. Use a role name that matches the system."); |
| 331 | } | 331 | } |
| 332 | else | 332 | else |
| 333 | { | 333 | { |
| @@ -340,7 +340,7 @@ public static class TeamMemberBatchExcelHelper | @@ -340,7 +340,7 @@ public static class TeamMemberBatchExcelHelper | ||
| 340 | 340 | ||
| 341 | if (regionTokens.Count == 0 && locationTokens.Count == 0 && !isCompanyAdmin) | 341 | if (regionTokens.Count == 0 && locationTokens.Count == 0 && !isCompanyAdmin) |
| 342 | { | 342 | { |
| 343 | - errors.Add("Region 与 Assigned Location Ids 至少填一项(均可留空时仅适用于 Company Admin 且已在 Web 端配置 Company)"); | 343 | + errors.Add("Fill at least one of Region or Assigned Location Ids (both can be empty only for Company Admin with Company configured on Web)."); |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | if (errors.Count > 0) | 346 | if (errors.Count > 0) |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TeamMemberRoleHelper.cs
| @@ -25,7 +25,8 @@ public static class TeamMemberRoleHelper | @@ -25,7 +25,8 @@ public static class TeamMemberRoleHelper | ||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | var name = roleName.Trim(); | 27 | var name = roleName.Trim(); |
| 28 | - if (string.Equals(name, "Company Admin", StringComparison.OrdinalIgnoreCase)) | 28 | + if (string.Equals(name, "Company Admin", StringComparison.OrdinalIgnoreCase) |
| 29 | + || string.Equals(name, "公司管理员", StringComparison.Ordinal)) | ||
| 29 | { | 30 | { |
| 30 | return true; | 31 | return true; |
| 31 | } | 32 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TenantContextGuard.cs
| @@ -13,7 +13,7 @@ public static class TenantContextGuard | @@ -13,7 +13,7 @@ public static class TenantContextGuard | ||
| 13 | /// 平台主库登录(JWT/__tenant 均无业务租户)时访问 fl_* 等业务表的友好提示。 | 13 | /// 平台主库登录(JWT/__tenant 均无业务租户)时访问 fl_* 等业务表的友好提示。 |
| 14 | /// </summary> | 14 | /// </summary> |
| 15 | public const string PlatformCannotAccessBusinessDataMessage = | 15 | public const string PlatformCannotAccessBusinessDataMessage = |
| 16 | - "当前为平台主库登录,无法访问公司业务数据(标签/产品/成员等)。请选择具体公司登录,或使用平台「公司管理」相关接口。"; | 16 | + "You are signed in to the platform host database and cannot access company business data (labels, products, team members, etc.). Sign in to a specific company or use platform company-management APIs."; |
| 17 | 17 | ||
| 18 | public static void EnsureTenantResolved(ICurrentTenant currentTenant, string? operation = null) | 18 | public static void EnsureTenantResolved(ICurrentTenant currentTenant, string? operation = null) |
| 19 | { | 19 | { |
| @@ -23,10 +23,10 @@ public static class TenantContextGuard | @@ -23,10 +23,10 @@ public static class TenantContextGuard | ||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | var hint = string.IsNullOrWhiteSpace(operation) | 25 | var hint = string.IsNullOrWhiteSpace(operation) |
| 26 | - ? "未识别租户上下文" | ||
| 27 | - : $"{operation}:未识别租户上下文"; | 26 | + ? "Tenant context could not be resolved" |
| 27 | + : $"{operation}: tenant context could not be resolved"; | ||
| 28 | throw new UserFriendlyException( | 28 | throw new UserFriendlyException( |
| 29 | - $"{hint}。请使用泰额登录接口(th-web-auth / th-app-auth)选择具体公司登录,或请求头 __tenant 携带租户 Id。"); | 29 | + $"{hint}. Sign in to a specific company via th-web-auth / th-app-auth, or send the tenant Id in the __tenant header."); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | /// <summary> | 32 | /// <summary> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TrainingFileScopeHelper.cs
| @@ -377,7 +377,7 @@ public static class TrainingFileScopeHelper | @@ -377,7 +377,7 @@ public static class TrainingFileScopeHelper | ||
| 377 | var missing = groupIds.Where(id => !existingSet.Contains(id)).ToList(); | 377 | var missing = groupIds.Where(id => !existingSet.Contains(id)).ToList(); |
| 378 | if (missing.Count > 0) | 378 | if (missing.Count > 0) |
| 379 | { | 379 | { |
| 380 | - throw new UserFriendlyException("存在无效的 Region Id"); | 380 | + throw new UserFriendlyException("Invalid Region Id(s)."); |
| 381 | } | 381 | } |
| 382 | } | 382 | } |
| 383 | 383 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppAuthScopeHelper.cs
| @@ -23,7 +23,7 @@ public static class UsAppAuthScopeHelper | @@ -23,7 +23,7 @@ public static class UsAppAuthScopeHelper | ||
| 23 | { | 23 | { |
| 24 | if (currentUser.Id is null) | 24 | if (currentUser.Id is null) |
| 25 | { | 25 | { |
| 26 | - throw new UserFriendlyException("用户未登录"); | 26 | + throw new UserFriendlyException("You are not signed in."); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | var kind = currentUser.FindClaim(UsAppJwtClaims.ClientKind)?.Value; | 29 | var kind = currentUser.FindClaim(UsAppJwtClaims.ClientKind)?.Value; |
| @@ -32,12 +32,12 @@ public static class UsAppAuthScopeHelper | @@ -32,12 +32,12 @@ public static class UsAppAuthScopeHelper | ||
| 32 | || string.Equals(kind, UsAppJwtClaims.ClientKindThApp, StringComparison.Ordinal); | 32 | || string.Equals(kind, UsAppJwtClaims.ClientKindThApp, StringComparison.Ordinal); |
| 33 | if (!isAppToken) | 33 | if (!isAppToken) |
| 34 | { | 34 | { |
| 35 | - throw new UserFriendlyException("请使用 App 登录令牌调用该接口"); | 35 | + throw new UserFriendlyException("Use an App sign-in token to call this API."); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | if (!await CanUseAdminScopeApisAsync(db, currentUser)) | 38 | if (!await CanUseAdminScopeApisAsync(db, currentUser)) |
| 39 | { | 39 | { |
| 40 | - throw new UserFriendlyException("仅管理员或 Company Admin 可使用公司/区域/门店筛选接口"); | 40 | + throw new UserFriendlyException("Only administrators or Company Admin may use company/region/location filter APIs."); |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| @@ -86,7 +86,7 @@ public static class UsAppAuthScopeHelper | @@ -86,7 +86,7 @@ public static class UsAppAuthScopeHelper | ||
| 86 | var pid = partnerId.Trim(); | 86 | var pid = partnerId.Trim(); |
| 87 | if (string.IsNullOrEmpty(pid)) | 87 | if (string.IsNullOrEmpty(pid)) |
| 88 | { | 88 | { |
| 89 | - throw new UserFriendlyException("请选择公司"); | 89 | + throw new UserFriendlyException("Select a company."); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | return await db.Queryable<FlGroupDbEntity>() | 92 | return await db.Queryable<FlGroupDbEntity>() |
| @@ -155,7 +155,7 @@ public static class UsAppAuthScopeHelper | @@ -155,7 +155,7 @@ public static class UsAppAuthScopeHelper | ||
| 155 | var locationId = input.LocationId?.Trim() ?? string.Empty; | 155 | var locationId = input.LocationId?.Trim() ?? string.Empty; |
| 156 | if (string.IsNullOrEmpty(partnerId) || string.IsNullOrEmpty(groupId) || string.IsNullOrEmpty(locationId)) | 156 | if (string.IsNullOrEmpty(partnerId) || string.IsNullOrEmpty(groupId) || string.IsNullOrEmpty(locationId)) |
| 157 | { | 157 | { |
| 158 | - throw new UserFriendlyException("请选择公司、区域和门店"); | 158 | + throw new UserFriendlyException("Select company, region, and location."); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | if (!ReportsRoleHelper.IsAdminRole(currentUser)) | 161 | if (!ReportsRoleHelper.IsAdminRole(currentUser)) |
| @@ -170,19 +170,19 @@ public static class UsAppAuthScopeHelper | @@ -170,19 +170,19 @@ public static class UsAppAuthScopeHelper | ||
| 170 | null); | 170 | null); |
| 171 | if (scopedIds is null || !scopedIds.Contains(locationId)) | 171 | if (scopedIds is null || !scopedIds.Contains(locationId)) |
| 172 | { | 172 | { |
| 173 | - throw new UserFriendlyException("门店与所选公司/区域不匹配"); | 173 | + throw new UserFriendlyException("Location does not match the selected company/region."); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | if (!Guid.TryParse(locationId, out var locationGuid)) | 176 | if (!Guid.TryParse(locationId, out var locationGuid)) |
| 177 | { | 177 | { |
| 178 | - throw new UserFriendlyException("无效的门店标识"); | 178 | + throw new UserFriendlyException("Invalid location identifier."); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | var loc = await db.Queryable<LocationAggregateRoot>() | 181 | var loc = await db.Queryable<LocationAggregateRoot>() |
| 182 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); | 182 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); |
| 183 | if (loc is null) | 183 | if (loc is null) |
| 184 | { | 184 | { |
| 185 | - throw new UserFriendlyException("门店不存在或已删除"); | 185 | + throw new UserFriendlyException("Location not found or removed."); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | var partner = await db.Queryable<FlPartnerDbEntity>() | 188 | var partner = await db.Queryable<FlPartnerDbEntity>() |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppPrintLogScopeHelper.cs
| @@ -71,20 +71,20 @@ public static class UsAppPrintLogScopeHelper | @@ -71,20 +71,20 @@ public static class UsAppPrintLogScopeHelper | ||
| 71 | 71 | ||
| 72 | if (currentUser.Id is null) | 72 | if (currentUser.Id is null) |
| 73 | { | 73 | { |
| 74 | - throw new UserFriendlyException("用户未登录"); | 74 | + throw new UserFriendlyException("You are not signed in."); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | var lid = TeamMemberListScopeHelper.NormalizeScopeKey(locationId); | 77 | var lid = TeamMemberListScopeHelper.NormalizeScopeKey(locationId); |
| 78 | if (string.IsNullOrEmpty(lid)) | 78 | if (string.IsNullOrEmpty(lid)) |
| 79 | { | 79 | { |
| 80 | - throw new UserFriendlyException("门店参数无效"); | 80 | + throw new UserFriendlyException("Invalid location parameter."); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | var accessible = await LocationScopeBindingHelper.ResolveAppAccessibleLocationIdsForUserAsync( | 83 | var accessible = await LocationScopeBindingHelper.ResolveAppAccessibleLocationIdsForUserAsync( |
| 84 | db, currentUser.Id.Value, currentUser); | 84 | db, currentUser.Id.Value, currentUser); |
| 85 | if (!accessible.Contains(lid, StringComparer.OrdinalIgnoreCase)) | 85 | if (!accessible.Contains(lid, StringComparer.OrdinalIgnoreCase)) |
| 86 | { | 86 | { |
| 87 | - throw new UserFriendlyException("当前账号未绑定该门店,无法查看"); | 87 | + throw new UserFriendlyException("This account is not bound to that location; access denied."); |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/MultiTenancy/EmbeddedTenantSqlScripts.cs
| @@ -19,7 +19,7 @@ public static class EmbeddedTenantSqlScripts | @@ -19,7 +19,7 @@ public static class EmbeddedTenantSqlScripts | ||
| 19 | { | 19 | { |
| 20 | var available = string.Join(", ", assembly.GetManifestResourceNames()); | 20 | var available = string.Join(", ", assembly.GetManifestResourceNames()); |
| 21 | throw new InvalidOperationException( | 21 | throw new InvalidOperationException( |
| 22 | - $"未找到嵌入 SQL 资源「{resourceName}」。可用资源:{available}"); | 22 | + $"Embedded SQL resource not found: \"{resourceName}\". Available resources: {available}"); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | using (stream) | 25 | using (stream) |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingPictureOptions.cs
0 → 100644
| 1 | +namespace FoodLabeling.Application.Options; | ||
| 2 | + | ||
| 3 | +/// <summary> | ||
| 4 | +/// 产品/类别图片落盘目录。Linux 统一在 <c>/www/wwwroot/picture/{版本}</c>,与 API 发布目录分离,避免部署清空图片。 | ||
| 5 | +/// </summary> | ||
| 6 | +public class FoodLabelingPictureOptions | ||
| 7 | +{ | ||
| 8 | + public const string SectionName = "FoodLabeling:Picture"; | ||
| 9 | + | ||
| 10 | + /// <summary>物理根目录,例如 <c>/www/wwwroot/picture/tetest</c>。</summary> | ||
| 11 | + public string RootPath { get; set; } = string.Empty; | ||
| 12 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AlertTemplateAppService.cs
| @@ -218,14 +218,14 @@ public class AlertTemplateAppService : ApplicationService, IAlertTemplateAppServ | @@ -218,14 +218,14 @@ public class AlertTemplateAppService : ApplicationService, IAlertTemplateAppServ | ||
| 218 | var tid = id?.Trim(); | 218 | var tid = id?.Trim(); |
| 219 | if (string.IsNullOrWhiteSpace(tid)) | 219 | if (string.IsNullOrWhiteSpace(tid)) |
| 220 | { | 220 | { |
| 221 | - throw new UserFriendlyException("模板Id不能为空"); | 221 | + throw new UserFriendlyException("Template Id is required."); |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | var entity = await _dbContext.SqlSugarClient.Queryable<FlAlertTemplateDbEntity>() | 224 | var entity = await _dbContext.SqlSugarClient.Queryable<FlAlertTemplateDbEntity>() |
| 225 | .FirstAsync(x => x.Id == tid && !x.IsDeleted); | 225 | .FirstAsync(x => x.Id == tid && !x.IsDeleted); |
| 226 | if (entity is null) | 226 | if (entity is null) |
| 227 | { | 227 | { |
| 228 | - throw new UserFriendlyException("告警模板不存在"); | 228 | + throw new UserFriendlyException("Alert template not found."); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | return entity; | 231 | return entity; |
| @@ -235,19 +235,19 @@ public class AlertTemplateAppService : ApplicationService, IAlertTemplateAppServ | @@ -235,19 +235,19 @@ public class AlertTemplateAppService : ApplicationService, IAlertTemplateAppServ | ||
| 235 | { | 235 | { |
| 236 | if (input is null) | 236 | if (input is null) |
| 237 | { | 237 | { |
| 238 | - throw new UserFriendlyException("入参不能为空"); | 238 | + throw new UserFriendlyException("Request body is required."); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | var name = input.TemplateName?.Trim(); | 241 | var name = input.TemplateName?.Trim(); |
| 242 | if (string.IsNullOrWhiteSpace(name)) | 242 | if (string.IsNullOrWhiteSpace(name)) |
| 243 | { | 243 | { |
| 244 | - throw new UserFriendlyException("模板名称不能为空"); | 244 | + throw new UserFriendlyException("Template name is required."); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | var format = input.DateTimeFormat?.Trim(); | 247 | var format = input.DateTimeFormat?.Trim(); |
| 248 | if (string.IsNullOrWhiteSpace(format)) | 248 | if (string.IsNullOrWhiteSpace(format)) |
| 249 | { | 249 | { |
| 250 | - throw new UserFriendlyException("日期时间格式不能为空"); | 250 | + throw new UserFriendlyException("Date/time format is required."); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | return (name, format); | 253 | return (name, format); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs
| @@ -108,8 +108,8 @@ public class AppUpdateAppService : ApplicationService, IAppUpdateAppService | @@ -108,8 +108,8 @@ public class AppUpdateAppService : ApplicationService, IAppUpdateAppService | ||
| 108 | if (apk is not { Exists: true, Length: > 0 }) | 108 | if (apk is not { Exists: true, Length: > 0 }) |
| 109 | { | 109 | { |
| 110 | throw new UserFriendlyException( | 110 | throw new UserFriendlyException( |
| 111 | - "APK 文件不存在,请放到: " + _options.ApkPath | ||
| 112 | - + "(当前工作目录=" + Environment.CurrentDirectory + ")"); | 111 | + "APK file not found. Place it at: " + _options.ApkPath |
| 112 | + + " (current working directory=" + Environment.CurrentDirectory + ")"); | ||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | var (_, remoteName) = AppUpdateVersionResolver.Resolve(apk, _options); | 115 | var (_, remoteName) = AppUpdateVersionResolver.Resolve(apk, _options); |
| @@ -124,7 +124,7 @@ public class AppUpdateAppService : ApplicationService, IAppUpdateAppService | @@ -124,7 +124,7 @@ public class AppUpdateAppService : ApplicationService, IAppUpdateAppService | ||
| 124 | { | 124 | { |
| 125 | if (!_options.Enabled) | 125 | if (!_options.Enabled) |
| 126 | { | 126 | { |
| 127 | - throw new UserFriendlyException("App 更新未启用"); | 127 | + throw new UserFriendlyException("App update is not enabled."); |
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | 130 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AuthSessionAppService.cs
| @@ -53,7 +53,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | @@ -53,7 +53,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | ||
| 53 | 53 | ||
| 54 | if (!CurrentUser.Id.HasValue) | 54 | if (!CurrentUser.Id.HasValue) |
| 55 | { | 55 | { |
| 56 | - throw new UserFriendlyException("用户未登录"); | 56 | + throw new UserFriendlyException("You are not signed in."); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // 避免走 UserManager.GetInfoAsync -> UserRepository.GetUserAllInfoAsync 的导航加载 | 59 | // 避免走 UserManager.GetInfoAsync -> UserRepository.GetUserAllInfoAsync 的导航加载 |
| @@ -62,7 +62,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | @@ -62,7 +62,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | ||
| 62 | var user = await _userRepository.GetByIdAsync(userId); | 62 | var user = await _userRepository.GetByIdAsync(userId); |
| 63 | if (user is null || user.IsDeleted) | 63 | if (user is null || user.IsDeleted) |
| 64 | { | 64 | { |
| 65 | - throw new UserFriendlyException("用户不存在"); | 65 | + throw new UserFriendlyException("User not found."); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | var userRoleIds = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity>() | 68 | var userRoleIds = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity>() |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlTeamMemberScopeDbEntity.cs
| @@ -21,6 +21,10 @@ public class FlTeamMemberScopeDbEntity | @@ -21,6 +21,10 @@ public class FlTeamMemberScopeDbEntity | ||
| 21 | [SugarColumn(Length = 20)] | 21 | [SugarColumn(Length = 20)] |
| 22 | public string AppliedLocationType { get; set; } = "SPECIFIED"; | 22 | public string AppliedLocationType { get; set; } = "SPECIFIED"; |
| 23 | 23 | ||
| 24 | + /// <summary>Location=ALL 时绑定的 Company(fl_partner.Id,逗号分隔)</summary> | ||
| 25 | + [SugarColumn(Length = 2000, IsNullable = true)] | ||
| 26 | + public string? PartnerIds { get; set; } | ||
| 27 | + | ||
| 24 | public DateTime? CreationTime { get; set; } | 28 | public DateTime? CreationTime { get; set; } |
| 25 | 29 | ||
| 26 | public DateTime? LastModificationTime { get; set; } | 30 | public DateTime? LastModificationTime { get; set; } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAlertTimerAppService.cs
| @@ -53,7 +53,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -53,7 +53,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 53 | /// <param name="input">分页查询入参</param> | 53 | /// <param name="input">分页查询入参</param> |
| 54 | /// <returns>分页计时器列表(含 remainingTime 倒计时秒数)</returns> | 54 | /// <returns>分页计时器列表(含 remainingTime 倒计时秒数)</returns> |
| 55 | /// <response code="200">成功返回分页列表</response> | 55 | /// <response code="200">成功返回分页列表</response> |
| 56 | - /// <response code="400">参数错误或未登录/无门店权限</response> | 56 | + /// <response code="400">参数错误或You are not signed in./无门店权限</response> |
| 57 | /// <response code="500">服务器错误</response> | 57 | /// <response code="500">服务器错误</response> |
| 58 | [Authorize] | 58 | [Authorize] |
| 59 | [HttpPost("label-alert-timer/list")] | 59 | [HttpPost("label-alert-timer/list")] |
| @@ -62,12 +62,12 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -62,12 +62,12 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 62 | { | 62 | { |
| 63 | if (input is null) | 63 | if (input is null) |
| 64 | { | 64 | { |
| 65 | - throw new UserFriendlyException("入参不能为空"); | 65 | + throw new UserFriendlyException("Request body is required."); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | if (!CurrentUser.Id.HasValue) | 68 | if (!CurrentUser.Id.HasValue) |
| 69 | { | 69 | { |
| 70 | - throw new UserFriendlyException("用户未登录"); | 70 | + throw new UserFriendlyException("You are not signed in."); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | var locationId = input.LocationId?.Trim(); | 73 | var locationId = input.LocationId?.Trim(); |
| @@ -120,7 +120,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -120,7 +120,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 120 | /// <param name="input">分页查询入参</param> | 120 | /// <param name="input">分页查询入参</param> |
| 121 | /// <returns>分页告警列表(含倒计时)</returns> | 121 | /// <returns>分页告警列表(含倒计时)</returns> |
| 122 | /// <response code="200">成功返回分页列表</response> | 122 | /// <response code="200">成功返回分页列表</response> |
| 123 | - /// <response code="400">未登录、无门店或无权限</response> | 123 | + /// <response code="400">Not signed in, no locations, or no permission</response> |
| 124 | /// <response code="500">服务器错误</response> | 124 | /// <response code="500">服务器错误</response> |
| 125 | [Authorize] | 125 | [Authorize] |
| 126 | [HttpPost("label-alert-timer/app-list")] | 126 | [HttpPost("label-alert-timer/app-list")] |
| @@ -129,12 +129,12 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -129,12 +129,12 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 129 | { | 129 | { |
| 130 | if (input is null) | 130 | if (input is null) |
| 131 | { | 131 | { |
| 132 | - throw new UserFriendlyException("入参不能为空"); | 132 | + throw new UserFriendlyException("Request body is required."); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | if (!CurrentUser.Id.HasValue) | 135 | if (!CurrentUser.Id.HasValue) |
| 136 | { | 136 | { |
| 137 | - throw new UserFriendlyException("用户未登录"); | 137 | + throw new UserFriendlyException("You are not signed in."); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | var locationId = input.LocationId?.Trim(); | 140 | var locationId = input.LocationId?.Trim(); |
| @@ -148,7 +148,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -148,7 +148,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 148 | 148 | ||
| 149 | if (string.IsNullOrWhiteSpace(locationId)) | 149 | if (string.IsNullOrWhiteSpace(locationId)) |
| 150 | { | 150 | { |
| 151 | - throw new UserFriendlyException("请先选择门店或传入 locationId"); | 151 | + throw new UserFriendlyException("Select a location or pass locationId."); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 154 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
| @@ -174,12 +174,12 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -174,12 +174,12 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 174 | var timerId = id?.Trim(); | 174 | var timerId = id?.Trim(); |
| 175 | if (string.IsNullOrWhiteSpace(timerId)) | 175 | if (string.IsNullOrWhiteSpace(timerId)) |
| 176 | { | 176 | { |
| 177 | - throw new UserFriendlyException("计时器Id不能为空"); | 177 | + throw new UserFriendlyException("Timer Id is required."); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | if (!CurrentUser.Id.HasValue) | 180 | if (!CurrentUser.Id.HasValue) |
| 181 | { | 181 | { |
| 182 | - throw new UserFriendlyException("用户未登录"); | 182 | + throw new UserFriendlyException("You are not signed in."); |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | var db = _dbContext.SqlSugarClient; | 185 | var db = _dbContext.SqlSugarClient; |
| @@ -190,7 +190,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -190,7 +190,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 190 | .FirstOrDefault(); | 190 | .FirstOrDefault(); |
| 191 | if (row is null) | 191 | if (row is null) |
| 192 | { | 192 | { |
| 193 | - throw new UserFriendlyException("计时器不存在或已删除"); | 193 | + throw new UserFriendlyException("Timer not found or removed."); |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 196 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
| @@ -236,7 +236,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -236,7 +236,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 236 | { | 236 | { |
| 237 | if (input is null) | 237 | if (input is null) |
| 238 | { | 238 | { |
| 239 | - throw new UserFriendlyException("入参不能为空"); | 239 | + throw new UserFriendlyException("Request body is required."); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | var timerId = input.TimerId?.Trim(); | 242 | var timerId = input.TimerId?.Trim(); |
| @@ -246,7 +246,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -246,7 +246,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 246 | string.IsNullOrWhiteSpace(batchId) && | 246 | string.IsNullOrWhiteSpace(batchId) && |
| 247 | string.IsNullOrWhiteSpace(printTaskId)) | 247 | string.IsNullOrWhiteSpace(printTaskId)) |
| 248 | { | 248 | { |
| 249 | - throw new UserFriendlyException("请至少提供 timerId、batchId 或 printTaskId 之一"); | 249 | + throw new UserFriendlyException("Provide at least one of timerId, batchId, or printTaskId."); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | var db = _dbContext.SqlSugarClient; | 252 | var db = _dbContext.SqlSugarClient; |
| @@ -297,7 +297,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | @@ -297,7 +297,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp | ||
| 297 | 297 | ||
| 298 | if (!CurrentUser.Id.HasValue) | 298 | if (!CurrentUser.Id.HasValue) |
| 299 | { | 299 | { |
| 300 | - throw new UserFriendlyException("用户未登录"); | 300 | + throw new UserFriendlyException("You are not signed in."); |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 303 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
| @@ -308,7 +308,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -308,7 +308,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 308 | var labelCode = id?.Trim(); | 308 | var labelCode = id?.Trim(); |
| 309 | if (string.IsNullOrWhiteSpace(labelCode)) | 309 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 310 | { | 310 | { |
| 311 | - throw new UserFriendlyException("标签Code不能为空"); | 311 | + throw new UserFriendlyException("labelCode is required."); |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | var db = _dbContext.SqlSugarClient; | 314 | var db = _dbContext.SqlSugarClient; |
| @@ -316,7 +316,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -316,7 +316,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 316 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 316 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 317 | if (label is null) | 317 | if (label is null) |
| 318 | { | 318 | { |
| 319 | - throw new UserFriendlyException("标签不存在"); | 319 | + throw new UserFriendlyException("Label not found."); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | var template = await LabelTemplateQueryHelper.QueryProjected(db) | 322 | var template = await LabelTemplateQueryHelper.QueryProjected(db) |
| @@ -452,21 +452,21 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -452,21 +452,21 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 452 | var labelName = input.LabelName?.Trim(); | 452 | var labelName = input.LabelName?.Trim(); |
| 453 | if (string.IsNullOrWhiteSpace(labelName)) | 453 | if (string.IsNullOrWhiteSpace(labelName)) |
| 454 | { | 454 | { |
| 455 | - throw new UserFriendlyException("标签名称不能为空"); | 455 | + throw new UserFriendlyException("Label name is required."); |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | if (input.ProductIds is null || input.ProductIds.Count == 0) | 458 | if (input.ProductIds is null || input.ProductIds.Count == 0) |
| 459 | { | 459 | { |
| 460 | - throw new UserFriendlyException("标签至少需要绑定一个产品"); | 460 | + throw new UserFriendlyException("A label must be bound to at least one product."); |
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) | 463 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) |
| 464 | { | 464 | { |
| 465 | - throw new UserFriendlyException("模板编码不能为空"); | 465 | + throw new UserFriendlyException("Template code is required."); |
| 466 | } | 466 | } |
| 467 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) | 467 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) |
| 468 | { | 468 | { |
| 469 | - throw new UserFriendlyException("标签分类Id不能为空"); | 469 | + throw new UserFriendlyException("Label category Id is required."); |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); | 472 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); |
| @@ -486,7 +486,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -486,7 +486,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 486 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); | 486 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); |
| 487 | if (template is null) | 487 | if (template is null) |
| 488 | { | 488 | { |
| 489 | - throw new UserFriendlyException("模板不存在"); | 489 | + throw new UserFriendlyException("Template not found."); |
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | // 唯一性校验(LabelCode) | 492 | // 唯一性校验(LabelCode) |
| @@ -494,7 +494,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -494,7 +494,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 494 | .AnyAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 494 | .AnyAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 495 | if (exists) | 495 | if (exists) |
| 496 | { | 496 | { |
| 497 | - throw new UserFriendlyException("标签编码已存在"); | 497 | + throw new UserFriendlyException("Label code already exists."); |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | // 插入 fl_label | 500 | // 插入 fl_label |
| @@ -594,26 +594,26 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -594,26 +594,26 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 594 | /// <param name="input">批量导入入参</param> | 594 | /// <param name="input">批量导入入参</param> |
| 595 | /// <returns>成功/失败统计与行级错误</returns> | 595 | /// <returns>成功/失败统计与行级错误</returns> |
| 596 | /// <response code="200">导入完成(可能部分成功)</response> | 596 | /// <response code="200">导入完成(可能部分成功)</response> |
| 597 | - /// <response code="400">入参非法或模板不存在</response> | 597 | + /// <response code="400">入参非法或Template not found.</response> |
| 598 | /// <response code="500">服务器错误</response> | 598 | /// <response code="500">服务器错误</response> |
| 599 | [UnitOfWork] | 599 | [UnitOfWork] |
| 600 | public async Task<LabelBatchCreateResultDto> BatchCreateAsync(LabelBatchCreateInputVo input) | 600 | public async Task<LabelBatchCreateResultDto> BatchCreateAsync(LabelBatchCreateInputVo input) |
| 601 | { | 601 | { |
| 602 | if (input?.Items is null || input.Items.Count == 0) | 602 | if (input?.Items is null || input.Items.Count == 0) |
| 603 | { | 603 | { |
| 604 | - throw new UserFriendlyException("批量导入行不能为空"); | 604 | + throw new UserFriendlyException("Import rows cannot be empty."); |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | const int maxRows = 500; | 607 | const int maxRows = 500; |
| 608 | if (input.Items.Count > maxRows) | 608 | if (input.Items.Count > maxRows) |
| 609 | { | 609 | { |
| 610 | - throw new UserFriendlyException($"单次最多导入 {maxRows} 行"); | 610 | + throw new UserFriendlyException($"Maximum {maxRows} rows per import."); |
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | var templateCode = input.TemplateCode?.Trim(); | 613 | var templateCode = input.TemplateCode?.Trim(); |
| 614 | if (string.IsNullOrWhiteSpace(templateCode)) | 614 | if (string.IsNullOrWhiteSpace(templateCode)) |
| 615 | { | 615 | { |
| 616 | - throw new UserFriendlyException("模板编码不能为空"); | 616 | + throw new UserFriendlyException("Template code is required."); |
| 617 | } | 617 | } |
| 618 | 618 | ||
| 619 | var db = _dbContext.SqlSugarClient; | 619 | var db = _dbContext.SqlSugarClient; |
| @@ -621,7 +621,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -621,7 +621,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 621 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == templateCode); | 621 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == templateCode); |
| 622 | if (template is null) | 622 | if (template is null) |
| 623 | { | 623 | { |
| 624 | - throw new UserFriendlyException("模板不存在"); | 624 | + throw new UserFriendlyException("Template not found."); |
| 625 | } | 625 | } |
| 626 | 626 | ||
| 627 | var templateElements = await LabelBatchTemplateDefaultsHelper.LoadTemplateElementsAsync(db, template.Id); | 627 | var templateElements = await LabelBatchTemplateDefaultsHelper.LoadTemplateElementsAsync(db, template.Id); |
| @@ -722,7 +722,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -722,7 +722,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 722 | result.Errors.Add(new LabelBatchCreateErrorDto | 722 | result.Errors.Add(new LabelBatchCreateErrorDto |
| 723 | { | 723 | { |
| 724 | RowNumber = 0, | 724 | RowNumber = 0, |
| 725 | - Message = $"标签已创建,但模板默认值保存失败:{ex.Message}" | 725 | + Message = $"The label was created, but saving template defaults failed: {ex.Message}" |
| 726 | }); | 726 | }); |
| 727 | } | 727 | } |
| 728 | } | 728 | } |
| @@ -762,28 +762,28 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -762,28 +762,28 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 762 | var labelCode = id?.Trim(); | 762 | var labelCode = id?.Trim(); |
| 763 | if (string.IsNullOrWhiteSpace(labelCode)) | 763 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 764 | { | 764 | { |
| 765 | - throw new UserFriendlyException("标签Code不能为空"); | 765 | + throw new UserFriendlyException("labelCode is required."); |
| 766 | } | 766 | } |
| 767 | 767 | ||
| 768 | var label = await LabelQueryHelper.QueryProjected(_dbContext.SqlSugarClient) | 768 | var label = await LabelQueryHelper.QueryProjected(_dbContext.SqlSugarClient) |
| 769 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 769 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 770 | if (label is null) | 770 | if (label is null) |
| 771 | { | 771 | { |
| 772 | - throw new UserFriendlyException("标签不存在"); | 772 | + throw new UserFriendlyException("Label not found."); |
| 773 | } | 773 | } |
| 774 | 774 | ||
| 775 | if (input.ProductIds is null || input.ProductIds.Count == 0) | 775 | if (input.ProductIds is null || input.ProductIds.Count == 0) |
| 776 | { | 776 | { |
| 777 | - throw new UserFriendlyException("标签至少需要绑定一个产品"); | 777 | + throw new UserFriendlyException("A label must be bound to at least one product."); |
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) | 780 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) |
| 781 | { | 781 | { |
| 782 | - throw new UserFriendlyException("模板编码不能为空"); | 782 | + throw new UserFriendlyException("Template code is required."); |
| 783 | } | 783 | } |
| 784 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) | 784 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) |
| 785 | { | 785 | { |
| 786 | - throw new UserFriendlyException("标签分类Id不能为空"); | 786 | + throw new UserFriendlyException("Label category Id is required."); |
| 787 | } | 787 | } |
| 788 | 788 | ||
| 789 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); | 789 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); |
| @@ -803,7 +803,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -803,7 +803,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 803 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); | 803 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); |
| 804 | if (template is null) | 804 | if (template is null) |
| 805 | { | 805 | { |
| 806 | - throw new UserFriendlyException("模板不存在"); | 806 | + throw new UserFriendlyException("Template not found."); |
| 807 | } | 807 | } |
| 808 | 808 | ||
| 809 | var oldCategoryId = label.LabelCategoryId; | 809 | var oldCategoryId = label.LabelCategoryId; |
| @@ -924,7 +924,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -924,7 +924,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 924 | var labelCode = input?.LabelCode?.Trim(); | 924 | var labelCode = input?.LabelCode?.Trim(); |
| 925 | if (string.IsNullOrWhiteSpace(labelCode)) | 925 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 926 | { | 926 | { |
| 927 | - throw new UserFriendlyException("labelCode不能为空"); | 927 | + throw new UserFriendlyException("labelCode is required."); |
| 928 | } | 928 | } |
| 929 | 929 | ||
| 930 | var baseTime = input?.BaseTime ?? DateTime.Now; | 930 | var baseTime = input?.BaseTime ?? DateTime.Now; |
| @@ -933,7 +933,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -933,7 +933,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 933 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 933 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 934 | if (label is null) | 934 | if (label is null) |
| 935 | { | 935 | { |
| 936 | - throw new UserFriendlyException("标签不存在"); | 936 | + throw new UserFriendlyException("Label not found."); |
| 937 | } | 937 | } |
| 938 | 938 | ||
| 939 | // 选择预览产品 | 939 | // 选择预览产品 |
| @@ -948,14 +948,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -948,14 +948,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 948 | 948 | ||
| 949 | if (string.IsNullOrWhiteSpace(productId)) | 949 | if (string.IsNullOrWhiteSpace(productId)) |
| 950 | { | 950 | { |
| 951 | - throw new UserFriendlyException("该标签未绑定产品,无法预览"); | 951 | + throw new UserFriendlyException("This label has no bound products; preview is unavailable."); |
| 952 | } | 952 | } |
| 953 | 953 | ||
| 954 | var product = await _dbContext.SqlSugarClient.Queryable<FlProductDbEntity>() | 954 | var product = await _dbContext.SqlSugarClient.Queryable<FlProductDbEntity>() |
| 955 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); | 955 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); |
| 956 | if (product is null) | 956 | if (product is null) |
| 957 | { | 957 | { |
| 958 | - throw new UserFriendlyException("预览产品不存在"); | 958 | + throw new UserFriendlyException("Preview product not found."); |
| 959 | } | 959 | } |
| 960 | 960 | ||
| 961 | // 取模板头 & elements | 961 | // 取模板头 & elements |
| @@ -963,7 +963,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -963,7 +963,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 963 | .FirstAsync(x => !x.IsDeleted && x.Id == label.TemplateId); | 963 | .FirstAsync(x => !x.IsDeleted && x.Id == label.TemplateId); |
| 964 | if (template is null) | 964 | if (template is null) |
| 965 | { | 965 | { |
| 966 | - throw new UserFriendlyException("模板不存在"); | 966 | + throw new UserFriendlyException("Template not found."); |
| 967 | } | 967 | } |
| 968 | 968 | ||
| 969 | var elements = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateElementDbEntity>() | 969 | var elements = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateElementDbEntity>() |
| @@ -1039,7 +1039,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1039,7 +1039,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1039 | { | 1039 | { |
| 1040 | if (string.IsNullOrWhiteSpace(locationId)) | 1040 | if (string.IsNullOrWhiteSpace(locationId)) |
| 1041 | { | 1041 | { |
| 1042 | - throw new UserFriendlyException("预览/打印需要 locationId 以填充 Company 信息"); | 1042 | + throw new UserFriendlyException("Preview/print requires locationId to fill Company information."); |
| 1043 | } | 1043 | } |
| 1044 | 1044 | ||
| 1045 | partnerForCompany = await PartnerCompanyDisplayHelper.ResolvePartnerByLocationIdAsync( | 1045 | partnerForCompany = await PartnerCompanyDisplayHelper.ResolvePartnerByLocationIdAsync( |
| @@ -1200,14 +1200,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1200,14 +1200,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1200 | var pid = partnerId.Trim(); | 1200 | var pid = partnerId.Trim(); |
| 1201 | if (LocationScopeBindingHelper.IsAllScopeSentinel(pid)) | 1201 | if (LocationScopeBindingHelper.IsAllScopeSentinel(pid)) |
| 1202 | { | 1202 | { |
| 1203 | - throw new UserFriendlyException("标签适用 Company 不支持 ALL,请传单个具体 Company Id"); | 1203 | + throw new UserFriendlyException("Label applicable Company does not support ALL; pass a single Company Id."); |
| 1204 | } | 1204 | } |
| 1205 | 1205 | ||
| 1206 | if (merged.Count > 0 | 1206 | if (merged.Count > 0 |
| 1207 | && (merged.Count > 1 | 1207 | && (merged.Count > 1 |
| 1208 | || !string.Equals(merged[0], pid, StringComparison.OrdinalIgnoreCase))) | 1208 | || !string.Equals(merged[0], pid, StringComparison.OrdinalIgnoreCase))) |
| 1209 | { | 1209 | { |
| 1210 | - throw new UserFriendlyException("partnerId 与 companyIds/partnerIds 不一致"); | 1210 | + throw new UserFriendlyException("partnerId does not match companyIds/partnerIds."); |
| 1211 | } | 1211 | } |
| 1212 | 1212 | ||
| 1213 | merged = new List<string> { pid }; | 1213 | merged = new List<string> { pid }; |
| @@ -1215,13 +1215,13 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1215,13 +1215,13 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1215 | 1215 | ||
| 1216 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(merged)) | 1216 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(merged)) |
| 1217 | { | 1217 | { |
| 1218 | - throw new UserFriendlyException("标签适用 Company 不支持 ALL,请传单个具体 Company Id"); | 1218 | + throw new UserFriendlyException("Label applicable Company does not support ALL; pass a single Company Id."); |
| 1219 | } | 1219 | } |
| 1220 | 1220 | ||
| 1221 | var concrete = LocationScopeBindingHelper.FilterConcreteScopeIds(merged); | 1221 | var concrete = LocationScopeBindingHelper.FilterConcreteScopeIds(merged); |
| 1222 | if (concrete.Count > 1) | 1222 | if (concrete.Count > 1) |
| 1223 | { | 1223 | { |
| 1224 | - throw new UserFriendlyException("标签适用 Company 仅支持单选(companyIds 最多传 1 个)"); | 1224 | + throw new UserFriendlyException("Label applicable Company allows only one selection (at most one companyIds entry)."); |
| 1225 | } | 1225 | } |
| 1226 | 1226 | ||
| 1227 | if (concrete.Count == 0) | 1227 | if (concrete.Count == 0) |
| @@ -1233,7 +1233,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1233,7 +1233,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1233 | .AnyAsync(x => !x.IsDeleted && x.Id == concrete[0]); | 1233 | .AnyAsync(x => !x.IsDeleted && x.Id == concrete[0]); |
| 1234 | if (!exists) | 1234 | if (!exists) |
| 1235 | { | 1235 | { |
| 1236 | - throw new UserFriendlyException("存在无效的 Company(partnerId/companyIds),请刷新后重试"); | 1236 | + throw new UserFriendlyException("Invalid Company (partnerId/companyIds). Refresh and try again."); |
| 1237 | } | 1237 | } |
| 1238 | 1238 | ||
| 1239 | return concrete[0]; | 1239 | return concrete[0]; |
| @@ -1255,7 +1255,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1255,7 +1255,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1255 | } | 1255 | } |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | - throw new UserFriendlyException("无法生成唯一标签编码,请稍后重试或手动填写编码"); | 1258 | + throw new UserFriendlyException("Could not generate a unique label code. Retry later or enter a code manually."); |
| 1259 | } | 1259 | } |
| 1260 | 1260 | ||
| 1261 | private async Task EnsureLabelTypeExistsIfProvidedAsync(string? labelTypeId) | 1261 | private async Task EnsureLabelTypeExistsIfProvidedAsync(string? labelTypeId) |
| @@ -1270,7 +1270,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1270,7 +1270,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1270 | .AnyAsync(x => !x.IsDeleted && x.Id == id); | 1270 | .AnyAsync(x => !x.IsDeleted && x.Id == id); |
| 1271 | if (!exists) | 1271 | if (!exists) |
| 1272 | { | 1272 | { |
| 1273 | - throw new UserFriendlyException("标签类型不存在"); | 1273 | + throw new UserFriendlyException("Label type not found."); |
| 1274 | } | 1274 | } |
| 1275 | } | 1275 | } |
| 1276 | } | 1276 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
| @@ -118,7 +118,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -118,7 +118,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 118 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 118 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 119 | if (entity is null) | 119 | if (entity is null) |
| 120 | { | 120 | { |
| 121 | - throw new UserFriendlyException("标签分类不存在"); | 121 | + throw new UserFriendlyException("Label category not found."); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | var dto = MapToGetOutput(entity); | 124 | var dto = MapToGetOutput(entity); |
| @@ -159,7 +159,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -159,7 +159,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 159 | var name = input.CategoryName?.Trim(); | 159 | var name = input.CategoryName?.Trim(); |
| 160 | if (string.IsNullOrWhiteSpace(name)) | 160 | if (string.IsNullOrWhiteSpace(name)) |
| 161 | { | 161 | { |
| 162 | - throw new UserFriendlyException("分类名称不能为空"); | 162 | + throw new UserFriendlyException("Category name is required."); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | var code = input.CategoryCode?.Trim(); | 165 | var code = input.CategoryCode?.Trim(); |
| @@ -215,7 +215,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -215,7 +215,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 215 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 215 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 216 | if (entity is null) | 216 | if (entity is null) |
| 217 | { | 217 | { |
| 218 | - throw new UserFriendlyException("标签分类不存在"); | 218 | + throw new UserFriendlyException("Label category not found."); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | var codeInput = input.CategoryCode?.Trim(); | 221 | var codeInput = input.CategoryCode?.Trim(); |
| @@ -228,7 +228,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -228,7 +228,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 228 | var name = input.CategoryName?.Trim(); | 228 | var name = input.CategoryName?.Trim(); |
| 229 | if (string.IsNullOrWhiteSpace(name)) | 229 | if (string.IsNullOrWhiteSpace(name)) |
| 230 | { | 230 | { |
| 231 | - throw new UserFriendlyException("分类名称不能为空"); | 231 | + throw new UserFriendlyException("Category name is required."); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | var displayText = input.DisplayText?.Trim(); | 234 | var displayText = input.DisplayText?.Trim(); |
| @@ -280,7 +280,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -280,7 +280,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 280 | .AnyAsync(x => !x.IsDeleted && x.LabelCategoryId == id); | 280 | .AnyAsync(x => !x.IsDeleted && x.LabelCategoryId == id); |
| 281 | if (used) | 281 | if (used) |
| 282 | { | 282 | { |
| 283 | - throw new UserFriendlyException("该标签分类已被标签引用,无法删除"); | 283 | + throw new UserFriendlyException("This label category is referenced by labels and cannot be deleted."); |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( | 286 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( |
| @@ -435,7 +435,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -435,7 +435,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 435 | } | 435 | } |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | - throw new UserFriendlyException("无法生成唯一分类编码,请稍后重试或手动填写编码"); | 438 | + throw new UserFriendlyException("Could not generate a unique category code. Retry later or enter a code manually."); |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | private async Task EnsureLabelCategoryCodeNotDuplicatedAsync(string code, string? excludeId = null) | 441 | private async Task EnsureLabelCategoryCodeNotDuplicatedAsync(string code, string? excludeId = null) |
| @@ -449,7 +449,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -449,7 +449,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 449 | 449 | ||
| 450 | if (await query.AnyAsync()) | 450 | if (await query.AnyAsync()) |
| 451 | { | 451 | { |
| 452 | - throw new UserFriendlyException("分类编码已存在"); | 452 | + throw new UserFriendlyException("Category code already exists."); |
| 453 | } | 453 | } |
| 454 | } | 454 | } |
| 455 | 455 | ||
| @@ -464,7 +464,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -464,7 +464,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 464 | 464 | ||
| 465 | if (await query.AnyAsync()) | 465 | if (await query.AnyAsync()) |
| 466 | { | 466 | { |
| 467 | - throw new UserFriendlyException("分类名称已存在"); | 467 | + throw new UserFriendlyException("Category name already exists."); |
| 468 | } | 468 | } |
| 469 | } | 469 | } |
| 470 | 470 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs
| @@ -101,7 +101,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -101,7 +101,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 101 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 101 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 102 | if (entity is null) | 102 | if (entity is null) |
| 103 | { | 103 | { |
| 104 | - throw new UserFriendlyException("多选项不存在"); | 104 | + throw new UserFriendlyException("Multiple option not found."); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | var dto = MapToGetOutput(entity); | 107 | var dto = MapToGetOutput(entity); |
| @@ -146,7 +146,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -146,7 +146,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 146 | var name = input.OptionName?.Trim(); | 146 | var name = input.OptionName?.Trim(); |
| 147 | if (string.IsNullOrWhiteSpace(name)) | 147 | if (string.IsNullOrWhiteSpace(name)) |
| 148 | { | 148 | { |
| 149 | - throw new UserFriendlyException("多选项名称不能为空"); | 149 | + throw new UserFriendlyException("Multiple option name is required."); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | var code = input.OptionCode?.Trim(); | 152 | var code = input.OptionCode?.Trim(); |
| @@ -202,7 +202,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -202,7 +202,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 202 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 202 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 203 | if (entity is null) | 203 | if (entity is null) |
| 204 | { | 204 | { |
| 205 | - throw new UserFriendlyException("多选项不存在"); | 205 | + throw new UserFriendlyException("Multiple option not found."); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | var codeInput = input.OptionCode?.Trim(); | 208 | var codeInput = input.OptionCode?.Trim(); |
| @@ -215,7 +215,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -215,7 +215,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 215 | var name = input.OptionName?.Trim(); | 215 | var name = input.OptionName?.Trim(); |
| 216 | if (string.IsNullOrWhiteSpace(name)) | 216 | if (string.IsNullOrWhiteSpace(name)) |
| 217 | { | 217 | { |
| 218 | - throw new UserFriendlyException("多选项名称不能为空"); | 218 | + throw new UserFriendlyException("Multiple option name is required."); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input); | 221 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input); |
| @@ -430,7 +430,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -430,7 +430,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 430 | } | 430 | } |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | - throw new UserFriendlyException("无法生成唯一多选项编码,请稍后重试或手动填写编码"); | 433 | + throw new UserFriendlyException("Could not generate a unique multiple-option code. Retry later or enter a code manually."); |
| 434 | } | 434 | } |
| 435 | 435 | ||
| 436 | private async Task EnsureOptionCodeNotDuplicatedAsync(string code, string? excludeId = null) | 436 | private async Task EnsureOptionCodeNotDuplicatedAsync(string code, string? excludeId = null) |
| @@ -444,7 +444,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -444,7 +444,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 444 | 444 | ||
| 445 | if (await query.AnyAsync()) | 445 | if (await query.AnyAsync()) |
| 446 | { | 446 | { |
| 447 | - throw new UserFriendlyException("多选项编码已存在"); | 447 | + throw new UserFriendlyException("Multiple option code already exists."); |
| 448 | } | 448 | } |
| 449 | } | 449 | } |
| 450 | 450 | ||
| @@ -459,7 +459,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -459,7 +459,7 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 459 | 459 | ||
| 460 | if (await query.AnyAsync()) | 460 | if (await query.AnyAsync()) |
| 461 | { | 461 | { |
| 462 | - throw new UserFriendlyException("多选项名称已存在"); | 462 | + throw new UserFriendlyException("Multiple option name already exists."); |
| 463 | } | 463 | } |
| 464 | } | 464 | } |
| 465 | 465 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTemplateAppService.cs
| @@ -122,7 +122,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -122,7 +122,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 122 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == id); | 122 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == id); |
| 123 | if (template is null) | 123 | if (template is null) |
| 124 | { | 124 | { |
| 125 | - throw new UserFriendlyException("模板不存在"); | 125 | + throw new UserFriendlyException("Template not found."); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | var elements = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateElementDbEntity>() | 128 | var elements = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateElementDbEntity>() |
| @@ -251,18 +251,18 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -251,18 +251,18 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 251 | var name = input.TemplateName?.Trim(); | 251 | var name = input.TemplateName?.Trim(); |
| 252 | if (string.IsNullOrWhiteSpace(code)) | 252 | if (string.IsNullOrWhiteSpace(code)) |
| 253 | { | 253 | { |
| 254 | - throw new UserFriendlyException("模板编码不能为空"); | 254 | + throw new UserFriendlyException("Template code is required."); |
| 255 | } | 255 | } |
| 256 | if (string.IsNullOrWhiteSpace(name)) | 256 | if (string.IsNullOrWhiteSpace(name)) |
| 257 | { | 257 | { |
| 258 | - throw new UserFriendlyException("模板名称不能为空"); | 258 | + throw new UserFriendlyException("Template name is required."); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | var duplicated = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateDbEntity>() | 261 | var duplicated = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateDbEntity>() |
| 262 | .AnyAsync(x => !x.IsDeleted && x.TemplateCode == code); | 262 | .AnyAsync(x => !x.IsDeleted && x.TemplateCode == code); |
| 263 | if (duplicated) | 263 | if (duplicated) |
| 264 | { | 264 | { |
| 265 | - throw new UserFriendlyException("模板编码已存在"); | 265 | + throw new UserFriendlyException("Template code already exists."); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | await PurgeSoftDeletedTemplatesByCodeAsync(code); | 268 | await PurgeSoftDeletedTemplatesByCodeAsync(code); |
| @@ -334,7 +334,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -334,7 +334,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 334 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == id); | 334 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == id); |
| 335 | if (template is null) | 335 | if (template is null) |
| 336 | { | 336 | { |
| 337 | - throw new UserFriendlyException("模板不存在"); | 337 | + throw new UserFriendlyException("Template not found."); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | var code = input.TemplateCode?.Trim(); | 340 | var code = input.TemplateCode?.Trim(); |
| @@ -345,7 +345,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -345,7 +345,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 345 | .AnyAsync(x => !x.IsDeleted && x.TemplateCode == code); | 345 | .AnyAsync(x => !x.IsDeleted && x.TemplateCode == code); |
| 346 | if (duplicated) | 346 | if (duplicated) |
| 347 | { | 347 | { |
| 348 | - throw new UserFriendlyException("模板编码已存在"); | 348 | + throw new UserFriendlyException("Template code already exists."); |
| 349 | } | 349 | } |
| 350 | } | 350 | } |
| 351 | 351 | ||
| @@ -418,7 +418,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -418,7 +418,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 418 | 418 | ||
| 419 | if (used) | 419 | if (used) |
| 420 | { | 420 | { |
| 421 | - throw new UserFriendlyException("该模板已被标签引用,无法删除"); | 421 | + throw new UserFriendlyException("This template is referenced by labels and cannot be deleted."); |
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | template.IsDeleted = true; | 424 | template.IsDeleted = true; |
| @@ -498,7 +498,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -498,7 +498,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 498 | var key = $"{productId}::{labelTypeId}"; | 498 | var key = $"{productId}::{labelTypeId}"; |
| 499 | if (!duplicateCheckSet.Add(key)) | 499 | if (!duplicateCheckSet.Add(key)) |
| 500 | { | 500 | { |
| 501 | - throw new UserFriendlyException($"模板默认值绑定重复:产品[{productId}]与标签类型[{labelTypeId}]只能存在一条"); | 501 | + throw new UserFriendlyException($"Duplicate template default binding: product [{productId}] and label type [{labelTypeId}] may only have one binding."); |
| 502 | } | 502 | } |
| 503 | } | 503 | } |
| 504 | 504 | ||
| @@ -514,12 +514,12 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -514,12 +514,12 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 514 | var labelTypeId = x.LabelTypeId?.Trim(); | 514 | var labelTypeId = x.LabelTypeId?.Trim(); |
| 515 | if (string.IsNullOrWhiteSpace(productId)) | 515 | if (string.IsNullOrWhiteSpace(productId)) |
| 516 | { | 516 | { |
| 517 | - throw new UserFriendlyException("模板默认值绑定中,产品Id不能为空"); | 517 | + throw new UserFriendlyException("In template default bindings, product Id is required."); |
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | if (string.IsNullOrWhiteSpace(labelTypeId)) | 520 | if (string.IsNullOrWhiteSpace(labelTypeId)) |
| 521 | { | 521 | { |
| 522 | - throw new UserFriendlyException("模板默认值绑定中,标签类型Id不能为空"); | 522 | + throw new UserFriendlyException("In template default bindings, label type Id is required."); |
| 523 | } | 523 | } |
| 524 | 524 | ||
| 525 | var json = x.DefaultValues is null ? null : JsonSerializer.Serialize(x.DefaultValues); | 525 | var json = x.DefaultValues is null ? null : JsonSerializer.Serialize(x.DefaultValues); |
| @@ -604,7 +604,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | @@ -604,7 +604,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ | ||
| 604 | var normalizedName = elementName?.Trim(); | 604 | var normalizedName = elementName?.Trim(); |
| 605 | if (string.IsNullOrWhiteSpace(normalizedName)) | 605 | if (string.IsNullOrWhiteSpace(normalizedName)) |
| 606 | { | 606 | { |
| 607 | - throw new UserFriendlyException("组件名字不能为空"); | 607 | + throw new UserFriendlyException("Component name is required."); |
| 608 | } | 608 | } |
| 609 | 609 | ||
| 610 | return normalizedName; | 610 | return normalizedName; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs
| @@ -106,7 +106,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -106,7 +106,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 106 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 106 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 107 | if (entity is null) | 107 | if (entity is null) |
| 108 | { | 108 | { |
| 109 | - throw new UserFriendlyException("标签类型不存在"); | 109 | + throw new UserFriendlyException("Label type not found."); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | var dto = MapToGetOutput(entity); | 112 | var dto = MapToGetOutput(entity); |
| @@ -147,7 +147,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -147,7 +147,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 147 | var name = input.TypeName?.Trim(); | 147 | var name = input.TypeName?.Trim(); |
| 148 | if (string.IsNullOrWhiteSpace(name)) | 148 | if (string.IsNullOrWhiteSpace(name)) |
| 149 | { | 149 | { |
| 150 | - throw new UserFriendlyException("类型名称不能为空"); | 150 | + throw new UserFriendlyException("Type name is required."); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | var code = input.TypeCode?.Trim(); | 153 | var code = input.TypeCode?.Trim(); |
| @@ -161,7 +161,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -161,7 +161,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 161 | .AnyAsync(x => !x.IsDeleted && x.TypeCode == code); | 161 | .AnyAsync(x => !x.IsDeleted && x.TypeCode == code); |
| 162 | if (codeDuplicated) | 162 | if (codeDuplicated) |
| 163 | { | 163 | { |
| 164 | - throw new UserFriendlyException("类型编码已存在"); | 164 | + throw new UserFriendlyException("Type code already exists."); |
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | 167 | ||
| @@ -169,7 +169,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -169,7 +169,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 169 | .AnyAsync(x => !x.IsDeleted && x.TypeName == name); | 169 | .AnyAsync(x => !x.IsDeleted && x.TypeName == name); |
| 170 | if (nameDuplicated) | 170 | if (nameDuplicated) |
| 171 | { | 171 | { |
| 172 | - throw new UserFriendlyException("类型名称已存在"); | 172 | + throw new UserFriendlyException("Type name already exists."); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input); | 175 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input); |
| @@ -209,13 +209,13 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -209,13 +209,13 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 209 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 209 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 210 | if (entity is null) | 210 | if (entity is null) |
| 211 | { | 211 | { |
| 212 | - throw new UserFriendlyException("标签类型不存在"); | 212 | + throw new UserFriendlyException("Label type not found."); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | var name = input.TypeName?.Trim(); | 215 | var name = input.TypeName?.Trim(); |
| 216 | if (string.IsNullOrWhiteSpace(name)) | 216 | if (string.IsNullOrWhiteSpace(name)) |
| 217 | { | 217 | { |
| 218 | - throw new UserFriendlyException("类型名称不能为空"); | 218 | + throw new UserFriendlyException("Type name is required."); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | var codeInput = input.TypeCode?.Trim(); | 221 | var codeInput = input.TypeCode?.Trim(); |
| @@ -231,7 +231,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -231,7 +231,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 231 | .AnyAsync(x => !x.IsDeleted && x.Id != id && x.TypeCode == code); | 231 | .AnyAsync(x => !x.IsDeleted && x.Id != id && x.TypeCode == code); |
| 232 | if (codeDuplicated) | 232 | if (codeDuplicated) |
| 233 | { | 233 | { |
| 234 | - throw new UserFriendlyException("类型编码已存在"); | 234 | + throw new UserFriendlyException("Type code already exists."); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | await PurgeSoftDeletedLabelTypesByCodeAsync(code); | 237 | await PurgeSoftDeletedLabelTypesByCodeAsync(code); |
| @@ -243,7 +243,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -243,7 +243,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 243 | .AnyAsync(x => !x.IsDeleted && x.Id != id && x.TypeName == name); | 243 | .AnyAsync(x => !x.IsDeleted && x.Id != id && x.TypeName == name); |
| 244 | if (nameDuplicated) | 244 | if (nameDuplicated) |
| 245 | { | 245 | { |
| 246 | - throw new UserFriendlyException("类型名称已存在"); | 246 | + throw new UserFriendlyException("Type name already exists."); |
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | 249 | ||
| @@ -280,7 +280,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -280,7 +280,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 280 | .AnyAsync(x => !x.IsDeleted && x.LabelTypeId == id); | 280 | .AnyAsync(x => !x.IsDeleted && x.LabelTypeId == id); |
| 281 | if (used) | 281 | if (used) |
| 282 | { | 282 | { |
| 283 | - throw new UserFriendlyException("该标签类型已被标签引用,无法删除"); | 283 | + throw new UserFriendlyException("This label type is referenced by labels and cannot be deleted."); |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( | 286 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( |
| @@ -317,7 +317,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -317,7 +317,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 317 | } | 317 | } |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | - throw new UserFriendlyException("无法生成唯一类型编码,请稍后重试或手动填写类型编码"); | 320 | + throw new UserFriendlyException("Could not generate a unique type code. Retry later or enter a code manually."); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | /// <summary> | 323 | /// <summary> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LocationAppService.cs
| @@ -82,19 +82,19 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -82,19 +82,19 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 82 | var locationCode = input.LocationCode?.Trim(); | 82 | var locationCode = input.LocationCode?.Trim(); |
| 83 | if (string.IsNullOrWhiteSpace(locationCode)) | 83 | if (string.IsNullOrWhiteSpace(locationCode)) |
| 84 | { | 84 | { |
| 85 | - throw new UserFriendlyException("Location ID不能为空"); | 85 | + throw new UserFriendlyException("Location ID is required."); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | var locationName = input.LocationName?.Trim(); | 88 | var locationName = input.LocationName?.Trim(); |
| 89 | if (string.IsNullOrWhiteSpace(locationName)) | 89 | if (string.IsNullOrWhiteSpace(locationName)) |
| 90 | { | 90 | { |
| 91 | - throw new UserFriendlyException("Location Name不能为空"); | 91 | + throw new UserFriendlyException("Location Name is required."); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | var isExist = await _locationRepository.IsAnyAsync(x => x.LocationCode == locationCode); | 94 | var isExist = await _locationRepository.IsAnyAsync(x => x.LocationCode == locationCode); |
| 95 | if (isExist) | 95 | if (isExist) |
| 96 | { | 96 | { |
| 97 | - throw new UserFriendlyException("Location ID已存在"); | 97 | + throw new UserFriendlyException("Location ID already exists."); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | var entity = new LocationAggregateRoot(GuidGenerator.Create()) | 100 | var entity = new LocationAggregateRoot(GuidGenerator.Create()) |
| @@ -125,6 +125,12 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -125,6 +125,12 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 125 | entity.Id.ToString(), | 125 | entity.Id.ToString(), |
| 126 | entity.Partner, | 126 | entity.Partner, |
| 127 | CurrentUser?.Id?.ToString()); | 127 | CurrentUser?.Id?.ToString()); |
| 128 | + await LocationScopeBindingHelper.BindLocationAllScopeUsersToNewLocationAsync( | ||
| 129 | + _dbContext.SqlSugarClient, | ||
| 130 | + GuidGenerator, | ||
| 131 | + entity.Id.ToString(), | ||
| 132 | + entity.Partner, | ||
| 133 | + CurrentUser?.Id?.ToString()); | ||
| 128 | 134 | ||
| 129 | return ToListDto(entity); | 135 | return ToListDto(entity); |
| 130 | } | 136 | } |
| @@ -139,13 +145,13 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -139,13 +145,13 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 139 | var entity = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 145 | var entity = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 140 | if (entity is null) | 146 | if (entity is null) |
| 141 | { | 147 | { |
| 142 | - throw new UserFriendlyException("门店不存在"); | 148 | + throw new UserFriendlyException("Location not found."); |
| 143 | } | 149 | } |
| 144 | 150 | ||
| 145 | var locationName = input.LocationName?.Trim(); | 151 | var locationName = input.LocationName?.Trim(); |
| 146 | if (string.IsNullOrWhiteSpace(locationName)) | 152 | if (string.IsNullOrWhiteSpace(locationName)) |
| 147 | { | 153 | { |
| 148 | - throw new UserFriendlyException("Location Name不能为空"); | 154 | + throw new UserFriendlyException("Location Name is required."); |
| 149 | } | 155 | } |
| 150 | 156 | ||
| 151 | entity.Partner = input.Partner?.Trim(); | 157 | entity.Partner = input.Partner?.Trim(); |
| @@ -176,7 +182,7 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -176,7 +182,7 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 176 | var entity = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 182 | var entity = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 177 | if (entity is null) | 183 | if (entity is null) |
| 178 | { | 184 | { |
| 179 | - throw new UserFriendlyException("门店不存在"); | 185 | + throw new UserFriendlyException("Location not found."); |
| 180 | } | 186 | } |
| 181 | 187 | ||
| 182 | await AccountManagementStructureHelper.EnsureLocationPartnerAllowedForMutationAsync( | 188 | await AccountManagementStructureHelper.EnsureLocationPartnerAllowedForMutationAsync( |
| @@ -193,19 +199,19 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -193,19 +199,19 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 193 | var dir = opt.TemplateDirectory?.Trim(); | 199 | var dir = opt.TemplateDirectory?.Trim(); |
| 194 | if (string.IsNullOrWhiteSpace(dir)) | 200 | if (string.IsNullOrWhiteSpace(dir)) |
| 195 | { | 201 | { |
| 196 | - throw new UserFriendlyException("未配置批量导入模板目录 FoodLabeling:BatchImport:TemplateDirectory"); | 202 | + throw new UserFriendlyException("Batch import template directory is not configured (FoodLabeling:BatchImport:TemplateDirectory)."); |
| 197 | } | 203 | } |
| 198 | 204 | ||
| 199 | var fileName = opt.LocationTemplateFileName?.Trim(); | 205 | var fileName = opt.LocationTemplateFileName?.Trim(); |
| 200 | if (string.IsNullOrWhiteSpace(fileName)) | 206 | if (string.IsNullOrWhiteSpace(fileName)) |
| 201 | { | 207 | { |
| 202 | - throw new UserFriendlyException("未配置模板文件名 FoodLabeling:BatchImport:LocationTemplateFileName"); | 208 | + throw new UserFriendlyException("Template file name is not configured (FoodLabeling:BatchImport:LocationTemplateFileName)."); |
| 203 | } | 209 | } |
| 204 | 210 | ||
| 205 | var fullPath = Path.Combine(dir, fileName); | 211 | var fullPath = Path.Combine(dir, fileName); |
| 206 | if (!File.Exists(fullPath)) | 212 | if (!File.Exists(fullPath)) |
| 207 | { | 213 | { |
| 208 | - throw new UserFriendlyException($"模板文件不存在:{fullPath}"); | 214 | + throw new UserFriendlyException($"Template file not found: {fullPath}"); |
| 209 | } | 215 | } |
| 210 | 216 | ||
| 211 | var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); | 217 | var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); |
| @@ -252,19 +258,19 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -252,19 +258,19 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 252 | { | 258 | { |
| 253 | if (input?.File is null || input.File.Length == 0) | 259 | if (input?.File is null || input.File.Length == 0) |
| 254 | { | 260 | { |
| 255 | - throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)"); | 261 | + throw new UserFriendlyException("Upload an Excel file (form field name: file)."); |
| 256 | } | 262 | } |
| 257 | 263 | ||
| 258 | var opt = _batchImportOptions.Value; | 264 | var opt = _batchImportOptions.Value; |
| 259 | if (input.File.Length > opt.MaxUploadBytes) | 265 | if (input.File.Length > opt.MaxUploadBytes) |
| 260 | { | 266 | { |
| 261 | - throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB"); | 267 | + throw new UserFriendlyException($"File too large; maximum {opt.MaxUploadBytes / 1024 / 1024} MB allowed."); |
| 262 | } | 268 | } |
| 263 | 269 | ||
| 264 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); | 270 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); |
| 265 | if (ext != ".xlsx") | 271 | if (ext != ".xlsx") |
| 266 | { | 272 | { |
| 267 | - throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件"); | 273 | + throw new UserFriendlyException("Only .xlsx Excel files are supported."); |
| 268 | } | 274 | } |
| 269 | 275 | ||
| 270 | await using var uploadStream = input.File.OpenReadStream(); | 276 | await using var uploadStream = input.File.OpenReadStream(); |
| @@ -311,20 +317,20 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -311,20 +317,20 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 311 | { | 317 | { |
| 312 | if (input?.Items is null || input.Items.Count == 0) | 318 | if (input?.Items is null || input.Items.Count == 0) |
| 313 | { | 319 | { |
| 314 | - throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)"); | 320 | + throw new UserFriendlyException("Submit at least one row to edit (items is required)."); |
| 315 | } | 321 | } |
| 316 | 322 | ||
| 317 | var opt = _batchImportOptions.Value; | 323 | var opt = _batchImportOptions.Value; |
| 318 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; | 324 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; |
| 319 | if (input.Items.Count > maxItems) | 325 | if (input.Items.Count > maxItems) |
| 320 | { | 326 | { |
| 321 | - throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交"); | 327 | + throw new UserFriendlyException($"Maximum {maxItems} rows per batch import. Submit in batches."); |
| 322 | } | 328 | } |
| 323 | 329 | ||
| 324 | var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty); | 330 | var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty); |
| 325 | if (effectiveCount == 0) | 331 | if (effectiveCount == 0) |
| 326 | { | 332 | { |
| 327 | - throw new UserFriendlyException("没有有效的门店 Id(请为待保存行填写 id,空行请使用 id 为空 GUID 或从列表中移除)"); | 333 | + throw new UserFriendlyException("No valid location Id (set id on rows to save; remove blank rows or use an empty GUID)."); |
| 328 | } | 334 | } |
| 329 | 335 | ||
| 330 | var result = new LocationBulkUpdateResultDto(); | 336 | var result = new LocationBulkUpdateResultDto(); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PictureAppService.cs
| 1 | using FoodLabeling.Application.Contracts.Dtos.Picture; | 1 | using FoodLabeling.Application.Contracts.Dtos.Picture; |
| 2 | using FoodLabeling.Application.Contracts.IServices; | 2 | using FoodLabeling.Application.Contracts.IServices; |
| 3 | +using FoodLabeling.Application.Helpers; | ||
| 4 | +using FoodLabeling.Application.Options; | ||
| 3 | using Microsoft.AspNetCore.Http; | 5 | using Microsoft.AspNetCore.Http; |
| 4 | using Microsoft.AspNetCore.Mvc; | 6 | using Microsoft.AspNetCore.Mvc; |
| 5 | using Microsoft.Extensions.Hosting; | 7 | using Microsoft.Extensions.Hosting; |
| 8 | +using Microsoft.Extensions.Options; | ||
| 6 | using Volo.Abp; | 9 | using Volo.Abp; |
| 7 | using Volo.Abp.Application.Services; | 10 | using Volo.Abp.Application.Services; |
| 8 | using Volo.Abp.Guids; | 11 | using Volo.Abp.Guids; |
| @@ -23,17 +26,29 @@ public class PictureAppService : ApplicationService, IPictureAppService | @@ -23,17 +26,29 @@ public class PictureAppService : ApplicationService, IPictureAppService | ||
| 23 | 26 | ||
| 24 | private readonly IGuidGenerator _guidGenerator; | 27 | private readonly IGuidGenerator _guidGenerator; |
| 25 | private readonly IHostEnvironment _hostEnvironment; | 28 | private readonly IHostEnvironment _hostEnvironment; |
| 29 | + private readonly FoodLabelingPictureOptions _pictureOptions; | ||
| 26 | 30 | ||
| 27 | - public PictureAppService(IGuidGenerator guidGenerator, IHostEnvironment hostEnvironment) | 31 | + public PictureAppService( |
| 32 | + IGuidGenerator guidGenerator, | ||
| 33 | + IHostEnvironment hostEnvironment, | ||
| 34 | + IOptions<FoodLabelingPictureOptions> pictureOptions) | ||
| 28 | { | 35 | { |
| 29 | _guidGenerator = guidGenerator; | 36 | _guidGenerator = guidGenerator; |
| 30 | _hostEnvironment = hostEnvironment; | 37 | _hostEnvironment = hostEnvironment; |
| 38 | + _pictureOptions = pictureOptions.Value; | ||
| 31 | } | 39 | } |
| 32 | 40 | ||
| 33 | /// <summary> | 41 | /// <summary> |
| 34 | - /// 上传类别图片(保存到 /www/wwwroot/FoodLabelingManagementUs/picture) | 42 | + /// 上传类别/产品图片(Linux 保存到 /www/wwwroot/picture/{版本}) |
| 35 | /// </summary> | 43 | /// </summary> |
| 36 | - /// <remarks>返回的 Url 可直接保存到 CategoryPhotoUrl。</remarks> | 44 | + /// <remarks> |
| 45 | + /// 与 API 发布目录分离,部署不会删除已上传图片。返回的 Url 可直接保存到 CategoryPhotoUrl / ProductImageUrl。 | ||
| 46 | + /// </remarks> | ||
| 47 | + /// <param name="input">上传表单</param> | ||
| 48 | + /// <returns>相对路径 Url,如 /picture/product/xxx.png</returns> | ||
| 49 | + /// <response code="200">上传成功</response> | ||
| 50 | + /// <response code="400">文件为空、过大或扩展名不支持</response> | ||
| 51 | + /// <response code="500">服务器写入失败</response> | ||
| 37 | [HttpPost] | 52 | [HttpPost] |
| 38 | [Consumes("multipart/form-data")] | 53 | [Consumes("multipart/form-data")] |
| 39 | [Route("/api/app/picture/category/upload")] | 54 | [Route("/api/app/picture/category/upload")] |
| @@ -41,18 +56,18 @@ public class PictureAppService : ApplicationService, IPictureAppService | @@ -41,18 +56,18 @@ public class PictureAppService : ApplicationService, IPictureAppService | ||
| 41 | { | 56 | { |
| 42 | if (input.File is null || input.File.Length <= 0) | 57 | if (input.File is null || input.File.Length <= 0) |
| 43 | { | 58 | { |
| 44 | - throw new UserFriendlyException("请选择要上传的图片文件"); | 59 | + throw new UserFriendlyException("Select an image file to upload."); |
| 45 | } | 60 | } |
| 46 | 61 | ||
| 47 | if (input.File.Length > MaxSizeBytes) | 62 | if (input.File.Length > MaxSizeBytes) |
| 48 | { | 63 | { |
| 49 | - throw new UserFriendlyException("图片大小不能超过5MB"); | 64 | + throw new UserFriendlyException("Image size cannot exceed 5 MB."); |
| 50 | } | 65 | } |
| 51 | 66 | ||
| 52 | var ext = Path.GetExtension(input.File.FileName ?? string.Empty); | 67 | var ext = Path.GetExtension(input.File.FileName ?? string.Empty); |
| 53 | if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext)) | 68 | if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext)) |
| 54 | { | 69 | { |
| 55 | - throw new UserFriendlyException("仅支持上传 jpg/jpeg/png/webp/gif 格式图片"); | 70 | + throw new UserFriendlyException("Only jpg/jpeg/png/webp/gif images are supported."); |
| 56 | } | 71 | } |
| 57 | 72 | ||
| 58 | var subDir = NormalizeSubDir(input.SubDir); | 73 | var subDir = NormalizeSubDir(input.SubDir); |
| @@ -77,12 +92,11 @@ public class PictureAppService : ApplicationService, IPictureAppService | @@ -77,12 +92,11 @@ public class PictureAppService : ApplicationService, IPictureAppService | ||
| 77 | }; | 92 | }; |
| 78 | } | 93 | } |
| 79 | 94 | ||
| 80 | - private string ResolvePictureRoot() | ||
| 81 | - { | ||
| 82 | - var linuxPictureRoot = "/www/wwwroot/FoodLabelingManagementUs/picture"; | ||
| 83 | - var webRootPicture = Path.Combine(_hostEnvironment.ContentRootPath, "wwwroot", "FoodLabelingManagementUs", "picture"); | ||
| 84 | - return Directory.Exists(linuxPictureRoot) ? linuxPictureRoot : webRootPicture; | ||
| 85 | - } | 95 | + private string ResolvePictureRoot() => |
| 96 | + FoodLabelingPictureRoot.Resolve( | ||
| 97 | + _pictureOptions.RootPath, | ||
| 98 | + _hostEnvironment.ContentRootPath, | ||
| 99 | + Path.Combine(_hostEnvironment.ContentRootPath, "wwwroot")); | ||
| 86 | 100 | ||
| 87 | private static string NormalizeSubDir(string? subDir) | 101 | private static string NormalizeSubDir(string? subDir) |
| 88 | { | 102 | { |
| @@ -99,7 +113,7 @@ public class PictureAppService : ApplicationService, IPictureAppService | @@ -99,7 +113,7 @@ public class PictureAppService : ApplicationService, IPictureAppService | ||
| 99 | 113 | ||
| 100 | if (s.Contains("..", StringComparison.Ordinal)) | 114 | if (s.Contains("..", StringComparison.Ordinal)) |
| 101 | { | 115 | { |
| 102 | - throw new UserFriendlyException("subDir 不能包含 .."); | 116 | + throw new UserFriendlyException("subDir must not contain .."); |
| 103 | } | 117 | } |
| 104 | 118 | ||
| 105 | return s; | 119 | return s; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductAppService.cs
| @@ -134,7 +134,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -134,7 +134,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 134 | { | 134 | { |
| 135 | if (id == Guid.Empty) | 135 | if (id == Guid.Empty) |
| 136 | { | 136 | { |
| 137 | - throw new UserFriendlyException("产品Id不能为空"); | 137 | + throw new UserFriendlyException("Product Id is required."); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | var productId = id.ToString(); | 140 | var productId = id.ToString(); |
| @@ -143,7 +143,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -143,7 +143,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 143 | 143 | ||
| 144 | if (entity is null) | 144 | if (entity is null) |
| 145 | { | 145 | { |
| 146 | - throw new UserFriendlyException("产品不存在"); | 146 | + throw new UserFriendlyException("Product not found."); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | await EnsureProductVisibleToCurrentUserAsync(entity); | 149 | await EnsureProductVisibleToCurrentUserAsync(entity); |
| @@ -241,7 +241,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -241,7 +241,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 241 | var name = input.ProductName?.Trim(); | 241 | var name = input.ProductName?.Trim(); |
| 242 | if (string.IsNullOrWhiteSpace(name)) | 242 | if (string.IsNullOrWhiteSpace(name)) |
| 243 | { | 243 | { |
| 244 | - throw new UserFriendlyException("产品名称不能为空"); | 244 | + throw new UserFriendlyException("Product name is required."); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | var code = input.ProductCode?.Trim(); | 247 | var code = input.ProductCode?.Trim(); |
| @@ -255,7 +255,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -255,7 +255,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 255 | .AnyAsync(x => !x.IsDeleted && x.ProductCode == code); | 255 | .AnyAsync(x => !x.IsDeleted && x.ProductCode == code); |
| 256 | if (duplicated) | 256 | if (duplicated) |
| 257 | { | 257 | { |
| 258 | - throw new UserFriendlyException("产品编码已存在"); | 258 | + throw new UserFriendlyException("Product code already exists."); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | await PurgeSoftDeletedProductsByCodeAsync(code); | 261 | await PurgeSoftDeletedProductsByCodeAsync(code); |
| @@ -292,7 +292,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -292,7 +292,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 292 | { | 292 | { |
| 293 | if (id == Guid.Empty) | 293 | if (id == Guid.Empty) |
| 294 | { | 294 | { |
| 295 | - throw new UserFriendlyException("产品Id不能为空"); | 295 | + throw new UserFriendlyException("Product Id is required."); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | var productId = id.ToString(); | 298 | var productId = id.ToString(); |
| @@ -300,7 +300,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -300,7 +300,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 300 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); | 300 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); |
| 301 | if (entity is null) | 301 | if (entity is null) |
| 302 | { | 302 | { |
| 303 | - throw new UserFriendlyException("产品不存在"); | 303 | + throw new UserFriendlyException("Product not found."); |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | await EnsureProductVisibleToCurrentUserAsync(entity); | 306 | await EnsureProductVisibleToCurrentUserAsync(entity); |
| @@ -308,7 +308,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -308,7 +308,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 308 | var name = input.ProductName?.Trim(); | 308 | var name = input.ProductName?.Trim(); |
| 309 | if (string.IsNullOrWhiteSpace(name)) | 309 | if (string.IsNullOrWhiteSpace(name)) |
| 310 | { | 310 | { |
| 311 | - throw new UserFriendlyException("产品名称不能为空"); | 311 | + throw new UserFriendlyException("Product name is required."); |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | var codeInput = input.ProductCode?.Trim(); | 314 | var codeInput = input.ProductCode?.Trim(); |
| @@ -324,7 +324,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -324,7 +324,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 324 | .AnyAsync(x => !x.IsDeleted && x.Id != productId && x.ProductCode == code); | 324 | .AnyAsync(x => !x.IsDeleted && x.Id != productId && x.ProductCode == code); |
| 325 | if (duplicated) | 325 | if (duplicated) |
| 326 | { | 326 | { |
| 327 | - throw new UserFriendlyException("产品编码已存在"); | 327 | + throw new UserFriendlyException("Product code already exists."); |
| 328 | } | 328 | } |
| 329 | } | 329 | } |
| 330 | 330 | ||
| @@ -354,7 +354,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -354,7 +354,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 354 | { | 354 | { |
| 355 | if (id == Guid.Empty) | 355 | if (id == Guid.Empty) |
| 356 | { | 356 | { |
| 357 | - throw new UserFriendlyException("产品Id不能为空"); | 357 | + throw new UserFriendlyException("Product Id is required."); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | var productId = id.ToString(); | 360 | var productId = id.ToString(); |
| @@ -362,7 +362,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -362,7 +362,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 362 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); | 362 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); |
| 363 | if (entity is null) | 363 | if (entity is null) |
| 364 | { | 364 | { |
| 365 | - throw new UserFriendlyException("产品不存在"); | 365 | + throw new UserFriendlyException("Product not found."); |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | await EnsureProductVisibleToCurrentUserAsync(entity); | 368 | await EnsureProductVisibleToCurrentUserAsync(entity); |
| @@ -379,19 +379,19 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -379,19 +379,19 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 379 | var dir = opt.TemplateDirectory?.Trim(); | 379 | var dir = opt.TemplateDirectory?.Trim(); |
| 380 | if (string.IsNullOrWhiteSpace(dir)) | 380 | if (string.IsNullOrWhiteSpace(dir)) |
| 381 | { | 381 | { |
| 382 | - throw new UserFriendlyException("未配置批量导入模板目录 FoodLabeling:BatchImport:TemplateDirectory"); | 382 | + throw new UserFriendlyException("Batch import template directory is not configured (FoodLabeling:BatchImport:TemplateDirectory)."); |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | var fileName = opt.ProductTemplateFileName?.Trim(); | 385 | var fileName = opt.ProductTemplateFileName?.Trim(); |
| 386 | if (string.IsNullOrWhiteSpace(fileName)) | 386 | if (string.IsNullOrWhiteSpace(fileName)) |
| 387 | { | 387 | { |
| 388 | - throw new UserFriendlyException("未配置模板文件名 FoodLabeling:BatchImport:ProductTemplateFileName"); | 388 | + throw new UserFriendlyException("Template file name is not configured (FoodLabeling:BatchImport:ProductTemplateFileName)."); |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | var fullPath = Path.Combine(dir, fileName); | 391 | var fullPath = Path.Combine(dir, fileName); |
| 392 | if (!File.Exists(fullPath)) | 392 | if (!File.Exists(fullPath)) |
| 393 | { | 393 | { |
| 394 | - throw new UserFriendlyException($"模板文件不存在:{fullPath}"); | 394 | + throw new UserFriendlyException($"Template file not found: {fullPath}"); |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); | 397 | var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); |
| @@ -441,19 +441,19 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -441,19 +441,19 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 441 | { | 441 | { |
| 442 | if (input?.File is null || input.File.Length == 0) | 442 | if (input?.File is null || input.File.Length == 0) |
| 443 | { | 443 | { |
| 444 | - throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)"); | 444 | + throw new UserFriendlyException("Upload an Excel file (form field name: file)."); |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | var opt = _batchImportOptions.Value; | 447 | var opt = _batchImportOptions.Value; |
| 448 | if (input.File.Length > opt.MaxUploadBytes) | 448 | if (input.File.Length > opt.MaxUploadBytes) |
| 449 | { | 449 | { |
| 450 | - throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB"); | 450 | + throw new UserFriendlyException($"File too large; maximum {opt.MaxUploadBytes / 1024 / 1024} MB allowed."); |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); | 453 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); |
| 454 | if (ext != ".xlsx") | 454 | if (ext != ".xlsx") |
| 455 | { | 455 | { |
| 456 | - throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件"); | 456 | + throw new UserFriendlyException("Only .xlsx Excel files are supported."); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | await using var uploadStream = input.File.OpenReadStream(); | 459 | await using var uploadStream = input.File.OpenReadStream(); |
| @@ -516,14 +516,14 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -516,14 +516,14 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 516 | { | 516 | { |
| 517 | if (input?.Items is null || input.Items.Count == 0) | 517 | if (input?.Items is null || input.Items.Count == 0) |
| 518 | { | 518 | { |
| 519 | - throw new UserFriendlyException("请至少提交一条导入数据(items 不能为空)"); | 519 | + throw new UserFriendlyException("Submit at least one row to import (items is required)."); |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | var opt = _batchImportOptions.Value; | 522 | var opt = _batchImportOptions.Value; |
| 523 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; | 523 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; |
| 524 | if (input.Items.Count > maxRows) | 524 | if (input.Items.Count > maxRows) |
| 525 | { | 525 | { |
| 526 | - throw new UserFriendlyException($"单次批量导入最多允许 {maxRows} 条,请分批提交"); | 526 | + throw new UserFriendlyException($"Maximum {maxRows} rows per batch import. Submit in batches."); |
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | var result = new ProductBatchImportOnlineResultDto(); | 529 | var result = new ProductBatchImportOnlineResultDto(); |
| @@ -556,14 +556,14 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -556,14 +556,14 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 556 | { | 556 | { |
| 557 | if (input?.Items is null || input.Items.Count == 0) | 557 | if (input?.Items is null || input.Items.Count == 0) |
| 558 | { | 558 | { |
| 559 | - throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)"); | 559 | + throw new UserFriendlyException("Submit at least one row to edit (items is required)."); |
| 560 | } | 560 | } |
| 561 | 561 | ||
| 562 | var opt = _batchImportOptions.Value; | 562 | var opt = _batchImportOptions.Value; |
| 563 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; | 563 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; |
| 564 | if (input.Items.Count > maxItems) | 564 | if (input.Items.Count > maxItems) |
| 565 | { | 565 | { |
| 566 | - throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交"); | 566 | + throw new UserFriendlyException($"Maximum {maxItems} rows per batch import. Submit in batches."); |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | var effectiveCount = input.Items.Count(static x => | 569 | var effectiveCount = input.Items.Count(static x => |
| @@ -573,7 +573,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -573,7 +573,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 573 | g != Guid.Empty); | 573 | g != Guid.Empty); |
| 574 | if (effectiveCount == 0) | 574 | if (effectiveCount == 0) |
| 575 | { | 575 | { |
| 576 | - throw new UserFriendlyException("没有有效的产品 Id(请为待保存行填写 Guid 格式 id)"); | 576 | + throw new UserFriendlyException("No valid product Id (set a Guid id on rows to save)."); |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | var result = new ProductBulkUpdateResultDto(); | 579 | var result = new ProductBulkUpdateResultDto(); |
| @@ -690,7 +690,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -690,7 +690,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 690 | { | 690 | { |
| 691 | if (!CurrentUser.Id.HasValue) | 691 | if (!CurrentUser.Id.HasValue) |
| 692 | { | 692 | { |
| 693 | - throw new UserFriendlyException("登录已过期,请重新登录"); | 693 | + throw new UserFriendlyException("Session expired. Please sign in again."); |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | if (ReportsRoleHelper.IsAdminRole(CurrentUser)) | 696 | if (ReportsRoleHelper.IsAdminRole(CurrentUser)) |
| @@ -707,7 +707,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -707,7 +707,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 707 | 707 | ||
| 708 | if (scopedLocationIds.Count == 0) | 708 | if (scopedLocationIds.Count == 0) |
| 709 | { | 709 | { |
| 710 | - throw new UserFriendlyException("无权访问该产品"); | 710 | + throw new UserFriendlyException("You do not have permission to access this product."); |
| 711 | } | 711 | } |
| 712 | 712 | ||
| 713 | if (string.Equals(entity.AvailabilityType, AllScopeBindingHelper.ScopeAll, StringComparison.OrdinalIgnoreCase)) | 713 | if (string.Equals(entity.AvailabilityType, AllScopeBindingHelper.ScopeAll, StringComparison.OrdinalIgnoreCase)) |
| @@ -721,7 +721,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -721,7 +721,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 721 | .ToListAsync(); | 721 | .ToListAsync(); |
| 722 | if (!productLocationIds.Any(id => scopedLocationIds.Contains(id))) | 722 | if (!productLocationIds.Any(id => scopedLocationIds.Contains(id))) |
| 723 | { | 723 | { |
| 724 | - throw new UserFriendlyException("无权访问该产品"); | 724 | + throw new UserFriendlyException("You do not have permission to access this product."); |
| 725 | } | 725 | } |
| 726 | } | 726 | } |
| 727 | 727 | ||
| @@ -837,7 +837,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -837,7 +837,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 837 | var n = categoryName.Trim(); | 837 | var n = categoryName.Trim(); |
| 838 | if (string.IsNullOrWhiteSpace(n)) | 838 | if (string.IsNullOrWhiteSpace(n)) |
| 839 | { | 839 | { |
| 840 | - throw new UserFriendlyException("产品分类名称不能为空"); | 840 | + throw new UserFriendlyException("Product category name is required."); |
| 841 | } | 841 | } |
| 842 | 842 | ||
| 843 | var lowered = n.ToLowerInvariant(); | 843 | var lowered = n.ToLowerInvariant(); |
| @@ -847,12 +847,12 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -847,12 +847,12 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 847 | 847 | ||
| 848 | if (matches.Count == 0) | 848 | if (matches.Count == 0) |
| 849 | { | 849 | { |
| 850 | - throw new UserFriendlyException($"未找到产品分类「{n}」"); | 850 | + throw new UserFriendlyException($"Product category not found: \"{n}\"."); |
| 851 | } | 851 | } |
| 852 | 852 | ||
| 853 | if (matches.Count > 1) | 853 | if (matches.Count > 1) |
| 854 | { | 854 | { |
| 855 | - throw new UserFriendlyException($"产品分类「{n}」存在多条记录,请在系统中使用唯一名称"); | 855 | + throw new UserFriendlyException($"Product category \"{n}\" matches multiple records; use a unique name in the system."); |
| 856 | } | 856 | } |
| 857 | 857 | ||
| 858 | return matches[0].Id; | 858 | return matches[0].Id; |
| @@ -888,7 +888,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -888,7 +888,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 888 | var byId = byIdList.FirstOrDefault(); | 888 | var byId = byIdList.FirstOrDefault(); |
| 889 | if (byId is null) | 889 | if (byId is null) |
| 890 | { | 890 | { |
| 891 | - throw new UserFriendlyException($"未找到门店 Id:{t}"); | 891 | + throw new UserFriendlyException($"Location Id not found: {t}"); |
| 892 | } | 892 | } |
| 893 | 893 | ||
| 894 | return byId.Id.ToString(); | 894 | return byId.Id.ToString(); |
| @@ -903,12 +903,12 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -903,12 +903,12 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 903 | 903 | ||
| 904 | if (matches.Count == 0) | 904 | if (matches.Count == 0) |
| 905 | { | 905 | { |
| 906 | - throw new UserFriendlyException($"未找到门店:{t}"); | 906 | + throw new UserFriendlyException($"Location not found: {t}"); |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | if (matches.Count > 1) | 909 | if (matches.Count > 1) |
| 910 | { | 910 | { |
| 911 | - throw new UserFriendlyException($"门店「{t}」存在多条匹配,请使用 Location Code 或 Guid"); | 911 | + throw new UserFriendlyException($"Location \"{t}\" matches multiple records; use Location Code or Guid."); |
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | return matches[0].Id.ToString(); | 914 | return matches[0].Id.ToString(); |
| @@ -930,7 +930,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -930,7 +930,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 930 | } | 930 | } |
| 931 | } | 931 | } |
| 932 | 932 | ||
| 933 | - throw new UserFriendlyException("无法生成唯一产品编码,请稍后重试或手动填写产品编码"); | 933 | + throw new UserFriendlyException("Could not generate a unique product code. Retry later or enter a code manually."); |
| 934 | } | 934 | } |
| 935 | 935 | ||
| 936 | private static void ApplyProductAppearanceToEntity(FlProductDbEntity entity, ProductCreateInputVo input) | 936 | private static void ApplyProductAppearanceToEntity(FlProductDbEntity entity, ProductCreateInputVo input) |
| @@ -1019,13 +1019,13 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1019,13 +1019,13 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1019 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(companyIds) | 1019 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(companyIds) |
| 1020 | || LocationScopeBindingHelper.IsAllScopeSentinel(input.PartnerId)) | 1020 | || LocationScopeBindingHelper.IsAllScopeSentinel(input.PartnerId)) |
| 1021 | { | 1021 | { |
| 1022 | - throw new UserFriendlyException("产品适用 Company 不支持 ALL,请传单个具体 Company Id"); | 1022 | + throw new UserFriendlyException("Product applicable Company does not support ALL; pass a single Company Id."); |
| 1023 | } | 1023 | } |
| 1024 | 1024 | ||
| 1025 | var concreteCompanyIds = LocationScopeBindingHelper.FilterConcreteScopeIds(companyIds); | 1025 | var concreteCompanyIds = LocationScopeBindingHelper.FilterConcreteScopeIds(companyIds); |
| 1026 | if (concreteCompanyIds.Count > 1) | 1026 | if (concreteCompanyIds.Count > 1) |
| 1027 | { | 1027 | { |
| 1028 | - throw new UserFriendlyException("产品适用 Company 仅支持单选(companyIds 最多传 1 个)"); | 1028 | + throw new UserFriendlyException("Product applicable Company allows only one selection (at most one companyIds entry)."); |
| 1029 | } | 1029 | } |
| 1030 | 1030 | ||
| 1031 | var fromCompanyIds = concreteCompanyIds.Count == 1 ? concreteCompanyIds[0] : null; | 1031 | var fromCompanyIds = concreteCompanyIds.Count == 1 ? concreteCompanyIds[0] : null; |
| @@ -1038,7 +1038,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1038,7 +1038,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1038 | if (!string.IsNullOrWhiteSpace(fromCompanyIds) | 1038 | if (!string.IsNullOrWhiteSpace(fromCompanyIds) |
| 1039 | && !string.Equals(fromPartnerId, fromCompanyIds, StringComparison.OrdinalIgnoreCase)) | 1039 | && !string.Equals(fromPartnerId, fromCompanyIds, StringComparison.OrdinalIgnoreCase)) |
| 1040 | { | 1040 | { |
| 1041 | - throw new UserFriendlyException("partnerId 与 companyIds 不一致"); | 1041 | + throw new UserFriendlyException("partnerId does not match companyIds."); |
| 1042 | } | 1042 | } |
| 1043 | 1043 | ||
| 1044 | return fromPartnerId; | 1044 | return fromPartnerId; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductCategoryAppService.cs
| @@ -124,7 +124,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -124,7 +124,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 124 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 124 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 125 | if (entity is null) | 125 | if (entity is null) |
| 126 | { | 126 | { |
| 127 | - throw new UserFriendlyException("类别不存在"); | 127 | + throw new UserFriendlyException("Category not found."); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | await EnsureCategoryVisibleToCurrentUserAsync(entity); | 130 | await EnsureCategoryVisibleToCurrentUserAsync(entity); |
| @@ -170,7 +170,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -170,7 +170,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 170 | var name = input.CategoryName?.Trim(); | 170 | var name = input.CategoryName?.Trim(); |
| 171 | if (string.IsNullOrWhiteSpace(name)) | 171 | if (string.IsNullOrWhiteSpace(name)) |
| 172 | { | 172 | { |
| 173 | - throw new UserFriendlyException("类别名称不能为空"); | 173 | + throw new UserFriendlyException("Category name is required."); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | var code = input.CategoryCode?.Trim(); | 176 | var code = input.CategoryCode?.Trim(); |
| @@ -229,7 +229,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -229,7 +229,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 229 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 229 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 230 | if (entity is null) | 230 | if (entity is null) |
| 231 | { | 231 | { |
| 232 | - throw new UserFriendlyException("类别不存在"); | 232 | + throw new UserFriendlyException("Category not found."); |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | await EnsureCategoryVisibleToCurrentUserAsync(entity); | 235 | await EnsureCategoryVisibleToCurrentUserAsync(entity); |
| @@ -244,7 +244,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -244,7 +244,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 244 | var name = input.CategoryName?.Trim(); | 244 | var name = input.CategoryName?.Trim(); |
| 245 | if (string.IsNullOrWhiteSpace(name)) | 245 | if (string.IsNullOrWhiteSpace(name)) |
| 246 | { | 246 | { |
| 247 | - throw new UserFriendlyException("类别名称不能为空"); | 247 | + throw new UserFriendlyException("Category name is required."); |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | var displayText = input.DisplayText?.Trim(); | 250 | var displayText = input.DisplayText?.Trim(); |
| @@ -302,7 +302,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -302,7 +302,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 302 | .AnyAsync(x => !x.IsDeleted && x.CategoryId == id); | 302 | .AnyAsync(x => !x.IsDeleted && x.CategoryId == id); |
| 303 | if (usedByProduct) | 303 | if (usedByProduct) |
| 304 | { | 304 | { |
| 305 | - throw new UserFriendlyException("该类别已被产品引用,无法删除"); | 305 | + throw new UserFriendlyException("This category is referenced by products and cannot be deleted."); |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | entity.IsDeleted = true; | 308 | entity.IsDeleted = true; |
| @@ -433,7 +433,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -433,7 +433,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 433 | 433 | ||
| 434 | if (scopedLocationIds.Count == 0) | 434 | if (scopedLocationIds.Count == 0) |
| 435 | { | 435 | { |
| 436 | - throw new UserFriendlyException("无权访问该类别"); | 436 | + throw new UserFriendlyException("You do not have permission to access this category."); |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | if (string.Equals(entity.AvailabilityType, "ALL", StringComparison.OrdinalIgnoreCase)) | 439 | if (string.Equals(entity.AvailabilityType, "ALL", StringComparison.OrdinalIgnoreCase)) |
| @@ -445,7 +445,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -445,7 +445,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 445 | .AnyAsync(cl => cl.CategoryId == entity.Id && scopedLocationIds.Contains(cl.LocationId)); | 445 | .AnyAsync(cl => cl.CategoryId == entity.Id && scopedLocationIds.Contains(cl.LocationId)); |
| 446 | if (!visible) | 446 | if (!visible) |
| 447 | { | 447 | { |
| 448 | - throw new UserFriendlyException("无权访问该类别"); | 448 | + throw new UserFriendlyException("You do not have permission to access this category."); |
| 449 | } | 449 | } |
| 450 | } | 450 | } |
| 451 | 451 | ||
| @@ -697,7 +697,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -697,7 +697,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 697 | } | 697 | } |
| 698 | } | 698 | } |
| 699 | 699 | ||
| 700 | - throw new UserFriendlyException("无法生成唯一类别编码,请稍后重试或手动填写编码"); | 700 | + throw new UserFriendlyException("Could not generate a unique category code. Retry later or enter a code manually."); |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | private async Task EnsureCategoryCodeNotDuplicatedAsync(string code, string? excludeId = null) | 703 | private async Task EnsureCategoryCodeNotDuplicatedAsync(string code, string? excludeId = null) |
| @@ -711,7 +711,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -711,7 +711,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 711 | 711 | ||
| 712 | if (await query.AnyAsync()) | 712 | if (await query.AnyAsync()) |
| 713 | { | 713 | { |
| 714 | - throw new UserFriendlyException("类别编码已存在"); | 714 | + throw new UserFriendlyException("Category code already exists."); |
| 715 | } | 715 | } |
| 716 | } | 716 | } |
| 717 | 717 | ||
| @@ -726,7 +726,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -726,7 +726,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 726 | 726 | ||
| 727 | if (await query.AnyAsync()) | 727 | if (await query.AnyAsync()) |
| 728 | { | 728 | { |
| 729 | - throw new UserFriendlyException("类别名称已存在"); | 729 | + throw new UserFriendlyException("Category name already exists."); |
| 730 | } | 730 | } |
| 731 | } | 731 | } |
| 732 | 732 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductLocationAppService.cs
| @@ -209,7 +209,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -209,7 +209,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 209 | var locationId = id?.Trim(); | 209 | var locationId = id?.Trim(); |
| 210 | if (string.IsNullOrWhiteSpace(locationId)) | 210 | if (string.IsNullOrWhiteSpace(locationId)) |
| 211 | { | 211 | { |
| 212 | - throw new UserFriendlyException("门店Id不能为空"); | 212 | + throw new UserFriendlyException("locationId is required."); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | var hasAvailabilityColumn = await ProductScopeSchemaHelper.HasAvailabilityTypeColumnAsync( | 215 | var hasAvailabilityColumn = await ProductScopeSchemaHelper.HasAvailabilityTypeColumnAsync( |
| @@ -292,7 +292,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -292,7 +292,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 292 | var locationId = input.LocationId?.Trim(); | 292 | var locationId = input.LocationId?.Trim(); |
| 293 | if (string.IsNullOrWhiteSpace(locationId)) | 293 | if (string.IsNullOrWhiteSpace(locationId)) |
| 294 | { | 294 | { |
| 295 | - throw new UserFriendlyException("门店Id不能为空"); | 295 | + throw new UserFriendlyException("locationId is required."); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | var productIds = input.ProductIds? | 298 | var productIds = input.ProductIds? |
| @@ -303,20 +303,20 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -303,20 +303,20 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 303 | 303 | ||
| 304 | if (productIds.Count == 0) | 304 | if (productIds.Count == 0) |
| 305 | { | 305 | { |
| 306 | - throw new UserFriendlyException("ProductIds至少1个"); | 306 | + throw new UserFriendlyException("At least one ProductId is required."); |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | // 校验门店存在 | 309 | // 校验门店存在 |
| 310 | if (!Guid.TryParse(locationId, out var gid)) | 310 | if (!Guid.TryParse(locationId, out var gid)) |
| 311 | { | 311 | { |
| 312 | - throw new UserFriendlyException("门店Id格式不正确"); | 312 | + throw new UserFriendlyException("Invalid locationId format."); |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | var locExists = await _dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() | 315 | var locExists = await _dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() |
| 316 | .AnyAsync(x => !x.IsDeleted && x.Id == gid); | 316 | .AnyAsync(x => !x.IsDeleted && x.Id == gid); |
| 317 | if (!locExists) | 317 | if (!locExists) |
| 318 | { | 318 | { |
| 319 | - throw new UserFriendlyException("门店不存在"); | 319 | + throw new UserFriendlyException("Location not found."); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | // 校验产品存在 | 322 | // 校验产品存在 |
| @@ -325,7 +325,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -325,7 +325,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 325 | .CountAsync(); | 325 | .CountAsync(); |
| 326 | if (productExistsCount != productIds.Count) | 326 | if (productExistsCount != productIds.Count) |
| 327 | { | 327 | { |
| 328 | - throw new UserFriendlyException("产品不存在"); | 328 | + throw new UserFriendlyException("Product not found."); |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | // 去重:避免唯一键重复 | 331 | // 去重:避免唯一键重复 |
| @@ -358,7 +358,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -358,7 +358,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 358 | var locationId = id?.Trim(); | 358 | var locationId = id?.Trim(); |
| 359 | if (string.IsNullOrWhiteSpace(locationId)) | 359 | if (string.IsNullOrWhiteSpace(locationId)) |
| 360 | { | 360 | { |
| 361 | - throw new UserFriendlyException("门店Id不能为空"); | 361 | + throw new UserFriendlyException("locationId is required."); |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | var productIds = input.ProductIds? | 364 | var productIds = input.ProductIds? |
| @@ -369,19 +369,19 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -369,19 +369,19 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 369 | 369 | ||
| 370 | if (productIds.Count == 0) | 370 | if (productIds.Count == 0) |
| 371 | { | 371 | { |
| 372 | - throw new UserFriendlyException("ProductIds至少1个"); | 372 | + throw new UserFriendlyException("At least one ProductId is required."); |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | if (!Guid.TryParse(locationId, out var gid)) | 375 | if (!Guid.TryParse(locationId, out var gid)) |
| 376 | { | 376 | { |
| 377 | - throw new UserFriendlyException("门店Id格式不正确"); | 377 | + throw new UserFriendlyException("Invalid locationId format."); |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | var locExists = await _dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() | 380 | var locExists = await _dbContext.SqlSugarClient.Queryable<LocationAggregateRoot>() |
| 381 | .AnyAsync(x => !x.IsDeleted && x.Id == gid); | 381 | .AnyAsync(x => !x.IsDeleted && x.Id == gid); |
| 382 | if (!locExists) | 382 | if (!locExists) |
| 383 | { | 383 | { |
| 384 | - throw new UserFriendlyException("门店不存在"); | 384 | + throw new UserFriendlyException("Location not found."); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | var productExistsCount = await _dbContext.SqlSugarClient.Queryable<FlProductDbEntity>() | 387 | var productExistsCount = await _dbContext.SqlSugarClient.Queryable<FlProductDbEntity>() |
| @@ -389,7 +389,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -389,7 +389,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 389 | .CountAsync(); | 389 | .CountAsync(); |
| 390 | if (productExistsCount != productIds.Count) | 390 | if (productExistsCount != productIds.Count) |
| 391 | { | 391 | { |
| 392 | - throw new UserFriendlyException("产品不存在"); | 392 | + throw new UserFriendlyException("Product not found."); |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | // 替换:先删后建 | 395 | // 替换:先删后建 |
| @@ -414,7 +414,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | @@ -414,7 +414,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp | ||
| 414 | var locationId = id?.Trim(); | 414 | var locationId = id?.Trim(); |
| 415 | if (string.IsNullOrWhiteSpace(locationId)) | 415 | if (string.IsNullOrWhiteSpace(locationId)) |
| 416 | { | 416 | { |
| 417 | - throw new UserFriendlyException("门店Id不能为空"); | 417 | + throw new UserFriendlyException("locationId is required."); |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | await _dbContext.SqlSugarClient.Deleteable<FlLocationProductDbEntity>() | 420 | await _dbContext.SqlSugarClient.Deleteable<FlLocationProductDbEntity>() |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacMenuAppService.cs
| @@ -56,7 +56,7 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService | @@ -56,7 +56,7 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService | ||
| 56 | .SingleAsync(); | 56 | .SingleAsync(); |
| 57 | if (entity is null) | 57 | if (entity is null) |
| 58 | { | 58 | { |
| 59 | - throw new UserFriendlyException("权限不存在"); | 59 | + throw new UserFriendlyException("Permission not found."); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | return new RbacMenuGetListOutputDto | 62 | return new RbacMenuGetListOutputDto |
| @@ -80,7 +80,7 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService | @@ -80,7 +80,7 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService | ||
| 80 | var name = input.MenuName?.Trim(); | 80 | var name = input.MenuName?.Trim(); |
| 81 | if (string.IsNullOrWhiteSpace(name)) | 81 | if (string.IsNullOrWhiteSpace(name)) |
| 82 | { | 82 | { |
| 83 | - throw new UserFriendlyException("权限名称不能为空"); | 83 | + throw new UserFriendlyException("Permission name is required."); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | var entity = new MenuDbEntity | 86 | var entity = new MenuDbEntity |
| @@ -114,13 +114,13 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService | @@ -114,13 +114,13 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService | ||
| 114 | .SingleAsync(); | 114 | .SingleAsync(); |
| 115 | if (entity is null) | 115 | if (entity is null) |
| 116 | { | 116 | { |
| 117 | - throw new UserFriendlyException("权限不存在"); | 117 | + throw new UserFriendlyException("Permission not found."); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | var name = input.MenuName?.Trim(); | 120 | var name = input.MenuName?.Trim(); |
| 121 | if (string.IsNullOrWhiteSpace(name)) | 121 | if (string.IsNullOrWhiteSpace(name)) |
| 122 | { | 122 | { |
| 123 | - throw new UserFriendlyException("权限名称不能为空"); | 123 | + throw new UserFriendlyException("Permission name is required."); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | entity.MenuName = name; | 126 | entity.MenuName = name; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleAppService.cs
| @@ -101,7 +101,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -101,7 +101,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 101 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 101 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 102 | if (entity is null) | 102 | if (entity is null) |
| 103 | { | 103 | { |
| 104 | - throw new UserFriendlyException("角色不存在"); | 104 | + throw new UserFriendlyException("Role not found."); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | var menuIds = await _roleMenuRepository._DbQueryable | 107 | var menuIds = await _roleMenuRepository._DbQueryable |
| @@ -135,18 +135,18 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -135,18 +135,18 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 135 | var roleCode = input.RoleCode?.Trim(); | 135 | var roleCode = input.RoleCode?.Trim(); |
| 136 | if (string.IsNullOrWhiteSpace(roleName)) | 136 | if (string.IsNullOrWhiteSpace(roleName)) |
| 137 | { | 137 | { |
| 138 | - throw new UserFriendlyException("角色名称不能为空"); | 138 | + throw new UserFriendlyException("Role name is required."); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | if (string.IsNullOrWhiteSpace(roleCode)) | 141 | if (string.IsNullOrWhiteSpace(roleCode)) |
| 142 | { | 142 | { |
| 143 | - throw new UserFriendlyException("角色编码不能为空"); | 143 | + throw new UserFriendlyException("Role code is required."); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | var isExist = await _roleRepository.IsAnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); | 146 | var isExist = await _roleRepository.IsAnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); |
| 147 | if (isExist) | 147 | if (isExist) |
| 148 | { | 148 | { |
| 149 | - throw new UserFriendlyException("角色名称或编码已存在"); | 149 | + throw new UserFriendlyException("Role name or code already exists."); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | var entity = new RoleAggregateRoot | 152 | var entity = new RoleAggregateRoot |
| @@ -176,19 +176,19 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -176,19 +176,19 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 176 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 176 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 177 | if (entity is null) | 177 | if (entity is null) |
| 178 | { | 178 | { |
| 179 | - throw new UserFriendlyException("角色不存在"); | 179 | + throw new UserFriendlyException("Role not found."); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | var roleName = input.RoleName?.Trim(); | 182 | var roleName = input.RoleName?.Trim(); |
| 183 | var roleCode = input.RoleCode?.Trim(); | 183 | var roleCode = input.RoleCode?.Trim(); |
| 184 | if (string.IsNullOrWhiteSpace(roleName)) | 184 | if (string.IsNullOrWhiteSpace(roleName)) |
| 185 | { | 185 | { |
| 186 | - throw new UserFriendlyException("角色名称不能为空"); | 186 | + throw new UserFriendlyException("Role name is required."); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | if (string.IsNullOrWhiteSpace(roleCode)) | 189 | if (string.IsNullOrWhiteSpace(roleCode)) |
| 190 | { | 190 | { |
| 191 | - throw new UserFriendlyException("角色编码不能为空"); | 191 | + throw new UserFriendlyException("Role code is required."); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | var isExist = await _roleRepository._DbQueryable | 194 | var isExist = await _roleRepository._DbQueryable |
| @@ -196,7 +196,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -196,7 +196,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 196 | .AnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); | 196 | .AnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); |
| 197 | if (isExist) | 197 | if (isExist) |
| 198 | { | 198 | { |
| 199 | - throw new UserFriendlyException("角色名称或编码已存在"); | 199 | + throw new UserFriendlyException("Role name or code already exists."); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | entity.RoleName = roleName; | 202 | entity.RoleName = roleName; |
| @@ -241,7 +241,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -241,7 +241,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 241 | var menuIds = ParseMenuPermissionKeys(input.MenuPermissionKeys); | 241 | var menuIds = ParseMenuPermissionKeys(input.MenuPermissionKeys); |
| 242 | if (menuIds.Count == 0) | 242 | if (menuIds.Count == 0) |
| 243 | { | 243 | { |
| 244 | - throw new UserFriendlyException("menuPermissionKeys 未包含有效的菜单 Id(Guid)"); | 244 | + throw new UserFriendlyException("menuPermissionKeys contains no valid menu Id (Guid)."); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | await SetRoleMenusAsync(roleId, menuIds); | 247 | await SetRoleMenusAsync(roleId, menuIds); |
| @@ -261,7 +261,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -261,7 +261,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 261 | if (menuIds.Count == 0) | 261 | if (menuIds.Count == 0) |
| 262 | { | 262 | { |
| 263 | throw new UserFriendlyException( | 263 | throw new UserFriendlyException( |
| 264 | - "accessPermissions 未匹配到任何菜单,请确认权限码与菜单 Router 一致,或先执行 menu_backfill_permission_code.sql 回填 Menu.PermissionCode"); | 264 | + "accessPermissions matched no menus. Verify permission codes match menu Router, or run menu_backfill_permission_code.sql to backfill Menu.PermissionCode."); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | await SetRoleMenusAsync(roleId, menuIds); | 267 | await SetRoleMenusAsync(roleId, menuIds); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleMenuAppService.cs
| @@ -37,7 +37,7 @@ public class RbacRoleMenuAppService : ApplicationService, IRbacRoleMenuAppServic | @@ -37,7 +37,7 @@ public class RbacRoleMenuAppService : ApplicationService, IRbacRoleMenuAppServic | ||
| 37 | var role = await _roleRepository.GetSingleAsync(x => x.Id == input.RoleId && x.IsDeleted == false); | 37 | var role = await _roleRepository.GetSingleAsync(x => x.Id == input.RoleId && x.IsDeleted == false); |
| 38 | if (role is null) | 38 | if (role is null) |
| 39 | { | 39 | { |
| 40 | - throw new UserFriendlyException("角色不存在"); | 40 | + throw new UserFriendlyException("Role not found."); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | var menuIds = input.MenuIds?.Distinct().ToList() ?? new List<Guid>(); | 43 | var menuIds = input.MenuIds?.Distinct().ToList() ?? new List<Guid>(); |
| @@ -90,7 +90,7 @@ public class RbacRoleMenuAppService : ApplicationService, IRbacRoleMenuAppServic | @@ -90,7 +90,7 @@ public class RbacRoleMenuAppService : ApplicationService, IRbacRoleMenuAppServic | ||
| 90 | var role = await _roleRepository.GetSingleAsync(x => x.Id == input.RoleId && x.IsDeleted == false); | 90 | var role = await _roleRepository.GetSingleAsync(x => x.Id == input.RoleId && x.IsDeleted == false); |
| 91 | if (role is null) | 91 | if (role is null) |
| 92 | { | 92 | { |
| 93 | - throw new UserFriendlyException("角色不存在"); | 93 | + throw new UserFriendlyException("Role not found."); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | var menuIds = input.MenuIds?.Distinct().ToList() ?? new List<Guid>(); | 96 | var menuIds = input.MenuIds?.Distinct().ToList() ?? new List<Guid>(); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ReportsAppService.cs
| @@ -43,12 +43,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -43,12 +43,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 43 | { | 43 | { |
| 44 | if (input is null) | 44 | if (input is null) |
| 45 | { | 45 | { |
| 46 | - throw new UserFriendlyException("入参不能为空"); | 46 | + throw new UserFriendlyException("Request body is required."); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | if (!CurrentUser.Id.HasValue) | 49 | if (!CurrentUser.Id.HasValue) |
| 50 | { | 50 | { |
| 51 | - throw new UserFriendlyException("用户未登录"); | 51 | + throw new UserFriendlyException("You are not signed in."); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 54 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
| @@ -165,12 +165,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -165,12 +165,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 165 | QuestPDF.Settings.License = LicenseType.Community; | 165 | QuestPDF.Settings.License = LicenseType.Community; |
| 166 | if (input is null) | 166 | if (input is null) |
| 167 | { | 167 | { |
| 168 | - throw new UserFriendlyException("入参不能为空"); | 168 | + throw new UserFriendlyException("Request body is required."); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | if (!CurrentUser.Id.HasValue) | 171 | if (!CurrentUser.Id.HasValue) |
| 172 | { | 172 | { |
| 173 | - throw new UserFriendlyException("用户未登录"); | 173 | + throw new UserFriendlyException("You are not signed in."); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 176 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
| @@ -201,7 +201,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -201,7 +201,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 201 | var count = await query.CountAsync(); | 201 | var count = await query.CountAsync(); |
| 202 | if (count > ExportPdfMaxRows) | 202 | if (count > ExportPdfMaxRows) |
| 203 | { | 203 | { |
| 204 | - throw new UserFriendlyException($"导出数据超过上限 {ExportPdfMaxRows} 条,请缩小筛选范围"); | 204 | + throw new UserFriendlyException($"Export exceeds the maximum of {ExportPdfMaxRows} rows. Narrow your filters and try again."); |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | var rows = await query.Take(ExportPdfMaxRows) | 207 | var rows = await query.Take(ExportPdfMaxRows) |
| @@ -311,12 +311,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -311,12 +311,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 311 | { | 311 | { |
| 312 | if (input is null) | 312 | if (input is null) |
| 313 | { | 313 | { |
| 314 | - throw new UserFriendlyException("入参不能为空"); | 314 | + throw new UserFriendlyException("Request body is required."); |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | if (!CurrentUser.Id.HasValue) | 317 | if (!CurrentUser.Id.HasValue) |
| 318 | { | 318 | { |
| 319 | - throw new UserFriendlyException("用户未登录"); | 319 | + throw new UserFriendlyException("You are not signed in."); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 322 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
| @@ -361,7 +361,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -361,7 +361,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 361 | var count = await query.CountAsync(); | 361 | var count = await query.CountAsync(); |
| 362 | if (count > ExportPdfMaxRows) | 362 | if (count > ExportPdfMaxRows) |
| 363 | { | 363 | { |
| 364 | - throw new UserFriendlyException($"导出数据超过上限 {ExportPdfMaxRows} 条,请缩小筛选范围"); | 364 | + throw new UserFriendlyException($"Export exceeds the maximum of {ExportPdfMaxRows} rows. Narrow your filters and try again."); |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | var pageRows = await query.Take(ExportPdfMaxRows) | 367 | var pageRows = await query.Take(ExportPdfMaxRows) |
| @@ -415,12 +415,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -415,12 +415,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 415 | { | 415 | { |
| 416 | if (input is null) | 416 | if (input is null) |
| 417 | { | 417 | { |
| 418 | - throw new UserFriendlyException("入参不能为空"); | 418 | + throw new UserFriendlyException("Request body is required."); |
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | if (!CurrentUser.Id.HasValue) | 421 | if (!CurrentUser.Id.HasValue) |
| 422 | { | 422 | { |
| 423 | - throw new UserFriendlyException("用户未登录"); | 423 | + throw new UserFriendlyException("You are not signed in."); |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 426 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
| @@ -494,12 +494,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -494,12 +494,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 494 | { | 494 | { |
| 495 | if (input is null) | 495 | if (input is null) |
| 496 | { | 496 | { |
| 497 | - throw new UserFriendlyException("入参不能为空"); | 497 | + throw new UserFriendlyException("Request body is required."); |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | if (!CurrentUser.Id.HasValue) | 500 | if (!CurrentUser.Id.HasValue) |
| 501 | { | 501 | { |
| 502 | - throw new UserFriendlyException("用户未登录"); | 502 | + throw new UserFriendlyException("You are not signed in."); |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 505 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TeamMemberAppService.cs
| @@ -20,6 +20,7 @@ using Yi.Framework.Rbac.Domain.Entities; | @@ -20,6 +20,7 @@ using Yi.Framework.Rbac.Domain.Entities; | ||
| 20 | using Yi.Framework.Rbac.Domain.Entities.ValueObjects; | 20 | using Yi.Framework.Rbac.Domain.Entities.ValueObjects; |
| 21 | using Yi.Framework.Rbac.Domain.Helpers; | 21 | using Yi.Framework.Rbac.Domain.Helpers; |
| 22 | using Yi.Framework.Rbac.Domain.Managers; | 22 | using Yi.Framework.Rbac.Domain.Managers; |
| 23 | +using Yi.Framework.Rbac.Domain.Shared.Consts; | ||
| 23 | using Yi.Framework.SqlSugarCore.Abstractions; | 24 | using Yi.Framework.SqlSugarCore.Abstractions; |
| 24 | 25 | ||
| 25 | namespace FoodLabeling.Application.Services; | 26 | namespace FoodLabeling.Application.Services; |
| @@ -95,7 +96,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -95,7 +96,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 95 | var user = await _userRepository.GetByIdAsync(id); | 96 | var user = await _userRepository.GetByIdAsync(id); |
| 96 | if (user is null || user.IsDeleted) | 97 | if (user is null || user.IsDeleted) |
| 97 | { | 98 | { |
| 98 | - throw new UserFriendlyException("成员不存在"); | 99 | + throw new UserFriendlyException("Team member not found."); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | var userIdString = id.ToString(); | 102 | var userIdString = id.ToString(); |
| @@ -127,13 +128,18 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -127,13 +128,18 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 127 | }) | 128 | }) |
| 128 | .ToList(); | 129 | .ToList(); |
| 129 | 130 | ||
| 130 | - var role = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity>() | ||
| 131 | - .FirstAsync(x => x.UserId == id); | 131 | + var role = await LoadPreferredUserRoleAsync(id); |
| 132 | 132 | ||
| 133 | var scopeLocationIds = assigned.Select(x => x.Id).ToList(); | 133 | var scopeLocationIds = assigned.Select(x => x.Id).ToList(); |
| 134 | var (partnerIds, regionIds, _) = await LocationScopeBindingHelper.ResolveMemberScopeFromLocationIdsAsync( | 134 | var (partnerIds, regionIds, _) = await LocationScopeBindingHelper.ResolveMemberScopeFromLocationIdsAsync( |
| 135 | _dbContext.SqlSugarClient, scopeLocationIds); | 135 | _dbContext.SqlSugarClient, scopeLocationIds); |
| 136 | 136 | ||
| 137 | + var dim = await LoadTeamMemberScopeAsync(id); | ||
| 138 | + if (partnerIds.Count == 0 && dim.PartnerIds.Count > 0) | ||
| 139 | + { | ||
| 140 | + partnerIds = dim.PartnerIds; | ||
| 141 | + } | ||
| 142 | + | ||
| 137 | if (await TeamMemberRoleHelper.IsCompanyAdminRoleAsync(_dbContext.SqlSugarClient, role?.RoleId) && | 143 | if (await TeamMemberRoleHelper.IsCompanyAdminRoleAsync(_dbContext.SqlSugarClient, role?.RoleId) && |
| 138 | partnerIds.Count > 0) | 144 | partnerIds.Count > 0) |
| 139 | { | 145 | { |
| @@ -142,7 +148,6 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -142,7 +148,6 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 142 | scopeLocationIds = assigned.Select(x => x.Id).ToList(); | 148 | scopeLocationIds = assigned.Select(x => x.Id).ToList(); |
| 143 | } | 149 | } |
| 144 | 150 | ||
| 145 | - var dim = await LoadTeamMemberScopeAsync(id); | ||
| 146 | // 库中存展开 Guid;结合 Applied* 维度回显 ["ALL"],与新增传 ALL 对称 | 151 | // 库中存展开 Guid;结合 Applied* 维度回显 ["ALL"],与新增传 ALL 对称 |
| 147 | (regionIds, scopeLocationIds, assigned) = | 152 | (regionIds, scopeLocationIds, assigned) = |
| 148 | await TeamMemberScopeDisplayHelper.CollapseScopeIdsToAllSentinelForEditAsync( | 153 | await TeamMemberScopeDisplayHelper.CollapseScopeIdsToAllSentinelForEditAsync( |
| @@ -205,7 +210,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -205,7 +210,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 205 | /// | 210 | /// |
| 206 | /// 参数说明: | 211 | /// 参数说明: |
| 207 | /// - partnerId / partnerIds: 展开 ALL 时的 Company 上下文(必填) | 212 | /// - partnerId / partnerIds: 展开 ALL 时的 Company 上下文(必填) |
| 208 | - /// - locationIds / locations: 可含 <c>ALL</c>;按该公司全部门店落库;列表 <c>assignedLocations</c> 展示 <c>All Location</c> | 213 | + /// - locationIds / locations: 可含 <c>ALL</c>;按该公司全部门店落库;该公司暂无门店时仍可保存,后续新建门店会自动绑定;列表 <c>assignedLocations</c> 展示 <c>All Location</c> |
| 209 | /// - regionIds / groupIds: 可含 <c>ALL</c>;为 ALL 且同时有具体 locationIds 时以门店为准;含具体 Guid 时按 Region 展开(忽略同传 locationIds) | 214 | /// - regionIds / groupIds: 可含 <c>ALL</c>;为 ALL 且同时有具体 locationIds 时以门店为准;含具体 Guid 时按 Region 展开(忽略同传 locationIds) |
| 210 | /// - 优先级:location ALL →(具体 location 且 region 空/ALL)→ region ALL → 具体 region → 具体 location → 仅 Company | 215 | /// - 优先级:location ALL →(具体 location 且 region 空/ALL)→ region ALL → 具体 region → 具体 location → 仅 Company |
| 211 | /// | 216 | /// |
| @@ -259,7 +264,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -259,7 +264,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 259 | } | 264 | } |
| 260 | 265 | ||
| 261 | await UpsertUserLocationsAsync(user.Id, scope.LocationIds); | 266 | await UpsertUserLocationsAsync(user.Id, scope.LocationIds); |
| 262 | - await UpsertTeamMemberScopeAsync(user.Id, scope.AppliedRegionType, scope.AppliedLocationType); | 267 | + await UpsertTeamMemberScopeAsync( |
| 268 | + user.Id, scope.AppliedRegionType, scope.AppliedLocationType, scope.PartnerIds); | ||
| 263 | 269 | ||
| 264 | return await GetAsync(user.Id); | 270 | return await GetAsync(user.Id); |
| 265 | } | 271 | } |
| @@ -301,7 +307,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -301,7 +307,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 301 | /// <param name="input">更新请求体</param> | 307 | /// <param name="input">更新请求体</param> |
| 302 | /// <returns>更新后的成员详情</returns> | 308 | /// <returns>更新后的成员详情</returns> |
| 303 | /// <response code="200">更新成功</response> | 309 | /// <response code="200">更新成功</response> |
| 304 | - /// <response code="400">参数不合法或成员不存在</response> | 310 | + /// <response code="400">参数不合法或Team member not found.</response> |
| 305 | /// <response code="500">服务器错误</response> | 311 | /// <response code="500">服务器错误</response> |
| 306 | public async Task<TeamMemberGetOutputDto> UpdateAsync(Guid id, TeamMemberUpdateInputVo input) | 312 | public async Task<TeamMemberGetOutputDto> UpdateAsync(Guid id, TeamMemberUpdateInputVo input) |
| 307 | { | 313 | { |
| @@ -320,7 +326,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -320,7 +326,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 320 | var user = await _userRepository.GetByIdAsync(id); | 326 | var user = await _userRepository.GetByIdAsync(id); |
| 321 | if (user is null || user.IsDeleted) | 327 | if (user is null || user.IsDeleted) |
| 322 | { | 328 | { |
| 323 | - throw new UserFriendlyException("成员不存在"); | 329 | + throw new UserFriendlyException("Team member not found."); |
| 324 | } | 330 | } |
| 325 | 331 | ||
| 326 | user.Name = input.FullName.Trim(); | 332 | user.Name = input.FullName.Trim(); |
| @@ -356,7 +362,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -356,7 +362,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 356 | } | 362 | } |
| 357 | 363 | ||
| 358 | await UpsertUserLocationsAsync(id, scope.LocationIds); | 364 | await UpsertUserLocationsAsync(id, scope.LocationIds); |
| 359 | - await UpsertTeamMemberScopeAsync(id, scope.AppliedRegionType, scope.AppliedLocationType); | 365 | + await UpsertTeamMemberScopeAsync( |
| 366 | + id, scope.AppliedRegionType, scope.AppliedLocationType, scope.PartnerIds); | ||
| 360 | 367 | ||
| 361 | return await GetAsync(id); | 368 | return await GetAsync(id); |
| 362 | } | 369 | } |
| @@ -512,19 +519,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -512,19 +519,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 512 | { | 519 | { |
| 513 | if (input?.File is null || input.File.Length == 0) | 520 | if (input?.File is null || input.File.Length == 0) |
| 514 | { | 521 | { |
| 515 | - throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)"); | 522 | + throw new UserFriendlyException("Upload an Excel file (form field name: file)."); |
| 516 | } | 523 | } |
| 517 | 524 | ||
| 518 | var opt = _batchImportOptions.Value; | 525 | var opt = _batchImportOptions.Value; |
| 519 | if (input.File.Length > opt.MaxUploadBytes) | 526 | if (input.File.Length > opt.MaxUploadBytes) |
| 520 | { | 527 | { |
| 521 | - throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB"); | 528 | + throw new UserFriendlyException($"File too large; maximum {opt.MaxUploadBytes / 1024 / 1024} MB allowed."); |
| 522 | } | 529 | } |
| 523 | 530 | ||
| 524 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); | 531 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); |
| 525 | if (ext != ".xlsx") | 532 | if (ext != ".xlsx") |
| 526 | { | 533 | { |
| 527 | - throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件"); | 534 | + throw new UserFriendlyException("Only .xlsx Excel files are supported."); |
| 528 | } | 535 | } |
| 529 | 536 | ||
| 530 | var roleMap = await BuildRoleNameToIdMapAsync(); | 537 | var roleMap = await BuildRoleNameToIdMapAsync(); |
| @@ -586,14 +593,14 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -586,14 +593,14 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 586 | { | 593 | { |
| 587 | if (input?.Items is null || input.Items.Count == 0) | 594 | if (input?.Items is null || input.Items.Count == 0) |
| 588 | { | 595 | { |
| 589 | - throw new UserFriendlyException("请至少提交一条导入数据(items 不能为空)"); | 596 | + throw new UserFriendlyException("Submit at least one row to import (items is required)."); |
| 590 | } | 597 | } |
| 591 | 598 | ||
| 592 | var opt = _batchImportOptions.Value; | 599 | var opt = _batchImportOptions.Value; |
| 593 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; | 600 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; |
| 594 | if (input.Items.Count > maxRows) | 601 | if (input.Items.Count > maxRows) |
| 595 | { | 602 | { |
| 596 | - throw new UserFriendlyException($"单次批量导入最多允许 {maxRows} 条,请分批提交"); | 603 | + throw new UserFriendlyException($"Maximum {maxRows} rows per batch import. Submit in batches."); |
| 597 | } | 604 | } |
| 598 | 605 | ||
| 599 | var defaultPassword = opt.TeamMemberImportDefaultPassword?.Trim() ?? string.Empty; | 606 | var defaultPassword = opt.TeamMemberImportDefaultPassword?.Trim() ?? string.Empty; |
| @@ -608,7 +615,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -608,7 +615,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 608 | if (string.IsNullOrEmpty(defaultPassword)) | 615 | if (string.IsNullOrEmpty(defaultPassword)) |
| 609 | { | 616 | { |
| 610 | throw new UserFriendlyException( | 617 | throw new UserFriendlyException( |
| 611 | - "未配置默认导入密码 FoodLabeling:BatchImport:TeamMemberImportDefaultPassword"); | 618 | + "Default import password is not configured (FoodLabeling:BatchImport:TeamMemberImportDefaultPassword)."); |
| 612 | } | 619 | } |
| 613 | 620 | ||
| 614 | vo.Password = defaultPassword; | 621 | vo.Password = defaultPassword; |
| @@ -638,20 +645,20 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -638,20 +645,20 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 638 | { | 645 | { |
| 639 | if (input?.Items is null || input.Items.Count == 0) | 646 | if (input?.Items is null || input.Items.Count == 0) |
| 640 | { | 647 | { |
| 641 | - throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)"); | 648 | + throw new UserFriendlyException("Submit at least one row to edit (items is required)."); |
| 642 | } | 649 | } |
| 643 | 650 | ||
| 644 | var opt = _batchImportOptions.Value; | 651 | var opt = _batchImportOptions.Value; |
| 645 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; | 652 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; |
| 646 | if (input.Items.Count > maxItems) | 653 | if (input.Items.Count > maxItems) |
| 647 | { | 654 | { |
| 648 | - throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交"); | 655 | + throw new UserFriendlyException($"Maximum {maxItems} rows per batch import. Submit in batches."); |
| 649 | } | 656 | } |
| 650 | 657 | ||
| 651 | var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty); | 658 | var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty); |
| 652 | if (effectiveCount == 0) | 659 | if (effectiveCount == 0) |
| 653 | { | 660 | { |
| 654 | - throw new UserFriendlyException("没有有效的成员 Id(请为待保存行填写 id)"); | 661 | + throw new UserFriendlyException("No valid member Id (set id on rows to save)."); |
| 655 | } | 662 | } |
| 656 | 663 | ||
| 657 | var result = new TeamMemberBulkUpdateResultDto(); | 664 | var result = new TeamMemberBulkUpdateResultDto(); |
| @@ -716,7 +723,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -716,7 +723,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 716 | .FirstAsync(); | 723 | .FirstAsync(); |
| 717 | if (byId is null) | 724 | if (byId is null) |
| 718 | { | 725 | { |
| 719 | - throw new UserFriendlyException($"无效门店 Id:{key}"); | 726 | + throw new UserFriendlyException($"Invalid location Id: {key}"); |
| 720 | } | 727 | } |
| 721 | 728 | ||
| 722 | result.Add(byId.Id.ToString()); | 729 | result.Add(byId.Id.ToString()); |
| @@ -728,7 +735,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -728,7 +735,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 728 | .FirstAsync(); | 735 | .FirstAsync(); |
| 729 | if (byCode is null) | 736 | if (byCode is null) |
| 730 | { | 737 | { |
| 731 | - throw new UserFriendlyException($"未找到门店 LocationCode:{key}(亦可填 location.Id Guid)"); | 738 | + throw new UserFriendlyException($"Location LocationCode not found: {key} (you may also use location.Id Guid)"); |
| 732 | } | 739 | } |
| 733 | 740 | ||
| 734 | result.Add(byCode.Id.ToString()); | 741 | result.Add(byCode.Id.ToString()); |
| @@ -758,7 +765,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -758,7 +765,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 758 | .FirstAsync(); | 765 | .FirstAsync(); |
| 759 | if (byId is null) | 766 | if (byId is null) |
| 760 | { | 767 | { |
| 761 | - throw new UserFriendlyException($"无效 Region Id:{key}"); | 768 | + throw new UserFriendlyException($"Invalid Region Id: {key}"); |
| 762 | } | 769 | } |
| 763 | 770 | ||
| 764 | result.Add(byId.Id.Trim()); | 771 | result.Add(byId.Id.Trim()); |
| @@ -774,13 +781,13 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -774,13 +781,13 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 774 | 781 | ||
| 775 | if (matches.Count == 0) | 782 | if (matches.Count == 0) |
| 776 | { | 783 | { |
| 777 | - throw new UserFriendlyException($"未找到 Region:{key}(可填 fl_group.Id 或 GroupName)"); | 784 | + throw new UserFriendlyException($"Region not found: {key} (use fl_group.Id or GroupName)"); |
| 778 | } | 785 | } |
| 779 | 786 | ||
| 780 | if (matches.Count > 1) | 787 | if (matches.Count > 1) |
| 781 | { | 788 | { |
| 782 | throw new UserFriendlyException( | 789 | throw new UserFriendlyException( |
| 783 | - $"Region 名称「{key}」存在多条记录,请改用 fl_group.Id(Guid)"); | 790 | + $"Region name \"{key}\" matches multiple records; use fl_group.Id (Guid)."); |
| 784 | } | 791 | } |
| 785 | 792 | ||
| 786 | result.Add(matches[0].Id.Trim()); | 793 | result.Add(matches[0].Id.Trim()); |
| @@ -837,11 +844,17 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -837,11 +844,17 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 837 | query = query.Where(u => userIds.Contains(u.Id)); | 844 | query = query.Where(u => userIds.Contains(u.Id)); |
| 838 | } | 845 | } |
| 839 | 846 | ||
| 847 | + var hideSelf = await ShouldHideCurrentUserInTeamMemberListAsync(); | ||
| 848 | + var selfId = CurrentUser?.Id; | ||
| 849 | + | ||
| 840 | if (scopeLocationIds is not null) | 850 | if (scopeLocationIds is not null) |
| 841 | { | 851 | { |
| 842 | if (scopeLocationIds.Count == 0) | 852 | if (scopeLocationIds.Count == 0) |
| 843 | { | 853 | { |
| 844 | - query = query.Where(_ => false); | 854 | + // Location=ALL 且暂无门店时,Company Admin 仍应能看到自己 |
| 855 | + query = selfId is Guid id && !hideSelf | ||
| 856 | + ? query.Where(u => u.Id == id) | ||
| 857 | + : query.Where(_ => false); | ||
| 845 | } | 858 | } |
| 846 | else | 859 | else |
| 847 | { | 860 | { |
| @@ -861,6 +874,11 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -861,6 +874,11 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 861 | .Distinct() | 874 | .Distinct() |
| 862 | .ToList(); | 875 | .ToList(); |
| 863 | 876 | ||
| 877 | + if (selfId is Guid id && !hideSelf && !allowedUserGuids.Contains(id)) | ||
| 878 | + { | ||
| 879 | + allowedUserGuids.Add(id); | ||
| 880 | + } | ||
| 881 | + | ||
| 864 | if (allowedUserGuids.Count == 0) | 882 | if (allowedUserGuids.Count == 0) |
| 865 | { | 883 | { |
| 866 | query = query.Where(_ => false); | 884 | query = query.Where(_ => false); |
| @@ -872,9 +890,33 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -872,9 +890,33 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 872 | } | 890 | } |
| 873 | } | 891 | } |
| 874 | 892 | ||
| 893 | + if (hideSelf && selfId is Guid hideId) | ||
| 894 | + { | ||
| 895 | + query = query.Where(u => u.Id != hideId); | ||
| 896 | + } | ||
| 897 | + | ||
| 875 | return query; | 898 | return query; |
| 876 | } | 899 | } |
| 877 | 900 | ||
| 901 | + /// <summary> | ||
| 902 | + /// 仅 RoleCode=admin 的账号在成员列表中隐藏自己;Company Admin 等其它角色要展示当前登录账号。 | ||
| 903 | + /// </summary> | ||
| 904 | + private async Task<bool> ShouldHideCurrentUserInTeamMemberListAsync() | ||
| 905 | + { | ||
| 906 | + if (CurrentUser?.Id is null) | ||
| 907 | + { | ||
| 908 | + return false; | ||
| 909 | + } | ||
| 910 | + | ||
| 911 | + if (ReportsRoleHelper.IsAdminRole(CurrentUser)) | ||
| 912 | + { | ||
| 913 | + return true; | ||
| 914 | + } | ||
| 915 | + | ||
| 916 | + return await ReportsRoleHelper.IsAdminRoleFromDbAsync( | ||
| 917 | + _dbContext.SqlSugarClient, CurrentUser.Id.Value); | ||
| 918 | + } | ||
| 919 | + | ||
| 878 | private async Task<List<TeamMemberGetListOutputDto>> MapUsersToOutputAsync( | 920 | private async Task<List<TeamMemberGetListOutputDto>> MapUsersToOutputAsync( |
| 879 | List<UserAggregateRoot> users, | 921 | List<UserAggregateRoot> users, |
| 880 | List<string>? scopeLocationIds, | 922 | List<string>? scopeLocationIds, |
| @@ -890,12 +932,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -890,12 +932,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 890 | 932 | ||
| 891 | var userRolePairs = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity, RoleAggregateRoot>((ur, r) => ur.RoleId == r.Id) | 933 | var userRolePairs = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity, RoleAggregateRoot>((ur, r) => ur.RoleId == r.Id) |
| 892 | .Where(ur => userIds.Contains(ur.UserId)) | 934 | .Where(ur => userIds.Contains(ur.UserId)) |
| 893 | - .Select((ur, r) => new { ur.UserId, r.Id, r.RoleName }) | 935 | + .Select((ur, r) => new UserRolePickRow |
| 936 | + { | ||
| 937 | + UserId = ur.UserId, | ||
| 938 | + Id = r.Id, | ||
| 939 | + RoleCode = r.RoleCode, | ||
| 940 | + RoleName = r.RoleName, | ||
| 941 | + OrderNum = r.OrderNum | ||
| 942 | + }) | ||
| 894 | .ToListAsync(); | 943 | .ToListAsync(); |
| 895 | 944 | ||
| 896 | var roleIdByUser = userRolePairs | 945 | var roleIdByUser = userRolePairs |
| 897 | .GroupBy(x => x.UserId) | 946 | .GroupBy(x => x.UserId) |
| 898 | - .ToDictionary(g => g.Key, g => (Guid?)g.First().Id); | 947 | + .ToDictionary(g => g.Key, g => (Guid?)PickPreferredRole(g)?.Id); |
| 899 | 948 | ||
| 900 | var allUserLocations = await _dbContext.SqlSugarClient.Queryable<UserLocationDbEntity>() | 949 | var allUserLocations = await _dbContext.SqlSugarClient.Queryable<UserLocationDbEntity>() |
| 901 | .Where(x => !x.IsDeleted) | 950 | .Where(x => !x.IsDeleted) |
| @@ -961,13 +1010,18 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -961,13 +1010,18 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 961 | foreach (var u in users) | 1010 | foreach (var u in users) |
| 962 | { | 1011 | { |
| 963 | roleIdByUser.TryGetValue(u.Id, out var listRoleId); | 1012 | roleIdByUser.TryGetValue(u.Id, out var listRoleId); |
| 964 | - var roleName = userRolePairs.FirstOrDefault(x => x.UserId == u.Id)?.RoleName; | 1013 | + var roleName = PickPreferredRole(userRolePairs.Where(x => x.UserId == u.Id))?.RoleName; |
| 965 | var userKey = TeamMemberListScopeHelper.UserKey(u.Id); | 1014 | var userKey = TeamMemberListScopeHelper.UserKey(u.Id); |
| 966 | assignedMap.TryGetValue(userKey, out var assigned); | 1015 | assignedMap.TryGetValue(userKey, out var assigned); |
| 967 | scopeIdsMap.TryGetValue(userKey, out var scopeIds); | 1016 | scopeIdsMap.TryGetValue(userKey, out var scopeIds); |
| 968 | dimMap.TryGetValue(userKey, out var dim); | 1017 | dimMap.TryGetValue(userKey, out var dim); |
| 969 | 1018 | ||
| 970 | var partnerIds = scopeIds?.PartnerIds ?? new List<string>(); | 1019 | var partnerIds = scopeIds?.PartnerIds ?? new List<string>(); |
| 1020 | + if (partnerIds.Count == 0 && dim?.PartnerIds is { Count: > 0 }) | ||
| 1021 | + { | ||
| 1022 | + partnerIds = dim.PartnerIds; | ||
| 1023 | + } | ||
| 1024 | + | ||
| 971 | var regionIds = scopeIds?.RegionIds ?? new List<string>(); | 1025 | var regionIds = scopeIds?.RegionIds ?? new List<string>(); |
| 972 | var assignedLocations = assigned ?? new List<TeamMemberAssignedLocationDto>(); | 1026 | var assignedLocations = assigned ?? new List<TeamMemberAssignedLocationDto>(); |
| 973 | 1027 | ||
| @@ -1147,17 +1201,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1147,17 +1201,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1147 | public List<string> RegionIds { get; init; } = new(); | 1201 | public List<string> RegionIds { get; init; } = new(); |
| 1148 | } | 1202 | } |
| 1149 | 1203 | ||
| 1150 | - private sealed class TeamMemberScopeSaveResult | 1204 | + private sealed class TeamMemberScopeSaveResult |
| 1151 | { | 1205 | { |
| 1152 | public string AppliedRegionType { get; init; } = AllScopeBindingHelper.ScopeSpecified; | 1206 | public string AppliedRegionType { get; init; } = AllScopeBindingHelper.ScopeSpecified; |
| 1153 | public string AppliedLocationType { get; init; } = AllScopeBindingHelper.ScopeSpecified; | 1207 | public string AppliedLocationType { get; init; } = AllScopeBindingHelper.ScopeSpecified; |
| 1154 | public List<string> LocationIds { get; init; } = new(); | 1208 | public List<string> LocationIds { get; init; } = new(); |
| 1209 | + public List<string> PartnerIds { get; init; } = new(); | ||
| 1155 | } | 1210 | } |
| 1156 | 1211 | ||
| 1157 | private sealed class TeamMemberScopeDimension | 1212 | private sealed class TeamMemberScopeDimension |
| 1158 | { | 1213 | { |
| 1159 | public string? AppliedRegionType { get; init; } | 1214 | public string? AppliedRegionType { get; init; } |
| 1160 | public string? AppliedLocationType { get; init; } | 1215 | public string? AppliedLocationType { get; init; } |
| 1216 | + public List<string> PartnerIds { get; init; } = new(); | ||
| 1161 | } | 1217 | } |
| 1162 | 1218 | ||
| 1163 | private async Task<TeamMemberScopeSaveResult> ResolveTeamMemberScopeForSaveAsync( | 1219 | private async Task<TeamMemberScopeSaveResult> ResolveTeamMemberScopeForSaveAsync( |
| @@ -1210,7 +1266,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1210,7 +1266,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1210 | _dbContext.SqlSugarClient, partnerIds, null, null); | 1266 | _dbContext.SqlSugarClient, partnerIds, null, null); |
| 1211 | if (fromPartner.Count == 0) | 1267 | if (fromPartner.Count == 0) |
| 1212 | { | 1268 | { |
| 1213 | - throw new UserFriendlyException("Company Admin 需绑定公司下门店,所选公司下暂无可用门店"); | 1269 | + throw new UserFriendlyException("Company Admin must be bound to locations under the company; no locations are available for the selected company."); |
| 1214 | } | 1270 | } |
| 1215 | 1271 | ||
| 1216 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, fromPartner); | 1272 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, fromPartner); |
| @@ -1218,7 +1274,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1218,7 +1274,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1218 | { | 1274 | { |
| 1219 | AppliedRegionType = AllScopeBindingHelper.ScopeAll, | 1275 | AppliedRegionType = AllScopeBindingHelper.ScopeAll, |
| 1220 | AppliedLocationType = AllScopeBindingHelper.ScopeAll, | 1276 | AppliedLocationType = AllScopeBindingHelper.ScopeAll, |
| 1221 | - LocationIds = fromPartner | 1277 | + LocationIds = fromPartner, |
| 1278 | + PartnerIds = partnerIds | ||
| 1222 | }; | 1279 | }; |
| 1223 | } | 1280 | } |
| 1224 | 1281 | ||
| @@ -1236,15 +1293,26 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1236,15 +1293,26 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1236 | regionInputForResolve = new List<string> { AllScopeBindingHelper.ScopeAll }; | 1293 | regionInputForResolve = new List<string> { AllScopeBindingHelper.ScopeAll }; |
| 1237 | } | 1294 | } |
| 1238 | 1295 | ||
| 1296 | + var allowEmptyAll = locationHasAllSentinel && partnerIds.Count > 0; | ||
| 1297 | + if (allowEmptyAll) | ||
| 1298 | + { | ||
| 1299 | + await LocationScopeBindingHelper.EnsurePartnerIdsExistAsync( | ||
| 1300 | + _dbContext.SqlSugarClient, partnerIds); | ||
| 1301 | + } | ||
| 1302 | + | ||
| 1239 | var merged = await LocationScopeBindingHelper.ResolveTeamMemberLocationIdsForSaveAsync( | 1303 | var merged = await LocationScopeBindingHelper.ResolveTeamMemberLocationIdsForSaveAsync( |
| 1240 | - _dbContext.SqlSugarClient, partnerIds, regionInputForResolve, locationInputForResolve); | 1304 | + _dbContext.SqlSugarClient, |
| 1305 | + partnerIds, | ||
| 1306 | + regionInputForResolve, | ||
| 1307 | + locationInputForResolve, | ||
| 1308 | + allowEmptyAll); | ||
| 1241 | 1309 | ||
| 1242 | - if (merged.Count == 0) | 1310 | + if (merged.Count == 0 && !allowEmptyAll) |
| 1243 | { | 1311 | { |
| 1244 | throw new UserFriendlyException( | 1312 | throw new UserFriendlyException( |
| 1245 | isCompanyAdmin | 1313 | isCompanyAdmin |
| 1246 | - ? "Company Admin 必须选择 Company,或指定 Region / 门店" | ||
| 1247 | - : "成员必须至少分配一个门店(公司/区域/门店至少选一项)"); | 1314 | + ? "Company Admin must select a Company, or specify Region / location(s)." |
| 1315 | + : "Each member must be assigned at least one location (select company, region, and/or location)."); | ||
| 1248 | } | 1316 | } |
| 1249 | 1317 | ||
| 1250 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged); | 1318 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged); |
| @@ -1290,7 +1358,10 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1290,7 +1358,10 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1290 | { | 1358 | { |
| 1291 | AppliedRegionType = appliedRegionType, | 1359 | AppliedRegionType = appliedRegionType, |
| 1292 | AppliedLocationType = appliedLocationType, | 1360 | AppliedLocationType = appliedLocationType, |
| 1293 | - LocationIds = merged | 1361 | + LocationIds = merged, |
| 1362 | + PartnerIds = AllScopeBindingHelper.IsDeclaredAll(appliedLocationType) | ||
| 1363 | + ? partnerIds | ||
| 1364 | + : new List<string>() | ||
| 1294 | }; | 1365 | }; |
| 1295 | } | 1366 | } |
| 1296 | 1367 | ||
| @@ -1306,17 +1377,22 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1306,17 +1377,22 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1306 | return new TeamMemberScopeDimension | 1377 | return new TeamMemberScopeDimension |
| 1307 | { | 1378 | { |
| 1308 | AppliedRegionType = row.AppliedRegionType, | 1379 | AppliedRegionType = row.AppliedRegionType, |
| 1309 | - AppliedLocationType = row.AppliedLocationType | 1380 | + AppliedLocationType = row.AppliedLocationType, |
| 1381 | + PartnerIds = LocationScopeBindingHelper.SplitPartnerIds(row.PartnerIds) | ||
| 1310 | }; | 1382 | }; |
| 1311 | } | 1383 | } |
| 1312 | 1384 | ||
| 1313 | private async Task UpsertTeamMemberScopeAsync( | 1385 | private async Task UpsertTeamMemberScopeAsync( |
| 1314 | Guid userId, | 1386 | Guid userId, |
| 1315 | string appliedRegionType, | 1387 | string appliedRegionType, |
| 1316 | - string appliedLocationType) | 1388 | + string appliedLocationType, |
| 1389 | + IReadOnlyList<string>? partnerIds) | ||
| 1317 | { | 1390 | { |
| 1318 | var userIdString = userId.ToString(); | 1391 | var userIdString = userId.ToString(); |
| 1319 | var now = DateTime.Now; | 1392 | var now = DateTime.Now; |
| 1393 | + var storedPartnerIds = AllScopeBindingHelper.IsDeclaredAll(appliedLocationType) | ||
| 1394 | + ? LocationScopeBindingHelper.JoinPartnerIds(partnerIds) | ||
| 1395 | + : null; | ||
| 1320 | var existing = await _dbContext.SqlSugarClient.Queryable<FlTeamMemberScopeDbEntity>() | 1396 | var existing = await _dbContext.SqlSugarClient.Queryable<FlTeamMemberScopeDbEntity>() |
| 1321 | .FirstAsync(x => x.UserId == userIdString); | 1397 | .FirstAsync(x => x.UserId == userIdString); |
| 1322 | if (existing is null) | 1398 | if (existing is null) |
| @@ -1326,6 +1402,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1326,6 +1402,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1326 | UserId = userIdString, | 1402 | UserId = userIdString, |
| 1327 | AppliedRegionType = appliedRegionType, | 1403 | AppliedRegionType = appliedRegionType, |
| 1328 | AppliedLocationType = appliedLocationType, | 1404 | AppliedLocationType = appliedLocationType, |
| 1405 | + PartnerIds = storedPartnerIds, | ||
| 1329 | CreationTime = now, | 1406 | CreationTime = now, |
| 1330 | LastModificationTime = now | 1407 | LastModificationTime = now |
| 1331 | }).ExecuteCommandAsync(); | 1408 | }).ExecuteCommandAsync(); |
| @@ -1334,6 +1411,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1334,6 +1411,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1334 | 1411 | ||
| 1335 | existing.AppliedRegionType = appliedRegionType; | 1412 | existing.AppliedRegionType = appliedRegionType; |
| 1336 | existing.AppliedLocationType = appliedLocationType; | 1413 | existing.AppliedLocationType = appliedLocationType; |
| 1414 | + existing.PartnerIds = storedPartnerIds; | ||
| 1337 | existing.LastModificationTime = now; | 1415 | existing.LastModificationTime = now; |
| 1338 | await _dbContext.SqlSugarClient.Updateable(existing).ExecuteCommandAsync(); | 1416 | await _dbContext.SqlSugarClient.Updateable(existing).ExecuteCommandAsync(); |
| 1339 | } | 1417 | } |
| @@ -1356,7 +1434,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1356,7 +1434,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1356 | result[TeamMemberListScopeHelper.NormalizeScopeKey(row.UserId)] = new TeamMemberScopeDimension | 1434 | result[TeamMemberListScopeHelper.NormalizeScopeKey(row.UserId)] = new TeamMemberScopeDimension |
| 1357 | { | 1435 | { |
| 1358 | AppliedRegionType = row.AppliedRegionType, | 1436 | AppliedRegionType = row.AppliedRegionType, |
| 1359 | - AppliedLocationType = row.AppliedLocationType | 1437 | + AppliedLocationType = row.AppliedLocationType, |
| 1438 | + PartnerIds = LocationScopeBindingHelper.SplitPartnerIds(row.PartnerIds) | ||
| 1360 | }; | 1439 | }; |
| 1361 | } | 1440 | } |
| 1362 | 1441 | ||
| @@ -1429,7 +1508,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1429,7 +1508,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1429 | .CountAsync(); | 1508 | .CountAsync(); |
| 1430 | if (validCount != wanted.Count) | 1509 | if (validCount != wanted.Count) |
| 1431 | { | 1510 | { |
| 1432 | - throw new UserFriendlyException("存在无效门店,请刷新后重试"); | 1511 | + throw new UserFriendlyException("Invalid location(s). Refresh and try again."); |
| 1433 | } | 1512 | } |
| 1434 | 1513 | ||
| 1435 | // 含已逻辑删除行:唯一键 UK_userlocation_user_location 覆盖全历史,不能对已删行再 INSERT | 1514 | // 含已逻辑删除行:唯一键 UK_userlocation_user_location 覆盖全历史,不能对已删行再 INSERT |
| @@ -1505,4 +1584,58 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1505,4 +1584,58 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1505 | await _dbContext.SqlSugarClient.Insertable(toInsert).ExecuteCommandAsync(); | 1584 | await _dbContext.SqlSugarClient.Insertable(toInsert).ExecuteCommandAsync(); |
| 1506 | } | 1585 | } |
| 1507 | } | 1586 | } |
| 1587 | + | ||
| 1588 | + /// <summary> | ||
| 1589 | + /// 一人多角色时优先「管理员」(admin),避免开通账号被显示成公司管理员。 | ||
| 1590 | + /// </summary> | ||
| 1591 | + private async Task<UserRoleEntity?> LoadPreferredUserRoleAsync(Guid userId) | ||
| 1592 | + { | ||
| 1593 | + var rows = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity, RoleAggregateRoot>((ur, r) => ur.RoleId == r.Id) | ||
| 1594 | + .Where((ur, r) => ur.UserId == userId && !r.IsDeleted) | ||
| 1595 | + .Select((ur, r) => new UserRolePickRow | ||
| 1596 | + { | ||
| 1597 | + UserId = ur.UserId, | ||
| 1598 | + Id = r.Id, | ||
| 1599 | + RoleCode = r.RoleCode, | ||
| 1600 | + RoleName = r.RoleName, | ||
| 1601 | + OrderNum = r.OrderNum | ||
| 1602 | + }) | ||
| 1603 | + .ToListAsync(); | ||
| 1604 | + var preferred = PickPreferredRole(rows); | ||
| 1605 | + if (preferred is null) | ||
| 1606 | + { | ||
| 1607 | + return null; | ||
| 1608 | + } | ||
| 1609 | + | ||
| 1610 | + return new UserRoleEntity | ||
| 1611 | + { | ||
| 1612 | + UserId = userId, | ||
| 1613 | + RoleId = preferred.Id | ||
| 1614 | + }; | ||
| 1615 | + } | ||
| 1616 | + | ||
| 1617 | + private static UserRolePickRow? PickPreferredRole(IEnumerable<UserRolePickRow> rows) | ||
| 1618 | + { | ||
| 1619 | + var list = rows.ToList(); | ||
| 1620 | + if (list.Count == 0) | ||
| 1621 | + { | ||
| 1622 | + return null; | ||
| 1623 | + } | ||
| 1624 | + | ||
| 1625 | + return list | ||
| 1626 | + .OrderByDescending(x => | ||
| 1627 | + string.Equals(x.RoleCode, UserConst.AdminRolesCode, StringComparison.OrdinalIgnoreCase) | ||
| 1628 | + || string.Equals(x.RoleName, "管理员", StringComparison.Ordinal)) | ||
| 1629 | + .ThenByDescending(x => x.OrderNum) | ||
| 1630 | + .First(); | ||
| 1631 | + } | ||
| 1632 | + | ||
| 1633 | + private sealed class UserRolePickRow | ||
| 1634 | + { | ||
| 1635 | + public Guid UserId { get; set; } | ||
| 1636 | + public Guid Id { get; set; } | ||
| 1637 | + public string? RoleCode { get; set; } | ||
| 1638 | + public string? RoleName { get; set; } | ||
| 1639 | + public int OrderNum { get; set; } | ||
| 1640 | + } | ||
| 1508 | } | 1641 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TrainingAppService.cs
| @@ -254,7 +254,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -254,7 +254,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 254 | var name = input.CategoryName?.Trim(); | 254 | var name = input.CategoryName?.Trim(); |
| 255 | if (string.IsNullOrWhiteSpace(name)) | 255 | if (string.IsNullOrWhiteSpace(name)) |
| 256 | { | 256 | { |
| 257 | - throw new UserFriendlyException("分类名称不能为空"); | 257 | + throw new UserFriendlyException("Category name is required."); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | var parentId = string.IsNullOrWhiteSpace(input.ParentId) ? null : input.ParentId.Trim(); | 260 | var parentId = string.IsNullOrWhiteSpace(input.ParentId) ? null : input.ParentId.Trim(); |
| @@ -264,12 +264,12 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -264,12 +264,12 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 264 | .FirstAsync(x => x.Id == parentId && !x.IsDeleted); | 264 | .FirstAsync(x => x.Id == parentId && !x.IsDeleted); |
| 265 | if (parent is null) | 265 | if (parent is null) |
| 266 | { | 266 | { |
| 267 | - throw new UserFriendlyException("父级分类不存在"); | 267 | + throw new UserFriendlyException("Parent category not found."); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | if (!string.IsNullOrWhiteSpace(parent.ParentId)) | 270 | if (!string.IsNullOrWhiteSpace(parent.ParentId)) |
| 271 | { | 271 | { |
| 272 | - throw new UserFriendlyException("仅支持两级分类,不能在二级分类下再建子级"); | 272 | + throw new UserFriendlyException("Only two category levels are supported; cannot add children under a level-2 category."); |
| 273 | } | 273 | } |
| 274 | } | 274 | } |
| 275 | 275 | ||
| @@ -277,7 +277,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -277,7 +277,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 277 | .AnyAsync(x => !x.IsDeleted && x.CategoryName == name && x.ParentId == parentId); | 277 | .AnyAsync(x => !x.IsDeleted && x.CategoryName == name && x.ParentId == parentId); |
| 278 | if (duplicated) | 278 | if (duplicated) |
| 279 | { | 279 | { |
| 280 | - throw new UserFriendlyException("同级分类名称已存在"); | 280 | + throw new UserFriendlyException("A sibling category with this name already exists."); |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | var now = DateTime.Now; | 283 | var now = DateTime.Now; |
| @@ -316,7 +316,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -316,7 +316,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 316 | /// <param name="input">分类信息</param> | 316 | /// <param name="input">分类信息</param> |
| 317 | /// <returns>更新后的分类</returns> | 317 | /// <returns>更新后的分类</returns> |
| 318 | /// <response code="200">更新成功</response> | 318 | /// <response code="200">更新成功</response> |
| 319 | - /// <response code="400">分类不存在或名称重复</response> | 319 | + /// <response code="400">Category not found.或名称重复</response> |
| 320 | /// <response code="500">服务器错误</response> | 320 | /// <response code="500">服务器错误</response> |
| 321 | public async Task<TrainingCategoryGetOutputDto> UpdateCategoryAsync(string id, TrainingCategoryUpdateInputVo input) | 321 | public async Task<TrainingCategoryGetOutputDto> UpdateCategoryAsync(string id, TrainingCategoryUpdateInputVo input) |
| 322 | { | 322 | { |
| @@ -324,14 +324,14 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -324,14 +324,14 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 324 | var name = input.CategoryName?.Trim(); | 324 | var name = input.CategoryName?.Trim(); |
| 325 | if (string.IsNullOrWhiteSpace(name)) | 325 | if (string.IsNullOrWhiteSpace(name)) |
| 326 | { | 326 | { |
| 327 | - throw new UserFriendlyException("分类名称不能为空"); | 327 | + throw new UserFriendlyException("Category name is required."); |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | var duplicated = await _dbContext.SqlSugarClient.Queryable<FlTrainingCategoryDbEntity>() | 330 | var duplicated = await _dbContext.SqlSugarClient.Queryable<FlTrainingCategoryDbEntity>() |
| 331 | .AnyAsync(x => !x.IsDeleted && x.Id != id && x.CategoryName == name && x.ParentId == entity.ParentId); | 331 | .AnyAsync(x => !x.IsDeleted && x.Id != id && x.CategoryName == name && x.ParentId == entity.ParentId); |
| 332 | if (duplicated) | 332 | if (duplicated) |
| 333 | { | 333 | { |
| 334 | - throw new UserFriendlyException("同级分类名称已存在"); | 334 | + throw new UserFriendlyException("A sibling category with this name already exists."); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | entity.CategoryName = name; | 337 | entity.CategoryName = name; |
| @@ -363,7 +363,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -363,7 +363,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 363 | .AnyAsync(x => !x.IsDeleted && x.ParentId == id); | 363 | .AnyAsync(x => !x.IsDeleted && x.ParentId == id); |
| 364 | if (hasChild) | 364 | if (hasChild) |
| 365 | { | 365 | { |
| 366 | - throw new UserFriendlyException("该一级分类下存在二级分类,无法删除"); | 366 | + throw new UserFriendlyException("This level-1 category has level-2 children and cannot be deleted."); |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | else | 369 | else |
| @@ -372,7 +372,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -372,7 +372,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 372 | .AnyAsync(x => !x.IsDeleted && x.CategoryId == id); | 372 | .AnyAsync(x => !x.IsDeleted && x.CategoryId == id); |
| 373 | if (hasFile) | 373 | if (hasFile) |
| 374 | { | 374 | { |
| 375 | - throw new UserFriendlyException("该二级分类下存在培训文件,无法删除"); | 375 | + throw new UserFriendlyException("This level-2 category has training files and cannot be deleted."); |
| 376 | } | 376 | } |
| 377 | } | 377 | } |
| 378 | 378 | ||
| @@ -412,30 +412,30 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -412,30 +412,30 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 412 | { | 412 | { |
| 413 | if (input.File is null || input.File.Length <= 0) | 413 | if (input.File is null || input.File.Length <= 0) |
| 414 | { | 414 | { |
| 415 | - throw new UserFriendlyException("请选择要上传的文件"); | 415 | + throw new UserFriendlyException("Select a file to upload."); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | if (input.File.Length > MaxFileSizeBytes) | 418 | if (input.File.Length > MaxFileSizeBytes) |
| 419 | { | 419 | { |
| 420 | - throw new UserFriendlyException("文件大小不能超过20MB"); | 420 | + throw new UserFriendlyException("File size cannot exceed 20 MB."); |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | var categoryId = input.CategoryId?.Trim(); | 423 | var categoryId = input.CategoryId?.Trim(); |
| 424 | if (string.IsNullOrWhiteSpace(categoryId)) | 424 | if (string.IsNullOrWhiteSpace(categoryId)) |
| 425 | { | 425 | { |
| 426 | - throw new UserFriendlyException("二级分类Id不能为空"); | 426 | + throw new UserFriendlyException("Level-2 category Id is required."); |
| 427 | } | 427 | } |
| 428 | 428 | ||
| 429 | var category = await GetCategoryOrThrowAsync(categoryId); | 429 | var category = await GetCategoryOrThrowAsync(categoryId); |
| 430 | if (string.IsNullOrWhiteSpace(category.ParentId)) | 430 | if (string.IsNullOrWhiteSpace(category.ParentId)) |
| 431 | { | 431 | { |
| 432 | - throw new UserFriendlyException("文件只能上传到二级分类"); | 432 | + throw new UserFriendlyException("Files can only be uploaded to level-2 categories."); |
| 433 | } | 433 | } |
| 434 | 434 | ||
| 435 | var ext = Path.GetExtension(input.File.FileName ?? string.Empty); | 435 | var ext = Path.GetExtension(input.File.FileName ?? string.Empty); |
| 436 | if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext)) | 436 | if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext)) |
| 437 | { | 437 | { |
| 438 | - throw new UserFriendlyException("不支持的文件格式"); | 438 | + throw new UserFriendlyException("Unsupported file format."); |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | var saveRoot = ResolveTrainingRoot(); | 441 | var saveRoot = ResolveTrainingRoot(); |
| @@ -541,7 +541,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -541,7 +541,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 541 | var fileName = input.FileName?.Trim(); | 541 | var fileName = input.FileName?.Trim(); |
| 542 | if (string.IsNullOrWhiteSpace(fileName)) | 542 | if (string.IsNullOrWhiteSpace(fileName)) |
| 543 | { | 543 | { |
| 544 | - throw new UserFriendlyException("文件名称不能为空"); | 544 | + throw new UserFriendlyException("File name is required."); |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | entity.FileName = fileName; | 547 | entity.FileName = fileName; |
| @@ -741,7 +741,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -741,7 +741,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 741 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 741 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 742 | if (entity is null) | 742 | if (entity is null) |
| 743 | { | 743 | { |
| 744 | - throw new UserFriendlyException("培训文件不存在"); | 744 | + throw new UserFriendlyException("Training file not found."); |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | return entity; | 747 | return entity; |
| @@ -753,7 +753,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | @@ -753,7 +753,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService | ||
| 753 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 753 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 754 | if (entity is null) | 754 | if (entity is null) |
| 755 | { | 755 | { |
| 756 | - throw new UserFriendlyException("分类不存在"); | 756 | + throw new UserFriendlyException("Category not found."); |
| 757 | } | 757 | } |
| 758 | 758 | ||
| 759 | return entity; | 759 | return entity; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppAuthAppService.cs
| @@ -93,7 +93,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -93,7 +93,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 93 | /// <param name="input">邮箱、密码;若系统开启验证码则需传 Uuid、Code</param> | 93 | /// <param name="input">邮箱、密码;若系统开启验证码则需传 Uuid、Code</param> |
| 94 | /// <returns>Token、RefreshToken 与绑定门店</returns> | 94 | /// <returns>Token、RefreshToken 与绑定门店</returns> |
| 95 | /// <response code="200">登录成功</response> | 95 | /// <response code="200">登录成功</response> |
| 96 | - /// <response code="400">参数或验证码错误</response> | 96 | + /// <response code="400">参数或Verification code is incorrect.</response> |
| 97 | /// <response code="500">服务器错误</response> | 97 | /// <response code="500">服务器错误</response> |
| 98 | [AllowAnonymous] | 98 | [AllowAnonymous] |
| 99 | public virtual async Task<UsAppLoginOutputDto> LoginAsync(UsAppLoginInputVo input) | 99 | public virtual async Task<UsAppLoginOutputDto> LoginAsync(UsAppLoginInputVo input) |
| @@ -101,7 +101,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -101,7 +101,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 101 | // 泰额 SaaS:由 ThUsAppAuthAppService 覆盖本方法,按邮箱反查租户后登录;此处仅单库模式。 | 101 | // 泰额 SaaS:由 ThUsAppAuthAppService 覆盖本方法,按邮箱反查租户后登录;此处仅单库模式。 |
| 102 | if (string.IsNullOrWhiteSpace(input.Password) || string.IsNullOrWhiteSpace(input.Email)) | 102 | if (string.IsNullOrWhiteSpace(input.Password) || string.IsNullOrWhiteSpace(input.Email)) |
| 103 | { | 103 | { |
| 104 | - throw new UserFriendlyException("请输入合理数据!"); | 104 | + throw new UserFriendlyException("Invalid input data."); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | ValidationImageCaptcha(input.Uuid, input.Code); | 107 | ValidationImageCaptcha(input.Uuid, input.Code); |
| @@ -109,7 +109,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -109,7 +109,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 109 | var user = await FindActiveUserByEmailAsync(input.Email.Trim()); | 109 | var user = await FindActiveUserByEmailAsync(input.Email.Trim()); |
| 110 | if (user is null) | 110 | if (user is null) |
| 111 | { | 111 | { |
| 112 | - throw new UserFriendlyException("登录失败!邮箱不存在!"); | 112 | + throw new UserFriendlyException("Sign-in failed: email does not exist."); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | if (!UserPasswordHelper.VerifyPlainPassword(user, input.Password)) | 115 | if (!UserPasswordHelper.VerifyPlainPassword(user, input.Password)) |
| @@ -161,7 +161,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -161,7 +161,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 161 | { | 161 | { |
| 162 | if (!CurrentUser.Id.HasValue) | 162 | if (!CurrentUser.Id.HasValue) |
| 163 | { | 163 | { |
| 164 | - throw new UserFriendlyException("用户未登录"); | 164 | + throw new UserFriendlyException("You are not signed in."); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | var list = await LoadBoundLocationsAsync(CurrentUser.Id.Value); | 167 | var list = await LoadBoundLocationsAsync(CurrentUser.Id.Value); |
| @@ -220,7 +220,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -220,7 +220,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 220 | await UsAppAuthScopeHelper.EnsureAppScopeCallerAsync(_dbContext.SqlSugarClient, CurrentUser); | 220 | await UsAppAuthScopeHelper.EnsureAppScopeCallerAsync(_dbContext.SqlSugarClient, CurrentUser); |
| 221 | if (!CurrentUser.Id.HasValue) | 221 | if (!CurrentUser.Id.HasValue) |
| 222 | { | 222 | { |
| 223 | - throw new UserFriendlyException("用户未登录"); | 223 | + throw new UserFriendlyException("You are not signed in."); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | return await UsAppAuthScopeHelper.SelectLocationAsync( | 226 | return await UsAppAuthScopeHelper.SelectLocationAsync( |
| @@ -240,7 +240,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -240,7 +240,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 240 | /// 查询单个门店详情(Location 页):地址、门店电话、经营时间、店长(角色含 manager 的绑定用户) | 240 | /// 查询单个门店详情(Location 页):地址、门店电话、经营时间、店长(角色含 manager 的绑定用户) |
| 241 | /// </summary> | 241 | /// </summary> |
| 242 | /// <remarks> | 242 | /// <remarks> |
| 243 | - /// 仅当当前登录用户在 <c>userlocation</c> 中绑定该 <c>locationId</c> 时可查;否则返回业务异常。 | 243 | + /// 仅当当前登录用户在 <c>userlocation</c> 中绑定该 <c>locationId</c> 时可查;否则返回Business error.。 |
| 244 | /// | 244 | /// |
| 245 | /// 店长:在同店绑定用户中,取 <c>Role.RoleCode</c> 或 <c>Role.RoleName</c>(忽略大小写)包含 <c>manager</c> 的第一条; | 245 | /// 店长:在同店绑定用户中,取 <c>Role.RoleCode</c> 或 <c>Role.RoleName</c>(忽略大小写)包含 <c>manager</c> 的第一条; |
| 246 | /// 若无匹配则店长姓名与电话均为「无」。 | 246 | /// 若无匹配则店长姓名与电话均为「无」。 |
| @@ -250,20 +250,20 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -250,20 +250,20 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 250 | /// <param name="locationId">门店主键(Guid 字符串)</param> | 250 | /// <param name="locationId">门店主键(Guid 字符串)</param> |
| 251 | /// <returns>与原型一致的展示字段</returns> | 251 | /// <returns>与原型一致的展示字段</returns> |
| 252 | /// <response code="200">成功</response> | 252 | /// <response code="200">成功</response> |
| 253 | - /// <response code="400">未登录、门店标识无效、未绑定或门店不存在</response> | 253 | + /// <response code="400">You are not signed in.、门店标识无效、未绑定或Location not found.</response> |
| 254 | /// <response code="500">服务器错误</response> | 254 | /// <response code="500">服务器错误</response> |
| 255 | [Authorize] | 255 | [Authorize] |
| 256 | public virtual async Task<UsAppLocationDetailOutputDto> GetLocationDetailAsync(string locationId) | 256 | public virtual async Task<UsAppLocationDetailOutputDto> GetLocationDetailAsync(string locationId) |
| 257 | { | 257 | { |
| 258 | if (!CurrentUser.Id.HasValue) | 258 | if (!CurrentUser.Id.HasValue) |
| 259 | { | 259 | { |
| 260 | - throw new UserFriendlyException("用户未登录"); | 260 | + throw new UserFriendlyException("You are not signed in."); |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | var lid = (locationId ?? string.Empty).Trim(); | 263 | var lid = (locationId ?? string.Empty).Trim(); |
| 264 | if (string.IsNullOrEmpty(lid) || !Guid.TryParse(lid, out var locationGuid)) | 264 | if (string.IsNullOrEmpty(lid) || !Guid.TryParse(lid, out var locationGuid)) |
| 265 | { | 265 | { |
| 266 | - throw new UserFriendlyException("无效的门店标识"); | 266 | + throw new UserFriendlyException("Invalid location identifier."); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 269 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
| @@ -277,7 +277,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -277,7 +277,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 277 | var loc = locRows.FirstOrDefault(); | 277 | var loc = locRows.FirstOrDefault(); |
| 278 | if (loc is null) | 278 | if (loc is null) |
| 279 | { | 279 | { |
| 280 | - throw new UserFriendlyException("门店不存在或已删除"); | 280 | + throw new UserFriendlyException("Location not found or removed."); |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | var (mgrName, mgrPhone) = await TryResolveStoreManagerAsync(lid); | 283 | var (mgrName, mgrPhone) = await TryResolveStoreManagerAsync(lid); |
| @@ -300,14 +300,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -300,14 +300,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 300 | { | 300 | { |
| 301 | if (!CurrentUser.Id.HasValue) | 301 | if (!CurrentUser.Id.HasValue) |
| 302 | { | 302 | { |
| 303 | - throw new UserFriendlyException("用户未登录"); | 303 | + throw new UserFriendlyException("You are not signed in."); |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | var userId = CurrentUser.Id.Value; | 306 | var userId = CurrentUser.Id.Value; |
| 307 | var user = await _userRepository.GetByIdAsync(userId); | 307 | var user = await _userRepository.GetByIdAsync(userId); |
| 308 | if (user is null || user.IsDeleted || !user.State) | 308 | if (user is null || user.IsDeleted || !user.State) |
| 309 | { | 309 | { |
| 310 | - throw new UserFriendlyException("用户不存在或已停用"); | 310 | + throw new UserFriendlyException("User not found or disabled."); |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | // 避免 SqlSugar 在该环境下对 Role 关联表达式解析异常(Select 不支持),这里改用显式 SQL 查询角色。 | 313 | // 避免 SqlSugar 在该环境下对 Role 关联表达式解析异常(Select 不支持),这里改用显式 SQL 查询角色。 |
| @@ -345,12 +345,12 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -345,12 +345,12 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 345 | { | 345 | { |
| 346 | if (input is null) | 346 | if (input is null) |
| 347 | { | 347 | { |
| 348 | - throw new UserFriendlyException("入参不能为空"); | 348 | + throw new UserFriendlyException("Request body is required."); |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | if (!CurrentUser.Id.HasValue) | 351 | if (!CurrentUser.Id.HasValue) |
| 352 | { | 352 | { |
| 353 | - throw new UserFriendlyException("用户未登录"); | 353 | + throw new UserFriendlyException("You are not signed in."); |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | var current = input.CurrentPassword ?? string.Empty; | 356 | var current = input.CurrentPassword ?? string.Empty; |
| @@ -359,17 +359,17 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -359,17 +359,17 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 359 | 359 | ||
| 360 | if (string.IsNullOrWhiteSpace(current) || string.IsNullOrWhiteSpace(newPwd) || string.IsNullOrWhiteSpace(confirm)) | 360 | if (string.IsNullOrWhiteSpace(current) || string.IsNullOrWhiteSpace(newPwd) || string.IsNullOrWhiteSpace(confirm)) |
| 361 | { | 361 | { |
| 362 | - throw new UserFriendlyException("请填写当前密码、新密码与确认密码"); | 362 | + throw new UserFriendlyException("Current password, new password, and confirmation are required."); |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | if (!string.Equals(newPwd, confirm, StringComparison.Ordinal)) | 365 | if (!string.Equals(newPwd, confirm, StringComparison.Ordinal)) |
| 366 | { | 366 | { |
| 367 | - throw new UserFriendlyException("新密码与确认密码不一致"); | 367 | + throw new UserFriendlyException("New password and confirmation do not match."); |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | if (string.Equals(current, newPwd, StringComparison.Ordinal)) | 370 | if (string.Equals(current, newPwd, StringComparison.Ordinal)) |
| 371 | { | 371 | { |
| 372 | - throw new UserFriendlyException("新密码不能与当前密码相同"); | 372 | + throw new UserFriendlyException("New password must differ from the current password."); |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | ValidateAppPasswordComplexity(newPwd); | 375 | ValidateAppPasswordComplexity(newPwd); |
| @@ -378,7 +378,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -378,7 +378,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 378 | var user = await _userRepository.GetByIdAsync(userId); | 378 | var user = await _userRepository.GetByIdAsync(userId); |
| 379 | if (user is null || user.IsDeleted || !user.State) | 379 | if (user is null || user.IsDeleted || !user.State) |
| 380 | { | 380 | { |
| 381 | - throw new UserFriendlyException("用户不存在或已停用"); | 381 | + throw new UserFriendlyException("User not found or disabled."); |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | if (!user.JudgePassword(current)) | 384 | if (!user.JudgePassword(current)) |
| @@ -470,27 +470,27 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -470,27 +470,27 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 470 | { | 470 | { |
| 471 | if (password.Length < 8) | 471 | if (password.Length < 8) |
| 472 | { | 472 | { |
| 473 | - throw new UserFriendlyException("新密码至少 8 位"); | 473 | + throw new UserFriendlyException("New password must be at least 8 characters."); |
| 474 | } | 474 | } |
| 475 | 475 | ||
| 476 | if (!password.Any(char.IsUpper)) | 476 | if (!password.Any(char.IsUpper)) |
| 477 | { | 477 | { |
| 478 | - throw new UserFriendlyException("新密码需包含大写字母"); | 478 | + throw new UserFriendlyException("New password must contain an uppercase letter."); |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | if (!password.Any(char.IsLower)) | 481 | if (!password.Any(char.IsLower)) |
| 482 | { | 482 | { |
| 483 | - throw new UserFriendlyException("新密码需包含小写字母"); | 483 | + throw new UserFriendlyException("New password must contain a lowercase letter."); |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | if (!password.Any(char.IsDigit)) | 486 | if (!password.Any(char.IsDigit)) |
| 487 | { | 487 | { |
| 488 | - throw new UserFriendlyException("新密码需包含至少一个数字"); | 488 | + throw new UserFriendlyException("New password must contain at least one digit."); |
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | if (!password.Any(c => !char.IsLetterOrDigit(c))) | 491 | if (!password.Any(c => !char.IsLetterOrDigit(c))) |
| 492 | { | 492 | { |
| 493 | - throw new UserFriendlyException("新密码需包含至少一个特殊字符"); | 493 | + throw new UserFriendlyException("New password must contain at least one special character."); |
| 494 | } | 494 | } |
| 495 | } | 495 | } |
| 496 | 496 | ||
| @@ -503,7 +503,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -503,7 +503,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 503 | 503 | ||
| 504 | if (!_captcha.Validate(uuid, code)) | 504 | if (!_captcha.Validate(uuid, code)) |
| 505 | { | 505 | { |
| 506 | - throw new UserFriendlyException("验证码错误"); | 506 | + throw new UserFriendlyException("Verification code is incorrect."); |
| 507 | } | 507 | } |
| 508 | } | 508 | } |
| 509 | 509 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs
| @@ -63,7 +63,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -63,7 +63,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 63 | { | 63 | { |
| 64 | if (string.IsNullOrWhiteSpace(input.LocationId)) | 64 | if (string.IsNullOrWhiteSpace(input.LocationId)) |
| 65 | { | 65 | { |
| 66 | - throw new UserFriendlyException("门店Id不能为空"); | 66 | + throw new UserFriendlyException("locationId is required."); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | var locationId = input.LocationId.Trim(); | 69 | var locationId = input.LocationId.Trim(); |
| @@ -348,19 +348,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -348,19 +348,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 348 | { | 348 | { |
| 349 | if (input is null) | 349 | if (input is null) |
| 350 | { | 350 | { |
| 351 | - throw new UserFriendlyException("入参不能为空"); | 351 | + throw new UserFriendlyException("Request body is required."); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | var locationId = input.LocationId?.Trim(); | 354 | var locationId = input.LocationId?.Trim(); |
| 355 | if (string.IsNullOrWhiteSpace(locationId)) | 355 | if (string.IsNullOrWhiteSpace(locationId)) |
| 356 | { | 356 | { |
| 357 | - throw new UserFriendlyException("门店Id不能为空"); | 357 | + throw new UserFriendlyException("locationId is required."); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | var labelCode = input.LabelCode?.Trim(); | 360 | var labelCode = input.LabelCode?.Trim(); |
| 361 | if (string.IsNullOrWhiteSpace(labelCode)) | 361 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 362 | { | 362 | { |
| 363 | - throw new UserFriendlyException("labelCode不能为空"); | 363 | + throw new UserFriendlyException("labelCode is required."); |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | var labelRow = await _dbContext.SqlSugarClient | 366 | var labelRow = await _dbContext.SqlSugarClient |
| @@ -393,7 +393,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -393,7 +393,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 393 | 393 | ||
| 394 | if (labelRow is null) | 394 | if (labelRow is null) |
| 395 | { | 395 | { |
| 396 | - throw new UserFriendlyException("标签不存在或不可用"); | 396 | + throw new UserFriendlyException("Label not found or unavailable."); |
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | var labelForScope = new FlLabelDbEntity | 399 | var labelForScope = new FlLabelDbEntity |
| @@ -406,7 +406,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -406,7 +406,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 406 | if (!await LabelRegionScopeHelper.LabelAppliesToLocationAsync( | 406 | if (!await LabelRegionScopeHelper.LabelAppliesToLocationAsync( |
| 407 | _dbContext.SqlSugarClient, labelForScope, locationId, storeGroupIds)) | 407 | _dbContext.SqlSugarClient, labelForScope, locationId, storeGroupIds)) |
| 408 | { | 408 | { |
| 409 | - throw new UserFriendlyException("该标签不属于当前门店"); | 409 | + throw new UserFriendlyException("This label does not belong to the current location."); |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | var previewProductId = await ResolvePreviewProductIdAsync(labelRow.Id, input.ProductId); | 412 | var previewProductId = await ResolvePreviewProductIdAsync(labelRow.Id, input.ProductId); |
| @@ -512,19 +512,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -512,19 +512,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 512 | { | 512 | { |
| 513 | if (input is null) | 513 | if (input is null) |
| 514 | { | 514 | { |
| 515 | - throw new UserFriendlyException("入参不能为空"); | 515 | + throw new UserFriendlyException("Request body is required."); |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | var locationId = input.LocationId?.Trim(); | 518 | var locationId = input.LocationId?.Trim(); |
| 519 | if (string.IsNullOrWhiteSpace(locationId)) | 519 | if (string.IsNullOrWhiteSpace(locationId)) |
| 520 | { | 520 | { |
| 521 | - throw new UserFriendlyException("门店Id不能为空"); | 521 | + throw new UserFriendlyException("locationId is required."); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | var labelCode = input.LabelCode?.Trim(); | 524 | var labelCode = input.LabelCode?.Trim(); |
| 525 | if (string.IsNullOrWhiteSpace(labelCode)) | 525 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 526 | { | 526 | { |
| 527 | - throw new UserFriendlyException("labelCode不能为空"); | 527 | + throw new UserFriendlyException("labelCode is required."); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; | 530 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; |
| @@ -576,7 +576,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -576,7 +576,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 576 | 576 | ||
| 577 | if (labelRow is null) | 577 | if (labelRow is null) |
| 578 | { | 578 | { |
| 579 | - throw new UserFriendlyException("标签不存在或不可用"); | 579 | + throw new UserFriendlyException("Label not found or unavailable."); |
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | await LabelRegionScopeHelper.EnsureLabelAppliesToLocationAsync( | 582 | await LabelRegionScopeHelper.EnsureLabelAppliesToLocationAsync( |
| @@ -719,19 +719,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -719,19 +719,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 719 | { | 719 | { |
| 720 | if (input is null) | 720 | if (input is null) |
| 721 | { | 721 | { |
| 722 | - throw new UserFriendlyException("入参不能为空"); | 722 | + throw new UserFriendlyException("Request body is required."); |
| 723 | } | 723 | } |
| 724 | 724 | ||
| 725 | var locationId = input.LocationId?.Trim(); | 725 | var locationId = input.LocationId?.Trim(); |
| 726 | if (string.IsNullOrWhiteSpace(locationId)) | 726 | if (string.IsNullOrWhiteSpace(locationId)) |
| 727 | { | 727 | { |
| 728 | - throw new UserFriendlyException("门店Id不能为空"); | 728 | + throw new UserFriendlyException("locationId is required."); |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | var taskId = input.TaskId?.Trim(); | 731 | var taskId = input.TaskId?.Trim(); |
| 732 | if (string.IsNullOrWhiteSpace(taskId)) | 732 | if (string.IsNullOrWhiteSpace(taskId)) |
| 733 | { | 733 | { |
| 734 | - throw new UserFriendlyException("taskId不能为空"); | 734 | + throw new UserFriendlyException("taskId is required."); |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; | 737 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; |
| @@ -765,20 +765,20 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -765,20 +765,20 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 765 | var currentUserId = CurrentUser?.Id?.ToString(); | 765 | var currentUserId = CurrentUser?.Id?.ToString(); |
| 766 | if (string.IsNullOrWhiteSpace(currentUserId)) | 766 | if (string.IsNullOrWhiteSpace(currentUserId)) |
| 767 | { | 767 | { |
| 768 | - throw new UserFriendlyException("未登录"); | 768 | + throw new UserFriendlyException("You are not signed in."); |
| 769 | } | 769 | } |
| 770 | 770 | ||
| 771 | var old = await _dbContext.SqlSugarClient.Queryable<FlLabelPrintTaskDbEntity>() | 771 | var old = await _dbContext.SqlSugarClient.Queryable<FlLabelPrintTaskDbEntity>() |
| 772 | .FirstAsync(x => x.Id == taskId); | 772 | .FirstAsync(x => x.Id == taskId); |
| 773 | if (old is null) | 773 | if (old is null) |
| 774 | { | 774 | { |
| 775 | - throw new UserFriendlyException("打印任务不存在"); | 775 | + throw new UserFriendlyException("Print task not found."); |
| 776 | } | 776 | } |
| 777 | 777 | ||
| 778 | // 已绑定该门店的账号可重打门店内任意历史任务(不限 CreatedBy) | 778 | // 已绑定该门店的账号可重打门店内任意历史任务(不限 CreatedBy) |
| 779 | if (!string.Equals(old.LocationId?.Trim(), locationId, StringComparison.OrdinalIgnoreCase)) | 779 | if (!string.Equals(old.LocationId?.Trim(), locationId, StringComparison.OrdinalIgnoreCase)) |
| 780 | { | 780 | { |
| 781 | - throw new UserFriendlyException("该任务不属于当前门店"); | 781 | + throw new UserFriendlyException("This task does not belong to the current location."); |
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | LabelTemplatePreviewDto? resolvedTemplate = null; | 784 | LabelTemplatePreviewDto? resolvedTemplate = null; |
| @@ -793,7 +793,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -793,7 +793,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 793 | 793 | ||
| 794 | if (resolvedTemplate is null) | 794 | if (resolvedTemplate is null) |
| 795 | { | 795 | { |
| 796 | - throw new UserFriendlyException("历史任务渲染快照解析失败,无法重打"); | 796 | + throw new UserFriendlyException("Failed to parse historical task render snapshot; reprint is unavailable."); |
| 797 | } | 797 | } |
| 798 | 798 | ||
| 799 | var now = DateTime.Now; | 799 | var now = DateTime.Now; |
| @@ -901,7 +901,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -901,7 +901,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 901 | /// <param name="input">分页查询入参</param> | 901 | /// <param name="input">分页查询入参</param> |
| 902 | /// <returns>分页打印日志</returns> | 902 | /// <returns>分页打印日志</returns> |
| 903 | /// <response code="200">成功</response> | 903 | /// <response code="200">成功</response> |
| 904 | - /// <response code="400">参数错误/未登录</response> | 904 | + /// <response code="400">参数错误/You are not signed in.</response> |
| 905 | /// <response code="500">服务器错误</response> | 905 | /// <response code="500">服务器错误</response> |
| 906 | [Authorize] | 906 | [Authorize] |
| 907 | [HttpPost] | 907 | [HttpPost] |
| @@ -909,18 +909,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -909,18 +909,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 909 | { | 909 | { |
| 910 | if (input is null) | 910 | if (input is null) |
| 911 | { | 911 | { |
| 912 | - throw new UserFriendlyException("入参不能为空"); | 912 | + throw new UserFriendlyException("Request body is required."); |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | if (!CurrentUser.Id.HasValue) | 915 | if (!CurrentUser.Id.HasValue) |
| 916 | { | 916 | { |
| 917 | - throw new UserFriendlyException("用户未登录"); | 917 | + throw new UserFriendlyException("You are not signed in."); |
| 918 | } | 918 | } |
| 919 | 919 | ||
| 920 | var locationId = input.LocationId?.Trim(); | 920 | var locationId = input.LocationId?.Trim(); |
| 921 | if (string.IsNullOrWhiteSpace(locationId)) | 921 | if (string.IsNullOrWhiteSpace(locationId)) |
| 922 | { | 922 | { |
| 923 | - throw new UserFriendlyException("门店Id不能为空"); | 923 | + throw new UserFriendlyException("locationId is required."); |
| 924 | } | 924 | } |
| 925 | 925 | ||
| 926 | var currentUserIdStr = CurrentUser.Id.Value.ToString(); | 926 | var currentUserIdStr = CurrentUser.Id.Value.ToString(); |
| @@ -1050,18 +1050,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -1050,18 +1050,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 1050 | { | 1050 | { |
| 1051 | if (input is null) | 1051 | if (input is null) |
| 1052 | { | 1052 | { |
| 1053 | - throw new UserFriendlyException("入参不能为空"); | 1053 | + throw new UserFriendlyException("Request body is required."); |
| 1054 | } | 1054 | } |
| 1055 | 1055 | ||
| 1056 | if (!CurrentUser.Id.HasValue) | 1056 | if (!CurrentUser.Id.HasValue) |
| 1057 | { | 1057 | { |
| 1058 | - throw new UserFriendlyException("用户未登录"); | 1058 | + throw new UserFriendlyException("You are not signed in."); |
| 1059 | } | 1059 | } |
| 1060 | 1060 | ||
| 1061 | var locationId = input.LocationId?.Trim(); | 1061 | var locationId = input.LocationId?.Trim(); |
| 1062 | if (string.IsNullOrWhiteSpace(locationId)) | 1062 | if (string.IsNullOrWhiteSpace(locationId)) |
| 1063 | { | 1063 | { |
| 1064 | - throw new UserFriendlyException("门店Id不能为空"); | 1064 | + throw new UserFriendlyException("locationId is required."); |
| 1065 | } | 1065 | } |
| 1066 | 1066 | ||
| 1067 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 1067 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppTrainingAppService.cs
| @@ -53,7 +53,7 @@ public class UsAppTrainingAppService : ApplicationService, IUsAppTrainingAppServ | @@ -53,7 +53,7 @@ public class UsAppTrainingAppService : ApplicationService, IUsAppTrainingAppServ | ||
| 53 | { | 53 | { |
| 54 | if (string.IsNullOrWhiteSpace(input.LocationId)) | 54 | if (string.IsNullOrWhiteSpace(input.LocationId)) |
| 55 | { | 55 | { |
| 56 | - throw new UserFriendlyException("门店Id不能为空"); | 56 | + throw new UserFriendlyException("locationId is required."); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | var locationId = input.LocationId.Trim(); | 59 | var locationId = input.LocationId.Trim(); |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer.sql
| @@ -35,3 +35,70 @@ CREATE TABLE IF NOT EXISTS `fl_label_alert_timer` ( | @@ -35,3 +35,70 @@ CREATE TABLE IF NOT EXISTS `fl_label_alert_timer` ( | ||
| 35 | KEY `idx_fl_label_alert_timer_expires` (`ExpiresAt`), | 35 | KEY `idx_fl_label_alert_timer_expires` (`ExpiresAt`), |
| 36 | KEY `idx_fl_label_alert_timer_printed` (`PrintedAt`) | 36 | KEY `idx_fl_label_alert_timer_printed` (`PrintedAt`) |
| 37 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='标签告警计时器'; | 37 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='标签告警计时器'; |
| 38 | + | ||
| 39 | +-- CodeFirst 可能先建成缺列旧表,CREATE IF NOT EXISTS 不会补列,必须幂等 ALTER | ||
| 40 | +SET @c := ( | ||
| 41 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 42 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'LocationName' | ||
| 43 | +); | ||
| 44 | +SET @ddl := IF( | ||
| 45 | + @c = 0, | ||
| 46 | + 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `LocationName` varchar(200) NULL DEFAULT NULL COMMENT ''门店名冗余'' AFTER `LocationId`', | ||
| 47 | + 'SELECT 1' | ||
| 48 | +); | ||
| 49 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; | ||
| 50 | + | ||
| 51 | +SET @c := ( | ||
| 52 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 53 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'AlertTemplateId' | ||
| 54 | +); | ||
| 55 | +SET @ddl := IF( | ||
| 56 | + @c = 0, | ||
| 57 | + 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `AlertTemplateId` varchar(36) NULL DEFAULT NULL COMMENT ''告警模板Id'' AFTER `Subtitle`', | ||
| 58 | + 'SELECT 1' | ||
| 59 | +); | ||
| 60 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; | ||
| 61 | + | ||
| 62 | +SET @c := ( | ||
| 63 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 64 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'AlertTemplateName' | ||
| 65 | +); | ||
| 66 | +SET @ddl := IF( | ||
| 67 | + @c = 0, | ||
| 68 | + 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `AlertTemplateName` varchar(200) NULL DEFAULT NULL COMMENT ''告警模板名称'' AFTER `AlertTemplateId`', | ||
| 69 | + 'SELECT 1' | ||
| 70 | +); | ||
| 71 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; | ||
| 72 | + | ||
| 73 | +SET @c := ( | ||
| 74 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 75 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'DateTimeFormat' | ||
| 76 | +); | ||
| 77 | +SET @ddl := IF( | ||
| 78 | + @c = 0, | ||
| 79 | + 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `DateTimeFormat` varchar(100) NULL DEFAULT NULL COMMENT ''过期时刻展示格式'' AFTER `AlertTemplateName`', | ||
| 80 | + 'SELECT 1' | ||
| 81 | +); | ||
| 82 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; | ||
| 83 | + | ||
| 84 | +SET @c := ( | ||
| 85 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 86 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'PrintedByUserId' | ||
| 87 | +); | ||
| 88 | +SET @ddl := IF( | ||
| 89 | + @c = 0, | ||
| 90 | + 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `PrintedByUserId` varchar(36) NULL DEFAULT NULL COMMENT ''打印人Id'' AFTER `DateTimeFormat`', | ||
| 91 | + 'SELECT 1' | ||
| 92 | +); | ||
| 93 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; | ||
| 94 | + | ||
| 95 | +SET @c := ( | ||
| 96 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 97 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'PrintedByUserName' | ||
| 98 | +); | ||
| 99 | +SET @ddl := IF( | ||
| 100 | + @c = 0, | ||
| 101 | + 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `PrintedByUserName` varchar(200) NULL DEFAULT NULL COMMENT ''打印人姓名'' AFTER `PrintedByUserId`', | ||
| 102 | + 'SELECT 1' | ||
| 103 | +); | ||
| 104 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_team_member_scope.sql
| @@ -7,7 +7,17 @@ CREATE TABLE IF NOT EXISTS `fl_team_member_scope` ( | @@ -7,7 +7,17 @@ CREATE TABLE IF NOT EXISTS `fl_team_member_scope` ( | ||
| 7 | `UserId` varchar(36) NOT NULL COMMENT '成员 User.Id', | 7 | `UserId` varchar(36) NOT NULL COMMENT '成员 User.Id', |
| 8 | `AppliedRegionType` varchar(20) NOT NULL DEFAULT 'SPECIFIED' COMMENT '适用Region:ALL/SPECIFIED', | 8 | `AppliedRegionType` varchar(20) NOT NULL DEFAULT 'SPECIFIED' COMMENT '适用Region:ALL/SPECIFIED', |
| 9 | `AppliedLocationType` varchar(20) NOT NULL DEFAULT 'SPECIFIED' COMMENT '适用Location:ALL/SPECIFIED', | 9 | `AppliedLocationType` varchar(20) NOT NULL DEFAULT 'SPECIFIED' COMMENT '适用Location:ALL/SPECIFIED', |
| 10 | + `PartnerIds` varchar(2000) NULL COMMENT 'Location=ALL 时绑定的 Company(fl_partner.Id,逗号分隔)', | ||
| 10 | `CreationTime` datetime NULL, | 11 | `CreationTime` datetime NULL, |
| 11 | `LastModificationTime` datetime NULL, | 12 | `LastModificationTime` datetime NULL, |
| 12 | PRIMARY KEY (`UserId`) | 13 | PRIMARY KEY (`UserId`) |
| 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Team Member 适用范围维度标记'; | 14 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Team Member 适用范围维度标记'; |
| 15 | + | ||
| 16 | +SET @c := ( | ||
| 17 | + SELECT COUNT(*) FROM information_schema.COLUMNS | ||
| 18 | + WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_team_member_scope' AND COLUMN_NAME = 'PartnerIds' | ||
| 19 | +); | ||
| 20 | +SET @ddl := IF(@c = 0, | ||
| 21 | + 'ALTER TABLE `fl_team_member_scope` ADD COLUMN `PartnerIds` varchar(2000) NULL COMMENT ''Location=ALL 时绑定的 Company(fl_partner.Id,逗号分隔)'' AFTER `AppliedLocationType`', | ||
| 22 | + 'SELECT 1'); | ||
| 23 | +PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/seed_platform_statistics_agents_host.sql
0 → 100644
| 1 | +-- 泰额 Host:平台统计 + 代理管理菜单 / 平台代理角色 / 代理扩展表 | ||
| 2 | +-- 仅在【主库 Host】执行,例如 antis-foodlabeling-test-host / antis-foodlabeling-host | ||
| 3 | +-- 禁止在租户业务库执行(平台菜单不会下发给公司;新建租户不需要本脚本) | ||
| 4 | +-- 可重复执行 | ||
| 5 | +-- | ||
| 6 | +-- 注意:文档草稿里的 f0010038 / f0010039 已占用为「支持」「API」, | ||
| 7 | +-- 本脚本改用 f0010040 / f0010041。 | ||
| 8 | + | ||
| 9 | +SET NAMES utf8mb4; | ||
| 10 | + | ||
| 11 | +-- 1) 菜单:平台统计 | ||
| 12 | +INSERT INTO `menu` ( | ||
| 13 | + `Id`, `IsDeleted`, `CreationTime`, `CreatorId`, `LastModifierId`, `LastModificationTime`, | ||
| 14 | + `OrderNum`, `State`, `MenuName`, `RouterName`, `MenuType`, `PermissionCode`, `ParentId`, | ||
| 15 | + `MenuIcon`, `Router`, `IsLink`, `IsCache`, `IsShow`, `Remark`, `Component`, `MenuSource`, | ||
| 16 | + `Query`, `ConcurrencyStamp` | ||
| 17 | +) | ||
| 18 | +SELECT | ||
| 19 | + 'f0010040-0001-4000-8000-000000000040', | ||
| 20 | + 0, NOW(), NULL, NULL, NULL, | ||
| 21 | + 8, 1, '平台统计', 'FoodLabelingPlatformStatistics', 1, 'menu.platform.statistics', | ||
| 22 | + 'f0010002-0001-4000-8000-000000000002', | ||
| 23 | + 'lucide:bar-chart-3', '/platform/statistics', 0, 0, 1, NULL, | ||
| 24 | + '/food-labeling/platform/statistics/index', 0, NULL, '' | ||
| 25 | +FROM DUAL | ||
| 26 | +WHERE NOT EXISTS ( | ||
| 27 | + SELECT 1 FROM `menu` WHERE `Id` = 'f0010040-0001-4000-8000-000000000040' | ||
| 28 | + OR `PermissionCode` = 'menu.platform.statistics' | ||
| 29 | +); | ||
| 30 | + | ||
| 31 | +-- 2) 菜单:代理管理 | ||
| 32 | +INSERT INTO `menu` ( | ||
| 33 | + `Id`, `IsDeleted`, `CreationTime`, `CreatorId`, `LastModifierId`, `LastModificationTime`, | ||
| 34 | + `OrderNum`, `State`, `MenuName`, `RouterName`, `MenuType`, `PermissionCode`, `ParentId`, | ||
| 35 | + `MenuIcon`, `Router`, `IsLink`, `IsCache`, `IsShow`, `Remark`, `Component`, `MenuSource`, | ||
| 36 | + `Query`, `ConcurrencyStamp` | ||
| 37 | +) | ||
| 38 | +SELECT | ||
| 39 | + 'f0010041-0001-4000-8000-000000000041', | ||
| 40 | + 0, NOW(), NULL, NULL, NULL, | ||
| 41 | + 9, 1, '代理管理', 'FoodLabelingPlatformAgents', 1, 'menu.platform.agents', | ||
| 42 | + 'f0010002-0001-4000-8000-000000000002', | ||
| 43 | + 'lucide:handshake', '/platform/agents', 0, 0, 1, NULL, | ||
| 44 | + '/food-labeling/platform/agents/index', 0, NULL, '' | ||
| 45 | +FROM DUAL | ||
| 46 | +WHERE NOT EXISTS ( | ||
| 47 | + SELECT 1 FROM `menu` WHERE `Id` = 'f0010041-0001-4000-8000-000000000041' | ||
| 48 | + OR `PermissionCode` = 'menu.platform.agents' | ||
| 49 | +); | ||
| 50 | + | ||
| 51 | +-- 3) 角色:平台代理 | ||
| 52 | +INSERT INTO `role` ( | ||
| 53 | + `Id`, `IsDeleted`, `CreationTime`, `CreatorId`, `LastModifierId`, `LastModificationTime`, | ||
| 54 | + `OrderNum`, `RoleName`, `RoleCode`, `Remark`, `DataScope`, `State`, | ||
| 55 | + `AccessPermissionCodes`, `ConcurrencyStamp` | ||
| 56 | +) | ||
| 57 | +SELECT | ||
| 58 | + 'f0020003-0001-4000-8000-000000000003', | ||
| 59 | + 0, NOW(), NULL, NULL, NULL, | ||
| 60 | + 998, '平台代理', 'platform-agent', '平台级代理:可创建公司并查看自建公司统计', 0, 1, | ||
| 61 | + NULL, '' | ||
| 62 | +FROM DUAL | ||
| 63 | +WHERE NOT EXISTS ( | ||
| 64 | + SELECT 1 FROM `role` WHERE `Id` = 'f0020003-0001-4000-8000-000000000003' | ||
| 65 | + OR `RoleCode` = 'platform-agent' | ||
| 66 | +); | ||
| 67 | + | ||
| 68 | +-- 4) admin 绑定新菜单(按 RoleCode,避免 Host 角色 Id 不一致) | ||
| 69 | +INSERT INTO `rolemenu` (`Id`, `RoleId`, `MenuId`) | ||
| 70 | +SELECT 'f0030043-0001-4000-8000-000000000043', r.`Id`, 'f0010040-0001-4000-8000-000000000040' | ||
| 71 | +FROM `role` r | ||
| 72 | +WHERE r.`RoleCode` = 'admin' AND r.`IsDeleted` = 0 | ||
| 73 | + AND NOT EXISTS ( | ||
| 74 | + SELECT 1 FROM `rolemenu` rm | ||
| 75 | + WHERE rm.`RoleId` = r.`Id` AND rm.`MenuId` = 'f0010040-0001-4000-8000-000000000040' | ||
| 76 | + ) | ||
| 77 | +LIMIT 1; | ||
| 78 | + | ||
| 79 | +INSERT INTO `rolemenu` (`Id`, `RoleId`, `MenuId`) | ||
| 80 | +SELECT 'f0030044-0001-4000-8000-000000000044', r.`Id`, 'f0010041-0001-4000-8000-000000000041' | ||
| 81 | +FROM `role` r | ||
| 82 | +WHERE r.`RoleCode` = 'admin' AND r.`IsDeleted` = 0 | ||
| 83 | + AND NOT EXISTS ( | ||
| 84 | + SELECT 1 FROM `rolemenu` rm | ||
| 85 | + WHERE rm.`RoleId` = r.`Id` AND rm.`MenuId` = 'f0010041-0001-4000-8000-000000000041' | ||
| 86 | + ) | ||
| 87 | +LIMIT 1; | ||
| 88 | + | ||
| 89 | +-- 5) 代理角色:平台管理 + SAAS公司 + 平台统计(不含代理管理) | ||
| 90 | +INSERT INTO `rolemenu` (`Id`, `RoleId`, `MenuId`) | ||
| 91 | +SELECT 'f0030045-0001-4000-8000-000000000045', r.`Id`, 'f0010002-0001-4000-8000-000000000002' | ||
| 92 | +FROM `role` r | ||
| 93 | +WHERE (r.`Id` = 'f0020003-0001-4000-8000-000000000003' OR r.`RoleCode` = 'platform-agent') | ||
| 94 | + AND r.`IsDeleted` = 0 | ||
| 95 | + AND NOT EXISTS ( | ||
| 96 | + SELECT 1 FROM `rolemenu` rm | ||
| 97 | + WHERE rm.`RoleId` = r.`Id` AND rm.`MenuId` = 'f0010002-0001-4000-8000-000000000002' | ||
| 98 | + ) | ||
| 99 | +LIMIT 1; | ||
| 100 | + | ||
| 101 | +INSERT INTO `rolemenu` (`Id`, `RoleId`, `MenuId`) | ||
| 102 | +SELECT 'f0030046-0001-4000-8000-000000000046', r.`Id`, 'f0010003-0001-4000-8000-000000000003' | ||
| 103 | +FROM `role` r | ||
| 104 | +WHERE (r.`Id` = 'f0020003-0001-4000-8000-000000000003' OR r.`RoleCode` = 'platform-agent') | ||
| 105 | + AND r.`IsDeleted` = 0 | ||
| 106 | + AND NOT EXISTS ( | ||
| 107 | + SELECT 1 FROM `rolemenu` rm | ||
| 108 | + WHERE rm.`RoleId` = r.`Id` AND rm.`MenuId` = 'f0010003-0001-4000-8000-000000000003' | ||
| 109 | + ) | ||
| 110 | +LIMIT 1; | ||
| 111 | + | ||
| 112 | +INSERT INTO `rolemenu` (`Id`, `RoleId`, `MenuId`) | ||
| 113 | +SELECT 'f0030047-0001-4000-8000-000000000047', r.`Id`, 'f0010040-0001-4000-8000-000000000040' | ||
| 114 | +FROM `role` r | ||
| 115 | +WHERE (r.`Id` = 'f0020003-0001-4000-8000-000000000003' OR r.`RoleCode` = 'platform-agent') | ||
| 116 | + AND r.`IsDeleted` = 0 | ||
| 117 | + AND NOT EXISTS ( | ||
| 118 | + SELECT 1 FROM `rolemenu` rm | ||
| 119 | + WHERE rm.`RoleId` = r.`Id` AND rm.`MenuId` = 'f0010040-0001-4000-8000-000000000040' | ||
| 120 | + ) | ||
| 121 | +LIMIT 1; | ||
| 122 | + | ||
| 123 | +-- 6) 代理扩展表(Host) | ||
| 124 | +CREATE TABLE IF NOT EXISTS `fl_th_platform_agent` ( | ||
| 125 | + `Id` varchar(36) NOT NULL COMMENT '主键,建议与 user.Id 相同', | ||
| 126 | + `UserId` varchar(36) NOT NULL COMMENT 'Host user.Id', | ||
| 127 | + `CompanyQuota` int NOT NULL DEFAULT 0 COMMENT '可创建公司上限', | ||
| 128 | + `Enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1启用 0停用', | ||
| 129 | + `Remark` varchar(255) NULL, | ||
| 130 | + `IsDeleted` tinyint(1) NOT NULL DEFAULT 0, | ||
| 131 | + `CreationTime` datetime NOT NULL, | ||
| 132 | + `CreatorId` varchar(36) NULL, | ||
| 133 | + `LastModificationTime` datetime NULL, | ||
| 134 | + `LastModifierId` varchar(36) NULL, | ||
| 135 | + `ConcurrencyStamp` varchar(255) NOT NULL DEFAULT '', | ||
| 136 | + PRIMARY KEY (`Id`), | ||
| 137 | + UNIQUE KEY `UK_fl_th_platform_agent_UserId` (`UserId`), | ||
| 138 | + KEY `IX_fl_th_platform_agent_Enabled` (`Enabled`) | ||
| 139 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='平台代理扩展(配额)'; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/MultiTenancy/ThCompanyListItemDto.cs
| @@ -25,4 +25,10 @@ public class ThCompanyListItemDto | @@ -25,4 +25,10 @@ public class ThCompanyListItemDto | ||
| 25 | 25 | ||
| 26 | /// <summary>已分配的 SaaS 菜单权限 Key 列表</summary> | 26 | /// <summary>已分配的 SaaS 菜单权限 Key 列表</summary> |
| 27 | public List<string> MenuPermissionKeys { get; set; } = new(); | 27 | public List<string> MenuPermissionKeys { get; set; } = new(); |
| 28 | + | ||
| 29 | + /// <summary>公司有效期截止;空表示永久有效</summary> | ||
| 30 | + public DateTime? ExpireTime { get; set; } | ||
| 31 | + | ||
| 32 | + /// <summary>当前是否已过期(超过有效期)</summary> | ||
| 33 | + public bool Expired { get; set; } | ||
| 28 | } | 34 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/MultiTenancy/ThProvisionTenantInputVo.cs
| @@ -42,6 +42,13 @@ public class ThProvisionTenantInputVo | @@ -42,6 +42,13 @@ public class ThProvisionTenantInputVo | ||
| 42 | public int DbType { get; set; } | 42 | public int DbType { get; set; } |
| 43 | 43 | ||
| 44 | /// <summary> | 44 | /// <summary> |
| 45 | + /// 公司有效期截止时间。空表示永久有效。 | ||
| 46 | + /// 仅传日期(时间为 00:00:00)时,当天 24:00 前仍可登录。 | ||
| 47 | + /// 超过后该公司主账号与子账号均无法登录、无法使用Business API。 | ||
| 48 | + /// </summary> | ||
| 49 | + public DateTime? ExpireTime { get; set; } | ||
| 50 | + | ||
| 51 | + /// <summary> | ||
| 45 | /// 创建后是否触发业务库 CodeFirst 初始化(建库 + 建表 + Seed)。 | 52 | /// 创建后是否触发业务库 CodeFirst 初始化(建库 + 建表 + Seed)。 |
| 46 | /// 为 true 时在后台异步执行,HTTP 立即返回;未完成前出参 DatabaseInitializing=true、DatabaseInitialized=false。 | 53 | /// 为 true 时在后台异步执行,HTTP 立即返回;未完成前出参 DatabaseInitializing=true、DatabaseInitialized=false。 |
| 47 | /// 同步补跑请调用 initialize-tenant-database 或 PUT tenant/init/{id}。 | 54 | /// 同步补跑请调用 initialize-tenant-database 或 PUT tenant/init/{id}。 |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/MultiTenancy/ThProvisionTenantOutputDto.cs
| @@ -18,4 +18,7 @@ public class ThProvisionTenantOutputDto | @@ -18,4 +18,7 @@ public class ThProvisionTenantOutputDto | ||
| 18 | 18 | ||
| 19 | /// <summary>业务库初始化是否已在后台进行中(与 DatabaseInitialized 互斥:进行中时为 true)</summary> | 19 | /// <summary>业务库初始化是否已在后台进行中(与 DatabaseInitialized 互斥:进行中时为 true)</summary> |
| 20 | public bool DatabaseInitializing { get; set; } | 20 | public bool DatabaseInitializing { get; set; } |
| 21 | + | ||
| 22 | + /// <summary>公司有效期截止;空表示永久</summary> | ||
| 23 | + public DateTime? ExpireTime { get; set; } | ||
| 21 | } | 24 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/MultiTenancy/ThUpdateCompanyValidityInputVo.cs
0 → 100644
| 1 | +using System.ComponentModel.DataAnnotations; | ||
| 2 | + | ||
| 3 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.MultiTenancy; | ||
| 4 | + | ||
| 5 | +/// <summary> | ||
| 6 | +/// 设置公司有效期(空 ExpireTime 表示永久有效) | ||
| 7 | +/// </summary> | ||
| 8 | +public class ThUpdateCompanyValidityInputVo | ||
| 9 | +{ | ||
| 10 | + /// <summary>租户 Id</summary> | ||
| 11 | + [Required] | ||
| 12 | + public Guid TenantId { get; set; } | ||
| 13 | + | ||
| 14 | + /// <summary> | ||
| 15 | + /// 有效期截止时间。传 null 表示永久有效。 | ||
| 16 | + /// 仅日期(00:00:00)表示当天结束前有效。 | ||
| 17 | + /// </summary> | ||
| 18 | + public DateTime? ExpireTime { get; set; } | ||
| 19 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/Platform/ThPlatformAgentDto.cs
0 → 100644
| 1 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 2 | + | ||
| 3 | +/// <summary> | ||
| 4 | +/// 平台代理账号 | ||
| 5 | +/// </summary> | ||
| 6 | +public class ThPlatformAgentDto | ||
| 7 | +{ | ||
| 8 | + /// <summary>用户 Id</summary> | ||
| 9 | + public Guid Id { get; set; } | ||
| 10 | + | ||
| 11 | + /// <summary>登录名</summary> | ||
| 12 | + public string UserName { get; set; } = string.Empty; | ||
| 13 | + | ||
| 14 | + /// <summary>邮箱</summary> | ||
| 15 | + public string Email { get; set; } = string.Empty; | ||
| 16 | + | ||
| 17 | + /// <summary>显示名</summary> | ||
| 18 | + public string DisplayName { get; set; } = string.Empty; | ||
| 19 | + | ||
| 20 | + /// <summary>可创建公司上限</summary> | ||
| 21 | + public int CompanyQuota { get; set; } | ||
| 22 | + | ||
| 23 | + /// <summary>已创建公司数</summary> | ||
| 24 | + public int CompanyUsed { get; set; } | ||
| 25 | + | ||
| 26 | + /// <summary>是否启用</summary> | ||
| 27 | + public bool Enabled { get; set; } | ||
| 28 | + | ||
| 29 | + /// <summary>创建时间</summary> | ||
| 30 | + public DateTime? CreationTime { get; set; } | ||
| 31 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/Platform/ThPlatformAgentGetListInput.cs
0 → 100644
| 1 | +using Yi.Framework.Ddd.Application.Contracts; | ||
| 2 | + | ||
| 3 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 4 | + | ||
| 5 | +/// <summary> | ||
| 6 | +/// 平台代理分页查询 | ||
| 7 | +/// </summary> | ||
| 8 | +public class ThPlatformAgentGetListInput : PagedAllResultRequestDto | ||
| 9 | +{ | ||
| 10 | + /// <summary>登录名 / 邮箱 / 显示名关键字</summary> | ||
| 11 | + public string? Keyword { get; set; } | ||
| 12 | + | ||
| 13 | + /// <summary>启用状态(与前端 State 筛选兼容)</summary> | ||
| 14 | + public bool? Enabled { get; set; } | ||
| 15 | + | ||
| 16 | + /// <summary>启用状态(前端查询表单字段名为 State)</summary> | ||
| 17 | + public bool? State { get; set; } | ||
| 18 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/Platform/ThPlatformAgentSaveInputVo.cs
0 → 100644
| 1 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 2 | + | ||
| 3 | +/// <summary> | ||
| 4 | +/// 新建 / 更新平台代理 | ||
| 5 | +/// </summary> | ||
| 6 | +public class ThPlatformAgentSaveInputVo | ||
| 7 | +{ | ||
| 8 | + /// <summary>登录名</summary> | ||
| 9 | + public string? UserName { get; set; } | ||
| 10 | + | ||
| 11 | + /// <summary>邮箱</summary> | ||
| 12 | + public string? Email { get; set; } | ||
| 13 | + | ||
| 14 | + /// <summary>显示名</summary> | ||
| 15 | + public string? DisplayName { get; set; } | ||
| 16 | + | ||
| 17 | + /// <summary>可创建公司上限</summary> | ||
| 18 | + public int? CompanyQuota { get; set; } | ||
| 19 | + | ||
| 20 | + /// <summary>是否启用</summary> | ||
| 21 | + public bool? Enabled { get; set; } | ||
| 22 | + | ||
| 23 | + /// <summary>密码;新建必填,编辑留空表示不修改</summary> | ||
| 24 | + public string? Password { get; set; } | ||
| 25 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/Platform/ThPlatformStatisticsCompanyGetListInput.cs
0 → 100644
| 1 | +using Yi.Framework.Ddd.Application.Contracts; | ||
| 2 | + | ||
| 3 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 4 | + | ||
| 5 | +/// <summary> | ||
| 6 | +/// 平台统计公司明细分页查询 | ||
| 7 | +/// </summary> | ||
| 8 | +public class ThPlatformStatisticsCompanyGetListInput : PagedAllResultRequestDto | ||
| 9 | +{ | ||
| 10 | + /// <summary>公司名称关键字</summary> | ||
| 11 | + public string? Keyword { get; set; } | ||
| 12 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/Platform/ThPlatformStatisticsCompanyItemDto.cs
0 → 100644
| 1 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 2 | + | ||
| 3 | +/// <summary> | ||
| 4 | +/// 平台统计公司明细行 | ||
| 5 | +/// </summary> | ||
| 6 | +public class ThPlatformStatisticsCompanyItemDto | ||
| 7 | +{ | ||
| 8 | + /// <summary>租户 Id</summary> | ||
| 9 | + public Guid Id { get; set; } | ||
| 10 | + | ||
| 11 | + /// <summary>公司名称</summary> | ||
| 12 | + public string CompanyName { get; set; } = string.Empty; | ||
| 13 | + | ||
| 14 | + /// <summary>标签数量</summary> | ||
| 15 | + public int LabelCount { get; set; } | ||
| 16 | + | ||
| 17 | + /// <summary>门店数量</summary> | ||
| 18 | + public int LocationCount { get; set; } | ||
| 19 | + | ||
| 20 | + /// <summary>区域数量</summary> | ||
| 21 | + public int RegionCount { get; set; } | ||
| 22 | + | ||
| 23 | + /// <summary>该公司最近使用时间</summary> | ||
| 24 | + public DateTime? LastUsedAt { get; set; } | ||
| 25 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/Platform/ThPlatformStatisticsOverviewDto.cs
0 → 100644
| 1 | +namespace FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 2 | + | ||
| 3 | +/// <summary> | ||
| 4 | +/// 平台统计概览 | ||
| 5 | +/// </summary> | ||
| 6 | +public class ThPlatformStatisticsOverviewDto | ||
| 7 | +{ | ||
| 8 | + /// <summary>公司数量</summary> | ||
| 9 | + public int CompanyCount { get; set; } | ||
| 10 | + | ||
| 11 | + /// <summary>区域数量(各租户 fl_group 合计)</summary> | ||
| 12 | + public int RegionCount { get; set; } | ||
| 13 | + | ||
| 14 | + /// <summary>门店数量(各租户 location 合计)</summary> | ||
| 15 | + public int LocationCount { get; set; } | ||
| 16 | + | ||
| 17 | + /// <summary>标签数量(各租户 fl_label 合计)</summary> | ||
| 18 | + public int LabelCount { get; set; } | ||
| 19 | + | ||
| 20 | + /// <summary>最近使用时间(各租户业务活跃时间的全局最大值)</summary> | ||
| 21 | + public DateTime? LastUsedAt { get; set; } | ||
| 22 | + | ||
| 23 | + /// <summary> | ||
| 24 | + /// 数据范围:<c>all</c> 平台管理员全部公司;<c>agent</c> 代理仅本人创建 | ||
| 25 | + /// </summary> | ||
| 26 | + public string Scope { get; set; } = "all"; | ||
| 27 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/IServices/IThMultiTenancyAppService.cs
| @@ -58,6 +58,11 @@ public interface IThMultiTenancyAppService : IApplicationService | @@ -58,6 +58,11 @@ public interface IThMultiTenancyAppService : IApplicationService | ||
| 58 | 58 | ||
| 59 | Task UpdateCompanyAdminAsync(ThUpdateCompanyAdminInputVo input); | 59 | Task UpdateCompanyAdminAsync(ThUpdateCompanyAdminInputVo input); |
| 60 | 60 | ||
| 61 | + /// <summary> | ||
| 62 | + /// 平台级管理员:设置公司有效期(空表示永久) | ||
| 63 | + /// </summary> | ||
| 64 | + Task UpdateCompanyValidityAsync(ThUpdateCompanyValidityInputVo input); | ||
| 65 | + | ||
| 61 | 66 | ||
| 62 | 67 | ||
| 63 | /// <summary> | 68 | /// <summary> |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/IServices/IThPlatformAgentAppService.cs
0 → 100644
| 1 | +using FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 2 | +using Volo.Abp.Application.Dtos; | ||
| 3 | +using Volo.Abp.Application.Services; | ||
| 4 | + | ||
| 5 | +namespace FoodLabeling.Th.Application.Contracts.IServices; | ||
| 6 | + | ||
| 7 | +/// <summary> | ||
| 8 | +/// 泰额平台代理管理(Host,仅 admin) | ||
| 9 | +/// </summary> | ||
| 10 | +public interface IThPlatformAgentAppService : IApplicationService | ||
| 11 | +{ | ||
| 12 | + /// <summary> | ||
| 13 | + /// 代理分页列表 | ||
| 14 | + /// </summary> | ||
| 15 | + Task<PagedResultDto<ThPlatformAgentDto>> GetListAsync(ThPlatformAgentGetListInput input); | ||
| 16 | + | ||
| 17 | + /// <summary> | ||
| 18 | + /// 代理详情 | ||
| 19 | + /// </summary> | ||
| 20 | + Task<ThPlatformAgentDto> GetAsync(Guid id); | ||
| 21 | + | ||
| 22 | + /// <summary> | ||
| 23 | + /// 新建代理账号 | ||
| 24 | + /// </summary> | ||
| 25 | + Task<ThPlatformAgentDto> CreateAsync(ThPlatformAgentSaveInputVo input); | ||
| 26 | + | ||
| 27 | + /// <summary> | ||
| 28 | + /// 更新代理 | ||
| 29 | + /// </summary> | ||
| 30 | + Task UpdateAsync(Guid id, ThPlatformAgentSaveInputVo input); | ||
| 31 | + | ||
| 32 | + /// <summary> | ||
| 33 | + /// 删除代理(软删用户与扩展行) | ||
| 34 | + /// </summary> | ||
| 35 | + Task DeleteAsync(Guid id); | ||
| 36 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/IServices/IThPlatformStatisticsAppService.cs
0 → 100644
| 1 | +using FoodLabeling.Th.Application.Contracts.Dtos.Platform; | ||
| 2 | +using Volo.Abp.Application.Dtos; | ||
| 3 | +using Volo.Abp.Application.Services; | ||
| 4 | + | ||
| 5 | +namespace FoodLabeling.Th.Application.Contracts.IServices; | ||
| 6 | + | ||
| 7 | +/// <summary> | ||
| 8 | +/// 泰额平台统计(Host) | ||
| 9 | +/// </summary> | ||
| 10 | +public interface IThPlatformStatisticsAppService : IApplicationService | ||
| 11 | +{ | ||
| 12 | + /// <summary> | ||
| 13 | + /// 平台统计概览 KPI | ||
| 14 | + /// </summary> | ||
| 15 | + Task<ThPlatformStatisticsOverviewDto> GetOverviewAsync(); | ||
| 16 | + | ||
| 17 | + /// <summary> | ||
| 18 | + /// 平台统计公司明细分页 | ||
| 19 | + /// </summary> | ||
| 20 | + Task<PagedResultDto<ThPlatformStatisticsCompanyItemDto>> GetCompaniesAsync( | ||
| 21 | + ThPlatformStatisticsCompanyGetListInput input); | ||
| 22 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Filters/FoodLabelingBusinessTenantActionFilter.cs
| 1 | using FoodLabeling.Application.Helpers; | 1 | using FoodLabeling.Application.Helpers; |
| 2 | +using FoodLabeling.Th.Application.MultiTenancy; | ||
| 2 | using Microsoft.AspNetCore.Mvc.Filters; | 3 | using Microsoft.AspNetCore.Mvc.Filters; |
| 3 | using Microsoft.Extensions.Options; | 4 | using Microsoft.Extensions.Options; |
| 4 | using Volo.Abp.DependencyInjection; | 5 | using Volo.Abp.DependencyInjection; |
| @@ -9,35 +10,45 @@ namespace FoodLabeling.Th.Application.Filters; | @@ -9,35 +10,45 @@ namespace FoodLabeling.Th.Application.Filters; | ||
| 9 | 10 | ||
| 10 | /// <summary> | 11 | /// <summary> |
| 11 | /// 泰额 SaaS:业务 AppService(fl_* / 租户 menu 等)须已解析租户上下文,禁止落到 host 主库。 | 12 | /// 泰额 SaaS:业务 AppService(fl_* / 租户 menu 等)须已解析租户上下文,禁止落到 host 主库。 |
| 12 | -/// 平台登录误调业务接口时返回友好错误,避免 <c>fl_label</c> 缺表 500。 | 13 | +/// 平台登录误调Business API时返回友好错误,避免 <c>fl_label</c> 缺表 500。 |
| 13 | /// </summary> | 14 | /// </summary> |
| 14 | public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITransientDependency | 15 | public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITransientDependency |
| 15 | { | 16 | { |
| 16 | private readonly ICurrentTenant _currentTenant; | 17 | private readonly ICurrentTenant _currentTenant; |
| 17 | private readonly DbConnOptions _dbConnOptions; | 18 | private readonly DbConnOptions _dbConnOptions; |
| 18 | private readonly ISqlSugarDbContext _dbContext; | 19 | private readonly ISqlSugarDbContext _dbContext; |
| 20 | + private readonly ThTenantValidityGuard _tenantValidityGuard; | ||
| 19 | 21 | ||
| 20 | public FoodLabelingBusinessTenantActionFilter( | 22 | public FoodLabelingBusinessTenantActionFilter( |
| 21 | ICurrentTenant currentTenant, | 23 | ICurrentTenant currentTenant, |
| 22 | IOptions<DbConnOptions> dbConnOptions, | 24 | IOptions<DbConnOptions> dbConnOptions, |
| 23 | - ISqlSugarDbContext dbContext) | 25 | + ISqlSugarDbContext dbContext, |
| 26 | + ThTenantValidityGuard tenantValidityGuard) | ||
| 24 | { | 27 | { |
| 25 | _currentTenant = currentTenant; | 28 | _currentTenant = currentTenant; |
| 26 | _dbConnOptions = dbConnOptions.Value; | 29 | _dbConnOptions = dbConnOptions.Value; |
| 27 | _dbContext = dbContext; | 30 | _dbContext = dbContext; |
| 31 | + _tenantValidityGuard = tenantValidityGuard; | ||
| 28 | } | 32 | } |
| 29 | 33 | ||
| 30 | - public Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) | 34 | + public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) |
| 31 | { | 35 | { |
| 32 | if (!_dbConnOptions.EnabledSaasMultiTenancy) | 36 | if (!_dbConnOptions.EnabledSaasMultiTenancy) |
| 33 | { | 37 | { |
| 34 | - return next(); | 38 | + await next(); |
| 39 | + return; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + if (_currentTenant.Id is { } currentTenantId && currentTenantId != Guid.Empty) | ||
| 43 | + { | ||
| 44 | + await _tenantValidityGuard.EnsureCompanyNotExpiredAsync(currentTenantId); | ||
| 35 | } | 45 | } |
| 36 | 46 | ||
| 37 | var path = context.HttpContext.Request.Path.Value ?? string.Empty; | 47 | var path = context.HttpContext.Request.Path.Value ?? string.Empty; |
| 38 | if (!RequiresBusinessTenant(path)) | 48 | if (!RequiresBusinessTenant(path)) |
| 39 | { | 49 | { |
| 40 | - return next(); | 50 | + await next(); |
| 51 | + return; | ||
| 41 | } | 52 | } |
| 42 | 53 | ||
| 43 | TenantContextGuard.EnsureBusinessTenantIfSaas(_currentTenant, _dbConnOptions, ResolveOperationLabel(path)); | 54 | TenantContextGuard.EnsureBusinessTenantIfSaas(_currentTenant, _dbConnOptions, ResolveOperationLabel(path)); |
| @@ -46,7 +57,7 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans | @@ -46,7 +57,7 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans | ||
| 46 | _dbConnOptions, | 57 | _dbConnOptions, |
| 47 | ResolveOperationLabel(path)); | 58 | ResolveOperationLabel(path)); |
| 48 | 59 | ||
| 49 | - return next(); | 60 | + await next(); |
| 50 | } | 61 | } |
| 51 | 62 | ||
| 52 | /// <summary> | 63 | /// <summary> |
| @@ -79,7 +90,7 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans | @@ -79,7 +90,7 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans | ||
| 79 | private static string ResolveOperationLabel(string path) | 90 | private static string ResolveOperationLabel(string path) |
| 80 | { | 91 | { |
| 81 | var segment = path.Split('/', StringSplitOptions.RemoveEmptyEntries).LastOrDefault(); | 92 | var segment = path.Split('/', StringSplitOptions.RemoveEmptyEntries).LastOrDefault(); |
| 82 | - return string.IsNullOrWhiteSpace(segment) ? "业务接口" : segment; | 93 | + return string.IsNullOrWhiteSpace(segment) ? "Business API" : segment; |
| 83 | } | 94 | } |
| 84 | 95 | ||
| 85 | /// <summary>平台侧路径片段(小写),命中则跳过业务租户校验。</summary> | 96 | /// <summary>平台侧路径片段(小写),命中则跳过业务租户校验。</summary> |
| @@ -90,9 +101,12 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans | @@ -90,9 +101,12 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans | ||
| 90 | "/us-app-auth", | 101 | "/us-app-auth", |
| 91 | "/th-multi-tenancy", | 102 | "/th-multi-tenancy", |
| 92 | "/th-tenant-provisioning", | 103 | "/th-tenant-provisioning", |
| 104 | + // 平台统计 / 代理管理:读 Host yitenant + fl_th_platform_agent,不要求业务租户 | ||
| 105 | + "/th-platform-statistics", | ||
| 106 | + "/th-platform-agents", | ||
| 93 | "/th-tenant-select", | 107 | "/th-tenant-select", |
| 94 | "/th-rbac", | 108 | "/th-rbac", |
| 95 | - // 平台管理员登录后拉主库菜单;__tenant 为空/全 0 时不可当业务接口拦截 | 109 | + // 平台管理员登录后拉主库菜单;__tenant 为空/全 0 时不可当Business API拦截 |
| 96 | "/auth-session", | 110 | "/auth-session", |
| 97 | // 平台登录可进 Dashboard:服务内返回空统计 | 111 | // 平台登录可进 Dashboard:服务内返回空统计 |
| 98 | "/dashboard", | 112 | "/dashboard", |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/FoodLabelingThTenantDatabaseMigrationContributor.cs
| 1 | +using System.Collections.Generic; | ||
| 1 | using FoodLabeling.Application.MultiTenancy; | 2 | using FoodLabeling.Application.MultiTenancy; |
| 2 | using Microsoft.Extensions.Logging; | 3 | using Microsoft.Extensions.Logging; |
| 3 | using Volo.Abp.DependencyInjection; | 4 | using Volo.Abp.DependencyInjection; |
| @@ -37,6 +38,7 @@ public class FoodLabelingThTenantDatabaseMigrationContributor | @@ -37,6 +38,7 @@ public class FoodLabelingThTenantDatabaseMigrationContributor | ||
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | var scriptAssembly = typeof(FoodLabelingTenantMigrationScriptNames).Assembly; | 40 | var scriptAssembly = typeof(FoodLabelingTenantMigrationScriptNames).Assembly; |
| 41 | + var errors = new List<string>(); | ||
| 40 | 42 | ||
| 41 | foreach (var resourceName in FoodLabelingTenantMigrationScriptNames.TenantInitializationOrder) | 43 | foreach (var resourceName in FoodLabelingTenantMigrationScriptNames.TenantInitializationOrder) |
| 42 | { | 44 | { |
| @@ -45,11 +47,29 @@ public class FoodLabelingThTenantDatabaseMigrationContributor | @@ -45,11 +47,29 @@ public class FoodLabelingThTenantDatabaseMigrationContributor | ||
| 45 | context.TenantId, | 47 | context.TenantId, |
| 46 | resourceName); | 48 | resourceName); |
| 47 | 49 | ||
| 48 | - var sql = EmbeddedTenantSqlScripts.Read(scriptAssembly, resourceName); | ||
| 49 | - await TenantSqlScriptExecutor.ExecuteMySqlScriptAsync( | ||
| 50 | - context.ConnectionString, | ||
| 51 | - sql, | ||
| 52 | - cancellationToken); | 50 | + try |
| 51 | + { | ||
| 52 | + var sql = EmbeddedTenantSqlScripts.Read(scriptAssembly, resourceName); | ||
| 53 | + await TenantSqlScriptExecutor.ExecuteMySqlScriptAsync( | ||
| 54 | + context.ConnectionString, | ||
| 55 | + sql, | ||
| 56 | + cancellationToken); | ||
| 57 | + } | ||
| 58 | + catch (Exception ex) | ||
| 59 | + { | ||
| 60 | + _logger.LogError( | ||
| 61 | + ex, | ||
| 62 | + "租户 {TenantId} 业务库迁移脚本失败 {Script},继续执行后续脚本", | ||
| 63 | + context.TenantId, | ||
| 64 | + resourceName); | ||
| 65 | + errors.Add($"{resourceName}: {ex.Message}"); | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + if (errors.Count > 0) | ||
| 70 | + { | ||
| 71 | + throw new InvalidOperationException( | ||
| 72 | + "租户库补充 SQL 部分失败(后续脚本已继续执行):" + string.Join(" | ", errors)); | ||
| 53 | } | 73 | } |
| 54 | } | 74 | } |
| 55 | } | 75 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantAdminAccountBootstrapper.cs
| @@ -15,7 +15,7 @@ using Yi.Framework.TenantManagement.Domain; | @@ -15,7 +15,7 @@ using Yi.Framework.TenantManagement.Domain; | ||
| 15 | namespace FoodLabeling.Th.Application.MultiTenancy; | 15 | namespace FoodLabeling.Th.Application.MultiTenancy; |
| 16 | 16 | ||
| 17 | /// <summary> | 17 | /// <summary> |
| 18 | -/// 新增租户后:将业务库默认 admin 账号同步为开通时填写的登录邮箱,并确保绑定 admin 角色。 | 18 | +/// 新增租户后:将业务库默认 admin 账号同步为开通时填写的登录邮箱,并确保绑定 admin(管理员)角色。 |
| 19 | /// </summary> | 19 | /// </summary> |
| 20 | public class TenantAdminAccountBootstrapper : ITransientDependency | 20 | public class TenantAdminAccountBootstrapper : ITransientDependency |
| 21 | { | 21 | { |
| @@ -97,7 +97,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -97,7 +97,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 97 | } | 97 | } |
| 98 | catch (Exception ex) | 98 | catch (Exception ex) |
| 99 | { | 99 | { |
| 100 | - _logger.LogWarning(ex, "租户 {TenantId} 凭据密码解密失败,仅同步账号", tenantId); | 100 | + _logger.LogWarning(ex, "租户 {TenantId} 凭据Password decryption failed.,仅同步账号", tenantId); |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | 103 | ||
| @@ -147,7 +147,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -147,7 +147,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 147 | tenantId, | 147 | tenantId, |
| 148 | normalizedEmail); | 148 | normalizedEmail); |
| 149 | throw new UserFriendlyException( | 149 | throw new UserFriendlyException( |
| 150 | - "租户业务库默认管理员账号缺失,无法同步登录邮箱,请重新初始化业务库或联系运维"); | 150 | + "Default tenant business administrator account is missing; cannot sync sign-in email. Re-initialize the business database or contact operations."); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | var renamed = await tenantDb.Updateable<UserAggregateRoot>() | 153 | var renamed = await tenantDb.Updateable<UserAggregateRoot>() |
| @@ -160,7 +160,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -160,7 +160,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 160 | if (renamed <= 0) | 160 | if (renamed <= 0) |
| 161 | { | 161 | { |
| 162 | throw new UserFriendlyException( | 162 | throw new UserFriendlyException( |
| 163 | - "租户业务库管理员账号同步失败(UserName/Email 未更新),请重试 initialize-tenant-database 或联系运维"); | 163 | + "Failed to sync tenant business administrator account (UserName/Email not updated). Retry initialize-tenant-database or contact operations."); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | if (!string.IsNullOrEmpty(plainPassword)) | 166 | if (!string.IsNullOrEmpty(plainPassword)) |
| @@ -231,7 +231,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -231,7 +231,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | /// <summary> | 233 | /// <summary> |
| 234 | - /// 幂等确保租户业务库管理员用户已绑定 RoleCode=admin 的角色。 | 234 | + /// 幂等确保租户业务库开通账号已绑定 RoleCode=admin 的管理员角色。 |
| 235 | /// </summary> | 235 | /// </summary> |
| 236 | public async Task EnsureTenantAdminRoleAsync(Guid tenantId, CancellationToken cancellationToken = default) | 236 | public async Task EnsureTenantAdminRoleAsync(Guid tenantId, CancellationToken cancellationToken = default) |
| 237 | { | 237 | { |
| @@ -259,7 +259,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -259,7 +259,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 259 | } | 259 | } |
| 260 | catch (UserFriendlyException ex) | 260 | catch (UserFriendlyException ex) |
| 261 | { | 261 | { |
| 262 | - _logger.LogWarning(ex, "租户 {TenantId} 业务库未就绪,跳过 admin 角色绑定", tenantId); | 262 | + _logger.LogWarning(ex, "租户 {TenantId} 业务库未就绪,跳过管理员角色绑定", tenantId); |
| 263 | return; | 263 | return; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| @@ -277,7 +277,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -277,7 +277,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | /// <summary> | 279 | /// <summary> |
| 280 | - /// 查找管理员用户并绑定 admin 角色;已有绑定则跳过。 | 280 | + /// 查找开通账号并绑定 admin;若仍绑着 companyAdmin 则替换为管理员。 |
| 281 | /// </summary> | 281 | /// </summary> |
| 282 | private async Task EnsureAdminRoleBoundAsync( | 282 | private async Task EnsureAdminRoleBoundAsync( |
| 283 | ISqlSugarClient tenantDb, | 283 | ISqlSugarClient tenantDb, |
| @@ -287,7 +287,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -287,7 +287,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 287 | { | 287 | { |
| 288 | var adminRoles = await tenantDb.Queryable<RoleAggregateRoot>() | 288 | var adminRoles = await tenantDb.Queryable<RoleAggregateRoot>() |
| 289 | .Where(r => !r.IsDeleted) | 289 | .Where(r => !r.IsDeleted) |
| 290 | - .Where(r => r.RoleCode == UserConst.AdminRolesCode || r.RoleCode == UserConst.Admin) | 290 | + .Where(r => r.RoleCode == UserConst.AdminRolesCode || r.RoleName == "管理员") |
| 291 | .OrderBy(r => r.OrderNum, OrderByType.Desc) | 291 | .OrderBy(r => r.OrderNum, OrderByType.Desc) |
| 292 | .Take(1) | 292 | .Take(1) |
| 293 | .ToListAsync(cancellationToken); | 293 | .ToListAsync(cancellationToken); |
| @@ -330,6 +330,19 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -330,6 +330,19 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 330 | return; | 330 | return; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | + var leftoverCompanyAdminRoleIds = await tenantDb.Queryable<RoleAggregateRoot>() | ||
| 334 | + .Where(r => !r.IsDeleted) | ||
| 335 | + .Where(r => r.RoleCode == UserConst.CompanyAdminRolesCode) | ||
| 336 | + .Where(r => r.Id != adminRole.Id) | ||
| 337 | + .Select(r => r.Id) | ||
| 338 | + .ToListAsync(cancellationToken); | ||
| 339 | + if (leftoverCompanyAdminRoleIds.Count > 0) | ||
| 340 | + { | ||
| 341 | + await tenantDb.Deleteable<UserRoleEntity>() | ||
| 342 | + .Where(ur => ur.UserId == adminUser.Id && leftoverCompanyAdminRoleIds.Contains(ur.RoleId)) | ||
| 343 | + .ExecuteCommandAsync(cancellationToken); | ||
| 344 | + } | ||
| 345 | + | ||
| 333 | var alreadyBound = await tenantDb.Queryable<UserRoleEntity>() | 346 | var alreadyBound = await tenantDb.Queryable<UserRoleEntity>() |
| 334 | .Where(ur => ur.UserId == adminUser.Id && ur.RoleId == adminRole.Id) | 347 | .Where(ur => ur.UserId == adminUser.Id && ur.RoleId == adminRole.Id) |
| 335 | .AnyAsync(); | 348 | .AnyAsync(); |
| @@ -346,7 +359,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -346,7 +359,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 346 | await tenantDb.Insertable(entity).ExecuteCommandAsync(cancellationToken); | 359 | await tenantDb.Insertable(entity).ExecuteCommandAsync(cancellationToken); |
| 347 | 360 | ||
| 348 | _logger.LogInformation( | 361 | _logger.LogInformation( |
| 349 | - "租户 {TenantId} 已为管理员 {UserName} 绑定 admin 角色", | 362 | + "租户 {TenantId} 已为开通账号 {UserName} 绑定管理员角色", |
| 350 | tenantId, | 363 | tenantId, |
| 351 | adminUser.UserName); | 364 | adminUser.UserName); |
| 352 | } | 365 | } |
| @@ -355,7 +368,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | @@ -355,7 +368,7 @@ public class TenantAdminAccountBootstrapper : ITransientDependency | ||
| 355 | { | 368 | { |
| 356 | if (string.IsNullOrWhiteSpace(_dbConnOptions.Url)) | 369 | if (string.IsNullOrWhiteSpace(_dbConnOptions.Url)) |
| 357 | { | 370 | { |
| 358 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 371 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 359 | } | 372 | } |
| 360 | 373 | ||
| 361 | var dbType = _dbConnOptions.DbType ?? DbType.MySql; | 374 | var dbType = _dbConnOptions.DbType ?? DbType.MySql; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantBusinessDatabaseAccessor.cs
| @@ -11,7 +11,7 @@ namespace FoodLabeling.Th.Application.MultiTenancy; | @@ -11,7 +11,7 @@ namespace FoodLabeling.Th.Application.MultiTenancy; | ||
| 11 | public static class TenantBusinessDatabaseAccessor | 11 | public static class TenantBusinessDatabaseAccessor |
| 12 | { | 12 | { |
| 13 | private const string InitializeTenantDatabaseHintTemplate = | 13 | private const string InitializeTenantDatabaseHintTemplate = |
| 14 | - "请先调用 POST /api/app/th-tenant-provisioning/initialize-tenant-database/{0} 初始化业务库"; | 14 | + "Call POST /api/app/th-tenant-provisioning/initialize-tenant-database/{0} to initialize the business database first"; |
| 15 | 15 | ||
| 16 | /// <summary> | 16 | /// <summary> |
| 17 | /// 解析租户业务库连接串;为空时按配置回填并写回主库 YiTenant。 | 17 | /// 解析租户业务库连接串;为空时按配置回填并写回主库 YiTenant。 |
| @@ -50,7 +50,7 @@ public static class TenantBusinessDatabaseAccessor | @@ -50,7 +50,7 @@ public static class TenantBusinessDatabaseAccessor | ||
| 50 | { | 50 | { |
| 51 | if (string.IsNullOrWhiteSpace(connectionString)) | 51 | if (string.IsNullOrWhiteSpace(connectionString)) |
| 52 | { | 52 | { |
| 53 | - throw new UserFriendlyException("租户业务库连接串不能为空"); | 53 | + throw new UserFriendlyException("Tenant business database connection string is required."); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | return new SqlSugarClient(new ConnectionConfig | 56 | return new SqlSugarClient(new ConnectionConfig |
| @@ -96,7 +96,7 @@ public static class TenantBusinessDatabaseAccessor | @@ -96,7 +96,7 @@ public static class TenantBusinessDatabaseAccessor | ||
| 96 | public static UserFriendlyException BuildMissingConnectionStringException(string tenantName) | 96 | public static UserFriendlyException BuildMissingConnectionStringException(string tenantName) |
| 97 | { | 97 | { |
| 98 | return new UserFriendlyException( | 98 | return new UserFriendlyException( |
| 99 | - $"租户「{tenantName}」未配置业务库连接串,请先在租户管理完善连接串或调用开通/初始化接口"); | 99 | + $"Tenant \"{tenantName}\" has no business database connection string. Configure it in tenant management or run provisioning/initialize APIs."); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | private static DbType ResolveDbType(DbType tenantDbType) | 102 | private static DbType ResolveDbType(DbType tenantDbType) |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantCompanyMenuSyncService.cs
| @@ -16,7 +16,7 @@ using Yi.Framework.TenantManagement.Domain; | @@ -16,7 +16,7 @@ using Yi.Framework.TenantManagement.Domain; | ||
| 16 | namespace FoodLabeling.Th.Application.MultiTenancy; | 16 | namespace FoodLabeling.Th.Application.MultiTenancy; |
| 17 | 17 | ||
| 18 | /// <summary> | 18 | /// <summary> |
| 19 | -/// 主库 fl_th_tenant_menu_permission 同步到租户业务库 menu 与 admin 角色 rolemenu。 | 19 | +/// 主库 fl_th_tenant_menu_permission 同步到租户业务库 menu,以及 admin / companyAdmin 角色 rolemenu。 |
| 20 | /// 主库使用稳定 f001 菜单 Id;租户 Seed 为随机 Guid,须先 upsert 主库菜单副本再写 RoleMenu。 | 20 | /// 主库使用稳定 f001 菜单 Id;租户 Seed 为随机 Guid,须先 upsert 主库菜单副本再写 RoleMenu。 |
| 21 | /// 主库读取使用 DbConnOptions.Url 独立 SqlSugarClient,避免后台 Init Scope 释放后仓储连接 ObjectDisposed。 | 21 | /// 主库读取使用 DbConnOptions.Url 独立 SqlSugarClient,避免后台 Init Scope 释放后仓储连接 ObjectDisposed。 |
| 22 | /// </summary> | 22 | /// </summary> |
| @@ -50,7 +50,7 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | @@ -50,7 +50,7 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | ||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | var tenant = await ThTenantHostDataAccessor.LoadTenantAsync(_dbConnOptions, tenantId) | 52 | var tenant = await ThTenantHostDataAccessor.LoadTenantAsync(_dbConnOptions, tenantId) |
| 53 | - ?? throw new UserFriendlyException("租户不存在"); | 53 | + ?? throw new UserFriendlyException("Tenant not found."); |
| 54 | 54 | ||
| 55 | var menuIds = await LoadNormalizedHostMenuIdsAsync(tenantId); | 55 | var menuIds = await LoadNormalizedHostMenuIdsAsync(tenantId); |
| 56 | var (connectionString, dbType) = await TenantBusinessDatabaseAccessor.ResolveConnectionAsync( | 56 | var (connectionString, dbType) = await TenantBusinessDatabaseAccessor.ResolveConnectionAsync( |
| @@ -69,17 +69,18 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | @@ -69,17 +69,18 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | ||
| 69 | return; | 69 | return; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | - var adminRole = await FindAdminRoleAsync(tenantDb, cancellationToken); | ||
| 73 | - if (adminRole is null) | 72 | + var targetRoles = await FindTenantMenuRolesAsync(tenantDb, cancellationToken); |
| 73 | + if (targetRoles.Count == 0) | ||
| 74 | { | 74 | { |
| 75 | - _logger.LogWarning("租户 {TenantId} 未找到 admin 角色,跳过公司菜单同步", tenantId); | 75 | + _logger.LogWarning("租户 {TenantId} 未找到 admin/companyAdmin 角色,跳过公司菜单同步", tenantId); |
| 76 | return; | 76 | return; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | if (menuIds.Count == 0) | 79 | if (menuIds.Count == 0) |
| 80 | { | 80 | { |
| 81 | + var emptyRoleIds = targetRoles.Select(r => r.Id).ToList(); | ||
| 81 | await tenantDb.Deleteable<RoleMenuEntity>() | 82 | await tenantDb.Deleteable<RoleMenuEntity>() |
| 82 | - .Where(x => x.RoleId == adminRole.Id) | 83 | + .Where(x => emptyRoleIds.Contains(x.RoleId)) |
| 83 | .ExecuteCommandAsync(cancellationToken); | 84 | .ExecuteCommandAsync(cancellationToken); |
| 84 | return; | 85 | return; |
| 85 | } | 86 | } |
| @@ -88,12 +89,17 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | @@ -88,12 +89,17 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | ||
| 88 | var menusToUpsert = CollectMenusWithAncestors(hostMenus, menuIds); | 89 | var menusToUpsert = CollectMenusWithAncestors(hostMenus, menuIds); |
| 89 | await UpsertTenantMenusAsync(tenantDb, menusToUpsert, cancellationToken); | 90 | await UpsertTenantMenusAsync(tenantDb, menusToUpsert, cancellationToken); |
| 90 | await HidePlatformQrMenusAsync(tenantDb, cancellationToken); | 91 | await HidePlatformQrMenusAsync(tenantDb, cancellationToken); |
| 91 | - await ReplaceAdminRoleMenusAsync(tenantDb, adminRole.Id, menusToUpsert.Select(m => m.Id).ToList(), cancellationToken); | 92 | + var syncedMenuIds = menusToUpsert.Select(m => m.Id).ToList(); |
| 93 | + foreach (var role in targetRoles) | ||
| 94 | + { | ||
| 95 | + await ReplaceAdminRoleMenusAsync(tenantDb, role.Id, syncedMenuIds, cancellationToken); | ||
| 96 | + } | ||
| 92 | 97 | ||
| 93 | _logger.LogInformation( | 98 | _logger.LogInformation( |
| 94 | - "租户 {TenantId} 已同步 {MenuCount} 条公司菜单到 admin 角色", | 99 | + "租户 {TenantId} 已同步 {MenuCount} 条公司菜单到 {RoleCount} 个角色", |
| 95 | tenantId, | 100 | tenantId, |
| 96 | - menusToUpsert.Count); | 101 | + menusToUpsert.Count, |
| 102 | + targetRoles.Count); | ||
| 97 | } | 103 | } |
| 98 | 104 | ||
| 99 | private async Task<List<Guid>> LoadNormalizedHostMenuIdsAsync(Guid tenantId) | 105 | private async Task<List<Guid>> LoadNormalizedHostMenuIdsAsync(Guid tenantId) |
| @@ -154,17 +160,21 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | @@ -154,17 +160,21 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran | ||
| 154 | .ToList(); | 160 | .ToList(); |
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | - private static async Task<RoleAggregateRoot?> FindAdminRoleAsync( | 163 | + private static async Task<List<RoleAggregateRoot>> FindTenantMenuRolesAsync( |
| 158 | ISqlSugarClient tenantDb, | 164 | ISqlSugarClient tenantDb, |
| 159 | CancellationToken cancellationToken) | 165 | CancellationToken cancellationToken) |
| 160 | { | 166 | { |
| 161 | - var adminRoles = await tenantDb.Queryable<RoleAggregateRoot>() | 167 | + var roles = await tenantDb.Queryable<RoleAggregateRoot>() |
| 162 | .Where(r => !r.IsDeleted) | 168 | .Where(r => !r.IsDeleted) |
| 163 | - .Where(r => r.RoleCode == UserConst.AdminRolesCode || r.RoleCode == UserConst.Admin) | ||
| 164 | - .OrderBy(r => r.OrderNum) | ||
| 165 | - .Take(1) | 169 | + .Where(r => r.RoleCode == UserConst.AdminRolesCode |
| 170 | + || r.RoleCode == UserConst.Admin | ||
| 171 | + || r.RoleCode == UserConst.CompanyAdminRolesCode) | ||
| 166 | .ToListAsync(cancellationToken); | 172 | .ToListAsync(cancellationToken); |
| 167 | - return adminRoles.FirstOrDefault(); | 173 | + |
| 174 | + return roles | ||
| 175 | + .GroupBy(r => r.RoleCode, StringComparer.OrdinalIgnoreCase) | ||
| 176 | + .Select(g => g.OrderByDescending(r => r.OrderNum).First()) | ||
| 177 | + .ToList(); | ||
| 168 | } | 178 | } |
| 169 | 179 | ||
| 170 | private static async Task HidePlatformQrMenusAsync( | 180 | private static async Task HidePlatformQrMenusAsync( |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantDatabaseBootstrapper.cs
| @@ -24,13 +24,13 @@ public static class TenantDatabaseBootstrapper | @@ -24,13 +24,13 @@ public static class TenantDatabaseBootstrapper | ||
| 24 | { | 24 | { |
| 25 | if (string.IsNullOrWhiteSpace(databaseName) || !SafeDatabaseNameRegex.IsMatch(databaseName)) | 25 | if (string.IsNullOrWhiteSpace(databaseName) || !SafeDatabaseNameRegex.IsMatch(databaseName)) |
| 26 | { | 26 | { |
| 27 | - throw new UserFriendlyException("租户连接串中的数据库名无效,无法建库"); | 27 | + throw new UserFriendlyException("Invalid database name in tenant connection string; cannot create database."); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | var createCandidates = BuildCreateDatabaseCandidates(dbConnOptions, tenantConnectionString); | 30 | var createCandidates = BuildCreateDatabaseCandidates(dbConnOptions, tenantConnectionString); |
| 31 | if (createCandidates.Count == 0) | 31 | if (createCandidates.Count == 0) |
| 32 | { | 32 | { |
| 33 | - throw new UserFriendlyException("未配置可用的数据库连接串,无法创建租户库"); | 33 | + throw new UserFriendlyException("No usable database connection string is configured; cannot create tenant database."); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | var createErrors = new List<string>(); | 36 | var createErrors = new List<string>(); |
| @@ -53,12 +53,12 @@ public static class TenantDatabaseBootstrapper | @@ -53,12 +53,12 @@ public static class TenantDatabaseBootstrapper | ||
| 53 | { | 53 | { |
| 54 | var userId = ExtractConnectionValue(tenantConnectionString, "uid") ?? "netteam"; | 54 | var userId = ExtractConnectionValue(tenantConnectionString, "uid") ?? "netteam"; |
| 55 | throw new UserFriendlyException( | 55 | throw new UserFriendlyException( |
| 56 | - $"创建租户库失败(库={databaseName})。尝试结果:{string.Join(" | ", createErrors)}。" + | ||
| 57 | - $"说明:MySQL 报 Access denied to database 新建库名时,通常是账号没有 CREATE 权限(与能否连上主库无关)。" + | ||
| 58 | - $"请在 appsettings 的 DbConnOptions.AdminConnectionString 配置高权限账号连接串后重试;或手动执行:" + | 56 | + $"Failed to create tenant database (database={databaseName}). Attempts: {string.Join(" | ", createErrors)}. " + |
| 57 | + $"When MySQL reports Access denied for a new database name, the account usually lacks CREATE privilege (unrelated to host connectivity)." + | ||
| 58 | + $"Configure a privileged connection string in appsettings DbConnOptions.AdminConnectionString and retry, or run manually: " + | ||
| 59 | $"{TenantDatabaseCollation.BuildCreateDatabaseSql(databaseName)}; " + | 59 | $"{TenantDatabaseCollation.BuildCreateDatabaseSql(databaseName)}; " + |
| 60 | $"GRANT ALL PRIVILEGES ON `{databaseName}`.* TO '{userId}'@'%'; " + | 60 | $"GRANT ALL PRIVILEGES ON `{databaseName}`.* TO '{userId}'@'%'; " + |
| 61 | - $"再调用 initialize-tenant-database 补跑建表与 Seed"); | 61 | + $"Then call initialize-tenant-database to run schema and seed."); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | TryGrantTenantDatabaseAccess( | 64 | TryGrantTenantDatabaseAccess( |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantResolveHelper.cs
| @@ -52,18 +52,18 @@ public static class TenantResolveHelper | @@ -52,18 +52,18 @@ public static class TenantResolveHelper | ||
| 52 | 52 | ||
| 53 | if (config is null || config.Id == Guid.Empty) | 53 | if (config is null || config.Id == Guid.Empty) |
| 54 | { | 54 | { |
| 55 | - throw new UserFriendlyException("租户不存在或已停用"); | 55 | + throw new UserFriendlyException("Tenant not found or disabled."); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | if (string.IsNullOrWhiteSpace(config.ConnectionStrings?.Default)) | 58 | if (string.IsNullOrWhiteSpace(config.ConnectionStrings?.Default)) |
| 59 | { | 59 | { |
| 60 | - throw new UserFriendlyException("租户未配置业务库连接串"); | 60 | + throw new UserFriendlyException("Tenant business database connection string is not configured."); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | return config; | 63 | return config; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | - throw new UserFriendlyException("请指定租户 Id 或租户名称"); | 66 | + throw new UserFriendlyException("Specify tenant Id or tenant name."); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | public static async Task<TenantConfiguration> ResolveTenantAsync( | 69 | public static async Task<TenantConfiguration> ResolveTenantAsync( |
| @@ -73,7 +73,7 @@ public static class TenantResolveHelper | @@ -73,7 +73,7 @@ public static class TenantResolveHelper | ||
| 73 | { | 73 | { |
| 74 | if (tenantId == Guid.Empty) | 74 | if (tenantId == Guid.Empty) |
| 75 | { | 75 | { |
| 76 | - throw new UserFriendlyException("租户 Id 不能为空"); | 76 | + throw new UserFriendlyException("Tenant Id is required."); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | TenantConfiguration? config; | 79 | TenantConfiguration? config; |
| @@ -84,12 +84,12 @@ public static class TenantResolveHelper | @@ -84,12 +84,12 @@ public static class TenantResolveHelper | ||
| 84 | 84 | ||
| 85 | if (config is null) | 85 | if (config is null) |
| 86 | { | 86 | { |
| 87 | - throw new UserFriendlyException("租户不存在或已停用"); | 87 | + throw new UserFriendlyException("Tenant not found or disabled."); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | if (string.IsNullOrWhiteSpace(config.ConnectionStrings?.Default)) | 90 | if (string.IsNullOrWhiteSpace(config.ConnectionStrings?.Default)) |
| 91 | { | 91 | { |
| 92 | - throw new UserFriendlyException("租户未配置业务库连接串"); | 92 | + throw new UserFriendlyException("Tenant business database connection string is not configured."); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | return config; | 95 | return config; |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantSelectCredentialCipher.cs
| @@ -19,7 +19,7 @@ public class TenantSelectCredentialCipher : ITransientDependency | @@ -19,7 +19,7 @@ public class TenantSelectCredentialCipher : ITransientDependency | ||
| 19 | var secretKey = options.Value.SecretKey?.Trim(); | 19 | var secretKey = options.Value.SecretKey?.Trim(); |
| 20 | if (string.IsNullOrEmpty(secretKey)) | 20 | if (string.IsNullOrEmpty(secretKey)) |
| 21 | { | 21 | { |
| 22 | - throw new AbpException("未配置 FoodLabeling:TenantSelectCrypto:SecretKey"); | 22 | + throw new AbpException("FoodLabeling:TenantSelectCrypto:SecretKey is not configured."); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | _key = SHA256.HashData(Encoding.UTF8.GetBytes(secretKey)); | 25 | _key = SHA256.HashData(Encoding.UTF8.GetBytes(secretKey)); |
| @@ -56,7 +56,7 @@ public class TenantSelectCredentialCipher : ITransientDependency | @@ -56,7 +56,7 @@ public class TenantSelectCredentialCipher : ITransientDependency | ||
| 56 | { | 56 | { |
| 57 | if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(passwordSalt)) | 57 | if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(passwordSalt)) |
| 58 | { | 58 | { |
| 59 | - throw new UserFriendlyException("密码解密失败"); | 59 | + throw new UserFriendlyException("Password decryption failed."); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | try | 62 | try |
| @@ -76,7 +76,7 @@ public class TenantSelectCredentialCipher : ITransientDependency | @@ -76,7 +76,7 @@ public class TenantSelectCredentialCipher : ITransientDependency | ||
| 76 | } | 76 | } |
| 77 | catch (Exception ex) when (ex is not UserFriendlyException) | 77 | catch (Exception ex) when (ex is not UserFriendlyException) |
| 78 | { | 78 | { |
| 79 | - throw new UserFriendlyException("密码解密失败"); | 79 | + throw new UserFriendlyException("Password decryption failed."); |
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThPlatformActor.cs
0 → 100644
| 1 | +namespace FoodLabeling.Th.Application.MultiTenancy; | ||
| 2 | + | ||
| 3 | +/// <summary> | ||
| 4 | +/// 平台端登录身份(Host admin / 平台代理) | ||
| 5 | +/// </summary> | ||
| 6 | +public sealed class ThPlatformActor | ||
| 7 | +{ | ||
| 8 | + /// <summary>当前用户 Id</summary> | ||
| 9 | + public Guid UserId { get; init; } | ||
| 10 | + | ||
| 11 | + /// <summary>是否平台超级管理员</summary> | ||
| 12 | + public bool IsAdmin { get; init; } | ||
| 13 | + | ||
| 14 | + /// <summary>是否平台代理</summary> | ||
| 15 | + public bool IsAgent { get; init; } | ||
| 16 | + | ||
| 17 | + /// <summary>统计范围:all / agent</summary> | ||
| 18 | + public string Scope => IsAdmin ? "all" : "agent"; | ||
| 19 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThPlatformActorResolver.cs
0 → 100644
| 1 | +using SqlSugar; | ||
| 2 | +using Volo.Abp; | ||
| 3 | +using Volo.Abp.DependencyInjection; | ||
| 4 | +using Volo.Abp.MultiTenancy; | ||
| 5 | +using Volo.Abp.Users; | ||
| 6 | +using Yi.Framework.Rbac.Domain.Entities; | ||
| 7 | +using Yi.Framework.Rbac.Domain.Shared.Consts; | ||
| 8 | +using Yi.Framework.SqlSugarCore.Abstractions; | ||
| 9 | + | ||
| 10 | +namespace FoodLabeling.Th.Application.MultiTenancy; | ||
| 11 | + | ||
| 12 | +/// <summary> | ||
| 13 | +/// 解析 Host 平台管理员 / 代理身份 | ||
| 14 | +/// </summary> | ||
| 15 | +public class ThPlatformActorResolver : ITransientDependency | ||
| 16 | +{ | ||
| 17 | + private readonly ICurrentUser _currentUser; | ||
| 18 | + private readonly ICurrentTenant _currentTenant; | ||
| 19 | + private readonly ISqlSugarRepository<UserRoleEntity, Guid> _userRoleRepository; | ||
| 20 | + | ||
| 21 | + public ThPlatformActorResolver( | ||
| 22 | + ICurrentUser currentUser, | ||
| 23 | + ICurrentTenant currentTenant, | ||
| 24 | + ISqlSugarRepository<UserRoleEntity, Guid> userRoleRepository) | ||
| 25 | + { | ||
| 26 | + _currentUser = currentUser; | ||
| 27 | + _currentTenant = currentTenant; | ||
| 28 | + _userRoleRepository = userRoleRepository; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /// <summary> | ||
| 32 | + /// 要求当前用户为平台管理员或平台代理 | ||
| 33 | + /// </summary> | ||
| 34 | + public async Task<ThPlatformActor> EnsurePlatformActorAsync() | ||
| 35 | + { | ||
| 36 | + var actor = await ResolveAsync(); | ||
| 37 | + if (!actor.IsAdmin && !actor.IsAgent) | ||
| 38 | + { | ||
| 39 | + throw new UserFriendlyException("Only platform administrators or platform agents may access this."); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + return actor; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /// <summary> | ||
| 46 | + /// 要求当前用户为平台超级管理员 | ||
| 47 | + /// </summary> | ||
| 48 | + public async Task<ThPlatformActor> EnsureAdminAsync() | ||
| 49 | + { | ||
| 50 | + var actor = await ResolveAsync(); | ||
| 51 | + if (!actor.IsAdmin) | ||
| 52 | + { | ||
| 53 | + throw new UserFriendlyException("Only platform administrators may manage agents."); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + return actor; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private async Task<ThPlatformActor> ResolveAsync() | ||
| 60 | + { | ||
| 61 | + if (_currentUser.Id is null || _currentUser.Id == Guid.Empty) | ||
| 62 | + { | ||
| 63 | + throw new UserFriendlyException("You are not signed in."); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + var userId = _currentUser.Id.Value; | ||
| 67 | + List<string> codes; | ||
| 68 | + using (_currentTenant.Change(null)) | ||
| 69 | + { | ||
| 70 | + codes = await _userRoleRepository._DbQueryable | ||
| 71 | + .InnerJoin<RoleAggregateRoot>((ur, r) => ur.RoleId == r.Id) | ||
| 72 | + .Where((ur, r) => ur.UserId == userId && !r.IsDeleted && r.State) | ||
| 73 | + .Select((ur, r) => r.RoleCode) | ||
| 74 | + .ToListAsync(); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + var isAdmin = codes.Any(c => | ||
| 78 | + string.Equals(c, UserConst.AdminRolesCode, StringComparison.OrdinalIgnoreCase)); | ||
| 79 | + var isAgent = codes.Any(c => | ||
| 80 | + string.Equals(c, UserConst.PlatformAgentRolesCode, StringComparison.OrdinalIgnoreCase)); | ||
| 81 | + | ||
| 82 | + return new ThPlatformActor | ||
| 83 | + { | ||
| 84 | + UserId = userId, | ||
| 85 | + IsAdmin = isAdmin, | ||
| 86 | + IsAgent = isAgent && !isAdmin | ||
| 87 | + }; | ||
| 88 | + } | ||
| 89 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThPlatformTenantStatsReader.cs
0 → 100644
| 1 | +using FoodLabeling.Th.Application.Contracts.Options; | ||
| 2 | +using Microsoft.Extensions.Options; | ||
| 3 | +using SqlSugar; | ||
| 4 | +using Volo.Abp.DependencyInjection; | ||
| 5 | +using Volo.Abp.MultiTenancy; | ||
| 6 | +using Yi.Framework.SqlSugarCore.Abstractions; | ||
| 7 | +using Yi.Framework.TenantManagement.Domain; | ||
| 8 | + | ||
| 9 | +namespace FoodLabeling.Th.Application.MultiTenancy; | ||
| 10 | + | ||
| 11 | +/// <summary> | ||
| 12 | +/// 跨租户读取区域 / 门店 / 标签数量与最近使用时间 | ||
| 13 | +/// </summary> | ||
| 14 | +public class ThPlatformTenantStatsReader : ITransientDependency | ||
| 15 | +{ | ||
| 16 | + private const int MaxConcurrency = 4; | ||
| 17 | + private static readonly Guid ProtectedDefaultTenantId = Guid.Parse("11111111-1111-1111-1111-111111111111"); | ||
| 18 | + | ||
| 19 | + private readonly FoodLabelingThTenantDatabaseOptions _dbOptions; | ||
| 20 | + private readonly ISqlSugarRepository<TenantAggregateRoot, Guid> _tenantRepository; | ||
| 21 | + private readonly ICurrentTenant _currentTenant; | ||
| 22 | + | ||
| 23 | + public ThPlatformTenantStatsReader( | ||
| 24 | + IOptions<FoodLabelingThTenantDatabaseOptions> dbOptions, | ||
| 25 | + ISqlSugarRepository<TenantAggregateRoot, Guid> tenantRepository, | ||
| 26 | + ICurrentTenant currentTenant) | ||
| 27 | + { | ||
| 28 | + _dbOptions = dbOptions.Value; | ||
| 29 | + _tenantRepository = tenantRepository; | ||
| 30 | + _currentTenant = currentTenant; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public static bool IsProtectedDefaultTenant(TenantAggregateRoot tenant) | ||
| 34 | + { | ||
| 35 | + return tenant.Id == ProtectedDefaultTenantId | ||
| 36 | + || string.Equals(tenant.Name, "Default", StringComparison.OrdinalIgnoreCase); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /// <summary> | ||
| 40 | + /// 读取单个租户业务库统计;库未初始化或表不存在时返回 0 | ||
| 41 | + /// </summary> | ||
| 42 | + public async Task<ThPlatformTenantStatSnapshot> ReadAsync(TenantAggregateRoot tenant) | ||
| 43 | + { | ||
| 44 | + try | ||
| 45 | + { | ||
| 46 | + var (connectionString, dbType) = await TenantBusinessDatabaseAccessor.ResolveConnectionAsync( | ||
| 47 | + tenant, | ||
| 48 | + _dbOptions, | ||
| 49 | + PersistTenantAsync); | ||
| 50 | + using var db = TenantBusinessDatabaseAccessor.CreateClient(connectionString, dbType); | ||
| 51 | + db.Ado.ExecuteCommand("SELECT 1"); | ||
| 52 | + | ||
| 53 | + var tables = await db.Ado.SqlQueryAsync<string>( | ||
| 54 | + @"SELECT TABLE_NAME | ||
| 55 | + FROM information_schema.TABLES | ||
| 56 | + WHERE TABLE_SCHEMA = DATABASE() | ||
| 57 | + AND TABLE_NAME IN ('fl_group','location','fl_label')"); | ||
| 58 | + var names = new HashSet<string>(tables, StringComparer.OrdinalIgnoreCase); | ||
| 59 | + | ||
| 60 | + var region = names.Contains("fl_group") | ||
| 61 | + ? await ScalarCountAsync(db, "fl_group") | ||
| 62 | + : 0; | ||
| 63 | + var location = names.Contains("location") | ||
| 64 | + ? await ScalarCountAsync(db, "location") | ||
| 65 | + : 0; | ||
| 66 | + var label = names.Contains("fl_label") | ||
| 67 | + ? await ScalarCountAsync(db, "fl_label") | ||
| 68 | + : 0; | ||
| 69 | + | ||
| 70 | + DateTime? lastUsed = null; | ||
| 71 | + foreach (var table in new[] { "fl_group", "location", "fl_label" }) | ||
| 72 | + { | ||
| 73 | + if (!names.Contains(table)) | ||
| 74 | + { | ||
| 75 | + continue; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + var ts = await db.Ado.SqlQuerySingleAsync<DateTime?>( | ||
| 79 | + $"SELECT MAX(COALESCE(`LastModificationTime`, `CreationTime`)) FROM `{table}` WHERE IFNULL(`IsDeleted`,0)=0"); | ||
| 80 | + if (ts is { Year: >= 1971 } value && (lastUsed is null || value > lastUsed)) | ||
| 81 | + { | ||
| 82 | + lastUsed = value; | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + return new ThPlatformTenantStatSnapshot | ||
| 87 | + { | ||
| 88 | + TenantId = tenant.Id, | ||
| 89 | + CompanyName = tenant.Name, | ||
| 90 | + RegionCount = region, | ||
| 91 | + LocationCount = location, | ||
| 92 | + LabelCount = label, | ||
| 93 | + LastUsedAt = lastUsed | ||
| 94 | + }; | ||
| 95 | + } | ||
| 96 | + catch | ||
| 97 | + { | ||
| 98 | + return new ThPlatformTenantStatSnapshot | ||
| 99 | + { | ||
| 100 | + TenantId = tenant.Id, | ||
| 101 | + CompanyName = tenant.Name | ||
| 102 | + }; | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /// <summary> | ||
| 107 | + /// 限制并发读取多个租户统计 | ||
| 108 | + /// </summary> | ||
| 109 | + public async Task<List<ThPlatformTenantStatSnapshot>> ReadManyAsync(IReadOnlyList<TenantAggregateRoot> tenants) | ||
| 110 | + { | ||
| 111 | + var result = new ThPlatformTenantStatSnapshot[tenants.Count]; | ||
| 112 | + using var gate = new SemaphoreSlim(MaxConcurrency); | ||
| 113 | + var tasks = tenants.Select(async (tenant, index) => | ||
| 114 | + { | ||
| 115 | + await gate.WaitAsync(); | ||
| 116 | + try | ||
| 117 | + { | ||
| 118 | + result[index] = await ReadAsync(tenant); | ||
| 119 | + } | ||
| 120 | + finally | ||
| 121 | + { | ||
| 122 | + gate.Release(); | ||
| 123 | + } | ||
| 124 | + }); | ||
| 125 | + await Task.WhenAll(tasks); | ||
| 126 | + return result.ToList(); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + private static async Task<int> ScalarCountAsync(ISqlSugarClient db, string table) | ||
| 130 | + { | ||
| 131 | + var value = await db.Ado.GetIntAsync( | ||
| 132 | + $"SELECT COUNT(1) FROM `{table}` WHERE IFNULL(`IsDeleted`,0)=0"); | ||
| 133 | + return value; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + private async Task PersistTenantAsync(TenantAggregateRoot tenant) | ||
| 137 | + { | ||
| 138 | + using (_currentTenant.Change(null)) | ||
| 139 | + { | ||
| 140 | + await _tenantRepository.UpdateAsync(tenant); | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | +} | ||
| 144 | + | ||
| 145 | +/// <summary> | ||
| 146 | +/// 单个租户统计快照 | ||
| 147 | +/// </summary> | ||
| 148 | +public sealed class ThPlatformTenantStatSnapshot | ||
| 149 | +{ | ||
| 150 | + public Guid TenantId { get; init; } | ||
| 151 | + | ||
| 152 | + public string CompanyName { get; init; } = string.Empty; | ||
| 153 | + | ||
| 154 | + public int RegionCount { get; init; } | ||
| 155 | + | ||
| 156 | + public int LocationCount { get; init; } | ||
| 157 | + | ||
| 158 | + public int LabelCount { get; init; } | ||
| 159 | + | ||
| 160 | + public DateTime? LastUsedAt { get; init; } | ||
| 161 | +} |
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThTenantHostDataAccessor.cs
| @@ -17,7 +17,7 @@ internal static class ThTenantHostDataAccessor | @@ -17,7 +17,7 @@ internal static class ThTenantHostDataAccessor | ||
| 17 | { | 17 | { |
| 18 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) | 18 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) |
| 19 | { | 19 | { |
| 20 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 20 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | var dbType = dbConnOptions.DbType ?? DbType.MySql; | 23 | var dbType = dbConnOptions.DbType ?? DbType.MySql; |
| @@ -32,7 +32,7 @@ internal static class ThTenantHostDataAccessor | @@ -32,7 +32,7 @@ internal static class ThTenantHostDataAccessor | ||
| 32 | { | 32 | { |
| 33 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) | 33 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) |
| 34 | { | 34 | { |
| 35 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 35 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | var dbType = dbConnOptions.DbType ?? DbType.MySql; | 38 | var dbType = dbConnOptions.DbType ?? DbType.MySql; |
| @@ -154,7 +154,7 @@ internal static class ThTenantHostDataAccessor | @@ -154,7 +154,7 @@ internal static class ThTenantHostDataAccessor | ||
| 154 | { | 154 | { |
| 155 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) | 155 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) |
| 156 | { | 156 | { |
| 157 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 157 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | var dbType = dbConnOptions.DbType ?? DbType.MySql; | 160 | var dbType = dbConnOptions.DbType ?? DbType.MySql; |
| @@ -170,7 +170,7 @@ internal static class ThTenantHostDataAccessor | @@ -170,7 +170,7 @@ internal static class ThTenantHostDataAccessor | ||
| 170 | { | 170 | { |
| 171 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) | 171 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) |
| 172 | { | 172 | { |
| 173 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 173 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | var dbType = dbConnOptions.DbType ?? DbType.MySql; | 176 | var dbType = dbConnOptions.DbType ?? DbType.MySql; |
| @@ -185,7 +185,7 @@ internal static class ThTenantHostDataAccessor | @@ -185,7 +185,7 @@ internal static class ThTenantHostDataAccessor | ||
| 185 | { | 185 | { |
| 186 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) | 186 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) |
| 187 | { | 187 | { |
| 188 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 188 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | var dbType = dbConnOptions.DbType ?? DbType.MySql; | 191 | var dbType = dbConnOptions.DbType ?? DbType.MySql; |
| @@ -195,7 +195,7 @@ internal static class ThTenantHostDataAccessor | @@ -195,7 +195,7 @@ internal static class ThTenantHostDataAccessor | ||
| 195 | .ExecuteCommandAsync(); | 195 | .ExecuteCommandAsync(); |
| 196 | if (rows <= 0) | 196 | if (rows <= 0) |
| 197 | { | 197 | { |
| 198 | - throw new UserFriendlyException("主库菜单更新失败(未影响任何行)"); | 198 | + throw new UserFriendlyException("Host menu update failed (no rows affected)."); |
| 199 | } | 199 | } |
| 200 | } | 200 | } |
| 201 | 201 | ||
| @@ -203,7 +203,7 @@ internal static class ThTenantHostDataAccessor | @@ -203,7 +203,7 @@ internal static class ThTenantHostDataAccessor | ||
| 203 | { | 203 | { |
| 204 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) | 204 | if (string.IsNullOrWhiteSpace(dbConnOptions.Url)) |
| 205 | { | 205 | { |
| 206 | - throw new UserFriendlyException("未配置主库连接字符串 DbConnOptions.Url"); | 206 | + throw new UserFriendlyException("Host database connection string DbConnOptions.Url is not configured."); |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | var dbType = dbConnOptions.DbType ?? DbType.MySql; | 209 | var dbType = dbConnOptions.DbType ?? DbType.MySql; |