Commit 9b25efa4c750eb7ab21cb3b8677bf68794c31a2e
Merge branch 'main' of http://39.98.150.180/wangming/Food-Labeling-Management-Platform
Showing
63 changed files
with
1653 additions
and
472 deletions
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs
| @@ -8,6 +8,9 @@ public class DashboardOverviewOutputDto | @@ -8,6 +8,9 @@ public class DashboardOverviewOutputDto | ||
| 8 | /// <summary>今日打印标签</summary> | 8 | /// <summary>今日打印标签</summary> |
| 9 | public DashboardMetricCardDto LabelsPrintedToday { get; set; } = new(); | 9 | public DashboardMetricCardDto LabelsPrintedToday { get; set; } = new(); |
| 10 | 10 | ||
| 11 | + /// <summary>标签总数(<c>fl_label</c>,与 Label 列表可见范围一致)</summary> | ||
| 12 | + public DashboardMetricCardDto Labels { get; set; } = new(); | ||
| 13 | + | ||
| 11 | /// <summary>启用模板数</summary> | 14 | /// <summary>启用模板数</summary> |
| 12 | public DashboardMetricCardDto ActiveTemplates { get; set; } = new(); | 15 | public DashboardMetricCardDto ActiveTemplates { get; set; } = new(); |
| 13 | 16 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/UsAppLabelPreviewDto.cs
| @@ -49,8 +49,16 @@ public class UsAppLabelPreviewDto | @@ -49,8 +49,16 @@ public class UsAppLabelPreviewDto | ||
| 49 | 49 | ||
| 50 | /// <summary> | 50 | /// <summary> |
| 51 | /// 当前预览上下文(模板+产品+标签类型)命中的默认值配置。 | 51 | /// 当前预览上下文(模板+产品+标签类型)命中的默认值配置。 |
| 52 | - /// 数据来源:fl_label_template_product_default.DefaultValuesJson | 52 | + /// 数据来源:fl_label_template_product_default.DefaultValuesJson,并与标签 |
| 53 | + /// <c>LabelInfoJson.templateInputValues</c> 合并(标签级优先)。 | ||
| 54 | + /// Nutrition Facts 元素的值为营养成分 JSON 字符串。 | ||
| 53 | /// </summary> | 55 | /// </summary> |
| 54 | public Dictionary<string, object?>? TemplateProductDefaultValues { get; set; } | 56 | public Dictionary<string, object?>? TemplateProductDefaultValues { get; set; } |
| 57 | + | ||
| 58 | + /// <summary> | ||
| 59 | + /// Nutrition Facts 元素已保存的营养成分表(elementId → 字段字典)。 | ||
| 60 | + /// 来源:标签 <c>templateInputValues</c> / 产品模板默认值中该元素对应的 JSON。 | ||
| 61 | + /// </summary> | ||
| 62 | + public Dictionary<string, Dictionary<string, string>> NutritionByElementId { get; set; } = new(); | ||
| 55 | } | 63 | } |
| 56 | 64 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IDashboardAppService.cs
| @@ -14,7 +14,10 @@ public interface IDashboardAppService : IApplicationService | @@ -14,7 +14,10 @@ public interface IDashboardAppService : IApplicationService | ||
| 14 | /// <remarks> | 14 | /// <remarks> |
| 15 | /// 按 Token 数据范围统计:<b>系统管理员</b>为全平台;<b>其它账号</b>仅统计其 <c>userlocation</c> 绑定门店所属公司范围内数据。 | 15 | /// 按 Token 数据范围统计:<b>系统管理员</b>为全平台;<b>其它账号</b>仅统计其 <c>userlocation</c> 绑定门店所属公司范围内数据。 |
| 16 | /// <c>companies</c> 统计可见 <c>fl_partner</c> 数;<c>regions</c> 统计可见 <c>fl_group</c> 数(与 Region 列表同一套 scope)。 | 16 | /// <c>companies</c> 统计可见 <c>fl_partner</c> 数;<c>regions</c> 统计可见 <c>fl_group</c> 数(与 Region 列表同一套 scope)。 |
| 17 | - /// <c>activeUsers</c> / <c>people</c> 仅统计有门店绑定的成员,且<b>不包含</b>内置系统 admin(用户名 <c>admin</c> 或角色码 <c>admin</c>)。 | 17 | + /// <c>labels</c> 统计可见 <c>fl_label</c> 总数(与 Label 列表无额外筛选时同一套 scope)。 |
| 18 | + /// <c>activeTemplates</c> 统计可见且启用的 <c>fl_label_template</c> 数(与 Label Templates 列表无额外筛选时同一套 scope)。 | ||
| 19 | + /// <c>people</c> 为注册用户数(与 Team Member 列表 TotalCount 一致);<c>activeUsers</c> 为其中 <c>State=true</c> 的用户数。 | ||
| 20 | + /// 系统 Admin 统计全部未删 User;非 Admin 仅统计在可见门店有 <c>userlocation</c> 绑定的用户。 | ||
| 18 | /// <c>recentLabels[].labelCode</c> 为门店当日打印序号 <c>yyyyMMdd-n</c>,规则与 <c>POST /api/app/us-app-labeling/preview</c>、print-log 一致。 | 21 | /// <c>recentLabels[].labelCode</c> 为门店当日打印序号 <c>yyyyMMdd-n</c>,规则与 <c>POST /api/app/us-app-labeling/preview</c>、print-log 一致。 |
| 19 | /// </remarks> | 22 | /// </remarks> |
| 20 | Task<DashboardOverviewOutputDto> GetOverviewAsync(); | 23 | Task<DashboardOverviewOutputDto> GetOverviewAsync(); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IGroupAppService.cs
| @@ -44,13 +44,23 @@ public interface IGroupAppService : IApplicationService | @@ -44,13 +44,23 @@ public interface IGroupAppService : IApplicationService | ||
| 44 | /// 若 <c>groupName</c> 相对原值发生变化(忽略大小写与首尾空格),会同步更新未删除门店 | 44 | /// 若 <c>groupName</c> 相对原值发生变化(忽略大小写与首尾空格),会同步更新未删除门店 |
| 45 | /// <c>location.GroupName</c>(精确匹配旧 Region 名称,且 <c>location.Partner</c> 与当前 Region 所属公司名称一致), | 45 | /// <c>location.GroupName</c>(精确匹配旧 Region 名称,且 <c>location.Partner</c> 与当前 Region 所属公司名称一致), |
| 46 | /// 避免跨公司同名 Region 误更新。 | 46 | /// 避免跨公司同名 Region 误更新。 |
| 47 | + /// 若 <c>State</c> 从 <c>true</c> 变为 <c>false</c>,级联停用其下全部 Location, | ||
| 48 | + /// 软删这些门店的 <c>userlocation</c> 绑定(不停用成员、不解绑其它门店); | ||
| 49 | + /// 若存在 <c>fl_team_member_region</c> 则删除该 Region 的成员关联; | ||
| 50 | + /// inactive→active 不自动恢复下级或绑定;已 inactive 再次保存不重复级联。 | ||
| 47 | /// </remarks> | 51 | /// </remarks> |
| 48 | Task<GroupGetOutputDto> UpdateAsync(Guid id, GroupUpdateInputVo input); | 52 | Task<GroupGetOutputDto> UpdateAsync(Guid id, GroupUpdateInputVo input); |
| 49 | 53 | ||
| 50 | /// <summary> | 54 | /// <summary> |
| 51 | /// 删除组织(逻辑删除) | 55 | /// 删除组织(逻辑删除) |
| 52 | /// </summary> | 56 | /// </summary> |
| 53 | - Task DeleteAsync(Guid id); | 57 | + /// <remarks> |
| 58 | + /// 默认强制自下而上:若 Region 下仍有未删除门店,返回英文提示并拒绝删除。 | ||
| 59 | + /// 传 <c>confirmCascade=true</c> 时,会先软删该 Region 下全部门店并清理 <c>userlocation</c>,再软删 Region。 | ||
| 60 | + /// </remarks> | ||
| 61 | + /// <param name="id">主键 Id</param> | ||
| 62 | + /// <param name="confirmCascade">为 <c>true</c> 时级联软删下级门店;默认 <c>false</c></param> | ||
| 63 | + Task DeleteAsync(Guid id, bool confirmCascade = false); | ||
| 54 | 64 | ||
| 55 | /// <summary> | 65 | /// <summary> |
| 56 | /// 按列表相同筛选条件全量导出组织(Region)为 PDF(不分页;与 <see cref="GetListAsync"/> 相同筛选与 Token 数据范围;单次最多 5000 条) | 66 | /// 按列表相同筛选条件全量导出组织(Region)为 PDF(不分页;与 <see cref="GetListAsync"/> 相同筛选与 Token 数据范围;单次最多 5000 条) |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILocationAppService.cs
| @@ -28,6 +28,10 @@ public interface ILocationAppService : IApplicationService | @@ -28,6 +28,10 @@ public interface ILocationAppService : IApplicationService | ||
| 28 | /// </summary> | 28 | /// </summary> |
| 29 | /// <param name="id">门店Id</param> | 29 | /// <param name="id">门店Id</param> |
| 30 | /// <param name="input">门店信息</param> | 30 | /// <param name="input">门店信息</param> |
| 31 | + /// <remarks> | ||
| 32 | + /// 若 <c>State</c> 从 <c>true</c> 变为 <c>false</c>,软删该门店的 <c>userlocation</c> 绑定(不停用成员); | ||
| 33 | + /// inactive→active 不自动恢复绑定;已 inactive 再次保存不重复级联。批量编辑经本方法逐条处理,同样生效。 | ||
| 34 | + /// </remarks> | ||
| 31 | Task<LocationGetListOutputDto> UpdateAsync(Guid id, LocationUpdateInputVo input); | 35 | Task<LocationGetListOutputDto> UpdateAsync(Guid id, LocationUpdateInputVo input); |
| 32 | 36 | ||
| 33 | /// <summary> | 37 | /// <summary> |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IPartnerAppService.cs
| @@ -74,6 +74,9 @@ public interface IPartnerAppService : IApplicationService | @@ -74,6 +74,9 @@ public interface IPartnerAppService : IApplicationService | ||
| 74 | /// <remarks> | 74 | /// <remarks> |
| 75 | /// 若 <c>partnerName</c> 相对原值发生变化(忽略大小写与首尾空格),会同步更新未删除门店 | 75 | /// 若 <c>partnerName</c> 相对原值发生变化(忽略大小写与首尾空格),会同步更新未删除门店 |
| 76 | /// <c>location.Partner</c>(精确匹配旧公司名称),以保持门店/产品/标签按名称解析的绑定关系。 | 76 | /// <c>location.Partner</c>(精确匹配旧公司名称),以保持门店/产品/标签按名称解析的绑定关系。 |
| 77 | + /// 若 <c>State</c> 从 <c>true</c> 变为 <c>false</c>,级联停用其下全部 Region、Location, | ||
| 78 | + /// 并将经该公司门店 <c>userlocation</c> 绑定的 Team Member 设为 <c>State=false</c>; | ||
| 79 | + /// inactive→active 不自动恢复下级或绑定;已 inactive 再次保存不重复级联。 | ||
| 77 | /// </remarks> | 80 | /// </remarks> |
| 78 | /// <response code="200">成功</response> | 81 | /// <response code="200">成功</response> |
| 79 | /// <response code="400">校验失败或记录不存在</response> | 82 | /// <response code="400">校验失败或记录不存在</response> |
| @@ -83,11 +86,16 @@ public interface IPartnerAppService : IApplicationService | @@ -83,11 +86,16 @@ public interface IPartnerAppService : IApplicationService | ||
| 83 | /// <summary> | 86 | /// <summary> |
| 84 | /// 删除合作伙伴(逻辑删除) | 87 | /// 删除合作伙伴(逻辑删除) |
| 85 | /// </summary> | 88 | /// </summary> |
| 89 | + /// <remarks> | ||
| 90 | + /// 默认强制自下而上:若 Company 下仍有未删除 Region 或 Location,返回英文提示并拒绝删除。 | ||
| 91 | + /// 传 <c>confirmCascade=true</c> 时,会先软删全部门店并清理 <c>userlocation</c>,再软删全部 Region,最后软删 Company。 | ||
| 92 | + /// </remarks> | ||
| 86 | /// <param name="id">主键 Id</param> | 93 | /// <param name="id">主键 Id</param> |
| 94 | + /// <param name="confirmCascade">为 <c>true</c> 时级联软删下级 Region 与 Location;默认 <c>false</c></param> | ||
| 87 | /// <response code="200">成功</response> | 95 | /// <response code="200">成功</response> |
| 88 | - /// <response code="400">Id 无效或记录不存在</response> | 96 | + /// <response code="400">Id 无效、记录不存在或存在下级需先删除/确认级联</response> |
| 89 | /// <response code="500">服务器错误</response> | 97 | /// <response code="500">服务器错误</response> |
| 90 | - Task DeleteAsync(Guid id); | 98 | + Task DeleteAsync(Guid id, bool confirmCascade = false); |
| 91 | 99 | ||
| 92 | /// <summary> | 100 | /// <summary> |
| 93 | /// 按当前列表筛选条件批量导出合作伙伴为 PDF(Account Management「Company」页签;不分页,上限 5000 条) | 101 | /// 按当前列表筛选条件批量导出合作伙伴为 PDF(Account Management「Company」页签;不分页,上限 5000 条) |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IUsAppLabelingAppService.cs
| @@ -18,6 +18,7 @@ public interface IUsAppLabelingAppService : IApplicationService | @@ -18,6 +18,7 @@ public interface IUsAppLabelingAppService : IApplicationService | ||
| 18 | /// <summary> | 18 | /// <summary> |
| 19 | /// App 打印预览:按标签编码解析模板并返回顶部展示字段 + 预览模板结构。 | 19 | /// App 打印预览:按标签编码解析模板并返回顶部展示字段 + 预览模板结构。 |
| 20 | /// 出参 <c>labelId</c> 为门店当日**下一个**打印序号(<c>yyyyMMdd-n</c>),非 <c>fl_label.Id</c>。 | 20 | /// 出参 <c>labelId</c> 为门店当日**下一个**打印序号(<c>yyyyMMdd-n</c>),非 <c>fl_label.Id</c>。 |
| 21 | + /// 出参 <c>nutritionByElementId</c> / <c>templateProductDefaultValues</c> 含 Nutrition Facts 已保存 JSON。 | ||
| 21 | /// </summary> | 22 | /// </summary> |
| 22 | Task<UsAppLabelPreviewDto> PreviewAsync(UsAppLabelPreviewInputVo input); | 23 | Task<UsAppLabelPreviewDto> PreviewAsync(UsAppLabelPreviewInputVo input); |
| 23 | 24 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs
0 → 100644
| 1 | +using FoodLabeling.Application.Services.DbModels; | ||
| 2 | +using FoodLabeling.Domain.Entities; | ||
| 3 | +using SqlSugar; | ||
| 4 | +using Volo.Abp; | ||
| 5 | + | ||
| 6 | +namespace FoodLabeling.Application.Helpers; | ||
| 7 | + | ||
| 8 | +/// <summary> | ||
| 9 | +/// Account Management 结构(Company / Region / Location)级联软删与 <c>userlocation</c> 清理。 | ||
| 10 | +/// </summary> | ||
| 11 | +public static class AccountStructureCascadeDeleteHelper | ||
| 12 | +{ | ||
| 13 | + /// <summary> | ||
| 14 | + /// 软删单个门店;影响行数为 0 时抛出 <see cref="UserFriendlyException"/>。 | ||
| 15 | + /// </summary> | ||
| 16 | + public static async Task SoftDeleteLocationAsync( | ||
| 17 | + ISqlSugarClient db, | ||
| 18 | + Guid locationId, | ||
| 19 | + DateTime now, | ||
| 20 | + Guid? modifierId) | ||
| 21 | + { | ||
| 22 | + var affected = await db.Updateable<LocationAggregateRoot>() | ||
| 23 | + .SetColumns(x => new LocationAggregateRoot | ||
| 24 | + { | ||
| 25 | + IsDeleted = true, | ||
| 26 | + LastModificationTime = now, | ||
| 27 | + LastModifierId = modifierId | ||
| 28 | + }) | ||
| 29 | + .Where(x => x.Id == locationId && !x.IsDeleted) | ||
| 30 | + .ExecuteCommandAsync(); | ||
| 31 | + | ||
| 32 | + if (affected == 0) | ||
| 33 | + { | ||
| 34 | + throw new UserFriendlyException("Location not found."); | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /// <summary> | ||
| 39 | + /// 统计 Region 下未删除门店数(按公司名称 + Region 名称精确匹配)。 | ||
| 40 | + /// </summary> | ||
| 41 | + public static Task<int> CountActiveLocationsByPartnerAndGroupAsync( | ||
| 42 | + ISqlSugarClient db, | ||
| 43 | + string partnerName, | ||
| 44 | + string groupName) | ||
| 45 | + { | ||
| 46 | + return db.Queryable<LocationAggregateRoot>() | ||
| 47 | + .Where(x => !x.IsDeleted && | ||
| 48 | + x.Partner == partnerName && | ||
| 49 | + x.GroupName == groupName) | ||
| 50 | + .CountAsync(); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /// <summary> | ||
| 54 | + /// 统计 Company 下未删除 Region 数。 | ||
| 55 | + /// </summary> | ||
| 56 | + public static Task<int> CountActiveGroupsByPartnerIdAsync(ISqlSugarClient db, string partnerId) | ||
| 57 | + { | ||
| 58 | + return db.Queryable<FlGroupDbEntity>() | ||
| 59 | + .Where(x => !x.IsDeleted && x.PartnerId == partnerId) | ||
| 60 | + .CountAsync(); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /// <summary> | ||
| 64 | + /// 统计 Company 下未删除门店数(按公司名称匹配 <c>location.Partner</c>)。 | ||
| 65 | + /// </summary> | ||
| 66 | + public static Task<int> CountActiveLocationsByPartnerNameAsync(ISqlSugarClient db, string partnerName) | ||
| 67 | + { | ||
| 68 | + return db.Queryable<LocationAggregateRoot>() | ||
| 69 | + .Where(x => !x.IsDeleted && x.Partner == partnerName) | ||
| 70 | + .CountAsync(); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /// <summary> | ||
| 74 | + /// 软删指定 Company + Region 下全部门店,并清理相关 <c>userlocation</c> 绑定。 | ||
| 75 | + /// </summary> | ||
| 76 | + public static async Task SoftDeleteLocationsByPartnerAndGroupAsync( | ||
| 77 | + ISqlSugarClient db, | ||
| 78 | + string partnerName, | ||
| 79 | + string groupName, | ||
| 80 | + DateTime now, | ||
| 81 | + Guid? modifierId, | ||
| 82 | + string? userLocationModifierId) | ||
| 83 | + { | ||
| 84 | + var locationIds = await db.Queryable<LocationAggregateRoot>() | ||
| 85 | + .Where(x => !x.IsDeleted && | ||
| 86 | + x.Partner == partnerName && | ||
| 87 | + x.GroupName == groupName) | ||
| 88 | + .Select(x => x.Id) | ||
| 89 | + .ToListAsync(); | ||
| 90 | + | ||
| 91 | + if (locationIds.Count == 0) | ||
| 92 | + { | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + await SoftDeleteLocationsByIdsAsync(db, locationIds, now, modifierId); | ||
| 97 | + await SoftDeleteUserLocationBindingsAsync(db, locationIds, now, userLocationModifierId); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /// <summary> | ||
| 101 | + /// 软删指定 Company 下全部门店,并清理相关 <c>userlocation</c> 绑定。 | ||
| 102 | + /// </summary> | ||
| 103 | + public static async Task SoftDeleteLocationsByPartnerNameAsync( | ||
| 104 | + ISqlSugarClient db, | ||
| 105 | + string partnerName, | ||
| 106 | + DateTime now, | ||
| 107 | + Guid? modifierId, | ||
| 108 | + string? userLocationModifierId) | ||
| 109 | + { | ||
| 110 | + var locationIds = await db.Queryable<LocationAggregateRoot>() | ||
| 111 | + .Where(x => !x.IsDeleted && x.Partner == partnerName) | ||
| 112 | + .Select(x => x.Id) | ||
| 113 | + .ToListAsync(); | ||
| 114 | + | ||
| 115 | + if (locationIds.Count == 0) | ||
| 116 | + { | ||
| 117 | + return; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + await SoftDeleteLocationsByIdsAsync(db, locationIds, now, modifierId); | ||
| 121 | + await SoftDeleteUserLocationBindingsAsync(db, locationIds, now, userLocationModifierId); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + /// <summary> | ||
| 125 | + /// 软删指定 Company 下全部 Region。 | ||
| 126 | + /// </summary> | ||
| 127 | + public static async Task SoftDeleteGroupsByPartnerIdAsync( | ||
| 128 | + ISqlSugarClient db, | ||
| 129 | + string partnerId, | ||
| 130 | + DateTime now, | ||
| 131 | + string? modifierId) | ||
| 132 | + { | ||
| 133 | + await db.Updateable<FlGroupDbEntity>() | ||
| 134 | + .SetColumns(x => new FlGroupDbEntity | ||
| 135 | + { | ||
| 136 | + IsDeleted = true, | ||
| 137 | + LastModificationTime = now, | ||
| 138 | + LastModifierId = modifierId | ||
| 139 | + }) | ||
| 140 | + .Where(x => !x.IsDeleted && x.PartnerId == partnerId) | ||
| 141 | + .ExecuteCommandAsync(); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /// <summary> | ||
| 145 | + /// 软删单个 Region。 | ||
| 146 | + /// </summary> | ||
| 147 | + public static async Task SoftDeleteGroupAsync( | ||
| 148 | + ISqlSugarClient db, | ||
| 149 | + string groupId, | ||
| 150 | + DateTime now, | ||
| 151 | + string? modifierId) | ||
| 152 | + { | ||
| 153 | + var affected = await db.Updateable<FlGroupDbEntity>() | ||
| 154 | + .SetColumns(x => new FlGroupDbEntity | ||
| 155 | + { | ||
| 156 | + IsDeleted = true, | ||
| 157 | + LastModificationTime = now, | ||
| 158 | + LastModifierId = modifierId | ||
| 159 | + }) | ||
| 160 | + .Where(x => !x.IsDeleted && x.Id == groupId) | ||
| 161 | + .ExecuteCommandAsync(); | ||
| 162 | + | ||
| 163 | + if (affected == 0) | ||
| 164 | + { | ||
| 165 | + throw new UserFriendlyException("Group not found."); | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + /// <summary> | ||
| 170 | + /// 软删单个 Company。 | ||
| 171 | + /// </summary> | ||
| 172 | + public static async Task SoftDeletePartnerAsync( | ||
| 173 | + ISqlSugarClient db, | ||
| 174 | + string partnerId, | ||
| 175 | + DateTime now, | ||
| 176 | + string? modifierId) | ||
| 177 | + { | ||
| 178 | + var affected = await db.Updateable<FlPartnerDbEntity>() | ||
| 179 | + .SetColumns(x => new FlPartnerDbEntity | ||
| 180 | + { | ||
| 181 | + IsDeleted = true, | ||
| 182 | + LastModificationTime = now, | ||
| 183 | + LastModifierId = modifierId | ||
| 184 | + }) | ||
| 185 | + .Where(x => !x.IsDeleted && x.Id == partnerId) | ||
| 186 | + .ExecuteCommandAsync(); | ||
| 187 | + | ||
| 188 | + if (affected == 0) | ||
| 189 | + { | ||
| 190 | + throw new UserFriendlyException("Partner not found."); | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + /// <summary> | ||
| 195 | + /// 清理单个门店的 <c>userlocation</c> 绑定(逻辑删除)。 | ||
| 196 | + /// </summary> | ||
| 197 | + public static Task SoftDeleteUserLocationBindingsForLocationAsync( | ||
| 198 | + ISqlSugarClient db, | ||
| 199 | + Guid locationId, | ||
| 200 | + DateTime now, | ||
| 201 | + string? modifierId) | ||
| 202 | + { | ||
| 203 | + return SoftDeleteUserLocationBindingsAsync(db, new[] { locationId }, now, modifierId); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + /// <summary> | ||
| 207 | + /// 清理指定门店 Id 列表对应的 <c>userlocation</c> 绑定(逻辑删除)。 | ||
| 208 | + /// </summary> | ||
| 209 | + public static Task SoftDeleteUserLocationBindingsAsync( | ||
| 210 | + ISqlSugarClient db, | ||
| 211 | + IReadOnlyList<Guid> locationIds, | ||
| 212 | + DateTime now, | ||
| 213 | + string? modifierId) => | ||
| 214 | + SoftDeleteUserLocationBindingsCoreAsync(db, locationIds, now, modifierId); | ||
| 215 | + | ||
| 216 | + /// <summary> | ||
| 217 | + /// Region 存在下级门店且未确认级联删除时的提示文案。 | ||
| 218 | + /// </summary> | ||
| 219 | + public static string BuildGroupCascadeRequiredMessage(int locationCount) => | ||
| 220 | + $"This region has {locationCount} location(s). Delete locations first (bottom-up), " + | ||
| 221 | + "or call DELETE again with confirmCascade=true to also soft-delete all child locations."; | ||
| 222 | + | ||
| 223 | + /// <summary> | ||
| 224 | + /// Company 存在下级 Region/Location 且未确认级联删除时的提示文案。 | ||
| 225 | + /// </summary> | ||
| 226 | + public static string BuildPartnerCascadeRequiredMessage(int groupCount, int locationCount) => | ||
| 227 | + $"This company has {groupCount} region(s) and {locationCount} location(s). " + | ||
| 228 | + "Delete child regions and locations first (bottom-up), " + | ||
| 229 | + "or call DELETE again with confirmCascade=true to also soft-delete all child regions and locations."; | ||
| 230 | + | ||
| 231 | + private static async Task SoftDeleteLocationsByIdsAsync( | ||
| 232 | + ISqlSugarClient db, | ||
| 233 | + IReadOnlyList<Guid> locationIds, | ||
| 234 | + DateTime now, | ||
| 235 | + Guid? modifierId) | ||
| 236 | + { | ||
| 237 | + if (locationIds.Count == 0) | ||
| 238 | + { | ||
| 239 | + return; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + await db.Updateable<LocationAggregateRoot>() | ||
| 243 | + .SetColumns(x => new LocationAggregateRoot | ||
| 244 | + { | ||
| 245 | + IsDeleted = true, | ||
| 246 | + LastModificationTime = now, | ||
| 247 | + LastModifierId = modifierId | ||
| 248 | + }) | ||
| 249 | + .Where(x => !x.IsDeleted && locationIds.Contains(x.Id)) | ||
| 250 | + .ExecuteCommandAsync(); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + private static async Task SoftDeleteUserLocationBindingsCoreAsync( | ||
| 254 | + ISqlSugarClient db, | ||
| 255 | + IReadOnlyList<Guid> locationIds, | ||
| 256 | + DateTime now, | ||
| 257 | + string? modifierId) | ||
| 258 | + { | ||
| 259 | + if (locationIds.Count == 0) | ||
| 260 | + { | ||
| 261 | + return; | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + var normalizedKeys = new HashSet<string>( | ||
| 265 | + locationIds | ||
| 266 | + .SelectMany(g => new[] | ||
| 267 | + { | ||
| 268 | + TeamMemberListScopeHelper.NormalizeScopeKey(g.ToString("D")), | ||
| 269 | + TeamMemberListScopeHelper.NormalizeScopeKey(g.ToString("N")) | ||
| 270 | + }) | ||
| 271 | + .Where(x => !string.IsNullOrEmpty(x)), | ||
| 272 | + StringComparer.OrdinalIgnoreCase); | ||
| 273 | + | ||
| 274 | + if (normalizedKeys.Count == 0) | ||
| 275 | + { | ||
| 276 | + return; | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + var bindings = await db.Queryable<UserLocationDbEntity>() | ||
| 280 | + .Where(x => !x.IsDeleted) | ||
| 281 | + .Select(x => new { x.Id, x.LocationId }) | ||
| 282 | + .ToListAsync(); | ||
| 283 | + | ||
| 284 | + var bindingIds = bindings | ||
| 285 | + .Where(x => | ||
| 286 | + { | ||
| 287 | + var key = TeamMemberListScopeHelper.NormalizeScopeKey(x.LocationId); | ||
| 288 | + return !string.IsNullOrEmpty(key) && normalizedKeys.Contains(key); | ||
| 289 | + }) | ||
| 290 | + .Select(x => x.Id) | ||
| 291 | + .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| 292 | + .ToList(); | ||
| 293 | + | ||
| 294 | + if (bindingIds.Count == 0) | ||
| 295 | + { | ||
| 296 | + return; | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + await db.Updateable<UserLocationDbEntity>() | ||
| 300 | + .SetColumns(x => new UserLocationDbEntity | ||
| 301 | + { | ||
| 302 | + IsDeleted = true, | ||
| 303 | + LastModificationTime = now, | ||
| 304 | + LastModifierId = modifierId | ||
| 305 | + }) | ||
| 306 | + .Where(x => bindingIds.Contains(x.Id)) | ||
| 307 | + .ExecuteCommandAsync(); | ||
| 308 | + } | ||
| 309 | +} |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeInactiveHelper.cs
0 → 100644
| 1 | +using FoodLabeling.Application.Services.DbModels; | ||
| 2 | +using FoodLabeling.Domain.Entities; | ||
| 3 | +using SqlSugar; | ||
| 4 | +using Yi.Framework.Rbac.Domain.Entities; | ||
| 5 | + | ||
| 6 | +namespace FoodLabeling.Application.Helpers; | ||
| 7 | + | ||
| 8 | +/// <summary> | ||
| 9 | +/// Account Management 结构(Company / Region / Location)停用(<c>State=false</c>)时的级联处理。 | ||
| 10 | +/// 仅在 <c>旧 State==true</c> 且 <c>新 State==false</c> 时触发;inactive→active 不自动恢复下级或绑定。 | ||
| 11 | +/// </summary> | ||
| 12 | +public static class AccountStructureCascadeInactiveHelper | ||
| 13 | +{ | ||
| 14 | + /// <summary> | ||
| 15 | + /// 判断是否从启用变为停用。 | ||
| 16 | + /// </summary> | ||
| 17 | + public static bool IsBecomingInactive(bool wasActive, bool newState) => wasActive && !newState; | ||
| 18 | + | ||
| 19 | + /// <summary> | ||
| 20 | + /// Company 停用时:其下全部 Region、Location 设为 <c>State=false</c>; | ||
| 21 | + /// 经该公司门店 <c>userlocation</c> 绑定的 Team Member 设为 <c>State=false</c>(不解绑 <c>userlocation</c>)。 | ||
| 22 | + /// </summary> | ||
| 23 | + public static async Task CascadePartnerInactiveAsync( | ||
| 24 | + ISqlSugarClient db, | ||
| 25 | + string partnerId, | ||
| 26 | + DateTime now, | ||
| 27 | + Guid? modifierId) | ||
| 28 | + { | ||
| 29 | + var modifierIdString = modifierId?.ToString(); | ||
| 30 | + | ||
| 31 | + await db.Updateable<FlGroupDbEntity>() | ||
| 32 | + .SetColumns(x => new FlGroupDbEntity | ||
| 33 | + { | ||
| 34 | + State = false, | ||
| 35 | + LastModificationTime = now, | ||
| 36 | + LastModifierId = modifierIdString | ||
| 37 | + }) | ||
| 38 | + .Where(x => !x.IsDeleted && x.PartnerId == partnerId && x.State) | ||
| 39 | + .ExecuteCommandAsync(); | ||
| 40 | + | ||
| 41 | + var locationIdStrings = await LocationScopeBindingHelper.ResolveLocationIdsFromPartnerIdsAsync( | ||
| 42 | + db, | ||
| 43 | + new[] { partnerId }); | ||
| 44 | + | ||
| 45 | + await DeactivateLocationsByIdsAsync(db, locationIdStrings, now, modifierId); | ||
| 46 | + await DeactivateUsersBoundToLocationsAsync(db, locationIdStrings, now, modifierId); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /// <summary> | ||
| 50 | + /// Region 停用时:其下全部 Location 设为 <c>State=false</c>; | ||
| 51 | + /// 软删这些门店的 <c>userlocation</c> 绑定(不解绑其它门店、不停用成员); | ||
| 52 | + /// 若存在 <c>fl_team_member_region</c> 表则删除该 Region 的成员关联。 | ||
| 53 | + /// </summary> | ||
| 54 | + public static async Task CascadeGroupInactiveAsync( | ||
| 55 | + ISqlSugarClient db, | ||
| 56 | + string groupId, | ||
| 57 | + DateTime now, | ||
| 58 | + Guid? modifierId, | ||
| 59 | + string? userLocationModifierId) | ||
| 60 | + { | ||
| 61 | + var locationIdStrings = await LocationScopeBindingHelper.ResolveLocationIdsFromGroupIdsAsync( | ||
| 62 | + db, | ||
| 63 | + new[] { groupId }); | ||
| 64 | + | ||
| 65 | + await DeactivateLocationsByIdsAsync(db, locationIdStrings, now, modifierId); | ||
| 66 | + | ||
| 67 | + var locationGuids = ParseLocationGuids(locationIdStrings); | ||
| 68 | + if (locationGuids.Count > 0) | ||
| 69 | + { | ||
| 70 | + await AccountStructureCascadeDeleteHelper.SoftDeleteUserLocationBindingsAsync( | ||
| 71 | + db, | ||
| 72 | + locationGuids, | ||
| 73 | + now, | ||
| 74 | + userLocationModifierId); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + await TryDeleteTeamMemberRegionByGroupIdAsync(db, groupId); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /// <summary> | ||
| 81 | + /// Location 停用时:软删该门店的 <c>userlocation</c> 绑定(不停用成员)。 | ||
| 82 | + /// </summary> | ||
| 83 | + public static Task CascadeLocationInactiveAsync( | ||
| 84 | + ISqlSugarClient db, | ||
| 85 | + Guid locationId, | ||
| 86 | + DateTime now, | ||
| 87 | + string? userLocationModifierId) => | ||
| 88 | + AccountStructureCascadeDeleteHelper.SoftDeleteUserLocationBindingsForLocationAsync( | ||
| 89 | + db, | ||
| 90 | + locationId, | ||
| 91 | + now, | ||
| 92 | + userLocationModifierId); | ||
| 93 | + | ||
| 94 | + private static async Task DeactivateLocationsByIdsAsync( | ||
| 95 | + ISqlSugarClient db, | ||
| 96 | + IReadOnlyList<string> locationIdStrings, | ||
| 97 | + DateTime now, | ||
| 98 | + Guid? modifierId) | ||
| 99 | + { | ||
| 100 | + var locationGuids = ParseLocationGuids(locationIdStrings); | ||
| 101 | + if (locationGuids.Count == 0) | ||
| 102 | + { | ||
| 103 | + return; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + await db.Updateable<LocationAggregateRoot>() | ||
| 107 | + .SetColumns(x => new LocationAggregateRoot | ||
| 108 | + { | ||
| 109 | + State = false, | ||
| 110 | + LastModificationTime = now, | ||
| 111 | + LastModifierId = modifierId | ||
| 112 | + }) | ||
| 113 | + .Where(x => !x.IsDeleted && locationGuids.Contains(x.Id) && x.State) | ||
| 114 | + .ExecuteCommandAsync(); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + private static async Task DeactivateUsersBoundToLocationsAsync( | ||
| 118 | + ISqlSugarClient db, | ||
| 119 | + IReadOnlyList<string> locationIdStrings, | ||
| 120 | + DateTime now, | ||
| 121 | + Guid? modifierId) | ||
| 122 | + { | ||
| 123 | + var userIds = await ResolveUserIdsBoundToLocationIdsAsync(db, locationIdStrings); | ||
| 124 | + if (userIds.Count == 0) | ||
| 125 | + { | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + await db.Updateable<UserAggregateRoot>() | ||
| 130 | + .SetColumns(x => new UserAggregateRoot | ||
| 131 | + { | ||
| 132 | + State = false, | ||
| 133 | + LastModificationTime = now, | ||
| 134 | + LastModifierId = modifierId | ||
| 135 | + }) | ||
| 136 | + .Where(x => !x.IsDeleted && x.State && userIds.Contains(x.Id)) | ||
| 137 | + .ExecuteCommandAsync(); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + private static async Task<List<Guid>> ResolveUserIdsBoundToLocationIdsAsync( | ||
| 141 | + ISqlSugarClient db, | ||
| 142 | + IReadOnlyList<string> locationIdStrings) | ||
| 143 | + { | ||
| 144 | + var normalizedKeys = new HashSet<string>( | ||
| 145 | + locationIdStrings | ||
| 146 | + .Select(id => TeamMemberListScopeHelper.NormalizeScopeKey(id)) | ||
| 147 | + .Where(x => !string.IsNullOrEmpty(x)), | ||
| 148 | + StringComparer.OrdinalIgnoreCase); | ||
| 149 | + | ||
| 150 | + if (normalizedKeys.Count == 0) | ||
| 151 | + { | ||
| 152 | + return new List<Guid>(); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + var bindings = await db.Queryable<UserLocationDbEntity>() | ||
| 156 | + .Where(x => !x.IsDeleted) | ||
| 157 | + .Select(x => new { x.UserId, x.LocationId }) | ||
| 158 | + .ToListAsync(); | ||
| 159 | + | ||
| 160 | + var userIdStrings = bindings | ||
| 161 | + .Where(x => normalizedKeys.Contains(TeamMemberListScopeHelper.NormalizeScopeKey(x.LocationId))) | ||
| 162 | + .Select(x => x.UserId) | ||
| 163 | + .Where(x => !string.IsNullOrWhiteSpace(x)) | ||
| 164 | + .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| 165 | + .ToList(); | ||
| 166 | + | ||
| 167 | + var result = new List<Guid>(); | ||
| 168 | + foreach (var uid in userIdStrings) | ||
| 169 | + { | ||
| 170 | + if (Guid.TryParse(uid.Trim(), out var guid)) | ||
| 171 | + { | ||
| 172 | + result.Add(guid); | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + return result; | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + private static List<Guid> ParseLocationGuids(IReadOnlyList<string> locationIdStrings) | ||
| 180 | + { | ||
| 181 | + var result = new List<Guid>(); | ||
| 182 | + foreach (var id in locationIdStrings) | ||
| 183 | + { | ||
| 184 | + if (Guid.TryParse(id?.Trim(), out var guid)) | ||
| 185 | + { | ||
| 186 | + result.Add(guid); | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + return result; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + private static async Task TryDeleteTeamMemberRegionByGroupIdAsync(ISqlSugarClient db, string groupId) | ||
| 194 | + { | ||
| 195 | + if (!await TeamMemberRegionScopeHelper.HasTableAsync(db)) | ||
| 196 | + { | ||
| 197 | + return; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + try | ||
| 201 | + { | ||
| 202 | + await db.Deleteable<FlTeamMemberRegionDbEntity>() | ||
| 203 | + .Where(x => x.GroupId == groupId) | ||
| 204 | + .ExecuteCommandAsync(); | ||
| 205 | + } | ||
| 206 | + catch | ||
| 207 | + { | ||
| 208 | + // 表探测通过但删除失败时静默跳过,与 TeamMemberRegionScopeHelper 一致 | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | +} |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AllScopeBindingHelper.cs
| @@ -428,9 +428,7 @@ public static class AllScopeBindingHelper | @@ -428,9 +428,7 @@ public static class AllScopeBindingHelper | ||
| 428 | return (partnerIds, regionIds, locs); | 428 | return (partnerIds, regionIds, locs); |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | - /// <summary> | ||
| 432 | - /// 标签/产品分类等:解析 Region + Location 落库(对齐 Label:Region=ALL 时可保留具体门店快照)。 | ||
| 433 | - /// </summary> | 431 | + /// <summary>标签/产品分类等 Region + Location 落库结果。</summary> |
| 434 | public sealed class LabelEntityRegionLocationSaveResult | 432 | public sealed class LabelEntityRegionLocationSaveResult |
| 435 | { | 433 | { |
| 436 | public string AvailabilityType { get; init; } = ScopeSpecified; | 434 | public string AvailabilityType { get; init; } = ScopeSpecified; |
| @@ -440,6 +438,10 @@ public static class AllScopeBindingHelper | @@ -440,6 +438,10 @@ public static class AllScopeBindingHelper | ||
| 440 | public List<string> LocationIds { get; init; } = new(); | 438 | public List<string> LocationIds { get; init; } = new(); |
| 441 | } | 439 | } |
| 442 | 440 | ||
| 441 | + /// <summary> | ||
| 442 | + /// 标签/产品分类等:解析 Region + Location 落库(对齐 Label:Region=ALL 时可保留具体门店快照)。 | ||
| 443 | + /// <paramref name="locationIdsRaw"/> 含 <c>ALL</c> 且已传具体 Region 时,为范围内 ALL(Scoped ALL),禁止升公司级 ALL。 | ||
| 444 | + /// </summary> | ||
| 443 | public static async Task<LabelEntityRegionLocationSaveResult> ResolveLabelEntityRegionLocationForSaveAsync( | 445 | public static async Task<LabelEntityRegionLocationSaveResult> ResolveLabelEntityRegionLocationForSaveAsync( |
| 444 | ISqlSugarClient db, | 446 | ISqlSugarClient db, |
| 445 | string? declaredAvailabilityType, | 447 | string? declaredAvailabilityType, |
| @@ -459,9 +461,14 @@ public static class AllScopeBindingHelper | @@ -459,9 +461,14 @@ public static class AllScopeBindingHelper | ||
| 459 | 461 | ||
| 460 | // 仅显式 ALL 哨兵视为 Region=ALL。 | 462 | // 仅显式 ALL 哨兵视为 Region=ALL。 |
| 461 | // 禁止「公司下仅 1 个 Region + 勾选该 Region」自动升 ALL(否则编辑回显/再提交会丢 SPECIFIED)。 | 463 | // 禁止「公司下仅 1 个 Region + 勾选该 Region」自动升 ALL(否则编辑回显/再提交会丢 SPECIFIED)。 |
| 462 | - // 无具体门店且未声明 SPECIFIED 时,才把「勾选当前全部 Region」归档为 ALL。 | 464 | + // locationIds=["ALL"] + 具体 RegionIds 为 Scoped ALL:禁止「勾选当前全部 Region」启发式升 Region=ALL。 |
| 463 | var regionHasAll = regionHasAllSentinel; | 465 | var regionHasAll = regionHasAllSentinel; |
| 464 | - if (!regionHasAll && regionIds.Count > 0 && explicitLocationIds.Count == 0 && !declaredSpecified) | 466 | + var isScopedAllWithConcreteRegions = locationHasAll && regionIds.Count > 0 && !regionHasAllSentinel; |
| 467 | + if (!regionHasAll | ||
| 468 | + && regionIds.Count > 0 | ||
| 469 | + && explicitLocationIds.Count == 0 | ||
| 470 | + && !declaredSpecified | ||
| 471 | + && !isScopedAllWithConcreteRegions) | ||
| 465 | { | 472 | { |
| 466 | var allRegions = await ResolveAllRegionIdsAsync( | 473 | var allRegions = await ResolveAllRegionIdsAsync( |
| 467 | db, | 474 | db, |
| @@ -469,9 +476,14 @@ public static class AllScopeBindingHelper | @@ -469,9 +476,14 @@ public static class AllScopeBindingHelper | ||
| 469 | regionHasAll = allRegions.Count > 0 && IsFullIdSelection(regionIds, allRegions); | 476 | regionHasAll = allRegions.Count > 0 && IsFullIdSelection(regionIds, allRegions); |
| 470 | } | 477 | } |
| 471 | 478 | ||
| 472 | - // 仅 locationIds 含 ALL 哨兵才按「全部门店」展开;有具体 Guid 时一律按 SPECIFIED 快照落库 | 479 | + // locationIds=["ALL"]:相对已传 RegionIds 为范围内 ALL;有具体 Region 时禁止升公司级 ALL |
| 473 | if (locationHasAll) | 480 | if (locationHasAll) |
| 474 | { | 481 | { |
| 482 | + if (isScopedAllWithConcreteRegions) | ||
| 483 | + { | ||
| 484 | + regionHasAll = false; | ||
| 485 | + } | ||
| 486 | + | ||
| 475 | if (regionHasAll) | 487 | if (regionHasAll) |
| 476 | { | 488 | { |
| 477 | var partnerScoped = await TryResolvePartnerScopedAllRegionAllLocationAsync( | 489 | var partnerScoped = await TryResolvePartnerScopedAllRegionAllLocationAsync( |
| @@ -594,7 +606,7 @@ public static class AllScopeBindingHelper | @@ -594,7 +606,7 @@ public static class AllScopeBindingHelper | ||
| 594 | 606 | ||
| 595 | if (availabilityType != ScopeAll && availabilityType != ScopeSpecified) | 607 | if (availabilityType != ScopeAll && availabilityType != ScopeSpecified) |
| 596 | { | 608 | { |
| 597 | - throw new UserFriendlyException("门店可用范围不合法(ALL/SPECIFIED)"); | 609 | + throw new UserFriendlyException("Invalid location availability scope (ALL/SPECIFIED)."); |
| 598 | } | 610 | } |
| 599 | 611 | ||
| 600 | var locationSpecified = string.Equals(availabilityType, ScopeSpecified, StringComparison.OrdinalIgnoreCase); | 612 | 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("User is 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, "请选择公司"); | ||
| 292 | - var gid = RequireNonEmpty(input.GroupId, "请选择区域"); | ||
| 293 | - var lid = RequireNonEmpty(input.LocationId, "请选择门店"); | 291 | + var pid = RequireNonEmpty(input.PartnerId, "Please select a Company."); |
| 292 | + var gid = RequireNonEmpty(input.GroupId, "Please select a Region."); | ||
| 293 | + var lid = RequireNonEmpty(input.LocationId, "Please 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 has been 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 has been 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/DashboardScopeHelper.cs
| @@ -9,7 +9,8 @@ using Yi.Framework.SqlSugarCore.Abstractions; | @@ -9,7 +9,8 @@ using Yi.Framework.SqlSugarCore.Abstractions; | ||
| 9 | namespace FoodLabeling.Application.Helpers; | 9 | namespace FoodLabeling.Application.Helpers; |
| 10 | 10 | ||
| 11 | /// <summary> | 11 | /// <summary> |
| 12 | -/// Dashboard 数据范围:管理员看全平台(用户指标排除内置系统 admin);非管理员仅看绑定门店所属公司范围。 | 12 | +/// Dashboard 数据范围:管理员看全平台;非管理员仅看绑定门店所属公司范围。 |
| 13 | +/// People / Active Users 口径与 Team Member 列表一致(Admin 统计全部未删 User;非 Admin 仅统计有 userlocation 绑定的用户)。 | ||
| 13 | /// </summary> | 14 | /// </summary> |
| 14 | public static class DashboardScopeHelper | 15 | public static class DashboardScopeHelper |
| 15 | { | 16 | { |
| @@ -59,69 +60,142 @@ public static class DashboardScopeHelper | @@ -59,69 +60,142 @@ public static class DashboardScopeHelper | ||
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | /// <summary> | 62 | /// <summary> |
| 62 | - /// 统计范围内成员数:须在 <c>userlocation</c> 中绑定范围内门店;排除平台系统 admin。 | 63 | + /// 统计范围内注册用户数,口径与 Team Member 列表 <c>BuildFilteredUserQueryAsync</c> 一致。 |
| 64 | + /// <c>scopeLocationIds == null</c>:全部未删 User;非 null:仅统计在范围内门店有 <c>userlocation</c> 绑定的用户。 | ||
| 63 | /// </summary> | 65 | /// </summary> |
| 64 | - public static async Task<int> CountScopedTeamMembersAsync( | 66 | + public static async Task<int> CountScopedRegisteredUsersAsync( |
| 65 | ISqlSugarClient db, | 67 | ISqlSugarClient db, |
| 66 | List<string>? scopeLocationIds, | 68 | List<string>? scopeLocationIds, |
| 67 | - HashSet<string> platformAdminUserIds, | ||
| 68 | bool activeOnly, | 69 | bool activeOnly, |
| 69 | DateTime? createdBefore) | 70 | DateTime? createdBefore) |
| 70 | { | 71 | { |
| 71 | - if (scopeLocationIds is { Count: 0 }) | 72 | + var userQuery = db.Queryable<UserAggregateRoot>() |
| 73 | + .Where(u => !u.IsDeleted); | ||
| 74 | + | ||
| 75 | + if (activeOnly) | ||
| 72 | { | 76 | { |
| 73 | - return 0; | 77 | + userQuery = userQuery.Where(u => u.State); |
| 74 | } | 78 | } |
| 75 | 79 | ||
| 76 | - var userLocQuery = db.Queryable<UserLocationDbEntity>() | ||
| 77 | - .Where(ul => !ul.IsDeleted); | ||
| 78 | - if (scopeLocationIds is not null) | 80 | + if (createdBefore.HasValue) |
| 79 | { | 81 | { |
| 80 | - userLocQuery = userLocQuery.Where(ul => scopeLocationIds.Contains(ul.LocationId)); | 82 | + userQuery = userQuery.Where(u => u.CreationTime < createdBefore.Value); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | - var scopedUserIdStrings = await userLocQuery | ||
| 84 | - .Select(ul => ul.UserId) | ||
| 85 | - .Distinct() | ||
| 86 | - .ToListAsync(); | ||
| 87 | - | ||
| 88 | - if (scopedUserIdStrings.Count == 0) | 85 | + if (scopeLocationIds is not null) |
| 89 | { | 86 | { |
| 90 | - return 0; | 87 | + if (scopeLocationIds.Count == 0) |
| 88 | + { | ||
| 89 | + return 0; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + var scopeGuidSet = TeamMemberListScopeHelper.ParseGuidHashSet(scopeLocationIds); | ||
| 93 | + var userLocationLinks = await db.Queryable<UserLocationDbEntity>() | ||
| 94 | + .Where(x => !x.IsDeleted) | ||
| 95 | + .Select(x => new { x.UserId, x.LocationId }) | ||
| 96 | + .ToListAsync(); | ||
| 97 | + | ||
| 98 | + var allowedUserGuids = userLocationLinks | ||
| 99 | + .Where(x => | ||
| 100 | + Guid.TryParse(x.LocationId, out var locGuid) && scopeGuidSet.Contains(locGuid)) | ||
| 101 | + .Select(x => x.UserId) | ||
| 102 | + .Select(TeamMemberListScopeHelper.NormalizeScopeKey) | ||
| 103 | + .Where(x => !string.IsNullOrEmpty(x)) | ||
| 104 | + .Select(x => Guid.Parse(x)) | ||
| 105 | + .Distinct() | ||
| 106 | + .ToList(); | ||
| 107 | + | ||
| 108 | + if (allowedUserGuids.Count == 0) | ||
| 109 | + { | ||
| 110 | + return 0; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + userQuery = userQuery.Where(u => allowedUserGuids.Contains(u.Id)); | ||
| 91 | } | 114 | } |
| 92 | 115 | ||
| 93 | - var scopedUserIds = new List<Guid>(); | ||
| 94 | - foreach (var s in scopedUserIdStrings) | 116 | + return await userQuery.CountAsync(); |
| 117 | + } | ||
| 118 | + | ||
| 119 | + /// <summary> | ||
| 120 | + /// 统计范围内标签数(<c>fl_label</c>,未删除),范围与 Label 列表无额外筛选时一致。 | ||
| 121 | + /// </summary> | ||
| 122 | + public static async Task<int> CountScopedLabelsAsync( | ||
| 123 | + ISqlSugarClient db, | ||
| 124 | + ISqlSugarDbContext dbContext, | ||
| 125 | + ICurrentUser currentUser, | ||
| 126 | + DateTime? createdBefore) | ||
| 127 | + { | ||
| 128 | + var scopedLocationIds = await TeamMemberListScopeHelper.ResolveListLocationIdsAsync( | ||
| 129 | + currentUser, dbContext, null, null, null); | ||
| 130 | + var scopedPartnerIds = await ResolveDashboardLabelScopedPartnerIdsAsync( | ||
| 131 | + db, dbContext, currentUser, scopedLocationIds); | ||
| 132 | + | ||
| 133 | + var labelQuery = LabelQueryHelper.ProjectListColumns( | ||
| 134 | + db.Queryable<FlLabelDbEntity>()) | ||
| 135 | + .Where(l => !l.IsDeleted); | ||
| 136 | + labelQuery = LabelRegionScopeHelper.ApplyLabelPartnerListFilter(labelQuery, scopedPartnerIds); | ||
| 137 | + | ||
| 138 | + var regionSchema = await LabelRegionSchemaHelper.GetStatusAsync(db); | ||
| 139 | + var applyLocationFilter = LabelEntityListScopeHelper.ShouldApplyLocationAvailabilityFilter( | ||
| 140 | + null, null, null); | ||
| 141 | + | ||
| 142 | + if (scopedLocationIds is not null && applyLocationFilter) | ||
| 95 | { | 143 | { |
| 96 | - if (platformAdminUserIds.Contains(s)) | 144 | + if (scopedLocationIds.Count == 0) |
| 97 | { | 145 | { |
| 98 | - continue; | 146 | + labelQuery = LabelRegionScopeHelper.ApplyLabelAllRegionOnlyFilter( |
| 147 | + db, labelQuery, regionSchema); | ||
| 99 | } | 148 | } |
| 100 | - | ||
| 101 | - if (Guid.TryParse(s, out var gid) && gid != Guid.Empty) | 149 | + else |
| 102 | { | 150 | { |
| 103 | - scopedUserIds.Add(gid); | 151 | + labelQuery = LabelRegionScopeHelper.ApplyLabelLocationListFilter( |
| 152 | + db, labelQuery, scopedLocationIds, regionSchema); | ||
| 104 | } | 153 | } |
| 105 | } | 154 | } |
| 106 | 155 | ||
| 107 | - if (scopedUserIds.Count == 0) | 156 | + if (createdBefore.HasValue) |
| 108 | { | 157 | { |
| 109 | - return 0; | 158 | + labelQuery = labelQuery.Where(l => l.CreationTime < createdBefore.Value); |
| 110 | } | 159 | } |
| 111 | 160 | ||
| 112 | - var userQuery = db.Queryable<UserAggregateRoot>() | ||
| 113 | - .Where(u => !u.IsDeleted && scopedUserIds.Contains(u.Id)); | ||
| 114 | - if (activeOnly) | 161 | + return await labelQuery.CountAsync(); |
| 162 | + } | ||
| 163 | + | ||
| 164 | + /// <summary> | ||
| 165 | + /// Dashboard 标签统计:Query 解析与 Token 可见公司求交集(对齐 Label 列表)。 | ||
| 166 | + /// </summary> | ||
| 167 | + private static async Task<List<string>?> ResolveDashboardLabelScopedPartnerIdsAsync( | ||
| 168 | + ISqlSugarClient db, | ||
| 169 | + ISqlSugarDbContext dbContext, | ||
| 170 | + ICurrentUser currentUser, | ||
| 171 | + List<string>? scopedLocationIds) | ||
| 172 | + { | ||
| 173 | + var fromQuery = await LabelEntityPartnerScopeHelper.ResolveListPartnerIdsAsync( | ||
| 174 | + db, null, null, scopedLocationIds); | ||
| 175 | + var partnerScope = await PartnerScopeHelper.ResolvePartnerScopeAsync(currentUser, dbContext); | ||
| 176 | + if (partnerScope.IsUnrestricted) | ||
| 115 | { | 177 | { |
| 116 | - userQuery = userQuery.Where(u => u.State); | 178 | + return fromQuery; |
| 117 | } | 179 | } |
| 118 | 180 | ||
| 119 | - if (createdBefore.HasValue) | 181 | + var allowed = partnerScope.AllowedPartnerIds.ToList(); |
| 182 | + if (allowed.Count == 0) | ||
| 120 | { | 183 | { |
| 121 | - userQuery = userQuery.Where(u => u.CreationTime < createdBefore.Value); | 184 | + return new List<string>(); |
| 122 | } | 185 | } |
| 123 | 186 | ||
| 124 | - return await userQuery.CountAsync(); | 187 | + if (fromQuery is null) |
| 188 | + { | ||
| 189 | + return allowed; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + if (fromQuery.Count == 0) | ||
| 193 | + { | ||
| 194 | + return new List<string>(); | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + var allowedSet = new HashSet<string>(allowed, StringComparer.OrdinalIgnoreCase); | ||
| 198 | + return fromQuery.Where(id => allowedSet.Contains(id)).ToList(); | ||
| 125 | } | 199 | } |
| 126 | 200 | ||
| 127 | /// <summary> | 201 | /// <summary> |
| @@ -193,6 +267,30 @@ public static class DashboardScopeHelper | @@ -193,6 +267,30 @@ public static class DashboardScopeHelper | ||
| 193 | } | 267 | } |
| 194 | 268 | ||
| 195 | /// <summary> | 269 | /// <summary> |
| 270 | + /// 统计范围内启用标签模板数(<c>fl_label_template</c>,未删除且 <c>State=true</c>), | ||
| 271 | + /// 范围与 Label Templates 列表无额外 partnerId/groupId/locationId 筛选时一致。 | ||
| 272 | + /// </summary> | ||
| 273 | + public static async Task<int> CountScopedActiveTemplatesAsync( | ||
| 274 | + ISqlSugarClient db, | ||
| 275 | + List<string>? scopedLocationIds, | ||
| 276 | + DateTime? createdBefore) | ||
| 277 | + { | ||
| 278 | + var query = db.Queryable<FlLabelTemplateDbEntity>() | ||
| 279 | + .Where(x => !x.IsDeleted && x.State); | ||
| 280 | + | ||
| 281 | + query = await LabelTemplateScopeHelper.ApplyTemplateScopeFilterAsync( | ||
| 282 | + db, query, scopedLocationIds, null, null, null); | ||
| 283 | + | ||
| 284 | + if (createdBefore.HasValue) | ||
| 285 | + { | ||
| 286 | + query = query.Where(x => x.CreationTime < createdBefore.Value); | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + query = LabelTemplateQueryHelper.ProjectListColumns(query); | ||
| 290 | + return await query.CountAsync(); | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + /// <summary> | ||
| 196 | /// 为打印任务查询附加门店范围(<c>scopeLocationIds == null</c> 不限制)。 | 294 | /// 为打印任务查询附加门店范围(<c>scopeLocationIds == null</c> 不限制)。 |
| 197 | /// </summary> | 295 | /// </summary> |
| 198 | public static ISugarQueryable<FlLabelPrintTaskDbEntity> ApplyPrintTaskLocationScope( | 296 | public static ISugarQueryable<FlLabelPrintTaskDbEntity> ApplyPrintTaskLocationScope( |
美国版/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: only one row is allowed for product [{row.ProductId}] and label type [{row.LabelTypeId}]."); |
| 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 cannot be empty."); |
| 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 tables are not ready. Ask an administrator to run the database migration (fl_label_entity_partner_scope.sql or fl_product_category_partner_scope.sql), then try again."); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | if (hasTable) | 198 | if (hasTable) |
| @@ -592,7 +592,7 @@ public static class LabelEntityPartnerScopeHelper | @@ -592,7 +592,7 @@ public static class LabelEntityPartnerScopeHelper | ||
| 592 | { | 592 | { |
| 593 | if (type != ScopeAll && type != ScopeSpecified) | 593 | if (type != ScopeAll && type != ScopeSpecified) |
| 594 | { | 594 | { |
| 595 | - throw new UserFriendlyException("适用 Company 范围不合法(ALL/SPECIFIED)"); | 595 | + throw new UserFriendlyException("Invalid applicable Company scope (ALL/SPECIFIED)."); |
| 596 | } | 596 | } |
| 597 | } | 597 | } |
| 598 | 598 | ||
| @@ -614,7 +614,7 @@ public static class LabelEntityPartnerScopeHelper | @@ -614,7 +614,7 @@ public static class LabelEntityPartnerScopeHelper | ||
| 614 | .CountAsync(); | 614 | .CountAsync(); |
| 615 | if (count != partnerIds.Count) | 615 | if (count != partnerIds.Count) |
| 616 | { | 616 | { |
| 617 | - throw new UserFriendlyException("存在无效的 Company(partnerIds/companyIds),请刷新后重试"); | 617 | + throw new UserFriendlyException("One or more Companies are invalid (partnerIds/companyIds). Refresh and try again."); |
| 618 | } | 618 | } |
| 619 | } | 619 | } |
| 620 | 620 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelRegionScopeHelper.cs
| @@ -51,6 +51,8 @@ public static class LabelRegionScopeHelper | @@ -51,6 +51,8 @@ public static class LabelRegionScopeHelper | ||
| 51 | /// <summary> | 51 | /// <summary> |
| 52 | /// 解析新增/编辑入参中的 Region / Location 范围。 | 52 | /// 解析新增/编辑入参中的 Region / Location 范围。 |
| 53 | /// 前端 Select All 常传 SPECIFIED + 当前全量 Id:覆盖全集时归档为 ALL(或不写门店快照),后续新增 Region/Location 动态适用。 | 53 | /// 前端 Select All 常传 SPECIFIED + 当前全量 Id:覆盖全集时归档为 ALL(或不写门店快照),后续新增 Region/Location 动态适用。 |
| 54 | + /// <paramref name="locationIds"/> 含 <c>ALL</c> 且已传具体 <paramref name="regionIds"/> 时,表示<strong>范围内 ALL</strong>(Scoped ALL): | ||
| 55 | + /// 落 <c>AppliedRegionType=SPECIFIED</c> + <c>fl_label_region</c>,不写 <c>fl_label_location</c>,禁止升公司级 <c>ALL</c>。 | ||
| 54 | /// </summary> | 56 | /// </summary> |
| 55 | public static async Task<LabelRegionScopeSaveResult> ResolveScopeForSaveAsync( | 57 | public static async Task<LabelRegionScopeSaveResult> ResolveScopeForSaveAsync( |
| 56 | ISqlSugarClient db, | 58 | ISqlSugarClient db, |
| @@ -71,7 +73,19 @@ public static class LabelRegionScopeHelper | @@ -71,7 +73,19 @@ public static class LabelRegionScopeHelper | ||
| 71 | var hasScopeArrays = regionIds is not null || groupIds is not null || locationIds is not null; | 73 | var hasScopeArrays = regionIds is not null || groupIds is not null || locationIds is not null; |
| 72 | var partnerContext = LocationScopeBindingHelper.NormalizeIds(partnerIdsForContext); | 74 | var partnerContext = LocationScopeBindingHelper.NormalizeIds(partnerIdsForContext); |
| 73 | 75 | ||
| 74 | - // locationIds / regionIds 含 ALL 哨兵:不归档为 Guid 校验,按全选处理(Company 由 fl_label.PartnerId 落库) | 76 | + // locationIds=["ALL"] + 具体 RegionIds → Scoped ALL(SPECIFIED + Region 快照,无门店快照) |
| 77 | + if (locationHasAll && mergedRegionIds.Count > 0 && !regionHasAll) | ||
| 78 | + { | ||
| 79 | + await ValidateRegionIdsExistAsync(db, mergedRegionIds); | ||
| 80 | + return new LabelRegionScopeSaveResult | ||
| 81 | + { | ||
| 82 | + AppliedRegionType = AppliedRegionSpecified, | ||
| 83 | + RegionIds = mergedRegionIds, | ||
| 84 | + LocationIds = new List<string>() | ||
| 85 | + }; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + // Region=ALL + Location=ALL(或无具体 Region)→ 公司级/全局 ALL(Partner 由 fl_label.PartnerId 落库) | ||
| 75 | if (locationHasAll || (regionHasAll && explicitLocationIds.Count == 0)) | 89 | if (locationHasAll || (regionHasAll && explicitLocationIds.Count == 0)) |
| 76 | { | 90 | { |
| 77 | return new LabelRegionScopeSaveResult | 91 | return new LabelRegionScopeSaveResult |
| @@ -104,13 +118,13 @@ public static class LabelRegionScopeHelper | @@ -104,13 +118,13 @@ public static class LabelRegionScopeHelper | ||
| 104 | 118 | ||
| 105 | if (type != AppliedRegionAll && type != AppliedRegionSpecified) | 119 | if (type != AppliedRegionAll && type != AppliedRegionSpecified) |
| 106 | { | 120 | { |
| 107 | - throw new UserFriendlyException("适用 Region 范围不合法(ALL/SPECIFIED)"); | 121 | + throw new UserFriendlyException("Invalid applicable Region scope (ALL/SPECIFIED)."); |
| 108 | } | 122 | } |
| 109 | 123 | ||
| 110 | if (mergedRegionIds.Count == 0 && explicitLocationIds.Count == 0 | 124 | if (mergedRegionIds.Count == 0 && explicitLocationIds.Count == 0 |
| 111 | && !string.Equals(type, AppliedRegionAll, StringComparison.OrdinalIgnoreCase)) | 125 | && !string.Equals(type, AppliedRegionAll, StringComparison.OrdinalIgnoreCase)) |
| 112 | { | 126 | { |
| 113 | - throw new UserFriendlyException("请指定 Region(regionIds)和/或门店(locationIds)"); | 127 | + throw new UserFriendlyException("Specify Region (regionIds) and/or Location (locationIds)."); |
| 114 | } | 128 | } |
| 115 | 129 | ||
| 116 | if (mergedRegionIds.Count > 0) | 130 | if (mergedRegionIds.Count > 0) |
| @@ -203,7 +217,7 @@ public static class LabelRegionScopeHelper | @@ -203,7 +217,7 @@ public static class LabelRegionScopeHelper | ||
| 203 | { | 217 | { |
| 204 | if (allLocationsInRegions.Count == 0) | 218 | if (allLocationsInRegions.Count == 0) |
| 205 | { | 219 | { |
| 206 | - throw new UserFriendlyException("指定 Region 下未匹配到有效门店,请检查 Region 或 locationIds"); | 220 | + throw new UserFriendlyException("No valid locations matched under the specified Region. Check Region or locationIds."); |
| 207 | } | 221 | } |
| 208 | 222 | ||
| 209 | if (explicitLocationIds.Count > 0) | 223 | if (explicitLocationIds.Count > 0) |
| @@ -229,7 +243,7 @@ public static class LabelRegionScopeHelper | @@ -229,7 +243,7 @@ public static class LabelRegionScopeHelper | ||
| 229 | db, resolvedPartnerContext, mergedRegionIds, explicitLocationIds); | 243 | db, resolvedPartnerContext, mergedRegionIds, explicitLocationIds); |
| 230 | if (mergedLocations.Count == 0) | 244 | if (mergedLocations.Count == 0) |
| 231 | { | 245 | { |
| 232 | - throw new UserFriendlyException("指定 Region 下未匹配到有效门店,请检查 Region 或 locationIds"); | 246 | + throw new UserFriendlyException("No valid locations matched under the specified Region. Check Region or locationIds."); |
| 233 | } | 247 | } |
| 234 | 248 | ||
| 235 | var invalid = explicitLocationIds | 249 | var invalid = explicitLocationIds |
| @@ -237,7 +251,7 @@ public static class LabelRegionScopeHelper | @@ -237,7 +251,7 @@ public static class LabelRegionScopeHelper | ||
| 237 | .ToList(); | 251 | .ToList(); |
| 238 | if (invalid.Count > 0) | 252 | if (invalid.Count > 0) |
| 239 | { | 253 | { |
| 240 | - throw new UserFriendlyException("所选门店必须属于所选 Region"); | 254 | + throw new UserFriendlyException("Selected locations must belong to the selected Region."); |
| 241 | } | 255 | } |
| 242 | 256 | ||
| 243 | return new LabelRegionScopeSaveResult | 257 | return new LabelRegionScopeSaveResult |
| @@ -487,7 +501,7 @@ public static class LabelRegionScopeHelper | @@ -487,7 +501,7 @@ public static class LabelRegionScopeHelper | ||
| 487 | null, | 501 | null, |
| 488 | regionIds, | 502 | regionIds, |
| 489 | locationIds, | 503 | locationIds, |
| 490 | - ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds)); | 504 | + ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds, regionIds)); |
| 491 | 505 | ||
| 492 | return new LabelRegionScopeDisplay | 506 | return new LabelRegionScopeDisplay |
| 493 | { | 507 | { |
| @@ -500,10 +514,14 @@ public static class LabelRegionScopeHelper | @@ -500,10 +514,14 @@ public static class LabelRegionScopeHelper | ||
| 500 | public static async Task<LabelLocationScopeDisplay> BuildLocationDisplayAsync( | 514 | public static async Task<LabelLocationScopeDisplay> BuildLocationDisplayAsync( |
| 501 | ISqlSugarClient db, | 515 | ISqlSugarClient db, |
| 502 | string? appliedRegionType, | 516 | string? appliedRegionType, |
| 503 | - IReadOnlyList<string> locationIds) | 517 | + IReadOnlyList<string> locationIds, |
| 518 | + string? labelId = null, | ||
| 519 | + IReadOnlyList<string>? regionIds = null) | ||
| 504 | { | 520 | { |
| 521 | + var persistedLocations = LocationScopeBindingHelper.NormalizeIds(locationIds); | ||
| 522 | + | ||
| 505 | if (string.Equals(appliedRegionType, AppliedRegionAll, StringComparison.OrdinalIgnoreCase) | 523 | if (string.Equals(appliedRegionType, AppliedRegionAll, StringComparison.OrdinalIgnoreCase) |
| 506 | - && locationIds.Count == 0) | 524 | + && persistedLocations.Count == 0) |
| 507 | { | 525 | { |
| 508 | return new LabelLocationScopeDisplay | 526 | return new LabelLocationScopeDisplay |
| 509 | { | 527 | { |
| @@ -512,7 +530,25 @@ public static class LabelRegionScopeHelper | @@ -512,7 +530,25 @@ public static class LabelRegionScopeHelper | ||
| 512 | }; | 530 | }; |
| 513 | } | 531 | } |
| 514 | 532 | ||
| 515 | - if (locationIds.Count == 0) | 533 | + var concreteRegions = LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds); |
| 534 | + if (concreteRegions.Count == 0 && !string.IsNullOrWhiteSpace(labelId)) | ||
| 535 | + { | ||
| 536 | + concreteRegions = await GetRegionIdsForLabelAsync(db, labelId); | ||
| 537 | + } | ||
| 538 | + | ||
| 539 | + // Scoped ALL:SPECIFIED + 有 Region 快照 + 无门店快照 → 范围内 Location 回显 ALL | ||
| 540 | + if (AllScopeBindingHelper.IsDeclaredSpecified(appliedRegionType) | ||
| 541 | + && concreteRegions.Count > 0 | ||
| 542 | + && persistedLocations.Count == 0) | ||
| 543 | + { | ||
| 544 | + return new LabelLocationScopeDisplay | ||
| 545 | + { | ||
| 546 | + Location = AllLocationsDisplay, | ||
| 547 | + LocationIds = new List<string> { AllScopeBindingHelper.ScopeAll } | ||
| 548 | + }; | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + if (persistedLocations.Count == 0) | ||
| 516 | { | 552 | { |
| 517 | return new LabelLocationScopeDisplay | 553 | return new LabelLocationScopeDisplay |
| 518 | { | 554 | { |
| @@ -521,7 +557,7 @@ public static class LabelRegionScopeHelper | @@ -521,7 +557,7 @@ public static class LabelRegionScopeHelper | ||
| 521 | }; | 557 | }; |
| 522 | } | 558 | } |
| 523 | 559 | ||
| 524 | - var guidList = locationIds.Where(x => Guid.TryParse(x, out _)).Select(Guid.Parse).ToList(); | 560 | + var guidList = persistedLocations.Where(x => Guid.TryParse(x, out _)).Select(Guid.Parse).ToList(); |
| 525 | var names = new List<string>(); | 561 | var names = new List<string>(); |
| 526 | if (guidList.Count > 0) | 562 | if (guidList.Count > 0) |
| 527 | { | 563 | { |
| @@ -539,9 +575,9 @@ public static class LabelRegionScopeHelper | @@ -539,9 +575,9 @@ public static class LabelRegionScopeHelper | ||
| 539 | var collapsed = await ScopeAllEchoHelper.CollapseScopeIdsToAllSentinelAsync( | 575 | var collapsed = await ScopeAllEchoHelper.CollapseScopeIdsToAllSentinelAsync( |
| 540 | db, | 576 | db, |
| 541 | null, | 577 | null, |
| 542 | - null, | ||
| 543 | - locationIds, | ||
| 544 | - ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds)); | 578 | + concreteRegions, |
| 579 | + persistedLocations, | ||
| 580 | + ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, persistedLocations, concreteRegions)); | ||
| 545 | 581 | ||
| 546 | return new LabelLocationScopeDisplay | 582 | return new LabelLocationScopeDisplay |
| 547 | { | 583 | { |
| @@ -772,7 +808,7 @@ public static class LabelRegionScopeHelper | @@ -772,7 +808,7 @@ public static class LabelRegionScopeHelper | ||
| 772 | var groupIds = await ResolveGroupIdsForLocationAsync(db, locationId); | 808 | var groupIds = await ResolveGroupIdsForLocationAsync(db, locationId); |
| 773 | if (!await LabelAppliesToLocationAsync(db, label, locationId, groupIds)) | 809 | if (!await LabelAppliesToLocationAsync(db, label, locationId, groupIds)) |
| 774 | { | 810 | { |
| 775 | - throw new UserFriendlyException("??????????????? Region"); | 811 | + throw new UserFriendlyException("This label does not apply to the Location's Region."); |
| 776 | } | 812 | } |
| 777 | } | 813 | } |
| 778 | 814 | ||
| @@ -1040,7 +1076,7 @@ public static class LabelRegionScopeHelper | @@ -1040,7 +1076,7 @@ public static class LabelRegionScopeHelper | ||
| 1040 | .CountAsync(); | 1076 | .CountAsync(); |
| 1041 | if (count != ids.Count) | 1077 | if (count != ids.Count) |
| 1042 | { | 1078 | { |
| 1043 | - throw new UserFriendlyException("存在无效的 Region Id,请刷新后重试"); | 1079 | + throw new UserFriendlyException("One or more Region Ids are invalid. Refresh and try again."); |
| 1044 | } | 1080 | } |
| 1045 | } | 1081 | } |
| 1046 | } | 1082 | } |
美国版/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("Custom date range requires 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 later than 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($"The reporting 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 cannot be empty."); |
| 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 cannot be empty."); |
| 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 cannot be empty."); |
| 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 tables are not ready. Ask an administrator to run the database migration (fl_label_template_scope.sql), then try again."); |
| 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("One or more Companies are invalid (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("One or more Regions are invalid (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 = "Could not find Location ID column (or synonyms). 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 limit of {maxRows} rows exceeded; remaining rows were ignored." |
| 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); |
| @@ -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("Invalid Latitude format."); |
| 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("Invalid Longitude format."); |
| 287 | } | 287 | } |
| 288 | else | 288 | else |
| 289 | { | 289 | { |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
| @@ -370,7 +370,7 @@ public static class LocationScopeBindingHelper | @@ -370,7 +370,7 @@ public static class LocationScopeBindingHelper | ||
| 370 | return expanded; | 370 | return expanded; |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | - throw new UserFriendlyException("选择全部门店时需指定 Company(partnerId / partnerIds)或 Region"); | 373 | + throw new UserFriendlyException("When selecting all locations, specify Company (partnerId / partnerIds) or Region."); |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | // 2. 具体门店 +(无区域 / 区域为 ALL)→ 只绑这些门店,避免 regionIds=ALL 盖掉单店 | 376 | // 2. 具体门店 +(无区域 / 区域为 ALL)→ 只绑这些门店,避免 regionIds=ALL 盖掉单店 |
| @@ -384,7 +384,7 @@ public static class LocationScopeBindingHelper | @@ -384,7 +384,7 @@ public static class LocationScopeBindingHelper | ||
| 384 | { | 384 | { |
| 385 | if (normalizedPartners.Count == 0) | 385 | if (normalizedPartners.Count == 0) |
| 386 | { | 386 | { |
| 387 | - throw new UserFriendlyException("选择全部 Region 时需指定 Company(partnerId / partnerIds)"); | 387 | + throw new UserFriendlyException("When selecting all Regions, specify Company (partnerId / partnerIds)."); |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | return await AllScopeBindingHelper.ResolveAllLocationIdsAsync(db, normalizedPartners, null); | 390 | return await AllScopeBindingHelper.ResolveAllLocationIdsAsync(db, normalizedPartners, null); |
| @@ -438,7 +438,7 @@ public static class LocationScopeBindingHelper | @@ -438,7 +438,7 @@ public static class LocationScopeBindingHelper | ||
| 438 | || (ContainsAllScopeSentinel(regionIds) | 438 | || (ContainsAllScopeSentinel(regionIds) |
| 439 | && FilterConcreteScopeIds(locationIds).Count == 0)) | 439 | && FilterConcreteScopeIds(locationIds).Count == 0)) |
| 440 | { | 440 | { |
| 441 | - throw new UserFriendlyException("门店范围含 ALL 哨兵时应归档为 ALL,不应进入 SPECIFIED 落库校验"); | 441 | + throw new UserFriendlyException("When location scope includes the ALL sentinel, it should be archived as ALL, not validated as SPECIFIED."); |
| 442 | } | 442 | } |
| 443 | 443 | ||
| 444 | var concreteRegions = FilterConcreteScopeIds(regionIds); | 444 | var concreteRegions = FilterConcreteScopeIds(regionIds); |
| @@ -458,7 +458,7 @@ public static class LocationScopeBindingHelper | @@ -458,7 +458,7 @@ public static class LocationScopeBindingHelper | ||
| 458 | concreteLocations); | 458 | concreteLocations); |
| 459 | if (merged.Count == 0) | 459 | if (merged.Count == 0) |
| 460 | { | 460 | { |
| 461 | - throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店"); | 461 | + throw new UserFriendlyException("When specifying applicable Region or Location, at least one valid location must match."); |
| 462 | } | 462 | } |
| 463 | 463 | ||
| 464 | await ValidateLocationIdsExistAsync(db, merged); | 464 | await ValidateLocationIdsExistAsync(db, merged); |
| @@ -488,7 +488,7 @@ public static class LocationScopeBindingHelper | @@ -488,7 +488,7 @@ public static class LocationScopeBindingHelper | ||
| 488 | 488 | ||
| 489 | if (fromRegions.Count == 0) | 489 | if (fromRegions.Count == 0) |
| 490 | { | 490 | { |
| 491 | - throw new UserFriendlyException("指定 Region 下未匹配到有效门店"); | 491 | + throw new UserFriendlyException("No valid locations matched under the specified Region."); |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | await ValidateLocationIdsExistAsync(db, fromRegions); | 494 | await ValidateLocationIdsExistAsync(db, fromRegions); |
| @@ -501,7 +501,7 @@ public static class LocationScopeBindingHelper | @@ -501,7 +501,7 @@ public static class LocationScopeBindingHelper | ||
| 501 | var fromPartners = await ResolveLocationIdsFromPartnerIdsAsync(db, concretePartners); | 501 | var fromPartners = await ResolveLocationIdsFromPartnerIdsAsync(db, concretePartners); |
| 502 | if (fromPartners.Count == 0) | 502 | if (fromPartners.Count == 0) |
| 503 | { | 503 | { |
| 504 | - throw new UserFriendlyException("指定 Company 下未匹配到有效门店"); | 504 | + throw new UserFriendlyException("No valid locations matched under the specified Company."); |
| 505 | } | 505 | } |
| 506 | 506 | ||
| 507 | await ValidateLocationIdsExistAsync(db, fromPartners); | 507 | await ValidateLocationIdsExistAsync(db, fromPartners); |
| @@ -764,7 +764,7 @@ public static class LocationScopeBindingHelper | @@ -764,7 +764,7 @@ public static class LocationScopeBindingHelper | ||
| 764 | { | 764 | { |
| 765 | if (!Guid.TryParse(id, out _)) | 765 | if (!Guid.TryParse(id, out _)) |
| 766 | { | 766 | { |
| 767 | - throw new UserFriendlyException("门店Id格式不正确"); | 767 | + throw new UserFriendlyException("Invalid Location ID format."); |
| 768 | } | 768 | } |
| 769 | } | 769 | } |
| 770 | 770 | ||
| @@ -774,7 +774,7 @@ public static class LocationScopeBindingHelper | @@ -774,7 +774,7 @@ public static class LocationScopeBindingHelper | ||
| 774 | .CountAsync(); | 774 | .CountAsync(); |
| 775 | if (existCount != ids.Count) | 775 | if (existCount != ids.Count) |
| 776 | { | 776 | { |
| 777 | - throw new UserFriendlyException("门店不存在"); | 777 | + throw new UserFriendlyException("Location not found."); |
| 778 | } | 778 | } |
| 779 | } | 779 | } |
| 780 | 780 |
美国版/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 = "Could not find Product and Product Category columns (or synonyms). 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 limit of {maxRows} rows exceeded; remaining rows were ignored." |
| 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/ScopeAllEchoHelper.cs
| @@ -88,6 +88,10 @@ public static class ScopeAllEchoHelper | @@ -88,6 +88,10 @@ public static class ScopeAllEchoHelper | ||
| 88 | && LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds).Count == 0 | 88 | && LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds).Count == 0 |
| 89 | && LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds).Count == 0, | 89 | && LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds).Count == 0, |
| 90 | IsLocationAll = AllScopeBindingHelper.IsDeclaredAll(availabilityType) | 90 | IsLocationAll = AllScopeBindingHelper.IsDeclaredAll(availabilityType) |
| 91 | + || (AllScopeBindingHelper.IsDeclaredSpecified(appliedRegionType) | ||
| 92 | + && LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds).Count > 0 | ||
| 93 | + && LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds).Count == 0 | ||
| 94 | + && !AllScopeBindingHelper.IsDeclaredAll(appliedRegionType)) | ||
| 91 | }; | 95 | }; |
| 92 | 96 | ||
| 93 | /// <summary>兼容旧调用:无 Region 类型时用 AvailabilityType 同时驱动 Region/Location。</summary> | 97 | /// <summary>兼容旧调用:无 Region 类型时用 AvailabilityType 同时驱动 Region/Location。</summary> |
| @@ -96,16 +100,25 @@ public static class ScopeAllEchoHelper | @@ -96,16 +100,25 @@ public static class ScopeAllEchoHelper | ||
| 96 | string? availabilityType) => | 100 | string? availabilityType) => |
| 97 | ForLabelEntityScope(appliedPartnerType, availabilityType, availabilityType); | 101 | ForLabelEntityScope(appliedPartnerType, availabilityType, availabilityType); |
| 98 | 102 | ||
| 99 | - /// <summary>Label:AppliedRegionType=ALL 且未落门店快照时 Region/Location 均为 ALL。</summary> | 103 | + /// <summary> |
| 104 | + /// Label:AppliedRegionType=ALL 且未落门店快照时 Region/Location 均为 ALL; | ||
| 105 | + /// Scoped ALL(SPECIFIED + 有 Region 快照 + 无门店快照)时 Location 回显 <c>["ALL"]</c>(范围内 ALL)。 | ||
| 106 | + /// </summary> | ||
| 100 | public static ScopeAllEchoOptions ForLabelRegionScope( | 107 | public static ScopeAllEchoOptions ForLabelRegionScope( |
| 101 | string? appliedRegionType, | 108 | string? appliedRegionType, |
| 102 | - IReadOnlyList<string> locationIds) | 109 | + IReadOnlyList<string> locationIds, |
| 110 | + IReadOnlyList<string>? regionIds = null) | ||
| 103 | { | 111 | { |
| 112 | + var persistedLocations = LocationScopeBindingHelper.NormalizeIds(locationIds); | ||
| 113 | + var concreteRegions = LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds); | ||
| 104 | var isRegionAll = AllScopeBindingHelper.IsDeclaredAll(appliedRegionType); | 114 | var isRegionAll = AllScopeBindingHelper.IsDeclaredAll(appliedRegionType); |
| 115 | + var isScopedLocationAll = AllScopeBindingHelper.IsDeclaredSpecified(appliedRegionType) | ||
| 116 | + && concreteRegions.Count > 0 | ||
| 117 | + && persistedLocations.Count == 0; | ||
| 105 | return new ScopeAllEchoOptions | 118 | return new ScopeAllEchoOptions |
| 106 | { | 119 | { |
| 107 | IsRegionAll = isRegionAll, | 120 | IsRegionAll = isRegionAll, |
| 108 | - IsLocationAll = isRegionAll && LocationScopeBindingHelper.NormalizeIds(locationIds).Count == 0 | 121 | + IsLocationAll = (isRegionAll && persistedLocations.Count == 0) || isScopedLocationAll |
| 109 | }; | 122 | }; |
| 110 | } | 123 | } |
| 111 | 124 |
美国版/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 = "Could not find Name and Email columns (or synonyms). 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 limit of {maxRows} rows exceeded; remaining rows were ignored." |
| 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("Sign-in account is required (fill UserName column, 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("Invalid Phone format (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 not found: \"{roleName.Trim()}\". Use a name that matches a system role."); |
| 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 Region or Assigned Location Ids (both may 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/UsAppAuthScopeHelper.cs
| @@ -23,18 +23,18 @@ public static class UsAppAuthScopeHelper | @@ -23,18 +23,18 @@ 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("User is not signed in."); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | var kind = currentUser.FindClaim(UsAppJwtClaims.ClientKind)?.Value; | 29 | var kind = currentUser.FindClaim(UsAppJwtClaims.ClientKind)?.Value; |
| 30 | if (!string.Equals(kind, UsAppJwtClaims.ClientKindUsApp, StringComparison.Ordinal)) | 30 | if (!string.Equals(kind, UsAppJwtClaims.ClientKindUsApp, StringComparison.Ordinal)) |
| 31 | { | 31 | { |
| 32 | - throw new UserFriendlyException("请使用 App 登录令牌调用该接口"); | 32 | + throw new UserFriendlyException("Use an App sign-in token to call this endpoint."); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | if (!await CanUseAdminScopeApisAsync(db, currentUser)) | 35 | if (!await CanUseAdminScopeApisAsync(db, currentUser)) |
| 36 | { | 36 | { |
| 37 | - throw new UserFriendlyException("仅管理员或 Company Admin 可使用公司/区域/门店筛选接口"); | 37 | + throw new UserFriendlyException("Only administrators or Company Admins can use Company/Region/Location filter endpoints."); |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| @@ -77,7 +77,7 @@ public static class UsAppAuthScopeHelper | @@ -77,7 +77,7 @@ public static class UsAppAuthScopeHelper | ||
| 77 | var pid = partnerId.Trim(); | 77 | var pid = partnerId.Trim(); |
| 78 | if (string.IsNullOrEmpty(pid)) | 78 | if (string.IsNullOrEmpty(pid)) |
| 79 | { | 79 | { |
| 80 | - throw new UserFriendlyException("请选择公司"); | 80 | + throw new UserFriendlyException("Please select a Company."); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | return await db.Queryable<FlGroupDbEntity>() | 83 | return await db.Queryable<FlGroupDbEntity>() |
| @@ -146,7 +146,7 @@ public static class UsAppAuthScopeHelper | @@ -146,7 +146,7 @@ public static class UsAppAuthScopeHelper | ||
| 146 | var locationId = input.LocationId?.Trim() ?? string.Empty; | 146 | var locationId = input.LocationId?.Trim() ?? string.Empty; |
| 147 | if (string.IsNullOrEmpty(partnerId) || string.IsNullOrEmpty(groupId) || string.IsNullOrEmpty(locationId)) | 147 | if (string.IsNullOrEmpty(partnerId) || string.IsNullOrEmpty(groupId) || string.IsNullOrEmpty(locationId)) |
| 148 | { | 148 | { |
| 149 | - throw new UserFriendlyException("请选择公司、区域和门店"); | 149 | + throw new UserFriendlyException("Please select Company, Region, and Location."); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | if (!ReportsRoleHelper.IsAdminRole(currentUser)) | 152 | if (!ReportsRoleHelper.IsAdminRole(currentUser)) |
| @@ -161,19 +161,19 @@ public static class UsAppAuthScopeHelper | @@ -161,19 +161,19 @@ public static class UsAppAuthScopeHelper | ||
| 161 | null); | 161 | null); |
| 162 | if (scopedIds is null || !scopedIds.Contains(locationId)) | 162 | if (scopedIds is null || !scopedIds.Contains(locationId)) |
| 163 | { | 163 | { |
| 164 | - throw new UserFriendlyException("门店与所选公司/区域不匹配"); | 164 | + throw new UserFriendlyException("Location does not match the selected Company/Region."); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | if (!Guid.TryParse(locationId, out var locationGuid)) | 167 | if (!Guid.TryParse(locationId, out var locationGuid)) |
| 168 | { | 168 | { |
| 169 | - throw new UserFriendlyException("无效的门店标识"); | 169 | + throw new UserFriendlyException("Invalid location identifier."); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | var loc = await db.Queryable<LocationAggregateRoot>() | 172 | var loc = await db.Queryable<LocationAggregateRoot>() |
| 173 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); | 173 | .FirstAsync(x => !x.IsDeleted && x.Id == locationGuid); |
| 174 | if (loc is null) | 174 | if (loc is null) |
| 175 | { | 175 | { |
| 176 | - throw new UserFriendlyException("门店不存在或已删除"); | 176 | + throw new UserFriendlyException("Location not found or has been removed."); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | var partner = await db.Queryable<FlPartnerDbEntity>() | 179 | 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("User is 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 the location and cannot view its data."); |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AuthSessionAppService.cs
| @@ -42,7 +42,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | @@ -42,7 +42,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | ||
| 42 | { | 42 | { |
| 43 | if (!CurrentUser.Id.HasValue) | 43 | if (!CurrentUser.Id.HasValue) |
| 44 | { | 44 | { |
| 45 | - throw new UserFriendlyException("用户未登录"); | 45 | + throw new UserFriendlyException("User is not signed in."); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | // 避免走 UserManager.GetInfoAsync -> UserRepository.GetUserAllInfoAsync 的导航加载 | 48 | // 避免走 UserManager.GetInfoAsync -> UserRepository.GetUserAllInfoAsync 的导航加载 |
| @@ -51,7 +51,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | @@ -51,7 +51,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService | ||
| 51 | var user = await _userRepository.GetByIdAsync(userId); | 51 | var user = await _userRepository.GetByIdAsync(userId); |
| 52 | if (user is null || user.IsDeleted) | 52 | if (user is null || user.IsDeleted) |
| 53 | { | 53 | { |
| 54 | - throw new UserFriendlyException("用户不存在"); | 54 | + throw new UserFriendlyException("User not found."); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | var userRoleIds = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity>() | 57 | var userRoleIds = await _dbContext.SqlSugarClient.Queryable<UserRoleEntity>() |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs
| @@ -45,8 +45,6 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | @@ -45,8 +45,6 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | ||
| 45 | var scopeLocationIds = await DashboardScopeHelper.ResolveDashboardLocationIdsAsync(CurrentUser, _dbContext); | 45 | var scopeLocationIds = await DashboardScopeHelper.ResolveDashboardLocationIdsAsync(CurrentUser, _dbContext); |
| 46 | var partnerScope = await PartnerScopeHelper.ResolvePartnerScopeAsync(CurrentUser, _dbContext); | 46 | var partnerScope = await PartnerScopeHelper.ResolvePartnerScopeAsync(CurrentUser, _dbContext); |
| 47 | var groupScope = await GroupListScopeHelper.ResolveAsync(CurrentUser, _dbContext); | 47 | var groupScope = await GroupListScopeHelper.ResolveAsync(CurrentUser, _dbContext); |
| 48 | - var platformAdminUserIds = await DashboardScopeHelper.GetPlatformAdminUserIdStringsAsync(db); | ||
| 49 | - | ||
| 50 | var printTodayQuery = DashboardScopeHelper.ApplyPrintTaskLocationScope( | 48 | var printTodayQuery = DashboardScopeHelper.ApplyPrintTaskLocationScope( |
| 51 | db.Queryable<FlLabelPrintTaskDbEntity>(), scopeLocationIds); | 49 | db.Queryable<FlLabelPrintTaskDbEntity>(), scopeLocationIds); |
| 52 | var printedToday = await printTodayQuery | 50 | var printedToday = await printTodayQuery |
| @@ -56,17 +54,15 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | @@ -56,17 +54,15 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | ||
| 56 | db.Queryable<FlLabelPrintTaskDbEntity>(), scopeLocationIds) | 54 | db.Queryable<FlLabelPrintTaskDbEntity>(), scopeLocationIds) |
| 57 | .CountAsync(x => x.CreationTime >= yesterdayStart && x.CreationTime < todayStart); | 55 | .CountAsync(x => x.CreationTime >= yesterdayStart && x.CreationTime < todayStart); |
| 58 | 56 | ||
| 59 | - var activeTemplates = await LabelTemplateQueryHelper.ProjectListColumns( | ||
| 60 | - _dbContext.SqlSugarClient.Queryable<FlLabelTemplateDbEntity>()) | ||
| 61 | - .CountAsync(x => !x.IsDeleted && x.State); | ||
| 62 | - var activeTemplatesPrevWeek = await LabelTemplateQueryHelper.ProjectListColumns( | ||
| 63 | - _dbContext.SqlSugarClient.Queryable<FlLabelTemplateDbEntity>()) | ||
| 64 | - .CountAsync(x => !x.IsDeleted && x.State && x.CreationTime < weekStart); | 57 | + var activeTemplates = await DashboardScopeHelper.CountScopedActiveTemplatesAsync( |
| 58 | + db, scopeLocationIds, createdBefore: null); | ||
| 59 | + var activeTemplatesPrevWeek = await DashboardScopeHelper.CountScopedActiveTemplatesAsync( | ||
| 60 | + db, scopeLocationIds, createdBefore: weekStart); | ||
| 65 | 61 | ||
| 66 | - var activeUsers = await DashboardScopeHelper.CountScopedTeamMembersAsync( | ||
| 67 | - db, scopeLocationIds, platformAdminUserIds, activeOnly: true, createdBefore: null); | ||
| 68 | - var activeUsersPrevWeek = await DashboardScopeHelper.CountScopedTeamMembersAsync( | ||
| 69 | - db, scopeLocationIds, platformAdminUserIds, activeOnly: true, createdBefore: weekStart); | 62 | + var activeUsers = await DashboardScopeHelper.CountScopedRegisteredUsersAsync( |
| 63 | + db, scopeLocationIds, activeOnly: true, createdBefore: null); | ||
| 64 | + var activeUsersPrevWeek = await DashboardScopeHelper.CountScopedRegisteredUsersAsync( | ||
| 65 | + db, scopeLocationIds, activeOnly: true, createdBefore: weekStart); | ||
| 70 | 66 | ||
| 71 | var labelsQuery = db.Queryable<FlLabelDbEntity>().Where(x => !x.IsDeleted && x.State); | 67 | var labelsQuery = db.Queryable<FlLabelDbEntity>().Where(x => !x.IsDeleted && x.State); |
| 72 | if (scopeLocationIds is not null) | 68 | if (scopeLocationIds is not null) |
| @@ -90,10 +86,15 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | @@ -90,10 +86,15 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | ||
| 90 | var locationsPrevWeek = await DashboardScopeHelper.CountScopedLocationsAsync( | 86 | var locationsPrevWeek = await DashboardScopeHelper.CountScopedLocationsAsync( |
| 91 | db, scopeLocationIds, weekStart); | 87 | db, scopeLocationIds, weekStart); |
| 92 | 88 | ||
| 93 | - var people = await DashboardScopeHelper.CountScopedTeamMembersAsync( | ||
| 94 | - db, scopeLocationIds, platformAdminUserIds, activeOnly: false, createdBefore: null); | ||
| 95 | - var peoplePrevWeek = await DashboardScopeHelper.CountScopedTeamMembersAsync( | ||
| 96 | - db, scopeLocationIds, platformAdminUserIds, activeOnly: false, createdBefore: weekStart); | 89 | + var people = await DashboardScopeHelper.CountScopedRegisteredUsersAsync( |
| 90 | + db, scopeLocationIds, activeOnly: false, createdBefore: null); | ||
| 91 | + var peoplePrevWeek = await DashboardScopeHelper.CountScopedRegisteredUsersAsync( | ||
| 92 | + db, scopeLocationIds, activeOnly: false, createdBefore: weekStart); | ||
| 93 | + | ||
| 94 | + var labels = await DashboardScopeHelper.CountScopedLabelsAsync( | ||
| 95 | + db, _dbContext, CurrentUser, createdBefore: null); | ||
| 96 | + var labelsPrevWeek = await DashboardScopeHelper.CountScopedLabelsAsync( | ||
| 97 | + db, _dbContext, CurrentUser, createdBefore: weekStart); | ||
| 97 | 98 | ||
| 98 | var productQuery = db.Queryable<FlProductDbEntity>().Where(x => !x.IsDeleted); | 99 | var productQuery = db.Queryable<FlProductDbEntity>().Where(x => !x.IsDeleted); |
| 99 | if (scopeLocationIds is not null) | 100 | if (scopeLocationIds is not null) |
| @@ -253,6 +254,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | @@ -253,6 +254,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | ||
| 253 | }).ToList(); | 254 | }).ToList(); |
| 254 | 255 | ||
| 255 | var labelsPrintedTodayCard = BuildMetricCard("labelsPrintedToday", "Labels Printed Today", printedToday, printedYesterday); | 256 | var labelsPrintedTodayCard = BuildMetricCard("labelsPrintedToday", "Labels Printed Today", printedToday, printedYesterday); |
| 257 | + var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek); | ||
| 256 | var activeTemplatesCard = BuildMetricCard("activeTemplates", "Active Templates", activeTemplates, activeTemplatesPrevWeek); | 258 | var activeTemplatesCard = BuildMetricCard("activeTemplates", "Active Templates", activeTemplates, activeTemplatesPrevWeek); |
| 257 | var activeUsersCard = BuildMetricCard("activeUsers", "Active Users", activeUsers, activeUsersPrevWeek); | 259 | var activeUsersCard = BuildMetricCard("activeUsers", "Active Users", activeUsers, activeUsersPrevWeek); |
| 258 | var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek); | 260 | var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek); |
| @@ -265,6 +267,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | @@ -265,6 +267,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | ||
| 265 | var output = new DashboardOverviewOutputDto | 267 | var output = new DashboardOverviewOutputDto |
| 266 | { | 268 | { |
| 267 | LabelsPrintedToday = labelsPrintedTodayCard, | 269 | LabelsPrintedToday = labelsPrintedTodayCard, |
| 270 | + Labels = labelsCard, | ||
| 268 | ActiveTemplates = activeTemplatesCard, | 271 | ActiveTemplates = activeTemplatesCard, |
| 269 | ActiveUsers = activeUsersCard, | 272 | ActiveUsers = activeUsersCard, |
| 270 | Labels = labelsCard, | 273 | Labels = labelsCard, |
| @@ -276,6 +279,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | @@ -276,6 +279,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService | ||
| 276 | MetricCards = new List<DashboardMetricCardDto> | 279 | MetricCards = new List<DashboardMetricCardDto> |
| 277 | { | 280 | { |
| 278 | labelsPrintedTodayCard, | 281 | labelsPrintedTodayCard, |
| 282 | + labelsCard, | ||
| 279 | activeTemplatesCard, | 283 | activeTemplatesCard, |
| 280 | activeUsersCard, | 284 | activeUsersCard, |
| 281 | labelsCard, | 285 | labelsCard, |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/GroupAppService.cs
| @@ -147,6 +147,7 @@ public class GroupAppService : ApplicationService, IGroupAppService | @@ -147,6 +147,7 @@ public class GroupAppService : ApplicationService, IGroupAppService | ||
| 147 | throw new UserFriendlyException("Group not found."); | 147 | throw new UserFriendlyException("Group not found."); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | + var wasActive = entity.State; | ||
| 150 | var oldGroupName = entity.GroupName; | 151 | var oldGroupName = entity.GroupName; |
| 151 | var oldPartnerIdForCascade = entity.PartnerId; | 152 | var oldPartnerIdForCascade = entity.PartnerId; |
| 152 | var name = input.GroupName?.Trim(); | 153 | var name = input.GroupName?.Trim(); |
| @@ -194,12 +195,23 @@ public class GroupAppService : ApplicationService, IGroupAppService | @@ -194,12 +195,23 @@ public class GroupAppService : ApplicationService, IGroupAppService | ||
| 194 | entity.LastModifierId = CurrentUser?.Id?.ToString(); | 195 | entity.LastModifierId = CurrentUser?.Id?.ToString(); |
| 195 | 196 | ||
| 196 | await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync(); | 197 | await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync(); |
| 198 | + | ||
| 199 | + if (AccountStructureCascadeInactiveHelper.IsBecomingInactive(wasActive, entity.State)) | ||
| 200 | + { | ||
| 201 | + await AccountStructureCascadeInactiveHelper.CascadeGroupInactiveAsync( | ||
| 202 | + _dbContext.SqlSugarClient, | ||
| 203 | + groupId, | ||
| 204 | + Clock.Now, | ||
| 205 | + CurrentUser?.Id, | ||
| 206 | + CurrentUser?.Id?.ToString()); | ||
| 207 | + } | ||
| 208 | + | ||
| 197 | return await GetAsync(id); | 209 | return await GetAsync(id); |
| 198 | } | 210 | } |
| 199 | 211 | ||
| 200 | /// <inheritdoc /> | 212 | /// <inheritdoc /> |
| 201 | [UnitOfWork] | 213 | [UnitOfWork] |
| 202 | - public async Task DeleteAsync(Guid id) | 214 | + public async Task DeleteAsync(Guid id, [FromQuery] bool confirmCascade = false) |
| 203 | { | 215 | { |
| 204 | await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext); | 216 | await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext); |
| 205 | 217 | ||
| @@ -209,17 +221,41 @@ public class GroupAppService : ApplicationService, IGroupAppService | @@ -209,17 +221,41 @@ public class GroupAppService : ApplicationService, IGroupAppService | ||
| 209 | } | 221 | } |
| 210 | 222 | ||
| 211 | var groupId = id.ToString(); | 223 | var groupId = id.ToString(); |
| 212 | - var entity = await _dbContext.SqlSugarClient.Queryable<FlGroupDbEntity>() | 224 | + var db = _dbContext.SqlSugarClient; |
| 225 | + var entity = await db.Queryable<FlGroupDbEntity>() | ||
| 213 | .FirstAsync(x => !x.IsDeleted && x.Id == groupId); | 226 | .FirstAsync(x => !x.IsDeleted && x.Id == groupId); |
| 214 | if (entity is null) | 227 | if (entity is null) |
| 215 | { | 228 | { |
| 216 | throw new UserFriendlyException("Group not found."); | 229 | throw new UserFriendlyException("Group not found."); |
| 217 | } | 230 | } |
| 218 | 231 | ||
| 219 | - entity.IsDeleted = true; | ||
| 220 | - entity.LastModificationTime = Clock.Now; | ||
| 221 | - entity.LastModifierId = CurrentUser?.Id?.ToString(); | ||
| 222 | - await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync(); | 232 | + var partnerName = await ResolvePartnerNameAsync(entity.PartnerId); |
| 233 | + if (string.Equals(partnerName, "None", StringComparison.OrdinalIgnoreCase)) | ||
| 234 | + { | ||
| 235 | + throw new UserFriendlyException("The selected company does not exist or has been removed."); | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + var groupName = entity.GroupName?.Trim() ?? string.Empty; | ||
| 239 | + var locationCount = await AccountStructureCascadeDeleteHelper.CountActiveLocationsByPartnerAndGroupAsync( | ||
| 240 | + db, partnerName, groupName); | ||
| 241 | + | ||
| 242 | + if (locationCount > 0 && !confirmCascade) | ||
| 243 | + { | ||
| 244 | + throw new UserFriendlyException( | ||
| 245 | + AccountStructureCascadeDeleteHelper.BuildGroupCascadeRequiredMessage(locationCount)); | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | + var now = Clock.Now; | ||
| 249 | + var modifierId = CurrentUser?.Id; | ||
| 250 | + var modifierIdString = modifierId?.ToString(); | ||
| 251 | + | ||
| 252 | + if (confirmCascade && locationCount > 0) | ||
| 253 | + { | ||
| 254 | + await AccountStructureCascadeDeleteHelper.SoftDeleteLocationsByPartnerAndGroupAsync( | ||
| 255 | + db, partnerName, groupName, now, modifierId, modifierIdString); | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + await AccountStructureCascadeDeleteHelper.SoftDeleteGroupAsync(db, groupId, now, modifierIdString); | ||
| 223 | } | 259 | } |
| 224 | 260 | ||
| 225 | /// <inheritdoc /> | 261 | /// <inheritdoc /> |
| @@ -303,14 +339,14 @@ public class GroupAppService : ApplicationService, IGroupAppService | @@ -303,14 +339,14 @@ public class GroupAppService : ApplicationService, IGroupAppService | ||
| 303 | { | 339 | { |
| 304 | if (input?.Items is null || input.Items.Count == 0) | 340 | if (input?.Items is null || input.Items.Count == 0) |
| 305 | { | 341 | { |
| 306 | - throw new UserFriendlyException("请至少提交一条导入数据(items 不能为空)"); | 342 | + throw new UserFriendlyException("Please submit at least one import item (items cannot be empty)."); |
| 307 | } | 343 | } |
| 308 | 344 | ||
| 309 | var opt = _batchImportOptions.Value; | 345 | var opt = _batchImportOptions.Value; |
| 310 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; | 346 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; |
| 311 | if (input.Items.Count > maxRows) | 347 | if (input.Items.Count > maxRows) |
| 312 | { | 348 | { |
| 313 | - throw new UserFriendlyException($"单次批量导入最多允许 {maxRows} 条,请分批提交"); | 349 | + throw new UserFriendlyException($"A maximum of {maxRows} rows is allowed per batch import. Please submit in smaller batches."); |
| 314 | } | 350 | } |
| 315 | 351 | ||
| 316 | var result = new GroupBatchImportOnlineResultDto(); | 352 | var result = new GroupBatchImportOnlineResultDto(); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
| @@ -223,7 +223,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -223,7 +223,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 223 | regionScopeMap[lid] = await LabelRegionScopeHelper.BuildScopeDisplayAsync( | 223 | regionScopeMap[lid] = await LabelRegionScopeHelper.BuildScopeDisplayAsync( |
| 224 | db, lid, applied, locIds); | 224 | db, lid, applied, locIds); |
| 225 | locationScopeMap[lid] = await LabelRegionScopeHelper.BuildLocationDisplayAsync( | 225 | locationScopeMap[lid] = await LabelRegionScopeHelper.BuildLocationDisplayAsync( |
| 226 | - db, applied, locIds); | 226 | + db, applied, locIds, lid); |
| 227 | locationIdsMap[lid] = locationScopeMap[lid].LocationIds; | 227 | locationIdsMap[lid] = locationScopeMap[lid].LocationIds; |
| 228 | labelMap.TryGetValue(lid, out var partnerRow); | 228 | labelMap.TryGetValue(lid, out var partnerRow); |
| 229 | partnerEchoMap[lid] = await BuildLabelPartnerEchoAsync( | 229 | partnerEchoMap[lid] = await BuildLabelPartnerEchoAsync( |
| @@ -310,7 +310,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -310,7 +310,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 310 | var labelCode = id?.Trim(); | 310 | var labelCode = id?.Trim(); |
| 311 | if (string.IsNullOrWhiteSpace(labelCode)) | 311 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 312 | { | 312 | { |
| 313 | - throw new UserFriendlyException("标签Code不能为空"); | 313 | + throw new UserFriendlyException("labelCode is required."); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | var db = _dbContext.SqlSugarClient; | 316 | var db = _dbContext.SqlSugarClient; |
| @@ -318,7 +318,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -318,7 +318,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 318 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 318 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 319 | if (label is null) | 319 | if (label is null) |
| 320 | { | 320 | { |
| 321 | - throw new UserFriendlyException("标签不存在"); | 321 | + throw new UserFriendlyException("Label not found."); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | var template = await LabelTemplateQueryHelper.QueryProjected(db) | 324 | var template = await LabelTemplateQueryHelper.QueryProjected(db) |
| @@ -394,21 +394,21 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -394,21 +394,21 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 394 | var labelName = input.LabelName?.Trim(); | 394 | var labelName = input.LabelName?.Trim(); |
| 395 | if (string.IsNullOrWhiteSpace(labelName)) | 395 | if (string.IsNullOrWhiteSpace(labelName)) |
| 396 | { | 396 | { |
| 397 | - throw new UserFriendlyException("标签名称不能为空"); | 397 | + throw new UserFriendlyException("Label name is required."); |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | if (input.ProductIds is null || input.ProductIds.Count == 0) | 400 | if (input.ProductIds is null || input.ProductIds.Count == 0) |
| 401 | { | 401 | { |
| 402 | - throw new UserFriendlyException("标签至少需要绑定一个产品"); | 402 | + throw new UserFriendlyException("A label must be bound to at least one product."); |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) | 405 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) |
| 406 | { | 406 | { |
| 407 | - throw new UserFriendlyException("模板编码不能为空"); | 407 | + throw new UserFriendlyException("Template code is required."); |
| 408 | } | 408 | } |
| 409 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) | 409 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) |
| 410 | { | 410 | { |
| 411 | - throw new UserFriendlyException("标签分类Id不能为空"); | 411 | + throw new UserFriendlyException("Label category ID is required."); |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); | 414 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); |
| @@ -428,7 +428,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -428,7 +428,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 428 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); | 428 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); |
| 429 | if (template is null) | 429 | if (template is null) |
| 430 | { | 430 | { |
| 431 | - throw new UserFriendlyException("模板不存在"); | 431 | + throw new UserFriendlyException("Template not found."); |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | // 唯一性校验(LabelCode) | 434 | // 唯一性校验(LabelCode) |
| @@ -436,7 +436,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -436,7 +436,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 436 | .AnyAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 436 | .AnyAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 437 | if (exists) | 437 | if (exists) |
| 438 | { | 438 | { |
| 439 | - throw new UserFriendlyException("标签编码已存在"); | 439 | + throw new UserFriendlyException("Label code already exists."); |
| 440 | } | 440 | } |
| 441 | 441 | ||
| 442 | // 插入 fl_label | 442 | // 插入 fl_label |
| @@ -534,26 +534,26 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -534,26 +534,26 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 534 | /// <param name="input">批量导入入参</param> | 534 | /// <param name="input">批量导入入参</param> |
| 535 | /// <returns>成功/失败统计与行级错误</returns> | 535 | /// <returns>成功/失败统计与行级错误</returns> |
| 536 | /// <response code="200">导入完成(可能部分成功)</response> | 536 | /// <response code="200">导入完成(可能部分成功)</response> |
| 537 | - /// <response code="400">入参非法或模板不存在</response> | 537 | + /// <response code="400">入参非法或Template not found.</response> |
| 538 | /// <response code="500">服务器错误</response> | 538 | /// <response code="500">服务器错误</response> |
| 539 | [UnitOfWork] | 539 | [UnitOfWork] |
| 540 | public async Task<LabelBatchCreateResultDto> BatchCreateAsync(LabelBatchCreateInputVo input) | 540 | public async Task<LabelBatchCreateResultDto> BatchCreateAsync(LabelBatchCreateInputVo input) |
| 541 | { | 541 | { |
| 542 | if (input?.Items is null || input.Items.Count == 0) | 542 | if (input?.Items is null || input.Items.Count == 0) |
| 543 | { | 543 | { |
| 544 | - throw new UserFriendlyException("批量导入行不能为空"); | 544 | + throw new UserFriendlyException("Batch import rows cannot be empty."); |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | const int maxRows = 500; | 547 | const int maxRows = 500; |
| 548 | if (input.Items.Count > maxRows) | 548 | if (input.Items.Count > maxRows) |
| 549 | { | 549 | { |
| 550 | - throw new UserFriendlyException($"单次最多导入 {maxRows} 行"); | 550 | + throw new UserFriendlyException($"A maximum of {maxRows} rows can be imported per batch."); |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | var templateCode = input.TemplateCode?.Trim(); | 553 | var templateCode = input.TemplateCode?.Trim(); |
| 554 | if (string.IsNullOrWhiteSpace(templateCode)) | 554 | if (string.IsNullOrWhiteSpace(templateCode)) |
| 555 | { | 555 | { |
| 556 | - throw new UserFriendlyException("模板编码不能为空"); | 556 | + throw new UserFriendlyException("Template code is required."); |
| 557 | } | 557 | } |
| 558 | 558 | ||
| 559 | var db = _dbContext.SqlSugarClient; | 559 | var db = _dbContext.SqlSugarClient; |
| @@ -561,7 +561,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -561,7 +561,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 561 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == templateCode); | 561 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == templateCode); |
| 562 | if (template is null) | 562 | if (template is null) |
| 563 | { | 563 | { |
| 564 | - throw new UserFriendlyException("模板不存在"); | 564 | + throw new UserFriendlyException("Template not found."); |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | var templateElements = await LabelBatchTemplateDefaultsHelper.LoadTemplateElementsAsync(db, template.Id); | 567 | var templateElements = await LabelBatchTemplateDefaultsHelper.LoadTemplateElementsAsync(db, template.Id); |
| @@ -662,7 +662,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -662,7 +662,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 662 | result.Errors.Add(new LabelBatchCreateErrorDto | 662 | result.Errors.Add(new LabelBatchCreateErrorDto |
| 663 | { | 663 | { |
| 664 | RowNumber = 0, | 664 | RowNumber = 0, |
| 665 | - Message = $"标签已创建,但模板默认值保存失败:{ex.Message}" | 665 | + Message = $"Label was created, but saving template defaults failed: {ex.Message}" |
| 666 | }); | 666 | }); |
| 667 | } | 667 | } |
| 668 | } | 668 | } |
| @@ -701,28 +701,28 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -701,28 +701,28 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 701 | var labelCode = id?.Trim(); | 701 | var labelCode = id?.Trim(); |
| 702 | if (string.IsNullOrWhiteSpace(labelCode)) | 702 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 703 | { | 703 | { |
| 704 | - throw new UserFriendlyException("标签Code不能为空"); | 704 | + throw new UserFriendlyException("labelCode is required."); |
| 705 | } | 705 | } |
| 706 | 706 | ||
| 707 | var label = await LabelQueryHelper.QueryProjected(_dbContext.SqlSugarClient) | 707 | var label = await LabelQueryHelper.QueryProjected(_dbContext.SqlSugarClient) |
| 708 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 708 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 709 | if (label is null) | 709 | if (label is null) |
| 710 | { | 710 | { |
| 711 | - throw new UserFriendlyException("标签不存在"); | 711 | + throw new UserFriendlyException("Label not found."); |
| 712 | } | 712 | } |
| 713 | 713 | ||
| 714 | if (input.ProductIds is null || input.ProductIds.Count == 0) | 714 | if (input.ProductIds is null || input.ProductIds.Count == 0) |
| 715 | { | 715 | { |
| 716 | - throw new UserFriendlyException("标签至少需要绑定一个产品"); | 716 | + throw new UserFriendlyException("A label must be bound to at least one product."); |
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) | 719 | if (string.IsNullOrWhiteSpace(input.TemplateCode)) |
| 720 | { | 720 | { |
| 721 | - throw new UserFriendlyException("模板编码不能为空"); | 721 | + throw new UserFriendlyException("Template code is required."); |
| 722 | } | 722 | } |
| 723 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) | 723 | if (string.IsNullOrWhiteSpace(input.LabelCategoryId)) |
| 724 | { | 724 | { |
| 725 | - throw new UserFriendlyException("标签分类Id不能为空"); | 725 | + throw new UserFriendlyException("Label category ID is required."); |
| 726 | } | 726 | } |
| 727 | 727 | ||
| 728 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); | 728 | await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId); |
| @@ -742,7 +742,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -742,7 +742,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 742 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); | 742 | .FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim()); |
| 743 | if (template is null) | 743 | if (template is null) |
| 744 | { | 744 | { |
| 745 | - throw new UserFriendlyException("模板不存在"); | 745 | + throw new UserFriendlyException("Template not found."); |
| 746 | } | 746 | } |
| 747 | 747 | ||
| 748 | var oldCategoryId = label.LabelCategoryId; | 748 | var oldCategoryId = label.LabelCategoryId; |
| @@ -877,7 +877,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -877,7 +877,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 877 | var labelCode = input?.LabelCode?.Trim(); | 877 | var labelCode = input?.LabelCode?.Trim(); |
| 878 | if (string.IsNullOrWhiteSpace(labelCode)) | 878 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 879 | { | 879 | { |
| 880 | - throw new UserFriendlyException("labelCode不能为空"); | 880 | + throw new UserFriendlyException("labelCode is required."); |
| 881 | } | 881 | } |
| 882 | 882 | ||
| 883 | var baseTime = input?.BaseTime ?? DateTime.Now; | 883 | var baseTime = input?.BaseTime ?? DateTime.Now; |
| @@ -886,7 +886,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -886,7 +886,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 886 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); | 886 | .FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode); |
| 887 | if (label is null) | 887 | if (label is null) |
| 888 | { | 888 | { |
| 889 | - throw new UserFriendlyException("标签不存在"); | 889 | + throw new UserFriendlyException("Label not found."); |
| 890 | } | 890 | } |
| 891 | 891 | ||
| 892 | // 选择预览产品 | 892 | // 选择预览产品 |
| @@ -901,14 +901,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -901,14 +901,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 901 | 901 | ||
| 902 | if (string.IsNullOrWhiteSpace(productId)) | 902 | if (string.IsNullOrWhiteSpace(productId)) |
| 903 | { | 903 | { |
| 904 | - throw new UserFriendlyException("该标签未绑定产品,无法预览"); | 904 | + throw new UserFriendlyException("This label has no bound product and cannot be previewed."); |
| 905 | } | 905 | } |
| 906 | 906 | ||
| 907 | var product = await _dbContext.SqlSugarClient.Queryable<FlProductDbEntity>() | 907 | var product = await _dbContext.SqlSugarClient.Queryable<FlProductDbEntity>() |
| 908 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); | 908 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); |
| 909 | if (product is null) | 909 | if (product is null) |
| 910 | { | 910 | { |
| 911 | - throw new UserFriendlyException("预览产品不存在"); | 911 | + throw new UserFriendlyException("Preview product not found."); |
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | // 取模板头 & elements | 914 | // 取模板头 & elements |
| @@ -916,7 +916,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -916,7 +916,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 916 | .FirstAsync(x => !x.IsDeleted && x.Id == label.TemplateId); | 916 | .FirstAsync(x => !x.IsDeleted && x.Id == label.TemplateId); |
| 917 | if (template is null) | 917 | if (template is null) |
| 918 | { | 918 | { |
| 919 | - throw new UserFriendlyException("模板不存在"); | 919 | + throw new UserFriendlyException("Template not found."); |
| 920 | } | 920 | } |
| 921 | 921 | ||
| 922 | var elements = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateElementDbEntity>() | 922 | var elements = await _dbContext.SqlSugarClient.Queryable<FlLabelTemplateElementDbEntity>() |
| @@ -992,7 +992,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -992,7 +992,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 992 | { | 992 | { |
| 993 | if (string.IsNullOrWhiteSpace(locationId)) | 993 | if (string.IsNullOrWhiteSpace(locationId)) |
| 994 | { | 994 | { |
| 995 | - throw new UserFriendlyException("预览/打印需要 locationId 以填充 Company 信息"); | 995 | + throw new UserFriendlyException("Preview/print requires locationId to fill Company information."); |
| 996 | } | 996 | } |
| 997 | 997 | ||
| 998 | partnerForCompany = await PartnerCompanyDisplayHelper.ResolvePartnerByLocationIdAsync( | 998 | partnerForCompany = await PartnerCompanyDisplayHelper.ResolvePartnerByLocationIdAsync( |
| @@ -1198,16 +1198,22 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1198,16 +1198,22 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1198 | partnerIds = !string.IsNullOrWhiteSpace(storedPartnerId) | 1198 | partnerIds = !string.IsNullOrWhiteSpace(storedPartnerId) |
| 1199 | ? new List<string> { storedPartnerId } | 1199 | ? new List<string> { storedPartnerId } |
| 1200 | : await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(db, locationIds); | 1200 | : await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(db, locationIds); |
| 1201 | + var persistedLocationIds = locationIds; | ||
| 1202 | + var regionIdsFromDb = !string.IsNullOrWhiteSpace(labelId) | ||
| 1203 | + ? await LabelRegionScopeHelper.GetRegionIdsForLabelAsync(db, labelId) | ||
| 1204 | + : new List<string>(); | ||
| 1201 | var storedRegionScope = !string.IsNullOrWhiteSpace(labelId) | 1205 | var storedRegionScope = !string.IsNullOrWhiteSpace(labelId) |
| 1202 | - ? await LabelRegionScopeHelper.BuildScopeDisplayAsync(db, labelId, appliedRegionType, locationIds) | 1206 | + ? await LabelRegionScopeHelper.BuildScopeDisplayAsync( |
| 1207 | + db, labelId, appliedRegionType, persistedLocationIds) | ||
| 1203 | : new LabelRegionScopeHelper.LabelRegionScopeDisplay { RegionIds = new List<string>() }; | 1208 | : new LabelRegionScopeHelper.LabelRegionScopeDisplay { RegionIds = new List<string>() }; |
| 1204 | regionIdsForDto = storedRegionScope.RegionIds; | 1209 | regionIdsForDto = storedRegionScope.RegionIds; |
| 1205 | var collapsed = await ScopeAllEchoHelper.CollapseScopeIdsToAllSentinelAsync( | 1210 | var collapsed = await ScopeAllEchoHelper.CollapseScopeIdsToAllSentinelAsync( |
| 1206 | db, | 1211 | db, |
| 1207 | partnerIds, | 1212 | partnerIds, |
| 1208 | regionIdsForDto, | 1213 | regionIdsForDto, |
| 1209 | - locationIds, | ||
| 1210 | - ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds)); | 1214 | + persistedLocationIds, |
| 1215 | + ScopeAllEchoHelper.ForLabelRegionScope( | ||
| 1216 | + appliedRegionType, persistedLocationIds, regionIdsFromDb)); | ||
| 1211 | if (string.IsNullOrWhiteSpace(storedPartnerId)) | 1217 | if (string.IsNullOrWhiteSpace(storedPartnerId)) |
| 1212 | { | 1218 | { |
| 1213 | partnerIds = collapsed.PartnerIds; | 1219 | partnerIds = collapsed.PartnerIds; |
| @@ -1226,7 +1232,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1226,7 +1232,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1226 | var locationDisplay = isDynamicAll | 1232 | var locationDisplay = isDynamicAll |
| 1227 | ? LabelRegionScopeHelper.AllLocationsDisplay | 1233 | ? LabelRegionScopeHelper.AllLocationsDisplay |
| 1228 | : (await LabelRegionScopeHelper.BuildLocationDisplayAsync( | 1234 | : (await LabelRegionScopeHelper.BuildLocationDisplayAsync( |
| 1229 | - db, appliedRegionType, locationIds)).Location; | 1235 | + db, appliedRegionType, locationIds, labelId)).Location; |
| 1230 | 1236 | ||
| 1231 | var companyIdsEcho = partnerIds.Count == 1 | 1237 | var companyIdsEcho = partnerIds.Count == 1 |
| 1232 | && !AllScopeBindingHelper.IsDeclaredAll(partnerIds[0]) | 1238 | && !AllScopeBindingHelper.IsDeclaredAll(partnerIds[0]) |
| @@ -1261,14 +1267,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1261,14 +1267,14 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1261 | var pid = partnerId.Trim(); | 1267 | var pid = partnerId.Trim(); |
| 1262 | if (LocationScopeBindingHelper.IsAllScopeSentinel(pid)) | 1268 | if (LocationScopeBindingHelper.IsAllScopeSentinel(pid)) |
| 1263 | { | 1269 | { |
| 1264 | - throw new UserFriendlyException("标签适用 Company 不支持 ALL,请传单个具体 Company Id"); | 1270 | + throw new UserFriendlyException("Label Company scope does not support ALL. Pass a single Company Id."); |
| 1265 | } | 1271 | } |
| 1266 | 1272 | ||
| 1267 | if (merged.Count > 0 | 1273 | if (merged.Count > 0 |
| 1268 | && (merged.Count > 1 | 1274 | && (merged.Count > 1 |
| 1269 | || !string.Equals(merged[0], pid, StringComparison.OrdinalIgnoreCase))) | 1275 | || !string.Equals(merged[0], pid, StringComparison.OrdinalIgnoreCase))) |
| 1270 | { | 1276 | { |
| 1271 | - throw new UserFriendlyException("partnerId 与 companyIds/partnerIds 不一致"); | 1277 | + throw new UserFriendlyException("partnerId does not match companyIds/partnerIds."); |
| 1272 | } | 1278 | } |
| 1273 | 1279 | ||
| 1274 | merged = new List<string> { pid }; | 1280 | merged = new List<string> { pid }; |
| @@ -1276,13 +1282,13 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1276,13 +1282,13 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1276 | 1282 | ||
| 1277 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(merged)) | 1283 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(merged)) |
| 1278 | { | 1284 | { |
| 1279 | - throw new UserFriendlyException("标签适用 Company 不支持 ALL,请传单个具体 Company Id"); | 1285 | + throw new UserFriendlyException("Label Company scope does not support ALL. Pass a single Company Id."); |
| 1280 | } | 1286 | } |
| 1281 | 1287 | ||
| 1282 | var concrete = LocationScopeBindingHelper.FilterConcreteScopeIds(merged); | 1288 | var concrete = LocationScopeBindingHelper.FilterConcreteScopeIds(merged); |
| 1283 | if (concrete.Count > 1) | 1289 | if (concrete.Count > 1) |
| 1284 | { | 1290 | { |
| 1285 | - throw new UserFriendlyException("标签适用 Company 仅支持单选(companyIds 最多传 1 个)"); | 1291 | + throw new UserFriendlyException("Label Company scope supports only one selection (companyIds may contain at most one item)."); |
| 1286 | } | 1292 | } |
| 1287 | 1293 | ||
| 1288 | if (concrete.Count == 0) | 1294 | if (concrete.Count == 0) |
| @@ -1294,7 +1300,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1294,7 +1300,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1294 | .AnyAsync(x => !x.IsDeleted && x.Id == concrete[0]); | 1300 | .AnyAsync(x => !x.IsDeleted && x.Id == concrete[0]); |
| 1295 | if (!exists) | 1301 | if (!exists) |
| 1296 | { | 1302 | { |
| 1297 | - throw new UserFriendlyException("存在无效的 Company(partnerId/companyIds),请刷新后重试"); | 1303 | + throw new UserFriendlyException("One or more Companies are invalid (partnerId/companyIds). Refresh and try again."); |
| 1298 | } | 1304 | } |
| 1299 | 1305 | ||
| 1300 | return concrete[0]; | 1306 | return concrete[0]; |
| @@ -1312,7 +1318,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | @@ -1312,7 +1318,7 @@ public class LabelAppService : ApplicationService, ILabelAppService | ||
| 1312 | .AnyAsync(x => !x.IsDeleted && x.Id == id); | 1318 | .AnyAsync(x => !x.IsDeleted && x.Id == id); |
| 1313 | if (!exists) | 1319 | if (!exists) |
| 1314 | { | 1320 | { |
| 1315 | - throw new UserFriendlyException("标签类型不存在"); | 1321 | + throw new UserFriendlyException("Label type not found."); |
| 1316 | } | 1322 | } |
| 1317 | } | 1323 | } |
| 1318 | 1324 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
| @@ -117,7 +117,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -117,7 +117,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 117 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 117 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 118 | if (entity is null) | 118 | if (entity is null) |
| 119 | { | 119 | { |
| 120 | - throw new UserFriendlyException("标签分类不存在"); | 120 | + throw new UserFriendlyException("Label category not found."); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | var dto = MapToGetOutput(entity); | 123 | var dto = MapToGetOutput(entity); |
| @@ -174,7 +174,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -174,7 +174,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 174 | var name = input.CategoryName?.Trim(); | 174 | var name = input.CategoryName?.Trim(); |
| 175 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) | 175 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) |
| 176 | { | 176 | { |
| 177 | - throw new UserFriendlyException("分类编码和名称不能为空"); | 177 | + throw new UserFriendlyException("Category code and name are required."); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | var displayText = input.DisplayText?.Trim(); | 180 | var displayText = input.DisplayText?.Trim(); |
| @@ -185,7 +185,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -185,7 +185,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 185 | .AnyAsync(x => !x.IsDeleted && (x.CategoryCode == code || x.CategoryName == name)); | 185 | .AnyAsync(x => !x.IsDeleted && (x.CategoryCode == code || x.CategoryName == name)); |
| 186 | if (duplicated) | 186 | if (duplicated) |
| 187 | { | 187 | { |
| 188 | - throw new UserFriendlyException("分类编码或名称已存在"); | 188 | + throw new UserFriendlyException("Category code or name already exists."); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | await PurgeSoftDeletedLabelCategoriesByCodeAsync(code); | 191 | await PurgeSoftDeletedLabelCategoriesByCodeAsync(code); |
| @@ -225,14 +225,14 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -225,14 +225,14 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 225 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 225 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 226 | if (entity is null) | 226 | if (entity is null) |
| 227 | { | 227 | { |
| 228 | - throw new UserFriendlyException("标签分类不存在"); | 228 | + throw new UserFriendlyException("Label category not found."); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | var code = input.CategoryCode?.Trim(); | 231 | var code = input.CategoryCode?.Trim(); |
| 232 | var name = input.CategoryName?.Trim(); | 232 | var name = input.CategoryName?.Trim(); |
| 233 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) | 233 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) |
| 234 | { | 234 | { |
| 235 | - throw new UserFriendlyException("分类编码和名称不能为空"); | 235 | + throw new UserFriendlyException("Category code and name are required."); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | var displayText = input.DisplayText?.Trim(); | 238 | var displayText = input.DisplayText?.Trim(); |
| @@ -243,7 +243,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -243,7 +243,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 243 | .AnyAsync(x => !x.IsDeleted && x.Id != id && (x.CategoryCode == code || x.CategoryName == name)); | 243 | .AnyAsync(x => !x.IsDeleted && x.Id != id && (x.CategoryCode == code || x.CategoryName == name)); |
| 244 | if (duplicated) | 244 | if (duplicated) |
| 245 | { | 245 | { |
| 246 | - throw new UserFriendlyException("分类编码或名称已存在"); | 246 | + throw new UserFriendlyException("Category code or name already exists."); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | entity.CategoryCode = code; | 249 | entity.CategoryCode = code; |
| @@ -296,7 +296,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | @@ -296,7 +296,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ | ||
| 296 | .AnyAsync(x => !x.IsDeleted && x.LabelCategoryId == id); | 296 | .AnyAsync(x => !x.IsDeleted && x.LabelCategoryId == id); |
| 297 | if (used) | 297 | if (used) |
| 298 | { | 298 | { |
| 299 | - throw new UserFriendlyException("该标签分类已被标签引用,无法删除"); | 299 | + throw new UserFriendlyException("This label category is referenced by labels and cannot be deleted."); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( | 302 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( |
美国版/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); |
| @@ -163,14 +163,14 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -163,14 +163,14 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 163 | var name = input.OptionName?.Trim(); | 163 | var name = input.OptionName?.Trim(); |
| 164 | if (string.IsNullOrWhiteSpace(name)) | 164 | if (string.IsNullOrWhiteSpace(name)) |
| 165 | { | 165 | { |
| 166 | - throw new UserFriendlyException("多选项名称不能为空"); | 166 | + throw new UserFriendlyException("Multiple option name is required."); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input); | 169 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input); |
| 170 | 170 | ||
| 171 | if (await IsMultipleOptionDuplicatedAsync(code, name, excludeId: null)) | 171 | if (await IsMultipleOptionDuplicatedAsync(code, name, excludeId: null)) |
| 172 | { | 172 | { |
| 173 | - throw new UserFriendlyException("多选项编码或名称已存在"); | 173 | + throw new UserFriendlyException("Multiple option code or name already exists."); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | // 唯一索引含软删行:同编码已删除记录会挡住 INSERT,创建前物理清理 | 176 | // 唯一索引含软删行:同编码已删除记录会挡住 INSERT,创建前物理清理 |
| @@ -216,21 +216,21 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | @@ -216,21 +216,21 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO | ||
| 216 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 216 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 217 | if (entity is null) | 217 | if (entity is null) |
| 218 | { | 218 | { |
| 219 | - throw new UserFriendlyException("多选项不存在"); | 219 | + throw new UserFriendlyException("Multiple option not found."); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | var code = NormalizeOptionCode(input.OptionCode); | 222 | var code = NormalizeOptionCode(input.OptionCode); |
| 223 | var name = input.OptionName?.Trim(); | 223 | var name = input.OptionName?.Trim(); |
| 224 | if (string.IsNullOrWhiteSpace(name)) | 224 | if (string.IsNullOrWhiteSpace(name)) |
| 225 | { | 225 | { |
| 226 | - throw new UserFriendlyException("多选项名称不能为空"); | 226 | + throw new UserFriendlyException("Multiple option name is required."); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input); | 229 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input); |
| 230 | 230 | ||
| 231 | if (await IsMultipleOptionDuplicatedAsync(code, name, excludeId: id)) | 231 | if (await IsMultipleOptionDuplicatedAsync(code, name, excludeId: id)) |
| 232 | { | 232 | { |
| 233 | - throw new UserFriendlyException("多选项编码或名称已存在"); | 233 | + throw new UserFriendlyException("Multiple option code or name already exists."); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | entity.OptionCode = code; | 236 | entity.OptionCode = code; |
美国版/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: only one row is allowed for product [{productId}] and label type [{labelTypeId}]."); |
| 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("Product Id is required in template default bindings."); |
| 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("Label type Id is required in template default bindings."); |
| 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
| @@ -61,7 +61,13 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -61,7 +61,13 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 61 | var entities = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); | 61 | var entities = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); |
| 62 | var ids = entities.Select(x => x.Id).ToList(); | 62 | var ids = entities.Select(x => x.Id).ToList(); |
| 63 | 63 | ||
| 64 | - var countMap = await BuildTypeLabelStatsMapAsync(ids, scopedLocationIds); | 64 | + var countMap = await BuildTypeLabelStatsMapAsync( |
| 65 | + ids, | ||
| 66 | + scopedLocationIds, | ||
| 67 | + scopedPartnerIds, | ||
| 68 | + input.PartnerId, | ||
| 69 | + input.GroupId, | ||
| 70 | + input.LocationId); | ||
| 65 | var scopeMap = await BuildTypeConfiguredScopeMapAsync(entities); | 71 | var scopeMap = await BuildTypeConfiguredScopeMapAsync(entities); |
| 66 | var partnerScopeMap = await LabelEntityPartnerScopeHelper.BuildPartnerScopeDisplayMapAsync( | 72 | var partnerScopeMap = await LabelEntityPartnerScopeHelper.BuildPartnerScopeDisplayMapAsync( |
| 67 | _dbContext.SqlSugarClient, | 73 | _dbContext.SqlSugarClient, |
| @@ -105,7 +111,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -105,7 +111,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 105 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 111 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 106 | if (entity is null) | 112 | if (entity is null) |
| 107 | { | 113 | { |
| 108 | - throw new UserFriendlyException("标签类型不存在"); | 114 | + throw new UserFriendlyException("Label type not found."); |
| 109 | } | 115 | } |
| 110 | 116 | ||
| 111 | var dto = MapToGetOutput(entity); | 117 | var dto = MapToGetOutput(entity); |
| @@ -162,7 +168,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -162,7 +168,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 162 | var name = input.TypeName?.Trim(); | 168 | var name = input.TypeName?.Trim(); |
| 163 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) | 169 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) |
| 164 | { | 170 | { |
| 165 | - throw new UserFriendlyException("类型编码和名称不能为空"); | 171 | + throw new UserFriendlyException("Type code and name are required."); |
| 166 | } | 172 | } |
| 167 | 173 | ||
| 168 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input); | 174 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input); |
| @@ -171,7 +177,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -171,7 +177,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 171 | .AnyAsync(x => !x.IsDeleted && (x.TypeCode == code || x.TypeName == name)); | 177 | .AnyAsync(x => !x.IsDeleted && (x.TypeCode == code || x.TypeName == name)); |
| 172 | if (duplicated) | 178 | if (duplicated) |
| 173 | { | 179 | { |
| 174 | - throw new UserFriendlyException("类型编码或名称已存在"); | 180 | + throw new UserFriendlyException("Type code or name already exists."); |
| 175 | } | 181 | } |
| 176 | 182 | ||
| 177 | // 唯一索引含软删行:同编码已删除记录会挡住 INSERT,创建前物理清理 | 183 | // 唯一索引含软删行:同编码已删除记录会挡住 INSERT,创建前物理清理 |
| @@ -209,14 +215,14 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -209,14 +215,14 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 209 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 215 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 210 | if (entity is null) | 216 | if (entity is null) |
| 211 | { | 217 | { |
| 212 | - throw new UserFriendlyException("标签类型不存在"); | 218 | + throw new UserFriendlyException("Label type not found."); |
| 213 | } | 219 | } |
| 214 | 220 | ||
| 215 | var code = input.TypeCode?.Trim(); | 221 | var code = input.TypeCode?.Trim(); |
| 216 | var name = input.TypeName?.Trim(); | 222 | var name = input.TypeName?.Trim(); |
| 217 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) | 223 | if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name)) |
| 218 | { | 224 | { |
| 219 | - throw new UserFriendlyException("类型编码和名称不能为空"); | 225 | + throw new UserFriendlyException("Type code and name are required."); |
| 220 | } | 226 | } |
| 221 | 227 | ||
| 222 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input); | 228 | var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input); |
| @@ -225,7 +231,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -225,7 +231,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 225 | .AnyAsync(x => !x.IsDeleted && x.Id != id && (x.TypeCode == code || x.TypeName == name)); | 231 | .AnyAsync(x => !x.IsDeleted && x.Id != id && (x.TypeCode == code || x.TypeName == name)); |
| 226 | if (duplicated) | 232 | if (duplicated) |
| 227 | { | 233 | { |
| 228 | - throw new UserFriendlyException("类型编码或名称已存在"); | 234 | + throw new UserFriendlyException("Type code or name already exists."); |
| 229 | } | 235 | } |
| 230 | 236 | ||
| 231 | entity.TypeCode = code; | 237 | entity.TypeCode = code; |
| @@ -272,7 +278,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -272,7 +278,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 272 | .AnyAsync(x => !x.IsDeleted && x.LabelTypeId == id); | 278 | .AnyAsync(x => !x.IsDeleted && x.LabelTypeId == id); |
| 273 | if (used) | 279 | if (used) |
| 274 | { | 280 | { |
| 275 | - throw new UserFriendlyException("该标签类型已被标签引用,无法删除"); | 281 | + throw new UserFriendlyException("This label type is referenced by labels and cannot be deleted."); |
| 276 | } | 282 | } |
| 277 | 283 | ||
| 278 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( | 284 | await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync( |
| @@ -439,9 +445,16 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -439,9 +445,16 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 439 | await _dbContext.SqlSugarClient.Insertable(rows).ExecuteCommandAsync(); | 445 | await _dbContext.SqlSugarClient.Insertable(rows).ExecuteCommandAsync(); |
| 440 | } | 446 | } |
| 441 | 447 | ||
| 448 | + /// <summary> | ||
| 449 | + /// 统计各类型下可见标签数量,范围与 Label 列表一致(Partner + Region/Location 动态命中)。 | ||
| 450 | + /// </summary> | ||
| 442 | private async Task<Dictionary<string, TypeLabelStats>> BuildTypeLabelStatsMapAsync( | 451 | private async Task<Dictionary<string, TypeLabelStats>> BuildTypeLabelStatsMapAsync( |
| 443 | List<string> typeIds, | 452 | List<string> typeIds, |
| 444 | - List<string>? scopedLocationIds) | 453 | + List<string>? scopedLocationIds, |
| 454 | + List<string>? scopedPartnerIds, | ||
| 455 | + string? partnerId, | ||
| 456 | + string? groupId, | ||
| 457 | + string? locationId) | ||
| 445 | { | 458 | { |
| 446 | var result = new Dictionary<string, TypeLabelStats>(StringComparer.Ordinal); | 459 | var result = new Dictionary<string, TypeLabelStats>(StringComparer.Ordinal); |
| 447 | if (typeIds.Count == 0) | 460 | if (typeIds.Count == 0) |
| @@ -449,11 +462,53 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -449,11 +462,53 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 449 | return result; | 462 | return result; |
| 450 | } | 463 | } |
| 451 | 464 | ||
| 452 | - var labelQuery = _dbContext.SqlSugarClient.Queryable<FlLabelDbEntity>() | 465 | + var db = _dbContext.SqlSugarClient; |
| 466 | + var regionSchema = await LabelRegionSchemaHelper.GetStatusAsync(db); | ||
| 467 | + var labelQuery = db.Queryable<FlLabelDbEntity>() | ||
| 453 | .Where(x => !x.IsDeleted) | 468 | .Where(x => !x.IsDeleted) |
| 454 | .Where(x => x.LabelTypeId != null && typeIds.Contains(x.LabelTypeId)); | 469 | .Where(x => x.LabelTypeId != null && typeIds.Contains(x.LabelTypeId)); |
| 455 | 470 | ||
| 456 | - labelQuery = ApplyLabelScopeOnLabels(labelQuery, scopedLocationIds); | 471 | + labelQuery = LabelRegionScopeHelper.ApplyLabelPartnerListFilter(labelQuery, scopedPartnerIds); |
| 472 | + | ||
| 473 | + var filterGroupId = groupId?.Trim(); | ||
| 474 | + var applyLocationFilter = LabelEntityListScopeHelper.ShouldApplyLocationAvailabilityFilter( | ||
| 475 | + partnerId, groupId, locationId); | ||
| 476 | + | ||
| 477 | + if (scopedLocationIds is not null && applyLocationFilter) | ||
| 478 | + { | ||
| 479 | + if (scopedLocationIds.Count == 0) | ||
| 480 | + { | ||
| 481 | + labelQuery = LabelRegionScopeHelper.ApplyLabelAllRegionOnlyFilter( | ||
| 482 | + db, labelQuery, regionSchema); | ||
| 483 | + } | ||
| 484 | + else if (!string.IsNullOrWhiteSpace(filterGroupId)) | ||
| 485 | + { | ||
| 486 | + labelQuery = LabelRegionScopeHelper.ApplyLabelRegionListFilter( | ||
| 487 | + db, labelQuery, filterGroupId, scopedLocationIds, regionSchema); | ||
| 488 | + } | ||
| 489 | + else | ||
| 490 | + { | ||
| 491 | + labelQuery = LabelRegionScopeHelper.ApplyLabelLocationListFilter( | ||
| 492 | + db, labelQuery, scopedLocationIds, regionSchema); | ||
| 493 | + } | ||
| 494 | + } | ||
| 495 | + else if (!string.IsNullOrWhiteSpace(partnerId) && !applyLocationFilter) | ||
| 496 | + { | ||
| 497 | + if (scopedLocationIds is null) | ||
| 498 | + { | ||
| 499 | + // 管理员且未展开到门店:不过滤 | ||
| 500 | + } | ||
| 501 | + else if (scopedLocationIds.Count == 0) | ||
| 502 | + { | ||
| 503 | + labelQuery = LabelRegionScopeHelper.ApplyLabelAllRegionOnlyFilter( | ||
| 504 | + db, labelQuery, regionSchema); | ||
| 505 | + } | ||
| 506 | + else | ||
| 507 | + { | ||
| 508 | + labelQuery = LabelRegionScopeHelper.ApplyLabelLocationListFilter( | ||
| 509 | + db, labelQuery, scopedLocationIds, regionSchema); | ||
| 510 | + } | ||
| 511 | + } | ||
| 457 | 512 | ||
| 458 | var rows = await labelQuery | 513 | var rows = await labelQuery |
| 459 | .Select(x => new { x.LabelTypeId, x.CreationTime, x.LastModificationTime }) | 514 | .Select(x => new { x.LabelTypeId, x.CreationTime, x.LastModificationTime }) |
| @@ -596,20 +651,6 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | @@ -596,20 +651,6 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService | ||
| 596 | return result; | 651 | return result; |
| 597 | } | 652 | } |
| 598 | 653 | ||
| 599 | - private static ISugarQueryable<FlLabelDbEntity> ApplyLabelScopeOnLabels( | ||
| 600 | - ISugarQueryable<FlLabelDbEntity> labelQuery, | ||
| 601 | - List<string>? scopedLocationIds) | ||
| 602 | - { | ||
| 603 | - if (scopedLocationIds is null) | ||
| 604 | - { | ||
| 605 | - return labelQuery; | ||
| 606 | - } | ||
| 607 | - | ||
| 608 | - return scopedLocationIds.Count == 0 | ||
| 609 | - ? labelQuery.Where(_ => false) | ||
| 610 | - : labelQuery.Where(l => scopedLocationIds.Contains(l.LocationId)); | ||
| 611 | - } | ||
| 612 | - | ||
| 613 | private sealed class TypeScopeData | 654 | private sealed class TypeScopeData |
| 614 | { | 655 | { |
| 615 | public string Region { get; init; } = string.Empty; | 656 | public string Region { get; init; } = string.Empty; |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LocationAppService.cs
| @@ -13,6 +13,7 @@ using Volo.Abp; | @@ -13,6 +13,7 @@ using Volo.Abp; | ||
| 13 | using Volo.Abp.Application.Dtos; | 13 | using Volo.Abp.Application.Dtos; |
| 14 | using Volo.Abp.Application.Services; | 14 | using Volo.Abp.Application.Services; |
| 15 | using Volo.Abp.Domain.Repositories; | 15 | using Volo.Abp.Domain.Repositories; |
| 16 | +using Volo.Abp.Uow; | ||
| 16 | using Yi.Framework.SqlSugarCore.Abstractions; | 17 | using Yi.Framework.SqlSugarCore.Abstractions; |
| 17 | 18 | ||
| 18 | namespace FoodLabeling.Application.Services; | 19 | namespace FoodLabeling.Application.Services; |
| @@ -137,6 +138,7 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -137,6 +138,7 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 137 | } | 138 | } |
| 138 | 139 | ||
| 139 | /// <inheritdoc /> | 140 | /// <inheritdoc /> |
| 141 | + [UnitOfWork] | ||
| 140 | public async Task<LocationGetListOutputDto> UpdateAsync(Guid id, [FromBody] LocationUpdateInputVo input) | 142 | public async Task<LocationGetListOutputDto> UpdateAsync(Guid id, [FromBody] LocationUpdateInputVo input) |
| 141 | { | 143 | { |
| 142 | await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext); | 144 | await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext); |
| @@ -214,11 +216,22 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -214,11 +216,22 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 214 | 216 | ||
| 215 | await _locationRepository.UpdateAsync(entity); | 217 | await _locationRepository.UpdateAsync(entity); |
| 216 | 218 | ||
| 219 | + // inactive 时始终解绑 Team Member(幂等):避免已 inactive 再保存时跳过,或历史残留绑定清不掉 | ||
| 220 | + if (!entity.State) | ||
| 221 | + { | ||
| 222 | + await AccountStructureCascadeInactiveHelper.CascadeLocationInactiveAsync( | ||
| 223 | + db, | ||
| 224 | + id, | ||
| 225 | + Clock.Now, | ||
| 226 | + CurrentUser?.Id?.ToString()); | ||
| 227 | + } | ||
| 228 | + | ||
| 217 | var saved = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 229 | var saved = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 218 | return await ToListDtoAsync(saved ?? entity); | 230 | return await ToListDtoAsync(saved ?? entity); |
| 219 | } | 231 | } |
| 220 | 232 | ||
| 221 | /// <inheritdoc /> | 233 | /// <inheritdoc /> |
| 234 | + [UnitOfWork] | ||
| 222 | public async Task DeleteAsync(Guid id) | 235 | public async Task DeleteAsync(Guid id) |
| 223 | { | 236 | { |
| 224 | await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext); | 237 | await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext); |
| @@ -232,8 +245,14 @@ public class LocationAppService : ApplicationService, ILocationAppService | @@ -232,8 +245,14 @@ public class LocationAppService : ApplicationService, ILocationAppService | ||
| 232 | await AccountManagementStructureHelper.EnsureLocationPartnerAllowedForMutationAsync( | 245 | await AccountManagementStructureHelper.EnsureLocationPartnerAllowedForMutationAsync( |
| 233 | CurrentUser, _dbContext, entity.Partner); | 246 | CurrentUser, _dbContext, entity.Partner); |
| 234 | 247 | ||
| 235 | - entity.IsDeleted = true; | ||
| 236 | - await _locationRepository.UpdateAsync(entity); | 248 | + var db = _dbContext.SqlSugarClient; |
| 249 | + var now = Clock.Now; | ||
| 250 | + var modifierId = CurrentUser?.Id; | ||
| 251 | + var userLocationModifierId = modifierId?.ToString(); | ||
| 252 | + | ||
| 253 | + await AccountStructureCascadeDeleteHelper.SoftDeleteLocationAsync(db, id, now, modifierId); | ||
| 254 | + await AccountStructureCascadeDeleteHelper.SoftDeleteUserLocationBindingsForLocationAsync( | ||
| 255 | + db, id, now, userLocationModifierId); | ||
| 237 | } | 256 | } |
| 238 | 257 | ||
| 239 | /// <inheritdoc /> | 258 | /// <inheritdoc /> |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PartnerAppService.cs
| @@ -116,6 +116,7 @@ public class PartnerAppService : ApplicationService, IPartnerAppService | @@ -116,6 +116,7 @@ public class PartnerAppService : ApplicationService, IPartnerAppService | ||
| 116 | throw new UserFriendlyException("Partner not found."); | 116 | throw new UserFriendlyException("Partner not found."); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | + var wasActive = entity.State; | ||
| 119 | var oldName = entity.PartnerName; | 120 | var oldName = entity.PartnerName; |
| 120 | var name = input.PartnerName?.Trim(); | 121 | var name = input.PartnerName?.Trim(); |
| 121 | if (string.IsNullOrWhiteSpace(name)) | 122 | if (string.IsNullOrWhiteSpace(name)) |
| @@ -156,12 +157,22 @@ public class PartnerAppService : ApplicationService, IPartnerAppService | @@ -156,12 +157,22 @@ public class PartnerAppService : ApplicationService, IPartnerAppService | ||
| 156 | entity.LastModifierId = CurrentUser?.Id?.ToString(); | 157 | entity.LastModifierId = CurrentUser?.Id?.ToString(); |
| 157 | 158 | ||
| 158 | await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync(); | 159 | await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync(); |
| 160 | + | ||
| 161 | + if (AccountStructureCascadeInactiveHelper.IsBecomingInactive(wasActive, entity.State)) | ||
| 162 | + { | ||
| 163 | + await AccountStructureCascadeInactiveHelper.CascadePartnerInactiveAsync( | ||
| 164 | + _dbContext.SqlSugarClient, | ||
| 165 | + partnerId, | ||
| 166 | + Clock.Now, | ||
| 167 | + CurrentUser?.Id); | ||
| 168 | + } | ||
| 169 | + | ||
| 159 | return await GetAsync(id); | 170 | return await GetAsync(id); |
| 160 | } | 171 | } |
| 161 | 172 | ||
| 162 | /// <inheritdoc /> | 173 | /// <inheritdoc /> |
| 163 | [UnitOfWork] | 174 | [UnitOfWork] |
| 164 | - public async Task DeleteAsync(Guid id) | 175 | + public async Task DeleteAsync(Guid id, [FromQuery] bool confirmCascade = false) |
| 165 | { | 176 | { |
| 166 | if (id == Guid.Empty) | 177 | if (id == Guid.Empty) |
| 167 | { | 178 | { |
| @@ -169,17 +180,45 @@ public class PartnerAppService : ApplicationService, IPartnerAppService | @@ -169,17 +180,45 @@ public class PartnerAppService : ApplicationService, IPartnerAppService | ||
| 169 | } | 180 | } |
| 170 | 181 | ||
| 171 | var partnerId = id.ToString(); | 182 | var partnerId = id.ToString(); |
| 172 | - var entity = await _dbContext.SqlSugarClient.Queryable<FlPartnerDbEntity>() | 183 | + var db = _dbContext.SqlSugarClient; |
| 184 | + var entity = await db.Queryable<FlPartnerDbEntity>() | ||
| 173 | .FirstAsync(x => !x.IsDeleted && x.Id == partnerId); | 185 | .FirstAsync(x => !x.IsDeleted && x.Id == partnerId); |
| 174 | if (entity is null) | 186 | if (entity is null) |
| 175 | { | 187 | { |
| 176 | throw new UserFriendlyException("Partner not found."); | 188 | throw new UserFriendlyException("Partner not found."); |
| 177 | } | 189 | } |
| 178 | 190 | ||
| 179 | - entity.IsDeleted = true; | ||
| 180 | - entity.LastModificationTime = Clock.Now; | ||
| 181 | - entity.LastModifierId = CurrentUser?.Id?.ToString(); | ||
| 182 | - await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync(); | 191 | + var partnerName = entity.PartnerName?.Trim() ?? string.Empty; |
| 192 | + var groupCount = await AccountStructureCascadeDeleteHelper.CountActiveGroupsByPartnerIdAsync(db, partnerId); | ||
| 193 | + var locationCount = await AccountStructureCascadeDeleteHelper.CountActiveLocationsByPartnerNameAsync( | ||
| 194 | + db, partnerName); | ||
| 195 | + | ||
| 196 | + if ((groupCount > 0 || locationCount > 0) && !confirmCascade) | ||
| 197 | + { | ||
| 198 | + throw new UserFriendlyException( | ||
| 199 | + AccountStructureCascadeDeleteHelper.BuildPartnerCascadeRequiredMessage(groupCount, locationCount)); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + var now = Clock.Now; | ||
| 203 | + var modifierId = CurrentUser?.Id; | ||
| 204 | + var modifierIdString = modifierId?.ToString(); | ||
| 205 | + | ||
| 206 | + if (confirmCascade && (groupCount > 0 || locationCount > 0)) | ||
| 207 | + { | ||
| 208 | + if (locationCount > 0) | ||
| 209 | + { | ||
| 210 | + await AccountStructureCascadeDeleteHelper.SoftDeleteLocationsByPartnerNameAsync( | ||
| 211 | + db, partnerName, now, modifierId, modifierIdString); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + if (groupCount > 0) | ||
| 215 | + { | ||
| 216 | + await AccountStructureCascadeDeleteHelper.SoftDeleteGroupsByPartnerIdAsync( | ||
| 217 | + db, partnerId, now, modifierIdString); | ||
| 218 | + } | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + await AccountStructureCascadeDeleteHelper.SoftDeletePartnerAsync(db, partnerId, now, modifierIdString); | ||
| 183 | } | 222 | } |
| 184 | 223 | ||
| 185 | /// <inheritdoc /> | 224 | /// <inheritdoc /> |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PictureAppService.cs
| @@ -41,18 +41,18 @@ public class PictureAppService : ApplicationService, IPictureAppService | @@ -41,18 +41,18 @@ public class PictureAppService : ApplicationService, IPictureAppService | ||
| 41 | { | 41 | { |
| 42 | if (input.File is null || input.File.Length <= 0) | 42 | if (input.File is null || input.File.Length <= 0) |
| 43 | { | 43 | { |
| 44 | - throw new UserFriendlyException("请选择要上传的图片文件"); | 44 | + throw new UserFriendlyException("Please select an image file to upload."); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | if (input.File.Length > MaxSizeBytes) | 47 | if (input.File.Length > MaxSizeBytes) |
| 48 | { | 48 | { |
| 49 | - throw new UserFriendlyException("图片大小不能超过5MB"); | 49 | + throw new UserFriendlyException("Image size cannot exceed 5 MB."); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | var ext = Path.GetExtension(input.File.FileName ?? string.Empty); | 52 | var ext = Path.GetExtension(input.File.FileName ?? string.Empty); |
| 53 | if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext)) | 53 | if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext)) |
| 54 | { | 54 | { |
| 55 | - throw new UserFriendlyException("仅支持上传 jpg/jpeg/png/webp/gif 格式图片"); | 55 | + throw new UserFriendlyException("Only jpg/jpeg/png/webp/gif images are supported."); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | var subDir = NormalizeSubDir(input.SubDir); | 58 | var subDir = NormalizeSubDir(input.SubDir); |
| @@ -99,7 +99,7 @@ public class PictureAppService : ApplicationService, IPictureAppService | @@ -99,7 +99,7 @@ public class PictureAppService : ApplicationService, IPictureAppService | ||
| 99 | 99 | ||
| 100 | if (s.Contains("..", StringComparison.Ordinal)) | 100 | if (s.Contains("..", StringComparison.Ordinal)) |
| 101 | { | 101 | { |
| 102 | - throw new UserFriendlyException("subDir 不能包含 .."); | 102 | + throw new UserFriendlyException("subDir cannot contain .."); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | return s; | 105 | 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); |
| @@ -258,7 +258,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -258,7 +258,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 258 | var name = input.ProductName?.Trim(); | 258 | var name = input.ProductName?.Trim(); |
| 259 | if (string.IsNullOrWhiteSpace(name)) | 259 | if (string.IsNullOrWhiteSpace(name)) |
| 260 | { | 260 | { |
| 261 | - throw new UserFriendlyException("产品名称不能为空"); | 261 | + throw new UserFriendlyException("Product name is required."); |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | var code = input.ProductCode?.Trim(); | 264 | var code = input.ProductCode?.Trim(); |
| @@ -272,7 +272,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -272,7 +272,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 272 | .AnyAsync(x => !x.IsDeleted && x.ProductCode == code); | 272 | .AnyAsync(x => !x.IsDeleted && x.ProductCode == code); |
| 273 | if (duplicated) | 273 | if (duplicated) |
| 274 | { | 274 | { |
| 275 | - throw new UserFriendlyException("产品编码已存在"); | 275 | + throw new UserFriendlyException("Product code already exists."); |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | await PurgeSoftDeletedProductsByCodeAsync(code); | 278 | await PurgeSoftDeletedProductsByCodeAsync(code); |
| @@ -314,7 +314,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -314,7 +314,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 314 | { | 314 | { |
| 315 | if (id == Guid.Empty) | 315 | if (id == Guid.Empty) |
| 316 | { | 316 | { |
| 317 | - throw new UserFriendlyException("产品Id不能为空"); | 317 | + throw new UserFriendlyException("Product ID is required."); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | var productId = id.ToString(); | 320 | var productId = id.ToString(); |
| @@ -322,7 +322,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -322,7 +322,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 322 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); | 322 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); |
| 323 | if (entity is null) | 323 | if (entity is null) |
| 324 | { | 324 | { |
| 325 | - throw new UserFriendlyException("产品不存在"); | 325 | + throw new UserFriendlyException("Product not found."); |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | await EnsureProductVisibleToCurrentUserAsync(entity); | 328 | await EnsureProductVisibleToCurrentUserAsync(entity); |
| @@ -330,7 +330,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -330,7 +330,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 330 | var name = input.ProductName?.Trim(); | 330 | var name = input.ProductName?.Trim(); |
| 331 | if (string.IsNullOrWhiteSpace(name)) | 331 | if (string.IsNullOrWhiteSpace(name)) |
| 332 | { | 332 | { |
| 333 | - throw new UserFriendlyException("产品名称不能为空"); | 333 | + throw new UserFriendlyException("Product name is required."); |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | var codeInput = input.ProductCode?.Trim(); | 336 | var codeInput = input.ProductCode?.Trim(); |
| @@ -346,7 +346,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -346,7 +346,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 346 | .AnyAsync(x => !x.IsDeleted && x.Id != productId && x.ProductCode == code); | 346 | .AnyAsync(x => !x.IsDeleted && x.Id != productId && x.ProductCode == code); |
| 347 | if (duplicated) | 347 | if (duplicated) |
| 348 | { | 348 | { |
| 349 | - throw new UserFriendlyException("产品编码已存在"); | 349 | + throw new UserFriendlyException("Product code already exists."); |
| 350 | } | 350 | } |
| 351 | } | 351 | } |
| 352 | 352 | ||
| @@ -379,7 +379,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -379,7 +379,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 379 | { | 379 | { |
| 380 | if (id == Guid.Empty) | 380 | if (id == Guid.Empty) |
| 381 | { | 381 | { |
| 382 | - throw new UserFriendlyException("产品Id不能为空"); | 382 | + throw new UserFriendlyException("Product ID is required."); |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | var productId = id.ToString(); | 385 | var productId = id.ToString(); |
| @@ -387,7 +387,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -387,7 +387,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 387 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); | 387 | .FirstAsync(x => !x.IsDeleted && x.Id == productId); |
| 388 | if (entity is null) | 388 | if (entity is null) |
| 389 | { | 389 | { |
| 390 | - throw new UserFriendlyException("产品不存在"); | 390 | + throw new UserFriendlyException("Product not found."); |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | await EnsureProductVisibleToCurrentUserAsync(entity); | 393 | await EnsureProductVisibleToCurrentUserAsync(entity); |
| @@ -404,19 +404,19 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -404,19 +404,19 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 404 | var dir = opt.TemplateDirectory?.Trim(); | 404 | var dir = opt.TemplateDirectory?.Trim(); |
| 405 | if (string.IsNullOrWhiteSpace(dir)) | 405 | if (string.IsNullOrWhiteSpace(dir)) |
| 406 | { | 406 | { |
| 407 | - throw new UserFriendlyException("未配置批量导入模板目录 FoodLabeling:BatchImport:TemplateDirectory"); | 407 | + throw new UserFriendlyException("Batch import template directory is not configured (FoodLabeling:BatchImport:TemplateDirectory)."); |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | var fileName = opt.ProductTemplateFileName?.Trim(); | 410 | var fileName = opt.ProductTemplateFileName?.Trim(); |
| 411 | if (string.IsNullOrWhiteSpace(fileName)) | 411 | if (string.IsNullOrWhiteSpace(fileName)) |
| 412 | { | 412 | { |
| 413 | - throw new UserFriendlyException("未配置模板文件名 FoodLabeling:BatchImport:ProductTemplateFileName"); | 413 | + throw new UserFriendlyException("Product template file name is not configured (FoodLabeling:BatchImport:ProductTemplateFileName)."); |
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | var fullPath = Path.Combine(dir, fileName); | 416 | var fullPath = Path.Combine(dir, fileName); |
| 417 | if (!File.Exists(fullPath)) | 417 | if (!File.Exists(fullPath)) |
| 418 | { | 418 | { |
| 419 | - throw new UserFriendlyException($"模板文件不存在:{fullPath}"); | 419 | + throw new UserFriendlyException($"Template file not found: {fullPath}"); |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); | 422 | var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); |
| @@ -466,19 +466,19 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -466,19 +466,19 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 466 | { | 466 | { |
| 467 | if (input?.File is null || input.File.Length == 0) | 467 | if (input?.File is null || input.File.Length == 0) |
| 468 | { | 468 | { |
| 469 | - throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)"); | 469 | + throw new UserFriendlyException("Please upload an Excel file (form field name: file)."); |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | var opt = _batchImportOptions.Value; | 472 | var opt = _batchImportOptions.Value; |
| 473 | if (input.File.Length > opt.MaxUploadBytes) | 473 | if (input.File.Length > opt.MaxUploadBytes) |
| 474 | { | 474 | { |
| 475 | - throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB"); | 475 | + throw new UserFriendlyException($"File is too large. Maximum allowed size is {opt.MaxUploadBytes / 1024 / 1024} MB."); |
| 476 | } | 476 | } |
| 477 | 477 | ||
| 478 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); | 478 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); |
| 479 | if (ext != ".xlsx") | 479 | if (ext != ".xlsx") |
| 480 | { | 480 | { |
| 481 | - throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件"); | 481 | + throw new UserFriendlyException("Only .xlsx Excel files are supported."); |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | await using var uploadStream = input.File.OpenReadStream(); | 484 | await using var uploadStream = input.File.OpenReadStream(); |
| @@ -591,14 +591,14 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -591,14 +591,14 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 591 | { | 591 | { |
| 592 | if (input?.Items is null || input.Items.Count == 0) | 592 | if (input?.Items is null || input.Items.Count == 0) |
| 593 | { | 593 | { |
| 594 | - throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)"); | 594 | + throw new UserFriendlyException("Please submit at least one edit item (items cannot be empty)."); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | var opt = _batchImportOptions.Value; | 597 | var opt = _batchImportOptions.Value; |
| 598 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; | 598 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; |
| 599 | if (input.Items.Count > maxItems) | 599 | if (input.Items.Count > maxItems) |
| 600 | { | 600 | { |
| 601 | - throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交"); | 601 | + throw new UserFriendlyException($"A maximum of {maxItems} rows is allowed per bulk edit. Please submit in smaller batches."); |
| 602 | } | 602 | } |
| 603 | 603 | ||
| 604 | var effectiveCount = input.Items.Count(static x => | 604 | var effectiveCount = input.Items.Count(static x => |
| @@ -608,7 +608,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -608,7 +608,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 608 | g != Guid.Empty); | 608 | g != Guid.Empty); |
| 609 | if (effectiveCount == 0) | 609 | if (effectiveCount == 0) |
| 610 | { | 610 | { |
| 611 | - throw new UserFriendlyException("没有有效的产品 Id(请为待保存行填写 Guid 格式 id)"); | 611 | + throw new UserFriendlyException("No valid product Id found. Provide a Guid-format id for rows to save."); |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | var result = new ProductBulkUpdateResultDto(); | 614 | var result = new ProductBulkUpdateResultDto(); |
| @@ -709,7 +709,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -709,7 +709,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 709 | { | 709 | { |
| 710 | if (!CurrentUser.Id.HasValue) | 710 | if (!CurrentUser.Id.HasValue) |
| 711 | { | 711 | { |
| 712 | - throw new UserFriendlyException("登录已过期,请重新登录"); | 712 | + throw new UserFriendlyException("Session expired. Please sign in again."); |
| 713 | } | 713 | } |
| 714 | 714 | ||
| 715 | if (ReportsRoleHelper.IsAdminRole(CurrentUser)) | 715 | if (ReportsRoleHelper.IsAdminRole(CurrentUser)) |
| @@ -726,7 +726,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -726,7 +726,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 726 | 726 | ||
| 727 | if (scopedLocationIds.Count == 0) | 727 | if (scopedLocationIds.Count == 0) |
| 728 | { | 728 | { |
| 729 | - throw new UserFriendlyException("无权访问该产品"); | 729 | + throw new UserFriendlyException("You do not have permission to access this product."); |
| 730 | } | 730 | } |
| 731 | 731 | ||
| 732 | if (string.Equals(entity.AvailabilityType, AllScopeBindingHelper.ScopeAll, StringComparison.OrdinalIgnoreCase)) | 732 | if (string.Equals(entity.AvailabilityType, AllScopeBindingHelper.ScopeAll, StringComparison.OrdinalIgnoreCase)) |
| @@ -765,7 +765,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -765,7 +765,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 765 | .ToListAsync(); | 765 | .ToListAsync(); |
| 766 | if (!productLocationIds.Any(id => scopedLocationIds.Contains(id))) | 766 | if (!productLocationIds.Any(id => scopedLocationIds.Contains(id))) |
| 767 | { | 767 | { |
| 768 | - throw new UserFriendlyException("无权访问该产品"); | 768 | + throw new UserFriendlyException("You do not have permission to access this product."); |
| 769 | } | 769 | } |
| 770 | } | 770 | } |
| 771 | 771 | ||
| @@ -936,7 +936,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -936,7 +936,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 936 | var n = categoryName.Trim(); | 936 | var n = categoryName.Trim(); |
| 937 | if (string.IsNullOrWhiteSpace(n)) | 937 | if (string.IsNullOrWhiteSpace(n)) |
| 938 | { | 938 | { |
| 939 | - throw new UserFriendlyException("产品分类名称不能为空"); | 939 | + throw new UserFriendlyException("Product category name is required."); |
| 940 | } | 940 | } |
| 941 | 941 | ||
| 942 | var lowered = n.ToLowerInvariant(); | 942 | var lowered = n.ToLowerInvariant(); |
| @@ -946,12 +946,12 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -946,12 +946,12 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 946 | 946 | ||
| 947 | if (matches.Count == 0) | 947 | if (matches.Count == 0) |
| 948 | { | 948 | { |
| 949 | - throw new UserFriendlyException($"未找到产品分类「{n}」"); | 949 | + throw new UserFriendlyException($"Product category not found: {n}"); |
| 950 | } | 950 | } |
| 951 | 951 | ||
| 952 | if (matches.Count > 1) | 952 | if (matches.Count > 1) |
| 953 | { | 953 | { |
| 954 | - throw new UserFriendlyException($"产品分类「{n}」存在多条记录,请在系统中使用唯一名称"); | 954 | + throw new UserFriendlyException($"Multiple product categories match \"{n}\". Use a unique name in the system."); |
| 955 | } | 955 | } |
| 956 | 956 | ||
| 957 | return matches[0].Id; | 957 | return matches[0].Id; |
| @@ -987,7 +987,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -987,7 +987,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 987 | var byId = byIdList.FirstOrDefault(); | 987 | var byId = byIdList.FirstOrDefault(); |
| 988 | if (byId is null) | 988 | if (byId is null) |
| 989 | { | 989 | { |
| 990 | - throw new UserFriendlyException($"未找到门店 Id:{t}"); | 990 | + throw new UserFriendlyException($"Location Id not found: {t}"); |
| 991 | } | 991 | } |
| 992 | 992 | ||
| 993 | return byId.Id.ToString(); | 993 | return byId.Id.ToString(); |
| @@ -1002,12 +1002,12 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1002,12 +1002,12 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1002 | 1002 | ||
| 1003 | if (matches.Count == 0) | 1003 | if (matches.Count == 0) |
| 1004 | { | 1004 | { |
| 1005 | - throw new UserFriendlyException($"未找到门店:{t}"); | 1005 | + throw new UserFriendlyException($"Location not found: {t}"); |
| 1006 | } | 1006 | } |
| 1007 | 1007 | ||
| 1008 | if (matches.Count > 1) | 1008 | if (matches.Count > 1) |
| 1009 | { | 1009 | { |
| 1010 | - throw new UserFriendlyException($"门店「{t}」存在多条匹配,请使用 Location Code 或 Guid"); | 1010 | + throw new UserFriendlyException($"Multiple locations match \"{t}\". Use Location Code or Guid."); |
| 1011 | } | 1011 | } |
| 1012 | 1012 | ||
| 1013 | return matches[0].Id.ToString(); | 1013 | return matches[0].Id.ToString(); |
| @@ -1029,7 +1029,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1029,7 +1029,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1029 | } | 1029 | } |
| 1030 | } | 1030 | } |
| 1031 | 1031 | ||
| 1032 | - throw new UserFriendlyException("无法生成唯一产品编码,请稍后重试或手动填写产品编码"); | 1032 | + throw new UserFriendlyException("Unable to generate a unique product code. Try again later or enter a code manually."); |
| 1033 | } | 1033 | } |
| 1034 | 1034 | ||
| 1035 | private static void ApplyProductAppearanceToEntity(FlProductDbEntity entity, ProductCreateInputVo input) | 1035 | private static void ApplyProductAppearanceToEntity(FlProductDbEntity entity, ProductCreateInputVo input) |
| @@ -1118,13 +1118,13 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1118,13 +1118,13 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1118 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(companyIds) | 1118 | if (AllScopeBindingHelper.HasAllScopeSentinelSelection(companyIds) |
| 1119 | || LocationScopeBindingHelper.IsAllScopeSentinel(input.PartnerId)) | 1119 | || LocationScopeBindingHelper.IsAllScopeSentinel(input.PartnerId)) |
| 1120 | { | 1120 | { |
| 1121 | - throw new UserFriendlyException("产品适用 Company 不支持 ALL,请传单个具体 Company Id"); | 1121 | + throw new UserFriendlyException("Product Company scope does not support ALL. Pass a single Company Id."); |
| 1122 | } | 1122 | } |
| 1123 | 1123 | ||
| 1124 | var concreteCompanyIds = LocationScopeBindingHelper.FilterConcreteScopeIds(companyIds); | 1124 | var concreteCompanyIds = LocationScopeBindingHelper.FilterConcreteScopeIds(companyIds); |
| 1125 | if (concreteCompanyIds.Count > 1) | 1125 | if (concreteCompanyIds.Count > 1) |
| 1126 | { | 1126 | { |
| 1127 | - throw new UserFriendlyException("产品适用 Company 仅支持单选(companyIds 最多传 1 个)"); | 1127 | + throw new UserFriendlyException("Product Company scope supports only one selection (companyIds may contain at most one item)."); |
| 1128 | } | 1128 | } |
| 1129 | 1129 | ||
| 1130 | var fromCompanyIds = concreteCompanyIds.Count == 1 ? concreteCompanyIds[0] : null; | 1130 | var fromCompanyIds = concreteCompanyIds.Count == 1 ? concreteCompanyIds[0] : null; |
| @@ -1137,7 +1137,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1137,7 +1137,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1137 | if (!string.IsNullOrWhiteSpace(fromCompanyIds) | 1137 | if (!string.IsNullOrWhiteSpace(fromCompanyIds) |
| 1138 | && !string.Equals(fromPartnerId, fromCompanyIds, StringComparison.OrdinalIgnoreCase)) | 1138 | && !string.Equals(fromPartnerId, fromCompanyIds, StringComparison.OrdinalIgnoreCase)) |
| 1139 | { | 1139 | { |
| 1140 | - throw new UserFriendlyException("partnerId 与 companyIds/partnerIds 不一致"); | 1140 | + throw new UserFriendlyException("partnerId does not match companyIds/partnerIds."); |
| 1141 | } | 1141 | } |
| 1142 | 1142 | ||
| 1143 | return fromPartnerId; | 1143 | return fromPartnerId; |
| @@ -1177,7 +1177,12 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1177,7 +1177,12 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1177 | 1177 | ||
| 1178 | var regionHasAll = regionHasAllSentinel; | 1178 | var regionHasAll = regionHasAllSentinel; |
| 1179 | var declaredSpecified = AllScopeBindingHelper.IsDeclaredSpecified(input.AvailabilityType); | 1179 | var declaredSpecified = AllScopeBindingHelper.IsDeclaredSpecified(input.AvailabilityType); |
| 1180 | - if (!regionHasAll && groupIds.Count > 0 && explicitLocationIds.Count == 0 && !declaredSpecified) | 1180 | + var isScopedAllWithConcreteRegions = locationHasAll && groupIds.Count > 0 && !regionHasAllSentinel; |
| 1181 | + if (!regionHasAll | ||
| 1182 | + && groupIds.Count > 0 | ||
| 1183 | + && explicitLocationIds.Count == 0 | ||
| 1184 | + && !declaredSpecified | ||
| 1185 | + && !isScopedAllWithConcreteRegions) | ||
| 1181 | { | 1186 | { |
| 1182 | var allRegions = await AllScopeBindingHelper.ResolveAllRegionIdsAsync( | 1187 | var allRegions = await AllScopeBindingHelper.ResolveAllRegionIdsAsync( |
| 1183 | _dbContext.SqlSugarClient, partnerContext); | 1188 | _dbContext.SqlSugarClient, partnerContext); |
| @@ -1197,6 +1202,11 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1197,6 +1202,11 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1197 | 1202 | ||
| 1198 | if (locationHasAll) | 1203 | if (locationHasAll) |
| 1199 | { | 1204 | { |
| 1205 | + if (isScopedAllWithConcreteRegions) | ||
| 1206 | + { | ||
| 1207 | + regionHasAll = false; | ||
| 1208 | + } | ||
| 1209 | + | ||
| 1200 | if (regionHasAll) | 1210 | if (regionHasAll) |
| 1201 | { | 1211 | { |
| 1202 | return new ProductScopeSaveResult | 1212 | return new ProductScopeSaveResult |
| @@ -1208,6 +1218,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1208,6 +1218,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1208 | }; | 1218 | }; |
| 1209 | } | 1219 | } |
| 1210 | 1220 | ||
| 1221 | + // Scoped ALL:部分 Region + Location ALL → SPECIFIED,不写门店快照(新区店靠 Region 动态匹配需 fl_product_region;此处展开区内门店快照) | ||
| 1211 | var expandRegions = groupIds.Count > 0 ? groupIds : null; | 1222 | var expandRegions = groupIds.Count > 0 ? groupIds : null; |
| 1212 | var expanded = await LocationScopeBindingHelper.ExpandScopedAllLocationsForSaveAsync( | 1223 | var expanded = await LocationScopeBindingHelper.ExpandScopedAllLocationsForSaveAsync( |
| 1213 | _dbContext.SqlSugarClient, | 1224 | _dbContext.SqlSugarClient, |
| @@ -1402,7 +1413,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1402,7 +1413,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1402 | || AllScopeBindingHelper.HasAllScopeSentinelSelection(groupIds) | 1413 | || AllScopeBindingHelper.HasAllScopeSentinelSelection(groupIds) |
| 1403 | || AllScopeBindingHelper.HasAllScopeSentinelSelection(locationIds)) | 1414 | || AllScopeBindingHelper.HasAllScopeSentinelSelection(locationIds)) |
| 1404 | { | 1415 | { |
| 1405 | - throw new UserFriendlyException("适用范围为全选(ALL),无需解析具体门店"); | 1416 | + throw new UserFriendlyException("Scope is ALL; no specific locations need to be resolved."); |
| 1406 | } | 1417 | } |
| 1407 | 1418 | ||
| 1408 | var concreteLocations = LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds); | 1419 | var concreteLocations = LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds); |
| @@ -1420,7 +1431,7 @@ public class ProductAppService : ApplicationService, IProductAppService | @@ -1420,7 +1431,7 @@ public class ProductAppService : ApplicationService, IProductAppService | ||
| 1420 | locationIds); | 1431 | locationIds); |
| 1421 | if (merged.Count == 0) | 1432 | if (merged.Count == 0) |
| 1422 | { | 1433 | { |
| 1423 | - throw new UserFriendlyException("指定适用 Company、Region 或门店时,至少需要匹配到一个有效门店"); | 1434 | + throw new UserFriendlyException("When specifying Company, Region, or Location scope, at least one valid location must match."); |
| 1424 | } | 1435 | } |
| 1425 | 1436 | ||
| 1426 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged); | 1437 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductCategoryAppService.cs
| @@ -123,7 +123,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -123,7 +123,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 123 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 123 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 124 | if (entity is null) | 124 | if (entity is null) |
| 125 | { | 125 | { |
| 126 | - throw new UserFriendlyException("类别不存在"); | 126 | + throw new UserFriendlyException("Category not found."); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | await EnsureCategoryVisibleToCurrentUserAsync(entity); | 129 | await EnsureCategoryVisibleToCurrentUserAsync(entity); |
| @@ -188,7 +188,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -188,7 +188,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 188 | var name = input.CategoryName?.Trim(); | 188 | var name = input.CategoryName?.Trim(); |
| 189 | if (string.IsNullOrWhiteSpace(name)) | 189 | if (string.IsNullOrWhiteSpace(name)) |
| 190 | { | 190 | { |
| 191 | - throw new UserFriendlyException("类别名称不能为空"); | 191 | + throw new UserFriendlyException("Category name is required."); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | var displayText = input.DisplayText?.Trim(); | 194 | var displayText = input.DisplayText?.Trim(); |
| @@ -236,7 +236,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -236,7 +236,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 236 | .FirstAsync(x => x.Id == id && !x.IsDeleted); | 236 | .FirstAsync(x => x.Id == id && !x.IsDeleted); |
| 237 | if (entity is null) | 237 | if (entity is null) |
| 238 | { | 238 | { |
| 239 | - throw new UserFriendlyException("类别不存在"); | 239 | + throw new UserFriendlyException("Category not found."); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | await EnsureCategoryVisibleToCurrentUserAsync(entity); | 242 | await EnsureCategoryVisibleToCurrentUserAsync(entity); |
| @@ -245,7 +245,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -245,7 +245,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 245 | var name = input.CategoryName?.Trim(); | 245 | var name = input.CategoryName?.Trim(); |
| 246 | if (string.IsNullOrWhiteSpace(name)) | 246 | if (string.IsNullOrWhiteSpace(name)) |
| 247 | { | 247 | { |
| 248 | - throw new UserFriendlyException("类别名称不能为空"); | 248 | + throw new UserFriendlyException("Category name is required."); |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | var displayText = input.DisplayText?.Trim(); | 251 | var displayText = input.DisplayText?.Trim(); |
| @@ -310,7 +310,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -310,7 +310,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 310 | .AnyAsync(x => !x.IsDeleted && x.CategoryId == id); | 310 | .AnyAsync(x => !x.IsDeleted && x.CategoryId == id); |
| 311 | if (usedByProduct) | 311 | if (usedByProduct) |
| 312 | { | 312 | { |
| 313 | - throw new UserFriendlyException("该类别已被产品引用,无法删除"); | 313 | + throw new UserFriendlyException("This category is referenced by products and cannot be deleted."); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | entity.IsDeleted = true; | 316 | entity.IsDeleted = true; |
| @@ -452,7 +452,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -452,7 +452,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 452 | 452 | ||
| 453 | if (scopedLocationIds.Count == 0) | 453 | if (scopedLocationIds.Count == 0) |
| 454 | { | 454 | { |
| 455 | - throw new UserFriendlyException("无权访问该类别"); | 455 | + throw new UserFriendlyException("You do not have permission to access this category."); |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | if (string.Equals(entity.AvailabilityType, "ALL", StringComparison.OrdinalIgnoreCase)) | 458 | if (string.Equals(entity.AvailabilityType, "ALL", StringComparison.OrdinalIgnoreCase)) |
| @@ -464,7 +464,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -464,7 +464,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 464 | .AnyAsync(cl => cl.CategoryId == entity.Id && scopedLocationIds.Contains(cl.LocationId)); | 464 | .AnyAsync(cl => cl.CategoryId == entity.Id && scopedLocationIds.Contains(cl.LocationId)); |
| 465 | if (!visible) | 465 | if (!visible) |
| 466 | { | 466 | { |
| 467 | - throw new UserFriendlyException("无权访问该类别"); | 467 | + throw new UserFriendlyException("You do not have permission to access this category."); |
| 468 | } | 468 | } |
| 469 | } | 469 | } |
| 470 | 470 | ||
| @@ -719,7 +719,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -719,7 +719,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 719 | { | 719 | { |
| 720 | if (await query.AnyAsync(x => x.CategoryName == name)) | 720 | if (await query.AnyAsync(x => x.CategoryName == name)) |
| 721 | { | 721 | { |
| 722 | - throw new UserFriendlyException("类别名称已存在"); | 722 | + throw new UserFriendlyException("Category name already exists."); |
| 723 | } | 723 | } |
| 724 | 724 | ||
| 725 | return; | 725 | return; |
| @@ -727,7 +727,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | @@ -727,7 +727,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp | ||
| 727 | 727 | ||
| 728 | if (await query.AnyAsync(x => x.CategoryCode == code || x.CategoryName == name)) | 728 | if (await query.AnyAsync(x => x.CategoryCode == code || x.CategoryName == name)) |
| 729 | { | 729 | { |
| 730 | - throw new UserFriendlyException("类别编码或名称已存在"); | 730 | + throw new UserFriendlyException("Category code or name already exists."); |
| 731 | } | 731 | } |
| 732 | } | 732 | } |
| 733 | 733 |
美国版/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("Location ID 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("Location ID 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 Location ID 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("Location ID 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 Location ID 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("Location ID 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
| @@ -100,7 +100,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -100,7 +100,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 100 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 100 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 101 | if (entity is null) | 101 | if (entity is null) |
| 102 | { | 102 | { |
| 103 | - throw new UserFriendlyException("角色不存在"); | 103 | + throw new UserFriendlyException("Role not found."); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | var menuIds = await _roleMenuRepository._DbQueryable | 106 | var menuIds = await _roleMenuRepository._DbQueryable |
| @@ -132,18 +132,18 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -132,18 +132,18 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 132 | var roleCode = input.RoleCode?.Trim(); | 132 | var roleCode = input.RoleCode?.Trim(); |
| 133 | if (string.IsNullOrWhiteSpace(roleName)) | 133 | if (string.IsNullOrWhiteSpace(roleName)) |
| 134 | { | 134 | { |
| 135 | - throw new UserFriendlyException("角色名称不能为空"); | 135 | + throw new UserFriendlyException("Role name is required."); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if (string.IsNullOrWhiteSpace(roleCode)) | 138 | if (string.IsNullOrWhiteSpace(roleCode)) |
| 139 | { | 139 | { |
| 140 | - throw new UserFriendlyException("角色编码不能为空"); | 140 | + throw new UserFriendlyException("Role code is required."); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | var isExist = await _roleRepository.IsAnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); | 143 | var isExist = await _roleRepository.IsAnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); |
| 144 | if (isExist) | 144 | if (isExist) |
| 145 | { | 145 | { |
| 146 | - throw new UserFriendlyException("角色名称或编码已存在"); | 146 | + throw new UserFriendlyException("Role name or code already exists."); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | var entity = new RoleAggregateRoot | 149 | var entity = new RoleAggregateRoot |
| @@ -173,19 +173,19 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -173,19 +173,19 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 173 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); | 173 | var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false); |
| 174 | if (entity is null) | 174 | if (entity is null) |
| 175 | { | 175 | { |
| 176 | - throw new UserFriendlyException("角色不存在"); | 176 | + throw new UserFriendlyException("Role not found."); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | var roleName = input.RoleName?.Trim(); | 179 | var roleName = input.RoleName?.Trim(); |
| 180 | var roleCode = input.RoleCode?.Trim(); | 180 | var roleCode = input.RoleCode?.Trim(); |
| 181 | if (string.IsNullOrWhiteSpace(roleName)) | 181 | if (string.IsNullOrWhiteSpace(roleName)) |
| 182 | { | 182 | { |
| 183 | - throw new UserFriendlyException("角色名称不能为空"); | 183 | + throw new UserFriendlyException("Role name is required."); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | if (string.IsNullOrWhiteSpace(roleCode)) | 186 | if (string.IsNullOrWhiteSpace(roleCode)) |
| 187 | { | 187 | { |
| 188 | - throw new UserFriendlyException("角色编码不能为空"); | 188 | + throw new UserFriendlyException("Role code is required."); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | var isExist = await _roleRepository._DbQueryable | 191 | var isExist = await _roleRepository._DbQueryable |
| @@ -193,7 +193,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -193,7 +193,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 193 | .AnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); | 193 | .AnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName); |
| 194 | if (isExist) | 194 | if (isExist) |
| 195 | { | 195 | { |
| 196 | - throw new UserFriendlyException("角色名称或编码已存在"); | 196 | + throw new UserFriendlyException("Role name or code already exists."); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | entity.RoleName = roleName; | 199 | entity.RoleName = roleName; |
| @@ -245,7 +245,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | @@ -245,7 +245,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService | ||
| 245 | if (menuIds.Count == 0) | 245 | if (menuIds.Count == 0) |
| 246 | { | 246 | { |
| 247 | throw new UserFriendlyException( | 247 | throw new UserFriendlyException( |
| 248 | - "accessPermissions 未匹配到任何菜单,请确认权限码与菜单 Router 一致,或先执行 menu_backfill_permission_code.sql 回填 Menu.PermissionCode"); | 248 | + "accessPermissions did not match any menus. Confirm permission codes match menu Router values, or run menu_backfill_permission_code.sql to backfill Menu.PermissionCode."); |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | await SetRoleMenusAsync(roleId, menuIds); | 251 | 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("User is not signed in."); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 54 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
| @@ -167,12 +167,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -167,12 +167,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 167 | QuestPDF.Settings.License = LicenseType.Community; | 167 | QuestPDF.Settings.License = LicenseType.Community; |
| 168 | if (input is null) | 168 | if (input is null) |
| 169 | { | 169 | { |
| 170 | - throw new UserFriendlyException("入参不能为空"); | 170 | + throw new UserFriendlyException("Request body is required."); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | if (!CurrentUser.Id.HasValue) | 173 | if (!CurrentUser.Id.HasValue) |
| 174 | { | 174 | { |
| 175 | - throw new UserFriendlyException("用户未登录"); | 175 | + throw new UserFriendlyException("User is not signed in."); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 178 | 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) |
| @@ -315,12 +315,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -315,12 +315,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 315 | { | 315 | { |
| 316 | if (input is null) | 316 | if (input is null) |
| 317 | { | 317 | { |
| 318 | - throw new UserFriendlyException("入参不能为空"); | 318 | + throw new UserFriendlyException("Request body is required."); |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | if (!CurrentUser.Id.HasValue) | 321 | if (!CurrentUser.Id.HasValue) |
| 322 | { | 322 | { |
| 323 | - throw new UserFriendlyException("用户未登录"); | 323 | + throw new UserFriendlyException("User is not signed in."); |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 326 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( |
| @@ -363,7 +363,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -363,7 +363,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 363 | var count = await query.CountAsync(); | 363 | var count = await query.CountAsync(); |
| 364 | if (count > ExportPdfMaxRows) | 364 | if (count > ExportPdfMaxRows) |
| 365 | { | 365 | { |
| 366 | - throw new UserFriendlyException($"导出数据超过上限 {ExportPdfMaxRows} 条,请缩小筛选范围"); | 366 | + throw new UserFriendlyException($"Export exceeds the maximum of {ExportPdfMaxRows} rows. Narrow your filters and try again."); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | var pageRows = await query.Take(ExportPdfMaxRows) | 369 | var pageRows = await query.Take(ExportPdfMaxRows) |
| @@ -417,12 +417,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | @@ -417,12 +417,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService | ||
| 417 | { | 417 | { |
| 418 | if (input is null) | 418 | if (input is null) |
| 419 | { | 419 | { |
| 420 | - throw new UserFriendlyException("入参不能为空"); | 420 | + throw new UserFriendlyException("Request body is required."); |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | if (!CurrentUser.Id.HasValue) | 423 | if (!CurrentUser.Id.HasValue) |
| 424 | { | 424 | { |
| 425 | - throw new UserFriendlyException("用户未登录"); | 425 | + throw new UserFriendlyException("User is not signed in."); |
| 426 | } | 426 | } |
| 427 | 427 | ||
| 428 | var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync( | 428 | 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("User is 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
| @@ -91,7 +91,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -91,7 +91,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 91 | var user = await _userRepository.GetByIdAsync(id); | 91 | var user = await _userRepository.GetByIdAsync(id); |
| 92 | if (user is null || user.IsDeleted) | 92 | if (user is null || user.IsDeleted) |
| 93 | { | 93 | { |
| 94 | - throw new UserFriendlyException("成员不存在"); | 94 | + throw new UserFriendlyException("Member not found."); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | var userIdString = id.ToString(); | 97 | var userIdString = id.ToString(); |
| @@ -301,7 +301,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -301,7 +301,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 301 | /// <param name="input">更新请求体</param> | 301 | /// <param name="input">更新请求体</param> |
| 302 | /// <returns>更新后的成员详情</returns> | 302 | /// <returns>更新后的成员详情</returns> |
| 303 | /// <response code="200">更新成功</response> | 303 | /// <response code="200">更新成功</response> |
| 304 | - /// <response code="400">参数不合法或成员不存在</response> | 304 | + /// <response code="400">参数不合法或Member not found.</response> |
| 305 | /// <response code="500">服务器错误</response> | 305 | /// <response code="500">服务器错误</response> |
| 306 | public async Task<TeamMemberGetOutputDto> UpdateAsync(Guid id, TeamMemberUpdateInputVo input) | 306 | public async Task<TeamMemberGetOutputDto> UpdateAsync(Guid id, TeamMemberUpdateInputVo input) |
| 307 | { | 307 | { |
| @@ -320,7 +320,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -320,7 +320,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 320 | var user = await _userRepository.GetByIdAsync(id); | 320 | var user = await _userRepository.GetByIdAsync(id); |
| 321 | if (user is null || user.IsDeleted) | 321 | if (user is null || user.IsDeleted) |
| 322 | { | 322 | { |
| 323 | - throw new UserFriendlyException("成员不存在"); | 323 | + throw new UserFriendlyException("Member not found."); |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | user.Name = input.FullName.Trim(); | 326 | user.Name = input.FullName.Trim(); |
| @@ -515,19 +515,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -515,19 +515,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 515 | { | 515 | { |
| 516 | if (input?.File is null || input.File.Length == 0) | 516 | if (input?.File is null || input.File.Length == 0) |
| 517 | { | 517 | { |
| 518 | - throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)"); | 518 | + throw new UserFriendlyException("Please upload an Excel file (form field name: file)."); |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | var opt = _batchImportOptions.Value; | 521 | var opt = _batchImportOptions.Value; |
| 522 | if (input.File.Length > opt.MaxUploadBytes) | 522 | if (input.File.Length > opt.MaxUploadBytes) |
| 523 | { | 523 | { |
| 524 | - throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB"); | 524 | + throw new UserFriendlyException($"File is too large. Maximum allowed size is {opt.MaxUploadBytes / 1024 / 1024} MB."); |
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); | 527 | var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant(); |
| 528 | if (ext != ".xlsx") | 528 | if (ext != ".xlsx") |
| 529 | { | 529 | { |
| 530 | - throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件"); | 530 | + throw new UserFriendlyException("Only .xlsx Excel files are supported."); |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 533 | var roleMap = await BuildRoleNameToIdMapAsync(); | 533 | var roleMap = await BuildRoleNameToIdMapAsync(); |
| @@ -589,14 +589,14 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -589,14 +589,14 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 589 | { | 589 | { |
| 590 | if (input?.Items is null || input.Items.Count == 0) | 590 | if (input?.Items is null || input.Items.Count == 0) |
| 591 | { | 591 | { |
| 592 | - throw new UserFriendlyException("请至少提交一条导入数据(items 不能为空)"); | 592 | + throw new UserFriendlyException("Please submit at least one import item (items cannot be empty)."); |
| 593 | } | 593 | } |
| 594 | 594 | ||
| 595 | var opt = _batchImportOptions.Value; | 595 | var opt = _batchImportOptions.Value; |
| 596 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; | 596 | var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows; |
| 597 | if (input.Items.Count > maxRows) | 597 | if (input.Items.Count > maxRows) |
| 598 | { | 598 | { |
| 599 | - throw new UserFriendlyException($"单次批量导入最多允许 {maxRows} 条,请分批提交"); | 599 | + throw new UserFriendlyException($"A maximum of {maxRows} rows is allowed per batch import. Please submit in smaller batches."); |
| 600 | } | 600 | } |
| 601 | 601 | ||
| 602 | var defaultPassword = opt.TeamMemberImportDefaultPassword?.Trim() ?? string.Empty; | 602 | var defaultPassword = opt.TeamMemberImportDefaultPassword?.Trim() ?? string.Empty; |
| @@ -611,7 +611,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -611,7 +611,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 611 | if (string.IsNullOrEmpty(defaultPassword)) | 611 | if (string.IsNullOrEmpty(defaultPassword)) |
| 612 | { | 612 | { |
| 613 | throw new UserFriendlyException( | 613 | throw new UserFriendlyException( |
| 614 | - "未配置默认导入密码 FoodLabeling:BatchImport:TeamMemberImportDefaultPassword"); | 614 | + "Default import password is not configured (FoodLabeling:BatchImport:TeamMemberImportDefaultPassword)."); |
| 615 | } | 615 | } |
| 616 | 616 | ||
| 617 | vo.Password = defaultPassword; | 617 | vo.Password = defaultPassword; |
| @@ -641,20 +641,20 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -641,20 +641,20 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 641 | { | 641 | { |
| 642 | if (input?.Items is null || input.Items.Count == 0) | 642 | if (input?.Items is null || input.Items.Count == 0) |
| 643 | { | 643 | { |
| 644 | - throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)"); | 644 | + throw new UserFriendlyException("Please submit at least one edit item (items cannot be empty)."); |
| 645 | } | 645 | } |
| 646 | 646 | ||
| 647 | var opt = _batchImportOptions.Value; | 647 | var opt = _batchImportOptions.Value; |
| 648 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; | 648 | var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems; |
| 649 | if (input.Items.Count > maxItems) | 649 | if (input.Items.Count > maxItems) |
| 650 | { | 650 | { |
| 651 | - throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交"); | 651 | + throw new UserFriendlyException($"A maximum of {maxItems} rows is allowed per bulk edit. Please submit in smaller batches."); |
| 652 | } | 652 | } |
| 653 | 653 | ||
| 654 | var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty); | 654 | var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty); |
| 655 | if (effectiveCount == 0) | 655 | if (effectiveCount == 0) |
| 656 | { | 656 | { |
| 657 | - throw new UserFriendlyException("没有有效的成员 Id(请为待保存行填写 id)"); | 657 | + throw new UserFriendlyException("No valid member Id found. Provide id for rows to save."); |
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | var result = new TeamMemberBulkUpdateResultDto(); | 660 | var result = new TeamMemberBulkUpdateResultDto(); |
| @@ -719,7 +719,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -719,7 +719,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 719 | .FirstAsync(); | 719 | .FirstAsync(); |
| 720 | if (byId is null) | 720 | if (byId is null) |
| 721 | { | 721 | { |
| 722 | - throw new UserFriendlyException($"无效门店 Id:{key}"); | 722 | + throw new UserFriendlyException($"Invalid location Id: {key}"); |
| 723 | } | 723 | } |
| 724 | 724 | ||
| 725 | result.Add(byId.Id.ToString()); | 725 | result.Add(byId.Id.ToString()); |
| @@ -731,7 +731,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -731,7 +731,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 731 | .FirstAsync(); | 731 | .FirstAsync(); |
| 732 | if (byCode is null) | 732 | if (byCode is null) |
| 733 | { | 733 | { |
| 734 | - throw new UserFriendlyException($"未找到门店 LocationCode:{key}(亦可填 location.Id Guid)"); | 734 | + throw new UserFriendlyException($"Location not found for LocationCode: {key} (you may also use location.Id Guid)."); |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | result.Add(byCode.Id.ToString()); | 737 | result.Add(byCode.Id.ToString()); |
| @@ -761,7 +761,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -761,7 +761,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 761 | .FirstAsync(); | 761 | .FirstAsync(); |
| 762 | if (byId is null) | 762 | if (byId is null) |
| 763 | { | 763 | { |
| 764 | - throw new UserFriendlyException($"无效 Region Id:{key}"); | 764 | + throw new UserFriendlyException($"Invalid Region Id: {key}"); |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | result.Add(byId.Id.Trim()); | 767 | result.Add(byId.Id.Trim()); |
| @@ -777,13 +777,13 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -777,13 +777,13 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 777 | 777 | ||
| 778 | if (matches.Count == 0) | 778 | if (matches.Count == 0) |
| 779 | { | 779 | { |
| 780 | - throw new UserFriendlyException($"未找到 Region:{key}(可填 fl_group.Id 或 GroupName)"); | 780 | + throw new UserFriendlyException($"Region not found: {key} (use fl_group.Id or GroupName)."); |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | if (matches.Count > 1) | 783 | if (matches.Count > 1) |
| 784 | { | 784 | { |
| 785 | throw new UserFriendlyException( | 785 | throw new UserFriendlyException( |
| 786 | - $"Region 名称「{key}」存在多条记录,请改用 fl_group.Id(Guid)"); | 786 | + $"Multiple regions match name \"{key}\". Use fl_group.Id (Guid) instead."); |
| 787 | } | 787 | } |
| 788 | 788 | ||
| 789 | result.Add(matches[0].Id.Trim()); | 789 | result.Add(matches[0].Id.Trim()); |
| @@ -1214,7 +1214,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1214,7 +1214,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1214 | _dbContext.SqlSugarClient, partnerIds, null, null); | 1214 | _dbContext.SqlSugarClient, partnerIds, null, null); |
| 1215 | if (fromPartner.Count == 0) | 1215 | if (fromPartner.Count == 0) |
| 1216 | { | 1216 | { |
| 1217 | - throw new UserFriendlyException("Company Admin 需绑定公司下门店,所选公司下暂无可用门店"); | 1217 | + throw new UserFriendlyException("Company Admin must be bound to locations under the company; no locations are available under the selected Company."); |
| 1218 | } | 1218 | } |
| 1219 | 1219 | ||
| 1220 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, fromPartner); | 1220 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, fromPartner); |
| @@ -1234,8 +1234,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1234,8 +1234,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1234 | { | 1234 | { |
| 1235 | throw new UserFriendlyException( | 1235 | throw new UserFriendlyException( |
| 1236 | isCompanyAdmin | 1236 | isCompanyAdmin |
| 1237 | - ? "Company Admin 必须选择 Company,或指定 Region / 门店" | ||
| 1238 | - : "成员必须至少分配一个门店(公司/区域/门店至少选一项)"); | 1237 | + ? "Company Admin must select a Company, or specify Region / Location." |
| 1238 | + : "Member must be assigned at least one Location (select Company, Region, or Location)."); | ||
| 1239 | } | 1239 | } |
| 1240 | 1240 | ||
| 1241 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged); | 1241 | await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged); |
| @@ -1435,7 +1435,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | @@ -1435,7 +1435,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService | ||
| 1435 | .CountAsync(); | 1435 | .CountAsync(); |
| 1436 | if (validCount != wanted.Count) | 1436 | if (validCount != wanted.Count) |
| 1437 | { | 1437 | { |
| 1438 | - throw new UserFriendlyException("存在无效门店,请刷新后重试"); | 1438 | + throw new UserFriendlyException("One or more locations are invalid. Refresh and try again."); |
| 1439 | } | 1439 | } |
| 1440 | 1440 | ||
| 1441 | // 含已逻辑删除行:唯一键 UK_userlocation_user_location 覆盖全历史,不能对已删行再 INSERT | 1441 | // 含已逻辑删除行:唯一键 UK_userlocation_user_location 覆盖全历史,不能对已删行再 INSERT |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppAuthAppService.cs
| @@ -90,14 +90,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -90,14 +90,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 90 | /// <param name="input">邮箱、密码;若系统开启验证码则需传 Uuid、Code</param> | 90 | /// <param name="input">邮箱、密码;若系统开启验证码则需传 Uuid、Code</param> |
| 91 | /// <returns>Token、RefreshToken 与绑定门店</returns> | 91 | /// <returns>Token、RefreshToken 与绑定门店</returns> |
| 92 | /// <response code="200">登录成功</response> | 92 | /// <response code="200">登录成功</response> |
| 93 | - /// <response code="400">参数或验证码错误</response> | 93 | + /// <response code="400">参数或Invalid verification code.</response> |
| 94 | /// <response code="500">服务器错误</response> | 94 | /// <response code="500">服务器错误</response> |
| 95 | [AllowAnonymous] | 95 | [AllowAnonymous] |
| 96 | public virtual async Task<UsAppLoginOutputDto> LoginAsync(UsAppLoginInputVo input) | 96 | public virtual async Task<UsAppLoginOutputDto> LoginAsync(UsAppLoginInputVo input) |
| 97 | { | 97 | { |
| 98 | if (string.IsNullOrWhiteSpace(input.Password) || string.IsNullOrWhiteSpace(input.Email)) | 98 | if (string.IsNullOrWhiteSpace(input.Password) || string.IsNullOrWhiteSpace(input.Email)) |
| 99 | { | 99 | { |
| 100 | - throw new UserFriendlyException("请输入合理数据!"); | 100 | + throw new UserFriendlyException("Please enter valid sign-in credentials."); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | ValidationImageCaptcha(input.Uuid, input.Code); | 103 | ValidationImageCaptcha(input.Uuid, input.Code); |
| @@ -105,7 +105,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -105,7 +105,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 105 | var user = await FindActiveUserByEmailAsync(input.Email.Trim()); | 105 | var user = await FindActiveUserByEmailAsync(input.Email.Trim()); |
| 106 | if (user is null) | 106 | if (user is null) |
| 107 | { | 107 | { |
| 108 | - throw new UserFriendlyException("登录失败!邮箱不存在!"); | 108 | + throw new UserFriendlyException("Sign-in failed: email does not exist."); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | if (!UserPasswordHelper.VerifyPlainPassword(user, input.Password)) | 111 | if (!UserPasswordHelper.VerifyPlainPassword(user, input.Password)) |
| @@ -157,7 +157,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -157,7 +157,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 157 | { | 157 | { |
| 158 | if (!CurrentUser.Id.HasValue) | 158 | if (!CurrentUser.Id.HasValue) |
| 159 | { | 159 | { |
| 160 | - throw new UserFriendlyException("用户未登录"); | 160 | + throw new UserFriendlyException("User is not signed in."); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | var list = await LoadBoundLocationsAsync(CurrentUser.Id.Value); | 163 | var list = await LoadBoundLocationsAsync(CurrentUser.Id.Value); |
| @@ -216,7 +216,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -216,7 +216,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 216 | await UsAppAuthScopeHelper.EnsureAppScopeCallerAsync(_dbContext.SqlSugarClient, CurrentUser); | 216 | await UsAppAuthScopeHelper.EnsureAppScopeCallerAsync(_dbContext.SqlSugarClient, CurrentUser); |
| 217 | if (!CurrentUser.Id.HasValue) | 217 | if (!CurrentUser.Id.HasValue) |
| 218 | { | 218 | { |
| 219 | - throw new UserFriendlyException("用户未登录"); | 219 | + throw new UserFriendlyException("User is not signed in."); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | return await UsAppAuthScopeHelper.SelectLocationAsync( | 222 | return await UsAppAuthScopeHelper.SelectLocationAsync( |
| @@ -236,7 +236,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -236,7 +236,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 236 | /// 查询单个门店详情(Location 页):地址、门店电话、经营时间、店长(角色含 manager 的绑定用户) | 236 | /// 查询单个门店详情(Location 页):地址、门店电话、经营时间、店长(角色含 manager 的绑定用户) |
| 237 | /// </summary> | 237 | /// </summary> |
| 238 | /// <remarks> | 238 | /// <remarks> |
| 239 | - /// 仅当当前登录用户在 <c>userlocation</c> 中绑定该 <c>locationId</c> 时可查;否则返回业务异常。 | 239 | + /// 仅当当前登录用户在 <c>userlocation</c> 中绑定该 <c>locationId</c> 时可查;否则返回Business error.。 |
| 240 | /// | 240 | /// |
| 241 | /// 店长:在同店绑定用户中,取 <c>Role.RoleCode</c> 或 <c>Role.RoleName</c>(忽略大小写)包含 <c>manager</c> 的第一条; | 241 | /// 店长:在同店绑定用户中,取 <c>Role.RoleCode</c> 或 <c>Role.RoleName</c>(忽略大小写)包含 <c>manager</c> 的第一条; |
| 242 | /// 若无匹配则店长姓名与电话均为「无」。 | 242 | /// 若无匹配则店长姓名与电话均为「无」。 |
| @@ -246,20 +246,20 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -246,20 +246,20 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 246 | /// <param name="locationId">门店主键(Guid 字符串)</param> | 246 | /// <param name="locationId">门店主键(Guid 字符串)</param> |
| 247 | /// <returns>与原型一致的展示字段</returns> | 247 | /// <returns>与原型一致的展示字段</returns> |
| 248 | /// <response code="200">成功</response> | 248 | /// <response code="200">成功</response> |
| 249 | - /// <response code="400">未登录、门店标识无效、未绑定或门店不存在</response> | 249 | + /// <response code="400">User is not signed in.、门店标识无效、未绑定或Location not found.</response> |
| 250 | /// <response code="500">服务器错误</response> | 250 | /// <response code="500">服务器错误</response> |
| 251 | [Authorize] | 251 | [Authorize] |
| 252 | public virtual async Task<UsAppLocationDetailOutputDto> GetLocationDetailAsync(string locationId) | 252 | public virtual async Task<UsAppLocationDetailOutputDto> GetLocationDetailAsync(string locationId) |
| 253 | { | 253 | { |
| 254 | if (!CurrentUser.Id.HasValue) | 254 | if (!CurrentUser.Id.HasValue) |
| 255 | { | 255 | { |
| 256 | - throw new UserFriendlyException("用户未登录"); | 256 | + throw new UserFriendlyException("User is not signed in."); |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | var lid = (locationId ?? string.Empty).Trim(); | 259 | var lid = (locationId ?? string.Empty).Trim(); |
| 260 | if (string.IsNullOrEmpty(lid) || !Guid.TryParse(lid, out var locationGuid)) | 260 | if (string.IsNullOrEmpty(lid) || !Guid.TryParse(lid, out var locationGuid)) |
| 261 | { | 261 | { |
| 262 | - throw new UserFriendlyException("无效的门店标识"); | 262 | + throw new UserFriendlyException("Invalid location identifier."); |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 265 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
| @@ -273,7 +273,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -273,7 +273,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 273 | var loc = locRows.FirstOrDefault(); | 273 | var loc = locRows.FirstOrDefault(); |
| 274 | if (loc is null) | 274 | if (loc is null) |
| 275 | { | 275 | { |
| 276 | - throw new UserFriendlyException("门店不存在或已删除"); | 276 | + throw new UserFriendlyException("Location not found or has been removed."); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | var (mgrName, mgrPhone) = await TryResolveStoreManagerAsync(lid); | 279 | var (mgrName, mgrPhone) = await TryResolveStoreManagerAsync(lid); |
| @@ -296,14 +296,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -296,14 +296,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 296 | { | 296 | { |
| 297 | if (!CurrentUser.Id.HasValue) | 297 | if (!CurrentUser.Id.HasValue) |
| 298 | { | 298 | { |
| 299 | - throw new UserFriendlyException("用户未登录"); | 299 | + throw new UserFriendlyException("User is not signed in."); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | var userId = CurrentUser.Id.Value; | 302 | var userId = CurrentUser.Id.Value; |
| 303 | var user = await _userRepository.GetByIdAsync(userId); | 303 | var user = await _userRepository.GetByIdAsync(userId); |
| 304 | if (user is null || user.IsDeleted || !user.State) | 304 | if (user is null || user.IsDeleted || !user.State) |
| 305 | { | 305 | { |
| 306 | - throw new UserFriendlyException("用户不存在或已停用"); | 306 | + throw new UserFriendlyException("User not found or disabled."); |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | // 避免 SqlSugar 在该环境下对 Role 关联表达式解析异常(Select 不支持),这里改用显式 SQL 查询角色。 | 309 | // 避免 SqlSugar 在该环境下对 Role 关联表达式解析异常(Select 不支持),这里改用显式 SQL 查询角色。 |
| @@ -341,12 +341,12 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -341,12 +341,12 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 341 | { | 341 | { |
| 342 | if (input is null) | 342 | if (input is null) |
| 343 | { | 343 | { |
| 344 | - throw new UserFriendlyException("入参不能为空"); | 344 | + throw new UserFriendlyException("Request body is required."); |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | if (!CurrentUser.Id.HasValue) | 347 | if (!CurrentUser.Id.HasValue) |
| 348 | { | 348 | { |
| 349 | - throw new UserFriendlyException("用户未登录"); | 349 | + throw new UserFriendlyException("User is not signed in."); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | var current = input.CurrentPassword ?? string.Empty; | 352 | var current = input.CurrentPassword ?? string.Empty; |
| @@ -355,17 +355,17 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -355,17 +355,17 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 355 | 355 | ||
| 356 | if (string.IsNullOrWhiteSpace(current) || string.IsNullOrWhiteSpace(newPwd) || string.IsNullOrWhiteSpace(confirm)) | 356 | if (string.IsNullOrWhiteSpace(current) || string.IsNullOrWhiteSpace(newPwd) || string.IsNullOrWhiteSpace(confirm)) |
| 357 | { | 357 | { |
| 358 | - throw new UserFriendlyException("请填写当前密码、新密码与确认密码"); | 358 | + throw new UserFriendlyException("Current password, new password, and confirmation are required."); |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | if (!string.Equals(newPwd, confirm, StringComparison.Ordinal)) | 361 | if (!string.Equals(newPwd, confirm, StringComparison.Ordinal)) |
| 362 | { | 362 | { |
| 363 | - throw new UserFriendlyException("新密码与确认密码不一致"); | 363 | + throw new UserFriendlyException("New password and confirmation do not match."); |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | if (string.Equals(current, newPwd, StringComparison.Ordinal)) | 366 | if (string.Equals(current, newPwd, StringComparison.Ordinal)) |
| 367 | { | 367 | { |
| 368 | - throw new UserFriendlyException("新密码不能与当前密码相同"); | 368 | + throw new UserFriendlyException("New password must be different from the current password."); |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | ValidateAppPasswordComplexity(newPwd); | 371 | ValidateAppPasswordComplexity(newPwd); |
| @@ -374,7 +374,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -374,7 +374,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 374 | var user = await _userRepository.GetByIdAsync(userId); | 374 | var user = await _userRepository.GetByIdAsync(userId); |
| 375 | if (user is null || user.IsDeleted || !user.State) | 375 | if (user is null || user.IsDeleted || !user.State) |
| 376 | { | 376 | { |
| 377 | - throw new UserFriendlyException("用户不存在或已停用"); | 377 | + throw new UserFriendlyException("User not found or disabled."); |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | if (!user.JudgePassword(current)) | 380 | if (!user.JudgePassword(current)) |
| @@ -466,27 +466,27 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -466,27 +466,27 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 466 | { | 466 | { |
| 467 | if (password.Length < 8) | 467 | if (password.Length < 8) |
| 468 | { | 468 | { |
| 469 | - throw new UserFriendlyException("新密码至少 8 位"); | 469 | + throw new UserFriendlyException("New password must be at least 8 characters."); |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | if (!password.Any(char.IsUpper)) | 472 | if (!password.Any(char.IsUpper)) |
| 473 | { | 473 | { |
| 474 | - throw new UserFriendlyException("新密码需包含大写字母"); | 474 | + throw new UserFriendlyException("New password must contain an uppercase letter."); |
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | if (!password.Any(char.IsLower)) | 477 | if (!password.Any(char.IsLower)) |
| 478 | { | 478 | { |
| 479 | - throw new UserFriendlyException("新密码需包含小写字母"); | 479 | + throw new UserFriendlyException("New password must contain a lowercase letter."); |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | if (!password.Any(char.IsDigit)) | 482 | if (!password.Any(char.IsDigit)) |
| 483 | { | 483 | { |
| 484 | - throw new UserFriendlyException("新密码需包含至少一个数字"); | 484 | + throw new UserFriendlyException("New password must contain at least one digit."); |
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | if (!password.Any(c => !char.IsLetterOrDigit(c))) | 487 | if (!password.Any(c => !char.IsLetterOrDigit(c))) |
| 488 | { | 488 | { |
| 489 | - throw new UserFriendlyException("新密码需包含至少一个特殊字符"); | 489 | + throw new UserFriendlyException("New password must contain at least one special character."); |
| 490 | } | 490 | } |
| 491 | } | 491 | } |
| 492 | 492 | ||
| @@ -499,7 +499,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | @@ -499,7 +499,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService | ||
| 499 | 499 | ||
| 500 | if (!_captcha.Validate(uuid, code)) | 500 | if (!_captcha.Validate(uuid, code)) |
| 501 | { | 501 | { |
| 502 | - throw new UserFriendlyException("验证码错误"); | 502 | + throw new UserFriendlyException("Invalid verification code."); |
| 503 | } | 503 | } |
| 504 | } | 504 | } |
| 505 | 505 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs
| @@ -64,7 +64,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -64,7 +64,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 64 | { | 64 | { |
| 65 | if (string.IsNullOrWhiteSpace(input.LocationId)) | 65 | if (string.IsNullOrWhiteSpace(input.LocationId)) |
| 66 | { | 66 | { |
| 67 | - throw new UserFriendlyException("门店Id不能为空"); | 67 | + throw new UserFriendlyException("Location ID is required."); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | var locationId = input.LocationId.Trim(); | 70 | var locationId = input.LocationId.Trim(); |
| @@ -334,7 +334,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -334,7 +334,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 334 | /// ``` | 334 | /// ``` |
| 335 | /// </remarks> | 335 | /// </remarks> |
| 336 | /// <param name="input">预览入参</param> | 336 | /// <param name="input">预览入参</param> |
| 337 | - /// <returns>顶部字段 + 预览模板结构</returns> | 337 | + /// <returns>顶部字段 + 预览模板结构(含 <c>nutritionByElementId</c> 营养成分 JSON)</returns> |
| 338 | /// <response code="200">成功</response> | 338 | /// <response code="200">成功</response> |
| 339 | /// <response code="400">参数错误/数据不存在</response> | 339 | /// <response code="400">参数错误/数据不存在</response> |
| 340 | /// <response code="500">服务器错误</response> | 340 | /// <response code="500">服务器错误</response> |
| @@ -343,19 +343,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -343,19 +343,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 343 | { | 343 | { |
| 344 | if (input is null) | 344 | if (input is null) |
| 345 | { | 345 | { |
| 346 | - throw new UserFriendlyException("入参不能为空"); | 346 | + throw new UserFriendlyException("Request body is required."); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | var locationId = input.LocationId?.Trim(); | 349 | var locationId = input.LocationId?.Trim(); |
| 350 | if (string.IsNullOrWhiteSpace(locationId)) | 350 | if (string.IsNullOrWhiteSpace(locationId)) |
| 351 | { | 351 | { |
| 352 | - throw new UserFriendlyException("门店Id不能为空"); | 352 | + throw new UserFriendlyException("Location ID is required."); |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | var labelCode = input.LabelCode?.Trim(); | 355 | var labelCode = input.LabelCode?.Trim(); |
| 356 | if (string.IsNullOrWhiteSpace(labelCode)) | 356 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 357 | { | 357 | { |
| 358 | - throw new UserFriendlyException("labelCode不能为空"); | 358 | + throw new UserFriendlyException("labelCode is required."); |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | var labelRow = await _dbContext.SqlSugarClient | 361 | var labelRow = await _dbContext.SqlSugarClient |
| @@ -389,7 +389,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -389,7 +389,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 389 | 389 | ||
| 390 | if (labelRow is null) | 390 | if (labelRow is null) |
| 391 | { | 391 | { |
| 392 | - throw new UserFriendlyException("标签不存在或不可用"); | 392 | + throw new UserFriendlyException("Label not found or unavailable."); |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | var labelForScope = new FlLabelDbEntity | 395 | var labelForScope = new FlLabelDbEntity |
| @@ -402,7 +402,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -402,7 +402,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 402 | if (!await LabelRegionScopeHelper.LabelAppliesToLocationAsync( | 402 | if (!await LabelRegionScopeHelper.LabelAppliesToLocationAsync( |
| 403 | _dbContext.SqlSugarClient, labelForScope, locationId, storeGroupIds)) | 403 | _dbContext.SqlSugarClient, labelForScope, locationId, storeGroupIds)) |
| 404 | { | 404 | { |
| 405 | - throw new UserFriendlyException("该标签不属于当前门店"); | 405 | + throw new UserFriendlyException("This label does not belong to the current Location."); |
| 406 | } | 406 | } |
| 407 | 407 | ||
| 408 | var previewProductId = await ResolvePreviewProductIdAsync(labelRow.Id, input.ProductId); | 408 | var previewProductId = await ResolvePreviewProductIdAsync(labelRow.Id, input.ProductId); |
| @@ -500,11 +500,25 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -500,11 +500,25 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 500 | } | 500 | } |
| 501 | } | 501 | } |
| 502 | 502 | ||
| 503 | + var nutritionByElementId = ExtractNutritionByElementId( | ||
| 504 | + template.Elements, | ||
| 505 | + templateProductDefaultValues); | ||
| 506 | + | ||
| 503 | if (templateProductDefaultValues is { Count: > 0 }) | 507 | if (templateProductDefaultValues is { Count: > 0 }) |
| 504 | { | 508 | { |
| 505 | ApplyTemplateProductDefaultValuesToPreviewElements(template.Elements, templateProductDefaultValues); | 509 | ApplyTemplateProductDefaultValuesToPreviewElements(template.Elements, templateProductDefaultValues); |
| 506 | } | 510 | } |
| 507 | 511 | ||
| 512 | + if (nutritionByElementId.Count > 0) | ||
| 513 | + { | ||
| 514 | + ApplyNutritionFactsJsonToPreviewElements(template.Elements, nutritionByElementId); | ||
| 515 | + foreach (var (elementId, fields) in nutritionByElementId) | ||
| 516 | + { | ||
| 517 | + templateProductDefaultValues ??= new Dictionary<string, object?>(); | ||
| 518 | + templateProductDefaultValues[elementId] = JsonSerializer.Serialize(fields); | ||
| 519 | + } | ||
| 520 | + } | ||
| 521 | + | ||
| 508 | return new UsAppLabelPreviewDto | 522 | return new UsAppLabelPreviewDto |
| 509 | { | 523 | { |
| 510 | LabelId = nextDailyLabelId, | 524 | LabelId = nextDailyLabelId, |
| @@ -520,7 +534,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -520,7 +534,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 520 | LabelLastEdited = labelRow.LastModificationTime ?? labelRow.CreationTime, | 534 | LabelLastEdited = labelRow.LastModificationTime ?? labelRow.CreationTime, |
| 521 | PreviewImageBase64Png = null, | 535 | PreviewImageBase64Png = null, |
| 522 | Template = template, | 536 | Template = template, |
| 523 | - TemplateProductDefaultValues = templateProductDefaultValues | 537 | + TemplateProductDefaultValues = templateProductDefaultValues, |
| 538 | + NutritionByElementId = nutritionByElementId | ||
| 524 | }; | 539 | }; |
| 525 | } | 540 | } |
| 526 | 541 | ||
| @@ -542,19 +557,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -542,19 +557,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 542 | { | 557 | { |
| 543 | if (input is null) | 558 | if (input is null) |
| 544 | { | 559 | { |
| 545 | - throw new UserFriendlyException("入参不能为空"); | 560 | + throw new UserFriendlyException("Request body is required."); |
| 546 | } | 561 | } |
| 547 | 562 | ||
| 548 | var locationId = input.LocationId?.Trim(); | 563 | var locationId = input.LocationId?.Trim(); |
| 549 | if (string.IsNullOrWhiteSpace(locationId)) | 564 | if (string.IsNullOrWhiteSpace(locationId)) |
| 550 | { | 565 | { |
| 551 | - throw new UserFriendlyException("门店Id不能为空"); | 566 | + throw new UserFriendlyException("Location ID is required."); |
| 552 | } | 567 | } |
| 553 | 568 | ||
| 554 | var labelCode = input.LabelCode?.Trim(); | 569 | var labelCode = input.LabelCode?.Trim(); |
| 555 | if (string.IsNullOrWhiteSpace(labelCode)) | 570 | if (string.IsNullOrWhiteSpace(labelCode)) |
| 556 | { | 571 | { |
| 557 | - throw new UserFriendlyException("labelCode不能为空"); | 572 | + throw new UserFriendlyException("labelCode is required."); |
| 558 | } | 573 | } |
| 559 | 574 | ||
| 560 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; | 575 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; |
| @@ -588,7 +603,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -588,7 +603,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 588 | 603 | ||
| 589 | if (labelRow is null) | 604 | if (labelRow is null) |
| 590 | { | 605 | { |
| 591 | - throw new UserFriendlyException("标签不存在或不可用"); | 606 | + throw new UserFriendlyException("Label not found or unavailable."); |
| 592 | } | 607 | } |
| 593 | 608 | ||
| 594 | await LabelRegionScopeHelper.EnsureLabelAppliesToLocationAsync( | 609 | await LabelRegionScopeHelper.EnsureLabelAppliesToLocationAsync( |
| @@ -733,19 +748,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -733,19 +748,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 733 | { | 748 | { |
| 734 | if (input is null) | 749 | if (input is null) |
| 735 | { | 750 | { |
| 736 | - throw new UserFriendlyException("入参不能为空"); | 751 | + throw new UserFriendlyException("Request body is required."); |
| 737 | } | 752 | } |
| 738 | 753 | ||
| 739 | var locationId = input.LocationId?.Trim(); | 754 | var locationId = input.LocationId?.Trim(); |
| 740 | if (string.IsNullOrWhiteSpace(locationId)) | 755 | if (string.IsNullOrWhiteSpace(locationId)) |
| 741 | { | 756 | { |
| 742 | - throw new UserFriendlyException("门店Id不能为空"); | 757 | + throw new UserFriendlyException("Location ID is required."); |
| 743 | } | 758 | } |
| 744 | 759 | ||
| 745 | var taskId = input.TaskId?.Trim(); | 760 | var taskId = input.TaskId?.Trim(); |
| 746 | if (string.IsNullOrWhiteSpace(taskId)) | 761 | if (string.IsNullOrWhiteSpace(taskId)) |
| 747 | { | 762 | { |
| 748 | - throw new UserFriendlyException("taskId不能为空"); | 763 | + throw new UserFriendlyException("taskId is required."); |
| 749 | } | 764 | } |
| 750 | 765 | ||
| 751 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; | 766 | var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity; |
| @@ -762,20 +777,20 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -762,20 +777,20 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 762 | var currentUserId = CurrentUser?.Id?.ToString(); | 777 | var currentUserId = CurrentUser?.Id?.ToString(); |
| 763 | if (string.IsNullOrWhiteSpace(currentUserId)) | 778 | if (string.IsNullOrWhiteSpace(currentUserId)) |
| 764 | { | 779 | { |
| 765 | - throw new UserFriendlyException("未登录"); | 780 | + throw new UserFriendlyException("User is not signed in."); |
| 766 | } | 781 | } |
| 767 | 782 | ||
| 768 | var old = await _dbContext.SqlSugarClient.Queryable<FlLabelPrintTaskDbEntity>() | 783 | var old = await _dbContext.SqlSugarClient.Queryable<FlLabelPrintTaskDbEntity>() |
| 769 | .FirstAsync(x => x.Id == taskId); | 784 | .FirstAsync(x => x.Id == taskId); |
| 770 | if (old is null) | 785 | if (old is null) |
| 771 | { | 786 | { |
| 772 | - throw new UserFriendlyException("打印任务不存在"); | 787 | + throw new UserFriendlyException("Print task not found."); |
| 773 | } | 788 | } |
| 774 | 789 | ||
| 775 | // 已绑定该门店的账号可重打门店内任意历史任务(不限 CreatedBy) | 790 | // 已绑定该门店的账号可重打门店内任意历史任务(不限 CreatedBy) |
| 776 | if (!string.Equals(old.LocationId?.Trim(), locationId, StringComparison.OrdinalIgnoreCase)) | 791 | if (!string.Equals(old.LocationId?.Trim(), locationId, StringComparison.OrdinalIgnoreCase)) |
| 777 | { | 792 | { |
| 778 | - throw new UserFriendlyException("该任务不属于当前门店"); | 793 | + throw new UserFriendlyException("This task does not belong to the current Location."); |
| 779 | } | 794 | } |
| 780 | 795 | ||
| 781 | LabelTemplatePreviewDto? resolvedTemplate = null; | 796 | LabelTemplatePreviewDto? resolvedTemplate = null; |
| @@ -790,7 +805,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -790,7 +805,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 790 | 805 | ||
| 791 | if (resolvedTemplate is null) | 806 | if (resolvedTemplate is null) |
| 792 | { | 807 | { |
| 793 | - throw new UserFriendlyException("历史任务渲染快照解析失败,无法重打"); | 808 | + throw new UserFriendlyException("Failed to parse the historical task render snapshot; reprint is not available."); |
| 794 | } | 809 | } |
| 795 | 810 | ||
| 796 | var now = DateTime.Now; | 811 | var now = DateTime.Now; |
| @@ -948,7 +963,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -948,7 +963,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 948 | /// <param name="input">分页查询入参</param> | 963 | /// <param name="input">分页查询入参</param> |
| 949 | /// <returns>分页打印日志</returns> | 964 | /// <returns>分页打印日志</returns> |
| 950 | /// <response code="200">成功</response> | 965 | /// <response code="200">成功</response> |
| 951 | - /// <response code="400">参数错误/未登录</response> | 966 | + /// <response code="400">参数错误/User is not signed in.</response> |
| 952 | /// <response code="500">服务器错误</response> | 967 | /// <response code="500">服务器错误</response> |
| 953 | [Authorize] | 968 | [Authorize] |
| 954 | [HttpPost] | 969 | [HttpPost] |
| @@ -956,18 +971,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -956,18 +971,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 956 | { | 971 | { |
| 957 | if (input is null) | 972 | if (input is null) |
| 958 | { | 973 | { |
| 959 | - throw new UserFriendlyException("入参不能为空"); | 974 | + throw new UserFriendlyException("Request body is required."); |
| 960 | } | 975 | } |
| 961 | 976 | ||
| 962 | if (!CurrentUser.Id.HasValue) | 977 | if (!CurrentUser.Id.HasValue) |
| 963 | { | 978 | { |
| 964 | - throw new UserFriendlyException("用户未登录"); | 979 | + throw new UserFriendlyException("User is not signed in."); |
| 965 | } | 980 | } |
| 966 | 981 | ||
| 967 | var locationId = input.LocationId?.Trim(); | 982 | var locationId = input.LocationId?.Trim(); |
| 968 | if (string.IsNullOrWhiteSpace(locationId)) | 983 | if (string.IsNullOrWhiteSpace(locationId)) |
| 969 | { | 984 | { |
| 970 | - throw new UserFriendlyException("门店Id不能为空"); | 985 | + throw new UserFriendlyException("Location ID is required."); |
| 971 | } | 986 | } |
| 972 | 987 | ||
| 973 | var currentUserIdStr = CurrentUser.Id.Value.ToString(); | 988 | var currentUserIdStr = CurrentUser.Id.Value.ToString(); |
| @@ -1097,18 +1112,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -1097,18 +1112,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 1097 | { | 1112 | { |
| 1098 | if (input is null) | 1113 | if (input is null) |
| 1099 | { | 1114 | { |
| 1100 | - throw new UserFriendlyException("入参不能为空"); | 1115 | + throw new UserFriendlyException("Request body is required."); |
| 1101 | } | 1116 | } |
| 1102 | 1117 | ||
| 1103 | if (!CurrentUser.Id.HasValue) | 1118 | if (!CurrentUser.Id.HasValue) |
| 1104 | { | 1119 | { |
| 1105 | - throw new UserFriendlyException("用户未登录"); | 1120 | + throw new UserFriendlyException("User is not signed in."); |
| 1106 | } | 1121 | } |
| 1107 | 1122 | ||
| 1108 | var locationId = input.LocationId?.Trim(); | 1123 | var locationId = input.LocationId?.Trim(); |
| 1109 | if (string.IsNullOrWhiteSpace(locationId)) | 1124 | if (string.IsNullOrWhiteSpace(locationId)) |
| 1110 | { | 1125 | { |
| 1111 | - throw new UserFriendlyException("门店Id不能为空"); | 1126 | + throw new UserFriendlyException("Location ID is required."); |
| 1112 | } | 1127 | } |
| 1113 | 1128 | ||
| 1114 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( | 1129 | await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync( |
| @@ -1319,6 +1334,10 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -1319,6 +1334,10 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 1319 | 1334 | ||
| 1320 | switch (type) | 1335 | switch (type) |
| 1321 | { | 1336 | { |
| 1337 | + case "NUTRITION": | ||
| 1338 | + case "NUTRITIONFACTS": | ||
| 1339 | + ApplyNutritionManualToConfig(cfg, ParseNutritionManualObject(stored)); | ||
| 1340 | + break; | ||
| 1322 | case "DATE": | 1341 | case "DATE": |
| 1323 | case "TIME": | 1342 | case "TIME": |
| 1324 | case "DURATION": | 1343 | case "DURATION": |
| @@ -1373,6 +1392,297 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | @@ -1373,6 +1392,297 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ | ||
| 1373 | } | 1392 | } |
| 1374 | } | 1393 | } |
| 1375 | 1394 | ||
| 1395 | + private const string NutritionCompositeSep = "###nut###"; | ||
| 1396 | + | ||
| 1397 | + private static bool IsNutritionPreviewElement(LabelTemplateElementDto el) | ||
| 1398 | + { | ||
| 1399 | + var type = (el.ElementType ?? string.Empty).Trim().ToUpperInvariant(); | ||
| 1400 | + if (type is "NUTRITION" or "NUTRITIONFACTS") | ||
| 1401 | + { | ||
| 1402 | + return true; | ||
| 1403 | + } | ||
| 1404 | + | ||
| 1405 | + var typeAdd = (el.TypeAdd ?? string.Empty).Trim().ToUpperInvariant(); | ||
| 1406 | + var name = (el.ElementName ?? string.Empty).Trim().ToUpperInvariant(); | ||
| 1407 | + return typeAdd.Contains("NUTRITION", StringComparison.Ordinal) | ||
| 1408 | + || name.Contains("NUTRITION", StringComparison.Ordinal); | ||
| 1409 | + } | ||
| 1410 | + | ||
| 1411 | + /// <summary> | ||
| 1412 | + /// 从标签/产品默认值中提取 Nutrition Facts JSON(elementId → 字段)。 | ||
| 1413 | + /// </summary> | ||
| 1414 | + private static Dictionary<string, Dictionary<string, string>> ExtractNutritionByElementId( | ||
| 1415 | + IList<LabelTemplateElementDto>? elements, | ||
| 1416 | + Dictionary<string, object?>? defaults) | ||
| 1417 | + { | ||
| 1418 | + var result = new Dictionary<string, Dictionary<string, string>>(StringComparer.Ordinal); | ||
| 1419 | + if (elements is null || elements.Count == 0 || defaults is not { Count: > 0 }) | ||
| 1420 | + { | ||
| 1421 | + return result; | ||
| 1422 | + } | ||
| 1423 | + | ||
| 1424 | + foreach (var el in elements) | ||
| 1425 | + { | ||
| 1426 | + if (!IsNutritionPreviewElement(el) || string.IsNullOrWhiteSpace(el.Id)) | ||
| 1427 | + { | ||
| 1428 | + continue; | ||
| 1429 | + } | ||
| 1430 | + | ||
| 1431 | + var manual = ResolveNutritionManualForElement(el, defaults); | ||
| 1432 | + if (manual.Count == 0) | ||
| 1433 | + { | ||
| 1434 | + continue; | ||
| 1435 | + } | ||
| 1436 | + | ||
| 1437 | + result[el.Id.Trim()] = manual; | ||
| 1438 | + } | ||
| 1439 | + | ||
| 1440 | + return result; | ||
| 1441 | + } | ||
| 1442 | + | ||
| 1443 | + private static Dictionary<string, string> ResolveNutritionManualForElement( | ||
| 1444 | + LabelTemplateElementDto el, | ||
| 1445 | + Dictionary<string, object?> defaults) | ||
| 1446 | + { | ||
| 1447 | + var stored = ResolveTemplateProductDefaultValueForElement(el, defaults); | ||
| 1448 | + var fromDirect = ParseNutritionManualObject(stored); | ||
| 1449 | + if (fromDirect.Count > 0) | ||
| 1450 | + { | ||
| 1451 | + return fromDirect; | ||
| 1452 | + } | ||
| 1453 | + | ||
| 1454 | + var id = el.Id?.Trim() ?? string.Empty; | ||
| 1455 | + if (string.IsNullOrWhiteSpace(id)) | ||
| 1456 | + { | ||
| 1457 | + return new Dictionary<string, string>(StringComparer.Ordinal); | ||
| 1458 | + } | ||
| 1459 | + | ||
| 1460 | + var prefix = id + NutritionCompositeSep; | ||
| 1461 | + var composite = new Dictionary<string, string>(StringComparer.Ordinal); | ||
| 1462 | + foreach (var kv in defaults) | ||
| 1463 | + { | ||
| 1464 | + if (kv.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) | ||
| 1465 | + { | ||
| 1466 | + composite[kv.Key[prefix.Length..]] = TemplateProductDefaultValueToStoredString(kv.Value) ?? string.Empty; | ||
| 1467 | + } | ||
| 1468 | + } | ||
| 1469 | + | ||
| 1470 | + return composite; | ||
| 1471 | + } | ||
| 1472 | + | ||
| 1473 | + private static Dictionary<string, string> ParseNutritionManualObject(string? raw) | ||
| 1474 | + { | ||
| 1475 | + var result = new Dictionary<string, string>(StringComparer.Ordinal); | ||
| 1476 | + if (string.IsNullOrWhiteSpace(raw)) | ||
| 1477 | + { | ||
| 1478 | + return result; | ||
| 1479 | + } | ||
| 1480 | + | ||
| 1481 | + var text = raw.Trim(); | ||
| 1482 | + if (!text.StartsWith('{')) | ||
| 1483 | + { | ||
| 1484 | + return result; | ||
| 1485 | + } | ||
| 1486 | + | ||
| 1487 | + try | ||
| 1488 | + { | ||
| 1489 | + using var doc = JsonDocument.Parse(text); | ||
| 1490 | + if (doc.RootElement.ValueKind != JsonValueKind.Object) | ||
| 1491 | + { | ||
| 1492 | + return result; | ||
| 1493 | + } | ||
| 1494 | + | ||
| 1495 | + foreach (var prop in doc.RootElement.EnumerateObject()) | ||
| 1496 | + { | ||
| 1497 | + var key = prop.Name.Trim(); | ||
| 1498 | + if (string.IsNullOrWhiteSpace(key)) | ||
| 1499 | + { | ||
| 1500 | + continue; | ||
| 1501 | + } | ||
| 1502 | + | ||
| 1503 | + result[key] = prop.Value.ValueKind switch | ||
| 1504 | + { | ||
| 1505 | + JsonValueKind.String => prop.Value.GetString() ?? string.Empty, | ||
| 1506 | + JsonValueKind.Null => string.Empty, | ||
| 1507 | + JsonValueKind.True => "true", | ||
| 1508 | + JsonValueKind.False => "false", | ||
| 1509 | + JsonValueKind.Number => prop.Value.GetRawText(), | ||
| 1510 | + _ => prop.Value.GetRawText() | ||
| 1511 | + }; | ||
| 1512 | + } | ||
| 1513 | + } | ||
| 1514 | + catch | ||
| 1515 | + { | ||
| 1516 | + return result; | ||
| 1517 | + } | ||
| 1518 | + | ||
| 1519 | + return result; | ||
| 1520 | + } | ||
| 1521 | + | ||
| 1522 | + private static void ApplyNutritionFactsJsonToPreviewElements( | ||
| 1523 | + IList<LabelTemplateElementDto>? elements, | ||
| 1524 | + Dictionary<string, Dictionary<string, string>> nutritionByElementId) | ||
| 1525 | + { | ||
| 1526 | + if (elements is null || elements.Count == 0 || nutritionByElementId.Count == 0) | ||
| 1527 | + { | ||
| 1528 | + return; | ||
| 1529 | + } | ||
| 1530 | + | ||
| 1531 | + foreach (var el in elements) | ||
| 1532 | + { | ||
| 1533 | + if (!IsNutritionPreviewElement(el) || string.IsNullOrWhiteSpace(el.Id)) | ||
| 1534 | + { | ||
| 1535 | + continue; | ||
| 1536 | + } | ||
| 1537 | + | ||
| 1538 | + if (!nutritionByElementId.TryGetValue(el.Id.Trim(), out var manual) || manual.Count == 0) | ||
| 1539 | + { | ||
| 1540 | + continue; | ||
| 1541 | + } | ||
| 1542 | + | ||
| 1543 | + var cfg = ParsePreviewElementConfig(el.ConfigJson); | ||
| 1544 | + ApplyNutritionManualToConfig(cfg, manual); | ||
| 1545 | + el.ConfigJson = cfg; | ||
| 1546 | + } | ||
| 1547 | + } | ||
| 1548 | + | ||
| 1549 | + private static void ApplyNutritionManualToConfig( | ||
| 1550 | + Dictionary<string, object?> cfg, | ||
| 1551 | + Dictionary<string, string> manual) | ||
| 1552 | + { | ||
| 1553 | + if (manual.Count == 0) | ||
| 1554 | + { | ||
| 1555 | + return; | ||
| 1556 | + } | ||
| 1557 | + | ||
| 1558 | + cfg["nutritionFactsJson"] = JsonSerializer.Serialize(manual); | ||
| 1559 | + foreach (var kv in manual) | ||
| 1560 | + { | ||
| 1561 | + var key = kv.Key?.Trim(); | ||
| 1562 | + if (string.IsNullOrWhiteSpace(key)) | ||
| 1563 | + { | ||
| 1564 | + continue; | ||
| 1565 | + } | ||
| 1566 | + | ||
| 1567 | + cfg[key] = kv.Value ?? string.Empty; | ||
| 1568 | + } | ||
| 1569 | + | ||
| 1570 | + if (TryPickNutritionField(manual, out var calories, "calories")) | ||
| 1571 | + { | ||
| 1572 | + cfg["calories"] = calories; | ||
| 1573 | + cfg["Calories"] = calories; | ||
| 1574 | + } | ||
| 1575 | + | ||
| 1576 | + if (TryPickNutritionField(manual, out var servings, "servingsPerContainer", "servings")) | ||
| 1577 | + { | ||
| 1578 | + cfg["servingsPerContainer"] = servings; | ||
| 1579 | + cfg["servings"] = servings; | ||
| 1580 | + } | ||
| 1581 | + | ||
| 1582 | + if (TryPickNutritionField(manual, out var servingSize, "servingSize", "serveSize")) | ||
| 1583 | + { | ||
| 1584 | + cfg["servingSize"] = servingSize; | ||
| 1585 | + cfg["serveSize"] = servingSize; | ||
| 1586 | + } | ||
| 1587 | + | ||
| 1588 | + if (TryPickNutritionField(manual, out var fat, "fat", "totalFat")) | ||
| 1589 | + { | ||
| 1590 | + cfg["fat"] = fat; | ||
| 1591 | + cfg["totalFat"] = fat; | ||
| 1592 | + } | ||
| 1593 | + | ||
| 1594 | + if (TryPickNutritionField(manual, out var carbs, "carbs", "totalCarbo", "totalCarbohydrate")) | ||
| 1595 | + { | ||
| 1596 | + cfg["carbs"] = carbs; | ||
| 1597 | + } | ||
| 1598 | + | ||
| 1599 | + if (TryPickNutritionField(manual, out var sugars, "totalSugar", "sugars")) | ||
| 1600 | + { | ||
| 1601 | + cfg["totalSugar"] = sugars; | ||
| 1602 | + } | ||
| 1603 | + | ||
| 1604 | + if (cfg.TryGetValue("fixedNutrients", out var fixedRaw) && fixedRaw is not null) | ||
| 1605 | + { | ||
| 1606 | + ApplyNutritionManualToFixedNutrients(cfg, manual); | ||
| 1607 | + } | ||
| 1608 | + } | ||
| 1609 | + | ||
| 1610 | + private static bool TryPickNutritionField( | ||
| 1611 | + Dictionary<string, string> manual, | ||
| 1612 | + out string value, | ||
| 1613 | + params string[] keys) | ||
| 1614 | + { | ||
| 1615 | + foreach (var key in keys) | ||
| 1616 | + { | ||
| 1617 | + foreach (var kv in manual) | ||
| 1618 | + { | ||
| 1619 | + if (string.Equals(kv.Key, key, StringComparison.OrdinalIgnoreCase) | ||
| 1620 | + && !string.IsNullOrWhiteSpace(kv.Value)) | ||
| 1621 | + { | ||
| 1622 | + value = kv.Value; | ||
| 1623 | + return true; | ||
| 1624 | + } | ||
| 1625 | + } | ||
| 1626 | + } | ||
| 1627 | + | ||
| 1628 | + value = string.Empty; | ||
| 1629 | + return false; | ||
| 1630 | + } | ||
| 1631 | + | ||
| 1632 | + private static void ApplyNutritionManualToFixedNutrients( | ||
| 1633 | + Dictionary<string, object?> cfg, | ||
| 1634 | + Dictionary<string, string> manual) | ||
| 1635 | + { | ||
| 1636 | + try | ||
| 1637 | + { | ||
| 1638 | + var json = JsonSerializer.Serialize(cfg["fixedNutrients"]); | ||
| 1639 | + var rows = JsonSerializer.Deserialize<List<Dictionary<string, object?>>>(json); | ||
| 1640 | + if (rows is null || rows.Count == 0) | ||
| 1641 | + { | ||
| 1642 | + return; | ||
| 1643 | + } | ||
| 1644 | + | ||
| 1645 | + foreach (var row in rows) | ||
| 1646 | + { | ||
| 1647 | + if (!row.TryGetValue("key", out var keyObj)) | ||
| 1648 | + { | ||
| 1649 | + continue; | ||
| 1650 | + } | ||
| 1651 | + | ||
| 1652 | + var key = Convert.ToString(keyObj, CultureInfo.InvariantCulture)?.Trim(); | ||
| 1653 | + if (string.IsNullOrWhiteSpace(key)) | ||
| 1654 | + { | ||
| 1655 | + continue; | ||
| 1656 | + } | ||
| 1657 | + | ||
| 1658 | + if (TryPickNutritionField(manual, out var amount, key, AliasForNutritionKey(key))) | ||
| 1659 | + { | ||
| 1660 | + row["value"] = amount; | ||
| 1661 | + } | ||
| 1662 | + | ||
| 1663 | + if (TryPickNutritionField(manual, out var pct, $"{key}Percent")) | ||
| 1664 | + { | ||
| 1665 | + row["dailyValuePercent"] = pct; | ||
| 1666 | + } | ||
| 1667 | + } | ||
| 1668 | + | ||
| 1669 | + cfg["fixedNutrients"] = rows; | ||
| 1670 | + } | ||
| 1671 | + catch | ||
| 1672 | + { | ||
| 1673 | + // keep original fixedNutrients when merge fails | ||
| 1674 | + } | ||
| 1675 | + } | ||
| 1676 | + | ||
| 1677 | + private static string AliasForNutritionKey(string key) => key switch | ||
| 1678 | + { | ||
| 1679 | + "fat" => "totalFat", | ||
| 1680 | + "totalFat" => "fat", | ||
| 1681 | + "carbs" => "totalCarbo", | ||
| 1682 | + "totalSugar" => "sugars", | ||
| 1683 | + _ => key | ||
| 1684 | + }; | ||
| 1685 | + | ||
| 1376 | private static string? ResolveTemplateProductDefaultValueForElement( | 1686 | private static string? ResolveTemplateProductDefaultValueForElement( |
| 1377 | LabelTemplateElementDto el, | 1687 | LabelTemplateElementDto el, |
| 1378 | Dictionary<string, object?> defaults) | 1688 | Dictionary<string, object?> defaults) |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs
| @@ -14,7 +14,7 @@ namespace Yi.Framework.Rbac.Application.Contracts.IServices | @@ -14,7 +14,7 @@ namespace Yi.Framework.Rbac.Application.Contracts.IServices | ||
| 14 | Task<bool> RestPasswordAsync(Guid userId, RestPasswordDto input); | 14 | Task<bool> RestPasswordAsync(Guid userId, RestPasswordDto input); |
| 15 | 15 | ||
| 16 | /// <summary> | 16 | /// <summary> |
| 17 | - /// 根据信息查询用户,可能为空,代表该用户不存在或禁用 | 17 | + /// 根据信息查询用户,可能为空,代表用户不存在或已禁用 |
| 18 | /// </summary> | 18 | /// </summary> |
| 19 | /// <param name="userName"></param> | 19 | /// <param name="userName"></param> |
| 20 | /// <param name="phone"></param> | 20 | /// <param name="phone"></param> |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs
| @@ -209,7 +209,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -209,7 +209,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 209 | var res = Regex.IsMatch(phone, @"^\d{11}$"); | 209 | var res = Regex.IsMatch(phone, @"^\d{11}$"); |
| 210 | if (res == false) | 210 | if (res == false) |
| 211 | { | 211 | { |
| 212 | - throw new UserFriendlyException("手机号码格式错误!请检查"); | 212 | + throw new UserFriendlyException("Invalid phone number format. Please check and try again."); |
| 213 | } | 213 | } |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -265,7 +265,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -265,7 +265,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 265 | if (validationPhoneType == ValidationPhoneTypeEnum.Register && | 265 | if (validationPhoneType == ValidationPhoneTypeEnum.Register && |
| 266 | await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone)) | 266 | await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone)) |
| 267 | { | 267 | { |
| 268 | - throw new UserFriendlyException("该手机号已被注册!"); | 268 | + throw new UserFriendlyException("This phone number is already registered."); |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | var value = await _phoneCache.GetAsync(new CaptchaPhoneCacheKey(validationPhoneType, input.Phone)); | 271 | var value = await _phoneCache.GetAsync(new CaptchaPhoneCacheKey(validationPhoneType, input.Phone)); |
| @@ -273,7 +273,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -273,7 +273,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 273 | //防止暴刷 | 273 | //防止暴刷 |
| 274 | if (value is not null) | 274 | if (value is not null) |
| 275 | { | 275 | { |
| 276 | - throw new UserFriendlyException($"{input.Phone}已发送过验证码,10分钟后可重试"); | 276 | + throw new UserFriendlyException($"A verification code was already sent to {input.Phone}. Try again in 10 minutes."); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | //生成一个4位数的验证码 | 279 | //生成一个4位数的验证码 |
| @@ -306,7 +306,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -306,7 +306,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 306 | return; | 306 | return; |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | - throw new UserFriendlyException("验证码错误"); | 309 | + throw new UserFriendlyException("Invalid verification code."); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | /// <summary> | 312 | /// <summary> |
| @@ -323,7 +323,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -323,7 +323,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 323 | var entity = await _userRepository.GetFirstAsync(x => x.Phone == input.Phone); | 323 | var entity = await _userRepository.GetFirstAsync(x => x.Phone == input.Phone); |
| 324 | if (entity is null) | 324 | if (entity is null) |
| 325 | { | 325 | { |
| 326 | - throw new UserFriendlyException("该手机号码未注册"); | 326 | + throw new UserFriendlyException("This phone number is not registered."); |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | await _accountManager.RestPasswordAsync(entity.Id, input.Password); | 329 | await _accountManager.RestPasswordAsync(entity.Id, input.Password); |
| @@ -395,17 +395,17 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -395,17 +395,17 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 395 | { | 395 | { |
| 396 | if (_rbacOptions.EnableRegister == false) | 396 | if (_rbacOptions.EnableRegister == false) |
| 397 | { | 397 | { |
| 398 | - throw new UserFriendlyException("该系统暂未开放注册功能"); | 398 | + throw new UserFriendlyException("Registration is not enabled for this system."); |
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | if (input.Phone is null) | 401 | if (input.Phone is null) |
| 402 | { | 402 | { |
| 403 | - throw new UserFriendlyException("手机号不能为空"); | 403 | + throw new UserFriendlyException("Phone number is required."); |
| 404 | } | 404 | } |
| 405 | //临时账号 | 405 | //临时账号 |
| 406 | if (input.UserName.StartsWith("ls_")) | 406 | if (input.UserName.StartsWith("ls_")) |
| 407 | { | 407 | { |
| 408 | - throw new UserFriendlyException("注册账号不能以ls_字符开头"); | 408 | + throw new UserFriendlyException("Registration account cannot start with ls_."); |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | if (_rbacOptions.EnableCaptcha) | 411 | if (_rbacOptions.EnableCaptcha) |
| @@ -442,7 +442,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -442,7 +442,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 442 | var userId = _currentUser.Id; | 442 | var userId = _currentUser.Id; |
| 443 | if (userId is null) | 443 | if (userId is null) |
| 444 | { | 444 | { |
| 445 | - throw new UserFriendlyException("用户未登录"); | 445 | + throw new UserFriendlyException("User is not signed in."); |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | //此处优先从缓存中获取 | 448 | //此处优先从缓存中获取 |
| @@ -459,7 +459,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -459,7 +459,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 459 | .Where(x => x.State == true) | 459 | .Where(x => x.State == true) |
| 460 | .FirstAsync(); | 460 | .FirstAsync(); |
| 461 | 461 | ||
| 462 | - //该用户不存在 | 462 | + //该User not found. |
| 463 | if (user is null) | 463 | if (user is null) |
| 464 | { | 464 | { |
| 465 | return null; | 465 | return null; |
| @@ -468,7 +468,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -468,7 +468,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 468 | //注意用户名大小写数据库不敏感问题 | 468 | //注意用户名大小写数据库不敏感问题 |
| 469 | if (userName is not null && !user.UserName.Equals(userName)) | 469 | if (userName is not null && !user.UserName.Equals(userName)) |
| 470 | { | 470 | { |
| 471 | - throw new UserFriendlyException($"该用户名不存在或已禁用-{userName}"); | 471 | + throw new UserFriendlyException($"Username not found or disabled: {userName}"); |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | var output = await _userManager.GetInfoAsync(user.Id); | 474 | var output = await _userManager.GetInfoAsync(user.Id); |
| @@ -487,7 +487,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -487,7 +487,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 487 | var userId = _currentUser.Id; | 487 | var userId = _currentUser.Id; |
| 488 | if (_currentUser.Id is null) | 488 | if (_currentUser.Id is null) |
| 489 | { | 489 | { |
| 490 | - throw new AbpAuthorizationException("用户未登录"); | 490 | + throw new AbpAuthorizationException("User is not signed in."); |
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | var data = await _userManager.GetInfoAsync(userId!.Value); | 493 | var data = await _userManager.GetInfoAsync(userId!.Value); |
| @@ -550,12 +550,12 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -550,12 +550,12 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 550 | { | 550 | { |
| 551 | if (input.OldPassword.Equals(input.NewPassword)) | 551 | if (input.OldPassword.Equals(input.NewPassword)) |
| 552 | { | 552 | { |
| 553 | - throw new UserFriendlyException("无效更新!输入的数据,新密码不能与老密码相同"); | 553 | + throw new UserFriendlyException("Invalid update: the new password cannot be the same as the current password."); |
| 554 | } | 554 | } |
| 555 | 555 | ||
| 556 | if (_currentUser.Id is null) | 556 | if (_currentUser.Id is null) |
| 557 | { | 557 | { |
| 558 | - throw new UserFriendlyException("用户未登录"); | 558 | + throw new UserFriendlyException("User is not signed in."); |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | await _accountManager.UpdatePasswordAsync(_currentUser.Id ?? Guid.Empty, input.NewPassword, | 561 | await _accountManager.UpdatePasswordAsync(_currentUser.Id ?? Guid.Empty, input.NewPassword, |
| @@ -574,7 +574,7 @@ namespace Yi.Framework.Rbac.Application.Services | @@ -574,7 +574,7 @@ namespace Yi.Framework.Rbac.Application.Services | ||
| 574 | { | 574 | { |
| 575 | if (string.IsNullOrEmpty(input.Password)) | 575 | if (string.IsNullOrEmpty(input.Password)) |
| 576 | { | 576 | { |
| 577 | - throw new UserFriendlyException("重置密码不能为空!"); | 577 | + throw new UserFriendlyException("Reset password cannot be empty."); |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | await _accountManager.RestPasswordAsync(userId, input.Password); | 580 | await _accountManager.RestPasswordAsync(userId, input.Password); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Authentication/AuthService.cs
| @@ -54,7 +54,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | @@ -54,7 +54,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | ||
| 54 | 54 | ||
| 55 | if (authEntity is null) | 55 | if (authEntity is null) |
| 56 | { | 56 | { |
| 57 | - throw new UserFriendlyException("第三方登录失败,请先注册后,在个人中心进行绑定该第三方后使用"); | 57 | + throw new UserFriendlyException("Third-party sign-in failed. Register first, then bind the provider in your profile."); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | var accessToken = await _accountManager.GetTokenByUserIdAsync(authEntity.UserId); | 60 | var accessToken = await _accountManager.GetTokenByUserIdAsync(authEntity.UserId); |
| @@ -77,7 +77,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | @@ -77,7 +77,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | ||
| 77 | var authEntityAny = await _repository.IsAnyAsync(x => x.OpenId == openId && x.AuthType == scheme); | 77 | var authEntityAny = await _repository.IsAnyAsync(x => x.OpenId == openId && x.AuthType == scheme); |
| 78 | if (authEntityAny) | 78 | if (authEntityAny) |
| 79 | { | 79 | { |
| 80 | - throw new UserFriendlyException("绑定失败,该第三方账号已被注册"); | 80 | + throw new UserFriendlyException("Binding failed: this third-party account is already registered."); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | var authAggregateRoot = new AuthAggregateRoot(scheme, userId ?? Guid.Empty, openId, name); | 83 | var authAggregateRoot = new AuthAggregateRoot(scheme, userId ?? Guid.Empty, openId, name); |
| @@ -90,7 +90,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | @@ -90,7 +90,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | ||
| 90 | { | 90 | { |
| 91 | if (HttpContext is null) | 91 | if (HttpContext is null) |
| 92 | { | 92 | { |
| 93 | - throw new AggregateException("HttpContext 参数为空"); | 93 | + throw new AggregateException("HttpContext parameter is null."); |
| 94 | } | 94 | } |
| 95 | var authenticateResult = await HttpContext.AuthenticateAsync(scheme); | 95 | var authenticateResult = await HttpContext.AuthenticateAsync(scheme); |
| 96 | if (!authenticateResult.Succeeded) | 96 | if (!authenticateResult.Succeeded) |
| @@ -178,7 +178,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | @@ -178,7 +178,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication | ||
| 178 | 178 | ||
| 179 | if (isAny) | 179 | if (isAny) |
| 180 | { | 180 | { |
| 181 | - throw new UserFriendlyException("该用户已有此应用授权"); | 181 | + throw new UserFriendlyException("This user already has authorization for this application."); |
| 182 | } | 182 | } |
| 183 | } | 183 | } |
| 184 | } | 184 | } |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs
| @@ -76,7 +76,7 @@ namespace Yi.Framework.Rbac.Application.Services.Monitor | @@ -76,7 +76,7 @@ namespace Yi.Framework.Rbac.Application.Services.Monitor | ||
| 76 | { | 76 | { |
| 77 | if (!EnableRedisCache) | 77 | if (!EnableRedisCache) |
| 78 | { | 78 | { |
| 79 | - throw new UserFriendlyException("后端程序未使用Redis缓存,无法对Redis进行监控,可切换使用Redis"); | 79 | + throw new UserFriendlyException("Redis cache is not enabled; Redis monitoring is unavailable. Switch to Redis to enable monitoring."); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | } | 82 | } |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/RoleService.cs
| @@ -99,7 +99,7 @@ namespace Yi.Framework.Rbac.Application.Services.System | @@ -99,7 +99,7 @@ namespace Yi.Framework.Rbac.Application.Services.System | ||
| 99 | var count = await query.CountAsync(); | 99 | var count = await query.CountAsync(); |
| 100 | if (count > exportPdfMaxRows) | 100 | if (count > exportPdfMaxRows) |
| 101 | { | 101 | { |
| 102 | - throw new UserFriendlyException($"导出数据超过上限 {exportPdfMaxRows} 条,请缩小筛选范围"); | 102 | + throw new UserFriendlyException($"Export exceeds the maximum of {exportPdfMaxRows} rows. Narrow your filters and try again."); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | var rows = await query.OrderBy(x => x.OrderNum, OrderByType.Desc).Take(exportPdfMaxRows).ToListAsync(); | 105 | var rows = await query.OrderBy(x => x.OrderNum, OrderByType.Desc).Take(exportPdfMaxRows).ToListAsync(); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/ConfigConst.cs
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DeptConst.cs
| @@ -12,6 +12,6 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | @@ -12,6 +12,6 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | ||
| 12 | 12 | ||
| 13 | public class DeptConst | 13 | public class DeptConst |
| 14 | { | 14 | { |
| 15 | - public const string Exist = "该部门已经存在"; | 15 | + public const string Exist = "This department already exists."; |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DictionaryConst.cs
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/PostConst.cs
| @@ -12,6 +12,6 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | @@ -12,6 +12,6 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | ||
| 12 | 12 | ||
| 13 | public class PostConst | 13 | public class PostConst |
| 14 | { | 14 | { |
| 15 | - public const string Exist = "该岗位已经存在"; | 15 | + public const string Exist = "This post already exists."; |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/RoleConst.cs
| @@ -12,6 +12,6 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | @@ -12,6 +12,6 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | ||
| 12 | 12 | ||
| 13 | public class RoleConst | 13 | public class RoleConst |
| 14 | { | 14 | { |
| 15 | - public const string Exist = "该角色已经存在"; | 15 | + public const string Exist = "This role already exists."; |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/UserConst.cs
| @@ -12,16 +12,16 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | @@ -12,16 +12,16 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts | ||
| 12 | 12 | ||
| 13 | public class UserConst | 13 | public class UserConst |
| 14 | { | 14 | { |
| 15 | - public const string Login_Error = "登录失败!用户名或密码错误!"; | ||
| 16 | - public const string Login_User_No_Exist = "登录失败!用户名不存在!"; | ||
| 17 | - public const string Login_Passworld_Error = "密码为空,添加失败!"; | ||
| 18 | - public const string Create_Passworld_Error = "密码格式错误,长度需大于等于6位"; | ||
| 19 | - public const string Exist = "用户已经存在,创建失败!"; | ||
| 20 | - public const string State_Is_State = "该用户已被禁用,请联系管理员进行恢复"; | ||
| 21 | - public const string No_Permission = "登录禁用!该用户分配无任何权限,无意义登录!"; | ||
| 22 | - public const string No_Role = "登录禁用!该用户分配无任何角色,无意义登录!"; | ||
| 23 | - public const string Name_Not_Allowed = "用户名被禁止"; | ||
| 24 | - public const string Phone_Repeat = "手机号已重复"; | 15 | + public const string Login_Error = "Sign-in failed: incorrect username or password."; |
| 16 | + public const string Login_User_No_Exist = "Sign-in failed: username does not exist."; | ||
| 17 | + public const string Login_Passworld_Error = "Password is required."; | ||
| 18 | + public const string Create_Passworld_Error = "Invalid password format. Password must be at least 6 characters."; | ||
| 19 | + public const string Exist = "User already exists."; | ||
| 20 | + public const string State_Is_State = "This account has been disabled. Contact an administrator."; | ||
| 21 | + public const string No_Permission = "Sign-in disabled: this user has no permissions assigned."; | ||
| 22 | + public const string No_Role = "Sign-in disabled: this user has no roles assigned."; | ||
| 23 | + public const string Name_Not_Allowed = "Username is not allowed."; | ||
| 24 | + public const string Phone_Repeat = "Phone number already in use."; | ||
| 25 | 25 | ||
| 26 | //子租户管理员 | 26 | //子租户管理员 |
| 27 | public const string Admin = "admin"; | 27 | public const string Admin = "admin"; |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Helpers/UserPasswordHelper.cs
| @@ -18,7 +18,7 @@ public static class UserPasswordHelper | @@ -18,7 +18,7 @@ public static class UserPasswordHelper | ||
| 18 | { | 18 | { |
| 19 | if (string.IsNullOrWhiteSpace(plainPassword)) | 19 | if (string.IsNullOrWhiteSpace(plainPassword)) |
| 20 | { | 20 | { |
| 21 | - throw new UserFriendlyException("密码不能为空"); | 21 | + throw new UserFriendlyException("Password is required."); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | user.EncryPassword ??= new EncryPasswordValueObject(); | 24 | user.EncryPassword ??= new EncryPasswordValueObject(); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs
| @@ -243,7 +243,7 @@ namespace Yi.Framework.Rbac.Domain.Managers | @@ -243,7 +243,7 @@ namespace Yi.Framework.Rbac.Domain.Managers | ||
| 243 | 243 | ||
| 244 | if (!user.JudgePassword(oldPassword)) | 244 | if (!user.JudgePassword(oldPassword)) |
| 245 | { | 245 | { |
| 246 | - throw new UserFriendlyException("无效更新!原密码错误!"); | 246 | + throw new UserFriendlyException("Invalid update: current password is incorrect."); |
| 247 | } | 247 | } |
| 248 | UserPasswordHelper.ApplyPlainPassword(user, newPassword); | 248 | UserPasswordHelper.ApplyPlainPassword(user, newPassword); |
| 249 | await _repository.UpdateAsync(user); | 249 | await _repository.UpdateAsync(user); |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AliyunManger.cs
| @@ -57,8 +57,8 @@ namespace Yi.Framework.Rbac.Domain.Managers | @@ -57,8 +57,8 @@ namespace Yi.Framework.Rbac.Domain.Managers | ||
| 57 | 57 | ||
| 58 | catch (Exception _error) | 58 | catch (Exception _error) |
| 59 | { | 59 | { |
| 60 | - _logger.LogError(_error, "阿里云短信发送错误:" + _error.Message); | ||
| 61 | - throw new UserFriendlyException("阿里云短信发送错误:" + _error.Message); | 60 | + _logger.LogError(_error, "Aliyun SMS send error:" + _error.Message); |
| 61 | + throw new UserFriendlyException("Aliyun SMS send error:" + _error.Message); | ||
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/UserManager.cs
| @@ -144,12 +144,12 @@ namespace Yi.Framework.Rbac.Domain.Managers | @@ -144,12 +144,12 @@ namespace Yi.Framework.Rbac.Domain.Managers | ||
| 144 | { | 144 | { |
| 145 | if (input.UserName == UserConst.Admin || input.UserName == UserConst.TenantAdmin) | 145 | if (input.UserName == UserConst.Admin || input.UserName == UserConst.TenantAdmin) |
| 146 | { | 146 | { |
| 147 | - throw new UserFriendlyException("用户名无效注册!"); | 147 | + throw new UserFriendlyException("Invalid username for registration."); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | if (input.UserName.Length < 2) | 150 | if (input.UserName.Length < 2) |
| 151 | { | 151 | { |
| 152 | - throw new UserFriendlyException("账号名需大于等于2位!"); | 152 | + throw new UserFriendlyException("Account name must be at least 2 characters."); |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | // 正则表达式,匹配只包含数字和字母的字符串 | 155 | // 正则表达式,匹配只包含数字和字母的字符串 |
| @@ -158,7 +158,7 @@ namespace Yi.Framework.Rbac.Domain.Managers | @@ -158,7 +158,7 @@ namespace Yi.Framework.Rbac.Domain.Managers | ||
| 158 | bool isMatch = Regex.IsMatch(input.UserName, pattern); | 158 | bool isMatch = Regex.IsMatch(input.UserName, pattern); |
| 159 | if (!isMatch) | 159 | if (!isMatch) |
| 160 | { | 160 | { |
| 161 | - throw new UserFriendlyException("用户名不能包含除【字母】与【数字】与【_】的其他字符"); | 161 | + throw new UserFriendlyException("Username may contain only letters, digits, and underscore (_)."); |
| 162 | } | 162 | } |
| 163 | } | 163 | } |
| 164 | 164 | ||
| @@ -235,7 +235,7 @@ namespace Yi.Framework.Rbac.Domain.Managers | @@ -235,7 +235,7 @@ namespace Yi.Framework.Rbac.Domain.Managers | ||
| 235 | if (user is null) | 235 | if (user is null) |
| 236 | { | 236 | { |
| 237 | //为了解决token前端缓存,后端数据库重新dbseed | 237 | //为了解决token前端缓存,后端数据库重新dbseed |
| 238 | - throw new UserFriendlyException($"数据错误,查询用户不存在,请重新登录"); | 238 | + throw new UserFriendlyException("Data error: user not found. Please sign in again."); |
| 239 | } | 239 | } |
| 240 | user.EncryPassword.Password = string.Empty; | 240 | user.EncryPassword.Password = string.Empty; |
| 241 | user.EncryPassword.Salt = string.Empty; | 241 | user.EncryPassword.Salt = string.Empty; |
美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
| @@ -48,7 +48,7 @@ namespace Yi.Abp.Application.Services | @@ -48,7 +48,7 @@ namespace Yi.Abp.Application.Services | ||
| 48 | [HttpGet("error")] | 48 | [HttpGet("error")] |
| 49 | public string GetError() | 49 | public string GetError() |
| 50 | { | 50 | { |
| 51 | - throw new UserFriendlyException("业务异常"); | 51 | + throw new UserFriendlyException("Business error."); |
| 52 | throw new Exception("系统异常"); | 52 | throw new Exception("系统异常"); |
| 53 | } | 53 | } |
| 54 | 54 |
美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
| @@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
| 27 | "Settings": { | 27 | "Settings": { |
| 28 | "Test": "hello" | 28 | "Test": "hello" |
| 29 | }, | 29 | }, |
| 30 | - | ||
| 31 | //数据库类型列表 | 30 | //数据库类型列表 |
| 32 | "DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle", "PostgreSQL" ], | 31 | "DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle", "PostgreSQL" ], |
| 33 | 32 |