diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs
index 82f2521..2b0e0e2 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs
+++ b/美国版/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
/// 今日打印标签
public DashboardMetricCardDto LabelsPrintedToday { get; set; } = new();
+ /// 标签总数(fl_label,与 Label 列表可见范围一致)
+ public DashboardMetricCardDto Labels { get; set; } = new();
+
/// 启用模板数
public DashboardMetricCardDto ActiveTemplates { get; set; } = new();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/UsAppLabelPreviewDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/UsAppLabelPreviewDto.cs
index 4e2e0c3..ce77dba 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/UsAppLabelPreviewDto.cs
+++ b/美国版/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
///
/// 当前预览上下文(模板+产品+标签类型)命中的默认值配置。
- /// 数据来源:fl_label_template_product_default.DefaultValuesJson
+ /// 数据来源:fl_label_template_product_default.DefaultValuesJson,并与标签
+ /// LabelInfoJson.templateInputValues 合并(标签级优先)。
+ /// Nutrition Facts 元素的值为营养成分 JSON 字符串。
///
public Dictionary? TemplateProductDefaultValues { get; set; }
+
+ ///
+ /// Nutrition Facts 元素已保存的营养成分表(elementId → 字段字典)。
+ /// 来源:标签 templateInputValues / 产品模板默认值中该元素对应的 JSON。
+ ///
+ public Dictionary> NutritionByElementId { get; set; } = new();
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IDashboardAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IDashboardAppService.cs
index 3d6c863..5604368 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IDashboardAppService.cs
+++ b/美国版/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
///
/// 按 Token 数据范围统计:系统管理员为全平台;其它账号仅统计其 userlocation 绑定门店所属公司范围内数据。
/// companies 统计可见 fl_partner 数;regions 统计可见 fl_group 数(与 Region 列表同一套 scope)。
- /// activeUsers / people 仅统计有门店绑定的成员,且不包含内置系统 admin(用户名 admin 或角色码 admin)。
+ /// labels 统计可见 fl_label 总数(与 Label 列表无额外筛选时同一套 scope)。
+ /// activeTemplates 统计可见且启用的 fl_label_template 数(与 Label Templates 列表无额外筛选时同一套 scope)。
+ /// people 为注册用户数(与 Team Member 列表 TotalCount 一致);activeUsers 为其中 State=true 的用户数。
+ /// 系统 Admin 统计全部未删 User;非 Admin 仅统计在可见门店有 userlocation 绑定的用户。
/// recentLabels[].labelCode 为门店当日打印序号 yyyyMMdd-n,规则与 POST /api/app/us-app-labeling/preview、print-log 一致。
///
Task GetOverviewAsync();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IGroupAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IGroupAppService.cs
index 91e1546..3a24e3f 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IGroupAppService.cs
+++ b/美国版/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
/// 若 groupName 相对原值发生变化(忽略大小写与首尾空格),会同步更新未删除门店
/// location.GroupName(精确匹配旧 Region 名称,且 location.Partner 与当前 Region 所属公司名称一致),
/// 避免跨公司同名 Region 误更新。
+ /// 若 State 从 true 变为 false,级联停用其下全部 Location,
+ /// 软删这些门店的 userlocation 绑定(不停用成员、不解绑其它门店);
+ /// 若存在 fl_team_member_region 则删除该 Region 的成员关联;
+ /// inactive→active 不自动恢复下级或绑定;已 inactive 再次保存不重复级联。
///
Task UpdateAsync(Guid id, GroupUpdateInputVo input);
///
/// 删除组织(逻辑删除)
///
- Task DeleteAsync(Guid id);
+ ///
+ /// 默认强制自下而上:若 Region 下仍有未删除门店,返回英文提示并拒绝删除。
+ /// 传 confirmCascade=true 时,会先软删该 Region 下全部门店并清理 userlocation,再软删 Region。
+ ///
+ /// 主键 Id
+ /// 为 true 时级联软删下级门店;默认 false
+ Task DeleteAsync(Guid id, bool confirmCascade = false);
///
/// 按列表相同筛选条件全量导出组织(Region)为 PDF(不分页;与 相同筛选与 Token 数据范围;单次最多 5000 条)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILocationAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILocationAppService.cs
index 29a5ff0..8175da7 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILocationAppService.cs
+++ b/美国版/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
///
/// 门店Id
/// 门店信息
+ ///
+ /// 若 State 从 true 变为 false,软删该门店的 userlocation 绑定(不停用成员);
+ /// inactive→active 不自动恢复绑定;已 inactive 再次保存不重复级联。批量编辑经本方法逐条处理,同样生效。
+ ///
Task UpdateAsync(Guid id, LocationUpdateInputVo input);
///
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IPartnerAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IPartnerAppService.cs
index 0569c69..4c7ab35 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IPartnerAppService.cs
+++ b/美国版/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
///
/// 若 partnerName 相对原值发生变化(忽略大小写与首尾空格),会同步更新未删除门店
/// location.Partner(精确匹配旧公司名称),以保持门店/产品/标签按名称解析的绑定关系。
+ /// 若 State 从 true 变为 false,级联停用其下全部 Region、Location,
+ /// 并将经该公司门店 userlocation 绑定的 Team Member 设为 State=false;
+ /// inactive→active 不自动恢复下级或绑定;已 inactive 再次保存不重复级联。
///
/// 成功
/// 校验失败或记录不存在
@@ -83,11 +86,16 @@ public interface IPartnerAppService : IApplicationService
///
/// 删除合作伙伴(逻辑删除)
///
+ ///
+ /// 默认强制自下而上:若 Company 下仍有未删除 Region 或 Location,返回英文提示并拒绝删除。
+ /// 传 confirmCascade=true 时,会先软删全部门店并清理 userlocation,再软删全部 Region,最后软删 Company。
+ ///
/// 主键 Id
+ /// 为 true 时级联软删下级 Region 与 Location;默认 false
/// 成功
- /// Id 无效或记录不存在
+ /// Id 无效、记录不存在或存在下级需先删除/确认级联
/// 服务器错误
- Task DeleteAsync(Guid id);
+ Task DeleteAsync(Guid id, bool confirmCascade = false);
///
/// 按当前列表筛选条件批量导出合作伙伴为 PDF(Account Management「Company」页签;不分页,上限 5000 条)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IUsAppLabelingAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IUsAppLabelingAppService.cs
index 50a50e0..a5a50f2 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IUsAppLabelingAppService.cs
+++ b/美国版/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
///
/// App 打印预览:按标签编码解析模板并返回顶部展示字段 + 预览模板结构。
/// 出参 labelId 为门店当日**下一个**打印序号(yyyyMMdd-n),非 fl_label.Id。
+ /// 出参 nutritionByElementId / templateProductDefaultValues 含 Nutrition Facts 已保存 JSON。
///
Task PreviewAsync(UsAppLabelPreviewInputVo input);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs
new file mode 100644
index 0000000..28ae1e0
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs
@@ -0,0 +1,309 @@
+using FoodLabeling.Application.Services.DbModels;
+using FoodLabeling.Domain.Entities;
+using SqlSugar;
+using Volo.Abp;
+
+namespace FoodLabeling.Application.Helpers;
+
+///
+/// Account Management 结构(Company / Region / Location)级联软删与 userlocation 清理。
+///
+public static class AccountStructureCascadeDeleteHelper
+{
+ ///
+ /// 软删单个门店;影响行数为 0 时抛出 。
+ ///
+ public static async Task SoftDeleteLocationAsync(
+ ISqlSugarClient db,
+ Guid locationId,
+ DateTime now,
+ Guid? modifierId)
+ {
+ var affected = await db.Updateable()
+ .SetColumns(x => new LocationAggregateRoot
+ {
+ IsDeleted = true,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => x.Id == locationId && !x.IsDeleted)
+ .ExecuteCommandAsync();
+
+ if (affected == 0)
+ {
+ throw new UserFriendlyException("Location not found.");
+ }
+ }
+
+ ///
+ /// 统计 Region 下未删除门店数(按公司名称 + Region 名称精确匹配)。
+ ///
+ public static Task CountActiveLocationsByPartnerAndGroupAsync(
+ ISqlSugarClient db,
+ string partnerName,
+ string groupName)
+ {
+ return db.Queryable()
+ .Where(x => !x.IsDeleted &&
+ x.Partner == partnerName &&
+ x.GroupName == groupName)
+ .CountAsync();
+ }
+
+ ///
+ /// 统计 Company 下未删除 Region 数。
+ ///
+ public static Task CountActiveGroupsByPartnerIdAsync(ISqlSugarClient db, string partnerId)
+ {
+ return db.Queryable()
+ .Where(x => !x.IsDeleted && x.PartnerId == partnerId)
+ .CountAsync();
+ }
+
+ ///
+ /// 统计 Company 下未删除门店数(按公司名称匹配 location.Partner)。
+ ///
+ public static Task CountActiveLocationsByPartnerNameAsync(ISqlSugarClient db, string partnerName)
+ {
+ return db.Queryable()
+ .Where(x => !x.IsDeleted && x.Partner == partnerName)
+ .CountAsync();
+ }
+
+ ///
+ /// 软删指定 Company + Region 下全部门店,并清理相关 userlocation 绑定。
+ ///
+ public static async Task SoftDeleteLocationsByPartnerAndGroupAsync(
+ ISqlSugarClient db,
+ string partnerName,
+ string groupName,
+ DateTime now,
+ Guid? modifierId,
+ string? userLocationModifierId)
+ {
+ var locationIds = await db.Queryable()
+ .Where(x => !x.IsDeleted &&
+ x.Partner == partnerName &&
+ x.GroupName == groupName)
+ .Select(x => x.Id)
+ .ToListAsync();
+
+ if (locationIds.Count == 0)
+ {
+ return;
+ }
+
+ await SoftDeleteLocationsByIdsAsync(db, locationIds, now, modifierId);
+ await SoftDeleteUserLocationBindingsAsync(db, locationIds, now, userLocationModifierId);
+ }
+
+ ///
+ /// 软删指定 Company 下全部门店,并清理相关 userlocation 绑定。
+ ///
+ public static async Task SoftDeleteLocationsByPartnerNameAsync(
+ ISqlSugarClient db,
+ string partnerName,
+ DateTime now,
+ Guid? modifierId,
+ string? userLocationModifierId)
+ {
+ var locationIds = await db.Queryable()
+ .Where(x => !x.IsDeleted && x.Partner == partnerName)
+ .Select(x => x.Id)
+ .ToListAsync();
+
+ if (locationIds.Count == 0)
+ {
+ return;
+ }
+
+ await SoftDeleteLocationsByIdsAsync(db, locationIds, now, modifierId);
+ await SoftDeleteUserLocationBindingsAsync(db, locationIds, now, userLocationModifierId);
+ }
+
+ ///
+ /// 软删指定 Company 下全部 Region。
+ ///
+ public static async Task SoftDeleteGroupsByPartnerIdAsync(
+ ISqlSugarClient db,
+ string partnerId,
+ DateTime now,
+ string? modifierId)
+ {
+ await db.Updateable()
+ .SetColumns(x => new FlGroupDbEntity
+ {
+ IsDeleted = true,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => !x.IsDeleted && x.PartnerId == partnerId)
+ .ExecuteCommandAsync();
+ }
+
+ ///
+ /// 软删单个 Region。
+ ///
+ public static async Task SoftDeleteGroupAsync(
+ ISqlSugarClient db,
+ string groupId,
+ DateTime now,
+ string? modifierId)
+ {
+ var affected = await db.Updateable()
+ .SetColumns(x => new FlGroupDbEntity
+ {
+ IsDeleted = true,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => !x.IsDeleted && x.Id == groupId)
+ .ExecuteCommandAsync();
+
+ if (affected == 0)
+ {
+ throw new UserFriendlyException("Group not found.");
+ }
+ }
+
+ ///
+ /// 软删单个 Company。
+ ///
+ public static async Task SoftDeletePartnerAsync(
+ ISqlSugarClient db,
+ string partnerId,
+ DateTime now,
+ string? modifierId)
+ {
+ var affected = await db.Updateable()
+ .SetColumns(x => new FlPartnerDbEntity
+ {
+ IsDeleted = true,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => !x.IsDeleted && x.Id == partnerId)
+ .ExecuteCommandAsync();
+
+ if (affected == 0)
+ {
+ throw new UserFriendlyException("Partner not found.");
+ }
+ }
+
+ ///
+ /// 清理单个门店的 userlocation 绑定(逻辑删除)。
+ ///
+ public static Task SoftDeleteUserLocationBindingsForLocationAsync(
+ ISqlSugarClient db,
+ Guid locationId,
+ DateTime now,
+ string? modifierId)
+ {
+ return SoftDeleteUserLocationBindingsAsync(db, new[] { locationId }, now, modifierId);
+ }
+
+ ///
+ /// 清理指定门店 Id 列表对应的 userlocation 绑定(逻辑删除)。
+ ///
+ public static Task SoftDeleteUserLocationBindingsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIds,
+ DateTime now,
+ string? modifierId) =>
+ SoftDeleteUserLocationBindingsCoreAsync(db, locationIds, now, modifierId);
+
+ ///
+ /// Region 存在下级门店且未确认级联删除时的提示文案。
+ ///
+ public static string BuildGroupCascadeRequiredMessage(int locationCount) =>
+ $"This region has {locationCount} location(s). Delete locations first (bottom-up), " +
+ "or call DELETE again with confirmCascade=true to also soft-delete all child locations.";
+
+ ///
+ /// Company 存在下级 Region/Location 且未确认级联删除时的提示文案。
+ ///
+ public static string BuildPartnerCascadeRequiredMessage(int groupCount, int locationCount) =>
+ $"This company has {groupCount} region(s) and {locationCount} location(s). " +
+ "Delete child regions and locations first (bottom-up), " +
+ "or call DELETE again with confirmCascade=true to also soft-delete all child regions and locations.";
+
+ private static async Task SoftDeleteLocationsByIdsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIds,
+ DateTime now,
+ Guid? modifierId)
+ {
+ if (locationIds.Count == 0)
+ {
+ return;
+ }
+
+ await db.Updateable()
+ .SetColumns(x => new LocationAggregateRoot
+ {
+ IsDeleted = true,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => !x.IsDeleted && locationIds.Contains(x.Id))
+ .ExecuteCommandAsync();
+ }
+
+ private static async Task SoftDeleteUserLocationBindingsCoreAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIds,
+ DateTime now,
+ string? modifierId)
+ {
+ if (locationIds.Count == 0)
+ {
+ return;
+ }
+
+ var normalizedKeys = new HashSet(
+ locationIds
+ .SelectMany(g => new[]
+ {
+ TeamMemberListScopeHelper.NormalizeScopeKey(g.ToString("D")),
+ TeamMemberListScopeHelper.NormalizeScopeKey(g.ToString("N"))
+ })
+ .Where(x => !string.IsNullOrEmpty(x)),
+ StringComparer.OrdinalIgnoreCase);
+
+ if (normalizedKeys.Count == 0)
+ {
+ return;
+ }
+
+ var bindings = await db.Queryable()
+ .Where(x => !x.IsDeleted)
+ .Select(x => new { x.Id, x.LocationId })
+ .ToListAsync();
+
+ var bindingIds = bindings
+ .Where(x =>
+ {
+ var key = TeamMemberListScopeHelper.NormalizeScopeKey(x.LocationId);
+ return !string.IsNullOrEmpty(key) && normalizedKeys.Contains(key);
+ })
+ .Select(x => x.Id)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+
+ if (bindingIds.Count == 0)
+ {
+ return;
+ }
+
+ await db.Updateable()
+ .SetColumns(x => new UserLocationDbEntity
+ {
+ IsDeleted = true,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => bindingIds.Contains(x.Id))
+ .ExecuteCommandAsync();
+ }
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeInactiveHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeInactiveHelper.cs
new file mode 100644
index 0000000..88b6d1d
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeInactiveHelper.cs
@@ -0,0 +1,211 @@
+using FoodLabeling.Application.Services.DbModels;
+using FoodLabeling.Domain.Entities;
+using SqlSugar;
+using Yi.Framework.Rbac.Domain.Entities;
+
+namespace FoodLabeling.Application.Helpers;
+
+///
+/// Account Management 结构(Company / Region / Location)停用(State=false)时的级联处理。
+/// 仅在 旧 State==true 且 新 State==false 时触发;inactive→active 不自动恢复下级或绑定。
+///
+public static class AccountStructureCascadeInactiveHelper
+{
+ ///
+ /// 判断是否从启用变为停用。
+ ///
+ public static bool IsBecomingInactive(bool wasActive, bool newState) => wasActive && !newState;
+
+ ///
+ /// Company 停用时:其下全部 Region、Location 设为 State=false;
+ /// 经该公司门店 userlocation 绑定的 Team Member 设为 State=false(不解绑 userlocation)。
+ ///
+ public static async Task CascadePartnerInactiveAsync(
+ ISqlSugarClient db,
+ string partnerId,
+ DateTime now,
+ Guid? modifierId)
+ {
+ var modifierIdString = modifierId?.ToString();
+
+ await db.Updateable()
+ .SetColumns(x => new FlGroupDbEntity
+ {
+ State = false,
+ LastModificationTime = now,
+ LastModifierId = modifierIdString
+ })
+ .Where(x => !x.IsDeleted && x.PartnerId == partnerId && x.State)
+ .ExecuteCommandAsync();
+
+ var locationIdStrings = await LocationScopeBindingHelper.ResolveLocationIdsFromPartnerIdsAsync(
+ db,
+ new[] { partnerId });
+
+ await DeactivateLocationsByIdsAsync(db, locationIdStrings, now, modifierId);
+ await DeactivateUsersBoundToLocationsAsync(db, locationIdStrings, now, modifierId);
+ }
+
+ ///
+ /// Region 停用时:其下全部 Location 设为 State=false;
+ /// 软删这些门店的 userlocation 绑定(不解绑其它门店、不停用成员);
+ /// 若存在 fl_team_member_region 表则删除该 Region 的成员关联。
+ ///
+ public static async Task CascadeGroupInactiveAsync(
+ ISqlSugarClient db,
+ string groupId,
+ DateTime now,
+ Guid? modifierId,
+ string? userLocationModifierId)
+ {
+ var locationIdStrings = await LocationScopeBindingHelper.ResolveLocationIdsFromGroupIdsAsync(
+ db,
+ new[] { groupId });
+
+ await DeactivateLocationsByIdsAsync(db, locationIdStrings, now, modifierId);
+
+ var locationGuids = ParseLocationGuids(locationIdStrings);
+ if (locationGuids.Count > 0)
+ {
+ await AccountStructureCascadeDeleteHelper.SoftDeleteUserLocationBindingsAsync(
+ db,
+ locationGuids,
+ now,
+ userLocationModifierId);
+ }
+
+ await TryDeleteTeamMemberRegionByGroupIdAsync(db, groupId);
+ }
+
+ ///
+ /// Location 停用时:软删该门店的 userlocation 绑定(不停用成员)。
+ ///
+ public static Task CascadeLocationInactiveAsync(
+ ISqlSugarClient db,
+ Guid locationId,
+ DateTime now,
+ string? userLocationModifierId) =>
+ AccountStructureCascadeDeleteHelper.SoftDeleteUserLocationBindingsForLocationAsync(
+ db,
+ locationId,
+ now,
+ userLocationModifierId);
+
+ private static async Task DeactivateLocationsByIdsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIdStrings,
+ DateTime now,
+ Guid? modifierId)
+ {
+ var locationGuids = ParseLocationGuids(locationIdStrings);
+ if (locationGuids.Count == 0)
+ {
+ return;
+ }
+
+ await db.Updateable()
+ .SetColumns(x => new LocationAggregateRoot
+ {
+ State = false,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => !x.IsDeleted && locationGuids.Contains(x.Id) && x.State)
+ .ExecuteCommandAsync();
+ }
+
+ private static async Task DeactivateUsersBoundToLocationsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIdStrings,
+ DateTime now,
+ Guid? modifierId)
+ {
+ var userIds = await ResolveUserIdsBoundToLocationIdsAsync(db, locationIdStrings);
+ if (userIds.Count == 0)
+ {
+ return;
+ }
+
+ await db.Updateable()
+ .SetColumns(x => new UserAggregateRoot
+ {
+ State = false,
+ LastModificationTime = now,
+ LastModifierId = modifierId
+ })
+ .Where(x => !x.IsDeleted && x.State && userIds.Contains(x.Id))
+ .ExecuteCommandAsync();
+ }
+
+ private static async Task> ResolveUserIdsBoundToLocationIdsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIdStrings)
+ {
+ var normalizedKeys = new HashSet(
+ locationIdStrings
+ .Select(id => TeamMemberListScopeHelper.NormalizeScopeKey(id))
+ .Where(x => !string.IsNullOrEmpty(x)),
+ StringComparer.OrdinalIgnoreCase);
+
+ if (normalizedKeys.Count == 0)
+ {
+ return new List();
+ }
+
+ var bindings = await db.Queryable()
+ .Where(x => !x.IsDeleted)
+ .Select(x => new { x.UserId, x.LocationId })
+ .ToListAsync();
+
+ var userIdStrings = bindings
+ .Where(x => normalizedKeys.Contains(TeamMemberListScopeHelper.NormalizeScopeKey(x.LocationId)))
+ .Select(x => x.UserId)
+ .Where(x => !string.IsNullOrWhiteSpace(x))
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+
+ var result = new List();
+ foreach (var uid in userIdStrings)
+ {
+ if (Guid.TryParse(uid.Trim(), out var guid))
+ {
+ result.Add(guid);
+ }
+ }
+
+ return result;
+ }
+
+ private static List ParseLocationGuids(IReadOnlyList locationIdStrings)
+ {
+ var result = new List();
+ foreach (var id in locationIdStrings)
+ {
+ if (Guid.TryParse(id?.Trim(), out var guid))
+ {
+ result.Add(guid);
+ }
+ }
+
+ return result;
+ }
+
+ private static async Task TryDeleteTeamMemberRegionByGroupIdAsync(ISqlSugarClient db, string groupId)
+ {
+ if (!await TeamMemberRegionScopeHelper.HasTableAsync(db))
+ {
+ return;
+ }
+
+ try
+ {
+ await db.Deleteable()
+ .Where(x => x.GroupId == groupId)
+ .ExecuteCommandAsync();
+ }
+ catch
+ {
+ // 表探测通过但删除失败时静默跳过,与 TeamMemberRegionScopeHelper 一致
+ }
+ }
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AllScopeBindingHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AllScopeBindingHelper.cs
index 000a003..22d0c42 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AllScopeBindingHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AllScopeBindingHelper.cs
@@ -428,9 +428,7 @@ public static class AllScopeBindingHelper
return (partnerIds, regionIds, locs);
}
- ///
- /// 标签/产品分类等:解析 Region + Location 落库(对齐 Label:Region=ALL 时可保留具体门店快照)。
- ///
+ /// 标签/产品分类等 Region + Location 落库结果。
public sealed class LabelEntityRegionLocationSaveResult
{
public string AvailabilityType { get; init; } = ScopeSpecified;
@@ -440,6 +438,10 @@ public static class AllScopeBindingHelper
public List LocationIds { get; init; } = new();
}
+ ///
+ /// 标签/产品分类等:解析 Region + Location 落库(对齐 Label:Region=ALL 时可保留具体门店快照)。
+ /// 含 ALL 且已传具体 Region 时,为范围内 ALL(Scoped ALL),禁止升公司级 ALL。
+ ///
public static async Task ResolveLabelEntityRegionLocationForSaveAsync(
ISqlSugarClient db,
string? declaredAvailabilityType,
@@ -459,9 +461,14 @@ public static class AllScopeBindingHelper
// 仅显式 ALL 哨兵视为 Region=ALL。
// 禁止「公司下仅 1 个 Region + 勾选该 Region」自动升 ALL(否则编辑回显/再提交会丢 SPECIFIED)。
- // 无具体门店且未声明 SPECIFIED 时,才把「勾选当前全部 Region」归档为 ALL。
+ // locationIds=["ALL"] + 具体 RegionIds 为 Scoped ALL:禁止「勾选当前全部 Region」启发式升 Region=ALL。
var regionHasAll = regionHasAllSentinel;
- if (!regionHasAll && regionIds.Count > 0 && explicitLocationIds.Count == 0 && !declaredSpecified)
+ var isScopedAllWithConcreteRegions = locationHasAll && regionIds.Count > 0 && !regionHasAllSentinel;
+ if (!regionHasAll
+ && regionIds.Count > 0
+ && explicitLocationIds.Count == 0
+ && !declaredSpecified
+ && !isScopedAllWithConcreteRegions)
{
var allRegions = await ResolveAllRegionIdsAsync(
db,
@@ -469,9 +476,14 @@ public static class AllScopeBindingHelper
regionHasAll = allRegions.Count > 0 && IsFullIdSelection(regionIds, allRegions);
}
- // 仅 locationIds 含 ALL 哨兵才按「全部门店」展开;有具体 Guid 时一律按 SPECIFIED 快照落库
+ // locationIds=["ALL"]:相对已传 RegionIds 为范围内 ALL;有具体 Region 时禁止升公司级 ALL
if (locationHasAll)
{
+ if (isScopedAllWithConcreteRegions)
+ {
+ regionHasAll = false;
+ }
+
if (regionHasAll)
{
var partnerScoped = await TryResolvePartnerScopedAllRegionAllLocationAsync(
@@ -594,7 +606,7 @@ public static class AllScopeBindingHelper
if (availabilityType != ScopeAll && availabilityType != ScopeSpecified)
{
- throw new UserFriendlyException("门店可用范围不合法(ALL/SPECIFIED)");
+ throw new UserFriendlyException("Invalid location availability scope (ALL/SPECIFIED).");
}
var locationSpecified = string.Equals(availabilityType, ScopeSpecified, StringComparison.OrdinalIgnoreCase);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AuthScopeQueryHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AuthScopeQueryHelper.cs
index be7c640..510ee8f 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AuthScopeQueryHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AuthScopeQueryHelper.cs
@@ -19,7 +19,7 @@ public static class AuthScopeQueryHelper
{
if (!currentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
}
@@ -52,7 +52,7 @@ public static class AuthScopeQueryHelper
{
EnsureLoggedIn(currentUser);
- var pid = RequireNonEmpty(partnerId, "公司标识不能为空");
+ var pid = RequireNonEmpty(partnerId, "Company identifier is required.");
await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid);
var listScope = await GroupListScopeHelper.ResolveAsync(currentUser, dbContext);
@@ -80,15 +80,15 @@ public static class AuthScopeQueryHelper
{
EnsureLoggedIn(currentUser);
- var pid = RequireNonEmpty(partnerId, "公司标识不能为空");
- var gid = RequireNonEmpty(groupId, "区域标识不能为空");
+ var pid = RequireNonEmpty(partnerId, "Company identifier is required.");
+ var gid = RequireNonEmpty(groupId, "Region identifier is required.");
await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid);
var group = await dbContext.SqlSugarClient.Queryable()
.FirstAsync(g => !g.IsDeleted && g.Id == gid && g.PartnerId == pid);
if (group is null)
{
- throw new UserFriendlyException("区域不存在或不属于所选公司");
+ throw new UserFriendlyException("Region not found or does not belong to the selected Company.");
}
var groupScope = await GroupListScopeHelper.ResolveAsync(currentUser, dbContext);
@@ -98,12 +98,12 @@ public static class AuthScopeQueryHelper
var allowedGroup = groupScope.AllowedGroupIds;
if (allowedPartner.Count > 0 && !allowedPartner.Contains(pid, StringComparer.OrdinalIgnoreCase))
{
- throw new UserFriendlyException("无权查看该区域");
+ throw new UserFriendlyException("You do not have permission to view this Region.");
}
if (allowedGroup.Count > 0 && !allowedGroup.Contains(gid, StringComparer.OrdinalIgnoreCase))
{
- throw new UserFriendlyException("无权查看该区域");
+ throw new UserFriendlyException("You do not have permission to view this Region.");
}
}
@@ -111,7 +111,7 @@ public static class AuthScopeQueryHelper
.FirstAsync(p => !p.IsDeleted && p.Id == pid);
if (partner is null)
{
- throw new UserFriendlyException("公司不存在");
+ throw new UserFriendlyException("Company not found.");
}
var partnerKeys = new List { partner.Id, partner.PartnerName ?? string.Empty }
@@ -263,7 +263,7 @@ public static class AuthScopeQueryHelper
if (!scope.AllowedPartnerIds.Contains(partnerId))
{
- throw new UserFriendlyException("无权查看该公司");
+ throw new UserFriendlyException("You do not have permission to view this Company.");
}
}
@@ -288,13 +288,13 @@ public static class AuthScopeQueryHelper
ISqlSugarDbContext dbContext,
AuthScopeSelectLocationInputVo input)
{
- var pid = RequireNonEmpty(input.PartnerId, "请选择公司");
- var gid = RequireNonEmpty(input.GroupId, "请选择区域");
- var lid = RequireNonEmpty(input.LocationId, "请选择门店");
+ var pid = RequireNonEmpty(input.PartnerId, "Please select a Company.");
+ var gid = RequireNonEmpty(input.GroupId, "Please select a Region.");
+ var lid = RequireNonEmpty(input.LocationId, "Please select a Location.");
if (!Guid.TryParse(lid, out var locationGuid))
{
- throw new UserFriendlyException("无效的门店标识");
+ throw new UserFriendlyException("Invalid location identifier.");
}
await EnsurePartnerAccessibleAsync(currentUser, dbContext, pid);
@@ -303,21 +303,21 @@ public static class AuthScopeQueryHelper
.FirstAsync(g => !g.IsDeleted && g.Id == gid && g.PartnerId == pid);
if (group is null)
{
- throw new UserFriendlyException("区域不存在或不属于所选公司");
+ throw new UserFriendlyException("Region not found or does not belong to the selected Company.");
}
var partner = await dbContext.SqlSugarClient.Queryable()
.FirstAsync(p => !p.IsDeleted && p.Id == pid);
if (partner is null)
{
- throw new UserFriendlyException("公司不存在");
+ throw new UserFriendlyException("Company not found.");
}
var loc = await dbContext.SqlSugarClient.Queryable()
.FirstAsync(x => !x.IsDeleted && x.Id == locationGuid);
if (loc is null)
{
- throw new UserFriendlyException("门店不存在或已删除");
+ throw new UserFriendlyException("Location not found or has been removed.");
}
var partnerKeys = new List { partner.Id, partner.PartnerName ?? string.Empty }
@@ -331,7 +331,7 @@ public static class AuthScopeQueryHelper
if (!partnerKeys.Contains(locPartner, StringComparer.Ordinal) ||
!string.Equals(locGroup, groupName, StringComparison.Ordinal))
{
- throw new UserFriendlyException("门店与所选公司/区域不匹配");
+ throw new UserFriendlyException("Location does not match the selected Company/Region.");
}
return new AuthScopeSelectLocationOutputDto
@@ -359,14 +359,14 @@ public static class AuthScopeQueryHelper
{
if (!Guid.TryParse(locationId.Trim(), out var locationGuid))
{
- throw new UserFriendlyException("无效的门店标识");
+ throw new UserFriendlyException("Invalid location identifier.");
}
var loc = await dbContext.SqlSugarClient.Queryable()
.FirstAsync(x => !x.IsDeleted && x.Id == locationGuid);
if (loc is null)
{
- throw new UserFriendlyException("门店不存在或已删除");
+ throw new UserFriendlyException("Location not found or has been removed.");
}
var pid = (partnerId ?? string.Empty).Trim();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/DashboardScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/DashboardScopeHelper.cs
index 93560f8..24a1699 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/DashboardScopeHelper.cs
+++ b/美国版/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;
namespace FoodLabeling.Application.Helpers;
///
-/// Dashboard 数据范围:管理员看全平台(用户指标排除内置系统 admin);非管理员仅看绑定门店所属公司范围。
+/// Dashboard 数据范围:管理员看全平台;非管理员仅看绑定门店所属公司范围。
+/// People / Active Users 口径与 Team Member 列表一致(Admin 统计全部未删 User;非 Admin 仅统计有 userlocation 绑定的用户)。
///
public static class DashboardScopeHelper
{
@@ -59,69 +60,142 @@ public static class DashboardScopeHelper
}
///
- /// 统计范围内成员数:须在 userlocation 中绑定范围内门店;排除平台系统 admin。
+ /// 统计范围内注册用户数,口径与 Team Member 列表 BuildFilteredUserQueryAsync 一致。
+ /// scopeLocationIds == null:全部未删 User;非 null:仅统计在范围内门店有 userlocation 绑定的用户。
///
- public static async Task CountScopedTeamMembersAsync(
+ public static async Task CountScopedRegisteredUsersAsync(
ISqlSugarClient db,
List? scopeLocationIds,
- HashSet platformAdminUserIds,
bool activeOnly,
DateTime? createdBefore)
{
- if (scopeLocationIds is { Count: 0 })
+ var userQuery = db.Queryable()
+ .Where(u => !u.IsDeleted);
+
+ if (activeOnly)
{
- return 0;
+ userQuery = userQuery.Where(u => u.State);
}
- var userLocQuery = db.Queryable()
- .Where(ul => !ul.IsDeleted);
- if (scopeLocationIds is not null)
+ if (createdBefore.HasValue)
{
- userLocQuery = userLocQuery.Where(ul => scopeLocationIds.Contains(ul.LocationId));
+ userQuery = userQuery.Where(u => u.CreationTime < createdBefore.Value);
}
- var scopedUserIdStrings = await userLocQuery
- .Select(ul => ul.UserId)
- .Distinct()
- .ToListAsync();
-
- if (scopedUserIdStrings.Count == 0)
+ if (scopeLocationIds is not null)
{
- return 0;
+ if (scopeLocationIds.Count == 0)
+ {
+ return 0;
+ }
+
+ var scopeGuidSet = TeamMemberListScopeHelper.ParseGuidHashSet(scopeLocationIds);
+ var userLocationLinks = await db.Queryable()
+ .Where(x => !x.IsDeleted)
+ .Select(x => new { x.UserId, x.LocationId })
+ .ToListAsync();
+
+ var allowedUserGuids = userLocationLinks
+ .Where(x =>
+ Guid.TryParse(x.LocationId, out var locGuid) && scopeGuidSet.Contains(locGuid))
+ .Select(x => x.UserId)
+ .Select(TeamMemberListScopeHelper.NormalizeScopeKey)
+ .Where(x => !string.IsNullOrEmpty(x))
+ .Select(x => Guid.Parse(x))
+ .Distinct()
+ .ToList();
+
+ if (allowedUserGuids.Count == 0)
+ {
+ return 0;
+ }
+
+ userQuery = userQuery.Where(u => allowedUserGuids.Contains(u.Id));
}
- var scopedUserIds = new List();
- foreach (var s in scopedUserIdStrings)
+ return await userQuery.CountAsync();
+ }
+
+ ///
+ /// 统计范围内标签数(fl_label,未删除),范围与 Label 列表无额外筛选时一致。
+ ///
+ public static async Task CountScopedLabelsAsync(
+ ISqlSugarClient db,
+ ISqlSugarDbContext dbContext,
+ ICurrentUser currentUser,
+ DateTime? createdBefore)
+ {
+ var scopedLocationIds = await TeamMemberListScopeHelper.ResolveListLocationIdsAsync(
+ currentUser, dbContext, null, null, null);
+ var scopedPartnerIds = await ResolveDashboardLabelScopedPartnerIdsAsync(
+ db, dbContext, currentUser, scopedLocationIds);
+
+ var labelQuery = LabelQueryHelper.ProjectListColumns(
+ db.Queryable())
+ .Where(l => !l.IsDeleted);
+ labelQuery = LabelRegionScopeHelper.ApplyLabelPartnerListFilter(labelQuery, scopedPartnerIds);
+
+ var regionSchema = await LabelRegionSchemaHelper.GetStatusAsync(db);
+ var applyLocationFilter = LabelEntityListScopeHelper.ShouldApplyLocationAvailabilityFilter(
+ null, null, null);
+
+ if (scopedLocationIds is not null && applyLocationFilter)
{
- if (platformAdminUserIds.Contains(s))
+ if (scopedLocationIds.Count == 0)
{
- continue;
+ labelQuery = LabelRegionScopeHelper.ApplyLabelAllRegionOnlyFilter(
+ db, labelQuery, regionSchema);
}
-
- if (Guid.TryParse(s, out var gid) && gid != Guid.Empty)
+ else
{
- scopedUserIds.Add(gid);
+ labelQuery = LabelRegionScopeHelper.ApplyLabelLocationListFilter(
+ db, labelQuery, scopedLocationIds, regionSchema);
}
}
- if (scopedUserIds.Count == 0)
+ if (createdBefore.HasValue)
{
- return 0;
+ labelQuery = labelQuery.Where(l => l.CreationTime < createdBefore.Value);
}
- var userQuery = db.Queryable()
- .Where(u => !u.IsDeleted && scopedUserIds.Contains(u.Id));
- if (activeOnly)
+ return await labelQuery.CountAsync();
+ }
+
+ ///
+ /// Dashboard 标签统计:Query 解析与 Token 可见公司求交集(对齐 Label 列表)。
+ ///
+ private static async Task?> ResolveDashboardLabelScopedPartnerIdsAsync(
+ ISqlSugarClient db,
+ ISqlSugarDbContext dbContext,
+ ICurrentUser currentUser,
+ List? scopedLocationIds)
+ {
+ var fromQuery = await LabelEntityPartnerScopeHelper.ResolveListPartnerIdsAsync(
+ db, null, null, scopedLocationIds);
+ var partnerScope = await PartnerScopeHelper.ResolvePartnerScopeAsync(currentUser, dbContext);
+ if (partnerScope.IsUnrestricted)
{
- userQuery = userQuery.Where(u => u.State);
+ return fromQuery;
}
- if (createdBefore.HasValue)
+ var allowed = partnerScope.AllowedPartnerIds.ToList();
+ if (allowed.Count == 0)
{
- userQuery = userQuery.Where(u => u.CreationTime < createdBefore.Value);
+ return new List();
}
- return await userQuery.CountAsync();
+ if (fromQuery is null)
+ {
+ return allowed;
+ }
+
+ if (fromQuery.Count == 0)
+ {
+ return new List();
+ }
+
+ var allowedSet = new HashSet(allowed, StringComparer.OrdinalIgnoreCase);
+ return fromQuery.Where(id => allowedSet.Contains(id)).ToList();
}
///
@@ -193,6 +267,30 @@ public static class DashboardScopeHelper
}
///
+ /// 统计范围内启用标签模板数(fl_label_template,未删除且 State=true),
+ /// 范围与 Label Templates 列表无额外 partnerId/groupId/locationId 筛选时一致。
+ ///
+ public static async Task CountScopedActiveTemplatesAsync(
+ ISqlSugarClient db,
+ List? scopedLocationIds,
+ DateTime? createdBefore)
+ {
+ var query = db.Queryable()
+ .Where(x => !x.IsDeleted && x.State);
+
+ query = await LabelTemplateScopeHelper.ApplyTemplateScopeFilterAsync(
+ db, query, scopedLocationIds, null, null, null);
+
+ if (createdBefore.HasValue)
+ {
+ query = query.Where(x => x.CreationTime < createdBefore.Value);
+ }
+
+ query = LabelTemplateQueryHelper.ProjectListColumns(query);
+ return await query.CountAsync();
+ }
+
+ ///
/// 为打印任务查询附加门店范围(scopeLocationIds == null 不限制)。
///
public static ISugarQueryable ApplyPrintTaskLocationScope(
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelBatchTemplateDefaultsHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelBatchTemplateDefaultsHelper.cs
index 56b5ebb..627bbb1 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelBatchTemplateDefaultsHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelBatchTemplateDefaultsHelper.cs
@@ -222,7 +222,7 @@ public static class LabelBatchTemplateDefaultsHelper
if (!duplicateCheckSet.Add(key))
{
throw new UserFriendlyException(
- $"模板默认值绑定重复:产品[{row.ProductId}]与标签类型[{row.LabelTypeId}]只能存在一条");
+ $"Duplicate template default binding: only one row is allowed for product [{row.ProductId}] and label type [{row.LabelTypeId}].");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
index 923500d..b1bd4c6 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
@@ -132,7 +132,7 @@ public static class LabelEntityPartnerScopeHelper
if (string.Equals(partnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase)
&& normalizedPartnerIds.Count == 0)
{
- throw new UserFriendlyException("指定适用 Company 时,partnerIds/companyIds 不能为空");
+ throw new UserFriendlyException("When specifying applicable Company, partnerIds/companyIds cannot be empty.");
}
if (normalizedPartnerIds.Count > 0)
@@ -192,7 +192,7 @@ public static class LabelEntityPartnerScopeHelper
if (needsPartnerRows && !hasTable)
{
throw new UserFriendlyException(
- "Company 适用范围关联表尚未就绪,请联系管理员执行数据库迁移(fl_label_entity_partner_scope.sql 或 fl_product_category_partner_scope.sql)后重试");
+ "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.");
}
if (hasTable)
@@ -592,7 +592,7 @@ public static class LabelEntityPartnerScopeHelper
{
if (type != ScopeAll && type != ScopeSpecified)
{
- throw new UserFriendlyException("适用 Company 范围不合法(ALL/SPECIFIED)");
+ throw new UserFriendlyException("Invalid applicable Company scope (ALL/SPECIFIED).");
}
}
@@ -614,7 +614,7 @@ public static class LabelEntityPartnerScopeHelper
.CountAsync();
if (count != partnerIds.Count)
{
- throw new UserFriendlyException("存在无效的 Company(partnerIds/companyIds),请刷新后重试");
+ throw new UserFriendlyException("One or more Companies are invalid (partnerIds/companyIds). Refresh and try again.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelRegionScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelRegionScopeHelper.cs
index 9655034..60cf025 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelRegionScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelRegionScopeHelper.cs
@@ -51,6 +51,8 @@ public static class LabelRegionScopeHelper
///
/// 解析新增/编辑入参中的 Region / Location 范围。
/// 前端 Select All 常传 SPECIFIED + 当前全量 Id:覆盖全集时归档为 ALL(或不写门店快照),后续新增 Region/Location 动态适用。
+ /// 含 ALL 且已传具体 时,表示范围内 ALL(Scoped ALL):
+ /// 落 AppliedRegionType=SPECIFIED + fl_label_region,不写 fl_label_location,禁止升公司级 ALL。
///
public static async Task ResolveScopeForSaveAsync(
ISqlSugarClient db,
@@ -71,7 +73,19 @@ public static class LabelRegionScopeHelper
var hasScopeArrays = regionIds is not null || groupIds is not null || locationIds is not null;
var partnerContext = LocationScopeBindingHelper.NormalizeIds(partnerIdsForContext);
- // locationIds / regionIds 含 ALL 哨兵:不归档为 Guid 校验,按全选处理(Company 由 fl_label.PartnerId 落库)
+ // locationIds=["ALL"] + 具体 RegionIds → Scoped ALL(SPECIFIED + Region 快照,无门店快照)
+ if (locationHasAll && mergedRegionIds.Count > 0 && !regionHasAll)
+ {
+ await ValidateRegionIdsExistAsync(db, mergedRegionIds);
+ return new LabelRegionScopeSaveResult
+ {
+ AppliedRegionType = AppliedRegionSpecified,
+ RegionIds = mergedRegionIds,
+ LocationIds = new List()
+ };
+ }
+
+ // Region=ALL + Location=ALL(或无具体 Region)→ 公司级/全局 ALL(Partner 由 fl_label.PartnerId 落库)
if (locationHasAll || (regionHasAll && explicitLocationIds.Count == 0))
{
return new LabelRegionScopeSaveResult
@@ -104,13 +118,13 @@ public static class LabelRegionScopeHelper
if (type != AppliedRegionAll && type != AppliedRegionSpecified)
{
- throw new UserFriendlyException("适用 Region 范围不合法(ALL/SPECIFIED)");
+ throw new UserFriendlyException("Invalid applicable Region scope (ALL/SPECIFIED).");
}
if (mergedRegionIds.Count == 0 && explicitLocationIds.Count == 0
&& !string.Equals(type, AppliedRegionAll, StringComparison.OrdinalIgnoreCase))
{
- throw new UserFriendlyException("请指定 Region(regionIds)和/或门店(locationIds)");
+ throw new UserFriendlyException("Specify Region (regionIds) and/or Location (locationIds).");
}
if (mergedRegionIds.Count > 0)
@@ -203,7 +217,7 @@ public static class LabelRegionScopeHelper
{
if (allLocationsInRegions.Count == 0)
{
- throw new UserFriendlyException("指定 Region 下未匹配到有效门店,请检查 Region 或 locationIds");
+ throw new UserFriendlyException("No valid locations matched under the specified Region. Check Region or locationIds.");
}
if (explicitLocationIds.Count > 0)
@@ -229,7 +243,7 @@ public static class LabelRegionScopeHelper
db, resolvedPartnerContext, mergedRegionIds, explicitLocationIds);
if (mergedLocations.Count == 0)
{
- throw new UserFriendlyException("指定 Region 下未匹配到有效门店,请检查 Region 或 locationIds");
+ throw new UserFriendlyException("No valid locations matched under the specified Region. Check Region or locationIds.");
}
var invalid = explicitLocationIds
@@ -237,7 +251,7 @@ public static class LabelRegionScopeHelper
.ToList();
if (invalid.Count > 0)
{
- throw new UserFriendlyException("所选门店必须属于所选 Region");
+ throw new UserFriendlyException("Selected locations must belong to the selected Region.");
}
return new LabelRegionScopeSaveResult
@@ -487,7 +501,7 @@ public static class LabelRegionScopeHelper
null,
regionIds,
locationIds,
- ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds));
+ ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds, regionIds));
return new LabelRegionScopeDisplay
{
@@ -500,10 +514,14 @@ public static class LabelRegionScopeHelper
public static async Task BuildLocationDisplayAsync(
ISqlSugarClient db,
string? appliedRegionType,
- IReadOnlyList locationIds)
+ IReadOnlyList locationIds,
+ string? labelId = null,
+ IReadOnlyList? regionIds = null)
{
+ var persistedLocations = LocationScopeBindingHelper.NormalizeIds(locationIds);
+
if (string.Equals(appliedRegionType, AppliedRegionAll, StringComparison.OrdinalIgnoreCase)
- && locationIds.Count == 0)
+ && persistedLocations.Count == 0)
{
return new LabelLocationScopeDisplay
{
@@ -512,7 +530,25 @@ public static class LabelRegionScopeHelper
};
}
- if (locationIds.Count == 0)
+ var concreteRegions = LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds);
+ if (concreteRegions.Count == 0 && !string.IsNullOrWhiteSpace(labelId))
+ {
+ concreteRegions = await GetRegionIdsForLabelAsync(db, labelId);
+ }
+
+ // Scoped ALL:SPECIFIED + 有 Region 快照 + 无门店快照 → 范围内 Location 回显 ALL
+ if (AllScopeBindingHelper.IsDeclaredSpecified(appliedRegionType)
+ && concreteRegions.Count > 0
+ && persistedLocations.Count == 0)
+ {
+ return new LabelLocationScopeDisplay
+ {
+ Location = AllLocationsDisplay,
+ LocationIds = new List { AllScopeBindingHelper.ScopeAll }
+ };
+ }
+
+ if (persistedLocations.Count == 0)
{
return new LabelLocationScopeDisplay
{
@@ -521,7 +557,7 @@ public static class LabelRegionScopeHelper
};
}
- var guidList = locationIds.Where(x => Guid.TryParse(x, out _)).Select(Guid.Parse).ToList();
+ var guidList = persistedLocations.Where(x => Guid.TryParse(x, out _)).Select(Guid.Parse).ToList();
var names = new List();
if (guidList.Count > 0)
{
@@ -539,9 +575,9 @@ public static class LabelRegionScopeHelper
var collapsed = await ScopeAllEchoHelper.CollapseScopeIdsToAllSentinelAsync(
db,
null,
- null,
- locationIds,
- ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds));
+ concreteRegions,
+ persistedLocations,
+ ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, persistedLocations, concreteRegions));
return new LabelLocationScopeDisplay
{
@@ -772,7 +808,7 @@ public static class LabelRegionScopeHelper
var groupIds = await ResolveGroupIdsForLocationAsync(db, locationId);
if (!await LabelAppliesToLocationAsync(db, label, locationId, groupIds))
{
- throw new UserFriendlyException("??????????????? Region");
+ throw new UserFriendlyException("This label does not apply to the Location's Region.");
}
}
@@ -1040,7 +1076,7 @@ public static class LabelRegionScopeHelper
.CountAsync();
if (count != ids.Count)
{
- throw new UserFriendlyException("存在无效的 Region Id,请刷新后重试");
+ throw new UserFriendlyException("One or more Region Ids are invalid. Refresh and try again.");
}
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelReportDateRangeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelReportDateRangeHelper.cs
index b727252..898d0f5 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelReportDateRangeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelReportDateRangeHelper.cs
@@ -34,7 +34,7 @@ public static class LabelReportDateRangeHelper
case "custom":
if (!startDate.HasValue || !endDate.HasValue)
{
- throw new UserFriendlyException("自定义日期须同时传入 startDate 与 endDate");
+ throw new UserFriendlyException("Custom date range requires both startDate and endDate.");
}
startDay = startDate.Value.Date;
@@ -42,7 +42,7 @@ public static class LabelReportDateRangeHelper
endExcl = endDay.AddDays(1);
if (startDay > endDay)
{
- throw new UserFriendlyException("开始日期不能晚于结束日期");
+ throw new UserFriendlyException("Start date cannot be later than end date.");
}
break;
@@ -60,7 +60,7 @@ public static class LabelReportDateRangeHelper
var dayCount = Math.Max(1, (int)Math.Ceiling((endExcl - startDay).TotalDays));
if (dayCount > MaxRangeDays)
{
- throw new UserFriendlyException($"统计区间不能超过 {MaxRangeDays} 天");
+ throw new UserFriendlyException($"The reporting range cannot exceed {MaxRangeDays} days.");
}
return new LabelReportResolvedRange
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplatePrintOrientationHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplatePrintOrientationHelper.cs
index 280e4ef..e8b2cdb 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplatePrintOrientationHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplatePrintOrientationHelper.cs
@@ -38,6 +38,6 @@ public static class LabelTemplatePrintOrientationHelper
return;
}
- throw new UserFriendlyException("printOrientation 仅支持 vertical 或 horizontal");
+ throw new UserFriendlyException("printOrientation supports only vertical or horizontal.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
index fdc8757..2373ffd 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
@@ -132,17 +132,17 @@ public static class LabelTemplateScopeHelper
if (string.Equals(partnerType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && partnerIds.Count == 0)
{
- throw new UserFriendlyException("指定适用 Company 时,partnerIds/companyIds 不能为空");
+ throw new UserFriendlyException("When specifying applicable Company, partnerIds/companyIds cannot be empty.");
}
if (string.Equals(regionType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && regionIds.Count == 0)
{
- throw new UserFriendlyException("指定适用 Region 时,regionIds/groupIds 不能为空");
+ throw new UserFriendlyException("When specifying applicable Region, regionIds/groupIds cannot be empty.");
}
if (string.Equals(locationType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) && locationIds.Count == 0)
{
- throw new UserFriendlyException("指定适用门店时,locationIds/appliedLocationIds 不能为空");
+ throw new UserFriendlyException("When specifying applicable locations, locationIds/appliedLocationIds cannot be empty.");
}
if (partnerIds.Count > 0)
@@ -175,7 +175,7 @@ public static class LabelTemplateScopeHelper
string.Equals(locationType, ScopeSpecified, StringComparison.OrdinalIgnoreCase) ? locationIds : null);
if (merged.Count == 0)
{
- throw new UserFriendlyException("指定适用范围后至少需要匹配到一个有效门店");
+ throw new UserFriendlyException("After specifying scope, at least one valid location must match.");
}
}
@@ -209,7 +209,7 @@ public static class LabelTemplateScopeHelper
if (needsPartnerRows && !hasPartnerTable)
{
throw new UserFriendlyException(
- "Company 适用范围关联表尚未就绪,请联系管理员执行数据库迁移(fl_label_template_scope.sql)后重试");
+ "Company scope tables are not ready. Ask an administrator to run the database migration (fl_label_template_scope.sql), then try again.");
}
if (hasPartnerTable)
@@ -602,7 +602,7 @@ public static class LabelTemplateScopeHelper
{
if (type != ScopeAll && type != ScopeSpecified)
{
- throw new UserFriendlyException($"适用{label}范围不合法(ALL/SPECIFIED)");
+ throw new UserFriendlyException($"Invalid applicable {label} scope (ALL/SPECIFIED).");
}
}
@@ -672,7 +672,7 @@ public static class LabelTemplateScopeHelper
.CountAsync();
if (count != partnerIds.Count)
{
- throw new UserFriendlyException("存在无效的 Company(partnerIds/companyIds),请刷新后重试");
+ throw new UserFriendlyException("One or more Companies are invalid (partnerIds/companyIds). Refresh and try again.");
}
}
@@ -689,7 +689,7 @@ public static class LabelTemplateScopeHelper
.CountAsync();
if (count != ids.Count)
{
- throw new UserFriendlyException("存在无效的 Region(regionIds/groupIds),请刷新后重试");
+ throw new UserFriendlyException("One or more Regions are invalid (regionIds/groupIds). Refresh and try again.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationBatchExcelHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationBatchExcelHelper.cs
index 7444884..a7eae04 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationBatchExcelHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationBatchExcelHelper.cs
@@ -73,7 +73,7 @@ public static class LocationBatchExcelHelper
parseErrors.Add(new LocationBatchImportErrorDto
{
RowNumber = 0,
- Message = "Excel 中无工作表"
+ Message = "The Excel file has no worksheets."
});
return result;
}
@@ -81,7 +81,7 @@ public static class LocationBatchExcelHelper
var headerRow = ws.Row(1);
if (!headerRow.CellsUsed().Any())
{
- parseErrors.Add(new LocationBatchImportErrorDto { RowNumber = 1, Message = "表头为空" });
+ parseErrors.Add(new LocationBatchImportErrorDto { RowNumber = 1, Message = "Header row is empty." });
return result;
}
@@ -91,7 +91,7 @@ public static class LocationBatchExcelHelper
parseErrors.Add(new LocationBatchImportErrorDto
{
RowNumber = 1,
- Message = "未找到「Location ID」列(或同义表头),请使用官方模板"
+ Message = "Could not find Location ID column (or synonyms). Use the official template."
});
return result;
}
@@ -105,7 +105,7 @@ public static class LocationBatchExcelHelper
parseErrors.Add(new LocationBatchImportErrorDto
{
RowNumber = rowNum,
- Message = $"已超过单次导入上限 {maxRows} 行,后续行已忽略"
+ Message = $"Import limit of {maxRows} rows exceeded; remaining rows were ignored."
});
break;
}
@@ -117,7 +117,7 @@ public static class LocationBatchExcelHelper
}
dataRowCount++;
- var errPrefix = $"第 {rowNum} 行";
+ var errPrefix = $"Row {rowNum}";
try
{
var input = BuildCreateInputFromRow(colMap, ws, rowNum, out var rowErrs);
@@ -270,7 +270,7 @@ public static class LocationBatchExcelHelper
{
if (!decimal.TryParse(latStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var latVal))
{
- errors.Add("Latitude 格式不正确");
+ errors.Add("Invalid Latitude format.");
}
else
{
@@ -283,7 +283,7 @@ public static class LocationBatchExcelHelper
{
if (!decimal.TryParse(lngStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var lngVal))
{
- errors.Add("Longitude 格式不正确");
+ errors.Add("Invalid Longitude format.");
}
else
{
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
index bf2634c..ade88f9 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
@@ -370,7 +370,7 @@ public static class LocationScopeBindingHelper
return expanded;
}
- throw new UserFriendlyException("选择全部门店时需指定 Company(partnerId / partnerIds)或 Region");
+ throw new UserFriendlyException("When selecting all locations, specify Company (partnerId / partnerIds) or Region.");
}
// 2. 具体门店 +(无区域 / 区域为 ALL)→ 只绑这些门店,避免 regionIds=ALL 盖掉单店
@@ -384,7 +384,7 @@ public static class LocationScopeBindingHelper
{
if (normalizedPartners.Count == 0)
{
- throw new UserFriendlyException("选择全部 Region 时需指定 Company(partnerId / partnerIds)");
+ throw new UserFriendlyException("When selecting all Regions, specify Company (partnerId / partnerIds).");
}
return await AllScopeBindingHelper.ResolveAllLocationIdsAsync(db, normalizedPartners, null);
@@ -438,7 +438,7 @@ public static class LocationScopeBindingHelper
|| (ContainsAllScopeSentinel(regionIds)
&& FilterConcreteScopeIds(locationIds).Count == 0))
{
- throw new UserFriendlyException("门店范围含 ALL 哨兵时应归档为 ALL,不应进入 SPECIFIED 落库校验");
+ throw new UserFriendlyException("When location scope includes the ALL sentinel, it should be archived as ALL, not validated as SPECIFIED.");
}
var concreteRegions = FilterConcreteScopeIds(regionIds);
@@ -458,7 +458,7 @@ public static class LocationScopeBindingHelper
concreteLocations);
if (merged.Count == 0)
{
- throw new UserFriendlyException("指定适用区域或门店时,至少需要匹配到一个有效门店");
+ throw new UserFriendlyException("When specifying applicable Region or Location, at least one valid location must match.");
}
await ValidateLocationIdsExistAsync(db, merged);
@@ -488,7 +488,7 @@ public static class LocationScopeBindingHelper
if (fromRegions.Count == 0)
{
- throw new UserFriendlyException("指定 Region 下未匹配到有效门店");
+ throw new UserFriendlyException("No valid locations matched under the specified Region.");
}
await ValidateLocationIdsExistAsync(db, fromRegions);
@@ -501,7 +501,7 @@ public static class LocationScopeBindingHelper
var fromPartners = await ResolveLocationIdsFromPartnerIdsAsync(db, concretePartners);
if (fromPartners.Count == 0)
{
- throw new UserFriendlyException("指定 Company 下未匹配到有效门店");
+ throw new UserFriendlyException("No valid locations matched under the specified Company.");
}
await ValidateLocationIdsExistAsync(db, fromPartners);
@@ -764,7 +764,7 @@ public static class LocationScopeBindingHelper
{
if (!Guid.TryParse(id, out _))
{
- throw new UserFriendlyException("门店Id格式不正确");
+ throw new UserFriendlyException("Invalid Location ID format.");
}
}
@@ -774,7 +774,7 @@ public static class LocationScopeBindingHelper
.CountAsync();
if (existCount != ids.Count)
{
- throw new UserFriendlyException("门店不存在");
+ throw new UserFriendlyException("Location not found.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ProductBatchExcelHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ProductBatchExcelHelper.cs
index ca552af..f25b321 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ProductBatchExcelHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ProductBatchExcelHelper.cs
@@ -62,14 +62,14 @@ public static class ProductBatchExcelHelper
?? wb.Worksheets.FirstOrDefault();
if (ws is null)
{
- parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 0, Message = "Excel 中无工作表" });
+ parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 0, Message = "The Excel file has no worksheets." });
return result;
}
var headerRow = ws.Row(1);
if (!headerRow.CellsUsed().Any())
{
- parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 1, Message = "表头为空" });
+ parseErrors.Add(new ProductBatchImportErrorDto { RowNumber = 1, Message = "Header row is empty." });
return result;
}
@@ -79,7 +79,7 @@ public static class ProductBatchExcelHelper
parseErrors.Add(new ProductBatchImportErrorDto
{
RowNumber = 1,
- Message = "未找到「Product」与「Product Category」列(或同义表头),请使用官方模板"
+ Message = "Could not find Product and Product Category columns (or synonyms). Use the official template."
});
return result;
}
@@ -93,7 +93,7 @@ public static class ProductBatchExcelHelper
parseErrors.Add(new ProductBatchImportErrorDto
{
RowNumber = rowNum,
- Message = $"已超过单次导入上限 {maxRows} 行,后续行已忽略"
+ Message = $"Import limit of {maxRows} rows exceeded; remaining rows were ignored."
});
break;
}
@@ -114,16 +114,16 @@ public static class ProductBatchExcelHelper
}
dataRowCount++;
- var errPrefix = $"第 {rowNum} 行";
+ var errPrefix = $"Row {rowNum}";
var rowErrs = new List();
if (string.IsNullOrWhiteSpace(productName))
{
- rowErrs.Add("Product 不能为空");
+ rowErrs.Add("Product is required.");
}
if (string.IsNullOrWhiteSpace(categoryName))
{
- rowErrs.Add("Product Category 不能为空");
+ rowErrs.Add("Product Category is required.");
}
if (rowErrs.Count > 0)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ScopeAllEchoHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ScopeAllEchoHelper.cs
index 750dec8..67d9136 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ScopeAllEchoHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/ScopeAllEchoHelper.cs
@@ -88,6 +88,10 @@ public static class ScopeAllEchoHelper
&& LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds).Count == 0
&& LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds).Count == 0,
IsLocationAll = AllScopeBindingHelper.IsDeclaredAll(availabilityType)
+ || (AllScopeBindingHelper.IsDeclaredSpecified(appliedRegionType)
+ && LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds).Count > 0
+ && LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds).Count == 0
+ && !AllScopeBindingHelper.IsDeclaredAll(appliedRegionType))
};
/// 兼容旧调用:无 Region 类型时用 AvailabilityType 同时驱动 Region/Location。
@@ -96,16 +100,25 @@ public static class ScopeAllEchoHelper
string? availabilityType) =>
ForLabelEntityScope(appliedPartnerType, availabilityType, availabilityType);
- /// Label:AppliedRegionType=ALL 且未落门店快照时 Region/Location 均为 ALL。
+ ///
+ /// Label:AppliedRegionType=ALL 且未落门店快照时 Region/Location 均为 ALL;
+ /// Scoped ALL(SPECIFIED + 有 Region 快照 + 无门店快照)时 Location 回显 ["ALL"](范围内 ALL)。
+ ///
public static ScopeAllEchoOptions ForLabelRegionScope(
string? appliedRegionType,
- IReadOnlyList locationIds)
+ IReadOnlyList locationIds,
+ IReadOnlyList? regionIds = null)
{
+ var persistedLocations = LocationScopeBindingHelper.NormalizeIds(locationIds);
+ var concreteRegions = LocationScopeBindingHelper.FilterConcreteScopeIds(regionIds);
var isRegionAll = AllScopeBindingHelper.IsDeclaredAll(appliedRegionType);
+ var isScopedLocationAll = AllScopeBindingHelper.IsDeclaredSpecified(appliedRegionType)
+ && concreteRegions.Count > 0
+ && persistedLocations.Count == 0;
return new ScopeAllEchoOptions
{
IsRegionAll = isRegionAll,
- IsLocationAll = isRegionAll && LocationScopeBindingHelper.NormalizeIds(locationIds).Count == 0
+ IsLocationAll = (isRegionAll && persistedLocations.Count == 0) || isScopedLocationAll
};
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TeamMemberBatchExcelHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TeamMemberBatchExcelHelper.cs
index 5c46776..0f72604 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TeamMemberBatchExcelHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/TeamMemberBatchExcelHelper.cs
@@ -80,7 +80,7 @@ public static class TeamMemberBatchExcelHelper
parseErrors.Add(new TeamMemberBatchImportErrorDto
{
RowNumber = 0,
- Message = "未配置默认导入密码 FoodLabeling:BatchImport:TeamMemberImportDefaultPassword"
+ Message = "Default import password is not configured (FoodLabeling:BatchImport:TeamMemberImportDefaultPassword)."
});
return result;
}
@@ -89,14 +89,14 @@ public static class TeamMemberBatchExcelHelper
var ws = wb.Worksheets.FirstOrDefault();
if (ws is null)
{
- parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 0, Message = "Excel 中无工作表" });
+ parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 0, Message = "The Excel file has no worksheets." });
return result;
}
var headerRow = ws.Row(1);
if (!headerRow.CellsUsed().Any())
{
- parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 1, Message = "表头为空" });
+ parseErrors.Add(new TeamMemberBatchImportErrorDto { RowNumber = 1, Message = "Header row is empty." });
return result;
}
@@ -106,7 +106,7 @@ public static class TeamMemberBatchExcelHelper
parseErrors.Add(new TeamMemberBatchImportErrorDto
{
RowNumber = 1,
- Message = "未找到「Name」与「Email」列(或同义表头),请使用官方模板"
+ Message = "Could not find Name and Email columns (or synonyms). Use the official template."
});
return result;
}
@@ -120,7 +120,7 @@ public static class TeamMemberBatchExcelHelper
parseErrors.Add(new TeamMemberBatchImportErrorDto
{
RowNumber = rowNum,
- Message = $"已超过单次导入上限 {maxRows} 行,后续行已忽略"
+ Message = $"Import limit of {maxRows} rows exceeded; remaining rows were ignored."
});
break;
}
@@ -133,7 +133,7 @@ public static class TeamMemberBatchExcelHelper
}
dataRowCount++;
- var errPrefix = $"第 {rowNum} 行";
+ var errPrefix = $"Row {rowNum}";
try
{
var input = BuildCreateInputFromRow(
@@ -280,12 +280,12 @@ public static class TeamMemberBatchExcelHelper
if (string.IsNullOrWhiteSpace(fullName))
{
- errors.Add("Name 不能为空");
+ errors.Add("Name is required.");
}
if (string.IsNullOrWhiteSpace(email))
{
- errors.Add("Email 不能为空");
+ errors.Add("Email is required.");
}
var login = string.IsNullOrWhiteSpace(userName) ? email.Trim() : userName.Trim();
@@ -293,13 +293,13 @@ public static class TeamMemberBatchExcelHelper
if (string.IsNullOrWhiteSpace(login))
{
- errors.Add("登录账号不能为空(可填 UserName 列,否则使用 Email)");
+ errors.Add("Sign-in account is required (fill UserName column, or Email will be used).");
}
var pwd = string.IsNullOrWhiteSpace(password) ? defaultPassword : password.Trim();
if (string.IsNullOrWhiteSpace(pwd))
{
- errors.Add("Password 不能为空且未配置默认密码");
+ errors.Add("Password is required and no default password is configured.");
}
long? phone = null;
@@ -308,7 +308,7 @@ public static class TeamMemberBatchExcelHelper
if (!long.TryParse(RegexDigitsOnly(phoneStr), NumberStyles.Integer, CultureInfo.InvariantCulture,
out var p))
{
- errors.Add("Phone 格式不正确(需为数字)");
+ errors.Add("Invalid Phone format (digits only).");
}
else
{
@@ -323,11 +323,11 @@ public static class TeamMemberBatchExcelHelper
}
else if (string.IsNullOrWhiteSpace(roleName))
{
- errors.Add("Role Name 不能为空(或填写有效的 Role Id Guid)");
+ errors.Add("Role Name is required (or provide a valid Role Id Guid).");
}
else if (!roleNameToId.TryGetValue(NormalizeRoleKey(roleName), out var rid))
{
- errors.Add($"未找到角色「{roleName.Trim()}」,请与系统角色名称一致");
+ errors.Add($"Role not found: \"{roleName.Trim()}\". Use a name that matches a system role.");
}
else
{
@@ -340,7 +340,7 @@ public static class TeamMemberBatchExcelHelper
if (regionTokens.Count == 0 && locationTokens.Count == 0 && !isCompanyAdmin)
{
- errors.Add("Region 与 Assigned Location Ids 至少填一项(均可留空时仅适用于 Company Admin 且已在 Web 端配置 Company)");
+ errors.Add("Fill at least Region or Assigned Location Ids (both may be empty only for Company Admin with Company configured on Web).");
}
if (errors.Count > 0)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppAuthScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppAuthScopeHelper.cs
index f9f4c8c..19cd78e 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppAuthScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppAuthScopeHelper.cs
@@ -23,18 +23,18 @@ public static class UsAppAuthScopeHelper
{
if (currentUser.Id is null)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var kind = currentUser.FindClaim(UsAppJwtClaims.ClientKind)?.Value;
if (!string.Equals(kind, UsAppJwtClaims.ClientKindUsApp, StringComparison.Ordinal))
{
- throw new UserFriendlyException("请使用 App 登录令牌调用该接口");
+ throw new UserFriendlyException("Use an App sign-in token to call this endpoint.");
}
if (!await CanUseAdminScopeApisAsync(db, currentUser))
{
- throw new UserFriendlyException("仅管理员或 Company Admin 可使用公司/区域/门店筛选接口");
+ throw new UserFriendlyException("Only administrators or Company Admins can use Company/Region/Location filter endpoints.");
}
}
@@ -77,7 +77,7 @@ public static class UsAppAuthScopeHelper
var pid = partnerId.Trim();
if (string.IsNullOrEmpty(pid))
{
- throw new UserFriendlyException("请选择公司");
+ throw new UserFriendlyException("Please select a Company.");
}
return await db.Queryable()
@@ -146,7 +146,7 @@ public static class UsAppAuthScopeHelper
var locationId = input.LocationId?.Trim() ?? string.Empty;
if (string.IsNullOrEmpty(partnerId) || string.IsNullOrEmpty(groupId) || string.IsNullOrEmpty(locationId))
{
- throw new UserFriendlyException("请选择公司、区域和门店");
+ throw new UserFriendlyException("Please select Company, Region, and Location.");
}
if (!ReportsRoleHelper.IsAdminRole(currentUser))
@@ -161,19 +161,19 @@ public static class UsAppAuthScopeHelper
null);
if (scopedIds is null || !scopedIds.Contains(locationId))
{
- throw new UserFriendlyException("门店与所选公司/区域不匹配");
+ throw new UserFriendlyException("Location does not match the selected Company/Region.");
}
if (!Guid.TryParse(locationId, out var locationGuid))
{
- throw new UserFriendlyException("无效的门店标识");
+ throw new UserFriendlyException("Invalid location identifier.");
}
var loc = await db.Queryable()
.FirstAsync(x => !x.IsDeleted && x.Id == locationGuid);
if (loc is null)
{
- throw new UserFriendlyException("门店不存在或已删除");
+ throw new UserFriendlyException("Location not found or has been removed.");
}
var partner = await db.Queryable()
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppPrintLogScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppPrintLogScopeHelper.cs
index bab9569..d35f83e 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppPrintLogScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/UsAppPrintLogScopeHelper.cs
@@ -71,20 +71,20 @@ public static class UsAppPrintLogScopeHelper
if (currentUser.Id is null)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var lid = TeamMemberListScopeHelper.NormalizeScopeKey(locationId);
if (string.IsNullOrEmpty(lid))
{
- throw new UserFriendlyException("门店参数无效");
+ throw new UserFriendlyException("Invalid location parameter.");
}
var accessible = await LocationScopeBindingHelper.ResolveAppAccessibleLocationIdsForUserAsync(
db, currentUser.Id.Value, currentUser);
if (!accessible.Contains(lid, StringComparer.OrdinalIgnoreCase))
{
- throw new UserFriendlyException("当前账号未绑定该门店,无法查看");
+ throw new UserFriendlyException("This account is not bound to the location and cannot view its data.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AuthSessionAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AuthSessionAppService.cs
index 1168681..44ce148 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AuthSessionAppService.cs
+++ b/美国版/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
{
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
// 避免走 UserManager.GetInfoAsync -> UserRepository.GetUserAllInfoAsync 的导航加载
@@ -51,7 +51,7 @@ public class AuthSessionAppService : ApplicationService, IAuthSessionAppService
var user = await _userRepository.GetByIdAsync(userId);
if (user is null || user.IsDeleted)
{
- throw new UserFriendlyException("用户不存在");
+ throw new UserFriendlyException("User not found.");
}
var userRoleIds = await _dbContext.SqlSugarClient.Queryable()
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs
index a4a2d5f..e305012 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs
+++ b/美国版/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
var scopeLocationIds = await DashboardScopeHelper.ResolveDashboardLocationIdsAsync(CurrentUser, _dbContext);
var partnerScope = await PartnerScopeHelper.ResolvePartnerScopeAsync(CurrentUser, _dbContext);
var groupScope = await GroupListScopeHelper.ResolveAsync(CurrentUser, _dbContext);
- var platformAdminUserIds = await DashboardScopeHelper.GetPlatformAdminUserIdStringsAsync(db);
-
var printTodayQuery = DashboardScopeHelper.ApplyPrintTaskLocationScope(
db.Queryable(), scopeLocationIds);
var printedToday = await printTodayQuery
@@ -56,17 +54,15 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
db.Queryable(), scopeLocationIds)
.CountAsync(x => x.CreationTime >= yesterdayStart && x.CreationTime < todayStart);
- var activeTemplates = await LabelTemplateQueryHelper.ProjectListColumns(
- _dbContext.SqlSugarClient.Queryable())
- .CountAsync(x => !x.IsDeleted && x.State);
- var activeTemplatesPrevWeek = await LabelTemplateQueryHelper.ProjectListColumns(
- _dbContext.SqlSugarClient.Queryable())
- .CountAsync(x => !x.IsDeleted && x.State && x.CreationTime < weekStart);
+ var activeTemplates = await DashboardScopeHelper.CountScopedActiveTemplatesAsync(
+ db, scopeLocationIds, createdBefore: null);
+ var activeTemplatesPrevWeek = await DashboardScopeHelper.CountScopedActiveTemplatesAsync(
+ db, scopeLocationIds, createdBefore: weekStart);
- var activeUsers = await DashboardScopeHelper.CountScopedTeamMembersAsync(
- db, scopeLocationIds, platformAdminUserIds, activeOnly: true, createdBefore: null);
- var activeUsersPrevWeek = await DashboardScopeHelper.CountScopedTeamMembersAsync(
- db, scopeLocationIds, platformAdminUserIds, activeOnly: true, createdBefore: weekStart);
+ var activeUsers = await DashboardScopeHelper.CountScopedRegisteredUsersAsync(
+ db, scopeLocationIds, activeOnly: true, createdBefore: null);
+ var activeUsersPrevWeek = await DashboardScopeHelper.CountScopedRegisteredUsersAsync(
+ db, scopeLocationIds, activeOnly: true, createdBefore: weekStart);
var labelsQuery = db.Queryable().Where(x => !x.IsDeleted && x.State);
if (scopeLocationIds is not null)
@@ -90,10 +86,15 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
var locationsPrevWeek = await DashboardScopeHelper.CountScopedLocationsAsync(
db, scopeLocationIds, weekStart);
- var people = await DashboardScopeHelper.CountScopedTeamMembersAsync(
- db, scopeLocationIds, platformAdminUserIds, activeOnly: false, createdBefore: null);
- var peoplePrevWeek = await DashboardScopeHelper.CountScopedTeamMembersAsync(
- db, scopeLocationIds, platformAdminUserIds, activeOnly: false, createdBefore: weekStart);
+ var people = await DashboardScopeHelper.CountScopedRegisteredUsersAsync(
+ db, scopeLocationIds, activeOnly: false, createdBefore: null);
+ var peoplePrevWeek = await DashboardScopeHelper.CountScopedRegisteredUsersAsync(
+ db, scopeLocationIds, activeOnly: false, createdBefore: weekStart);
+
+ var labels = await DashboardScopeHelper.CountScopedLabelsAsync(
+ db, _dbContext, CurrentUser, createdBefore: null);
+ var labelsPrevWeek = await DashboardScopeHelper.CountScopedLabelsAsync(
+ db, _dbContext, CurrentUser, createdBefore: weekStart);
var productQuery = db.Queryable().Where(x => !x.IsDeleted);
if (scopeLocationIds is not null)
@@ -253,6 +254,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
}).ToList();
var labelsPrintedTodayCard = BuildMetricCard("labelsPrintedToday", "Labels Printed Today", printedToday, printedYesterday);
+ var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek);
var activeTemplatesCard = BuildMetricCard("activeTemplates", "Active Templates", activeTemplates, activeTemplatesPrevWeek);
var activeUsersCard = BuildMetricCard("activeUsers", "Active Users", activeUsers, activeUsersPrevWeek);
var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek);
@@ -265,6 +267,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
var output = new DashboardOverviewOutputDto
{
LabelsPrintedToday = labelsPrintedTodayCard,
+ Labels = labelsCard,
ActiveTemplates = activeTemplatesCard,
ActiveUsers = activeUsersCard,
Labels = labelsCard,
@@ -276,6 +279,7 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
MetricCards = new List
{
labelsPrintedTodayCard,
+ labelsCard,
activeTemplatesCard,
activeUsersCard,
labelsCard,
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/GroupAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/GroupAppService.cs
index 97048ea..467da3b 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/GroupAppService.cs
+++ b/美国版/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
throw new UserFriendlyException("Group not found.");
}
+ var wasActive = entity.State;
var oldGroupName = entity.GroupName;
var oldPartnerIdForCascade = entity.PartnerId;
var name = input.GroupName?.Trim();
@@ -194,12 +195,23 @@ public class GroupAppService : ApplicationService, IGroupAppService
entity.LastModifierId = CurrentUser?.Id?.ToString();
await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync();
+
+ if (AccountStructureCascadeInactiveHelper.IsBecomingInactive(wasActive, entity.State))
+ {
+ await AccountStructureCascadeInactiveHelper.CascadeGroupInactiveAsync(
+ _dbContext.SqlSugarClient,
+ groupId,
+ Clock.Now,
+ CurrentUser?.Id,
+ CurrentUser?.Id?.ToString());
+ }
+
return await GetAsync(id);
}
///
[UnitOfWork]
- public async Task DeleteAsync(Guid id)
+ public async Task DeleteAsync(Guid id, [FromQuery] bool confirmCascade = false)
{
await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext);
@@ -209,17 +221,41 @@ public class GroupAppService : ApplicationService, IGroupAppService
}
var groupId = id.ToString();
- var entity = await _dbContext.SqlSugarClient.Queryable()
+ var db = _dbContext.SqlSugarClient;
+ var entity = await db.Queryable()
.FirstAsync(x => !x.IsDeleted && x.Id == groupId);
if (entity is null)
{
throw new UserFriendlyException("Group not found.");
}
- entity.IsDeleted = true;
- entity.LastModificationTime = Clock.Now;
- entity.LastModifierId = CurrentUser?.Id?.ToString();
- await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync();
+ var partnerName = await ResolvePartnerNameAsync(entity.PartnerId);
+ if (string.Equals(partnerName, "None", StringComparison.OrdinalIgnoreCase))
+ {
+ throw new UserFriendlyException("The selected company does not exist or has been removed.");
+ }
+
+ var groupName = entity.GroupName?.Trim() ?? string.Empty;
+ var locationCount = await AccountStructureCascadeDeleteHelper.CountActiveLocationsByPartnerAndGroupAsync(
+ db, partnerName, groupName);
+
+ if (locationCount > 0 && !confirmCascade)
+ {
+ throw new UserFriendlyException(
+ AccountStructureCascadeDeleteHelper.BuildGroupCascadeRequiredMessage(locationCount));
+ }
+
+ var now = Clock.Now;
+ var modifierId = CurrentUser?.Id;
+ var modifierIdString = modifierId?.ToString();
+
+ if (confirmCascade && locationCount > 0)
+ {
+ await AccountStructureCascadeDeleteHelper.SoftDeleteLocationsByPartnerAndGroupAsync(
+ db, partnerName, groupName, now, modifierId, modifierIdString);
+ }
+
+ await AccountStructureCascadeDeleteHelper.SoftDeleteGroupAsync(db, groupId, now, modifierIdString);
}
///
@@ -303,14 +339,14 @@ public class GroupAppService : ApplicationService, IGroupAppService
{
if (input?.Items is null || input.Items.Count == 0)
{
- throw new UserFriendlyException("请至少提交一条导入数据(items 不能为空)");
+ throw new UserFriendlyException("Please submit at least one import item (items cannot be empty).");
}
var opt = _batchImportOptions.Value;
var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows;
if (input.Items.Count > maxRows)
{
- throw new UserFriendlyException($"单次批量导入最多允许 {maxRows} 条,请分批提交");
+ throw new UserFriendlyException($"A maximum of {maxRows} rows is allowed per batch import. Please submit in smaller batches.");
}
var result = new GroupBatchImportOnlineResultDto();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
index 8dcfe77..56e1d53 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
+++ b/美国版/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
regionScopeMap[lid] = await LabelRegionScopeHelper.BuildScopeDisplayAsync(
db, lid, applied, locIds);
locationScopeMap[lid] = await LabelRegionScopeHelper.BuildLocationDisplayAsync(
- db, applied, locIds);
+ db, applied, locIds, lid);
locationIdsMap[lid] = locationScopeMap[lid].LocationIds;
labelMap.TryGetValue(lid, out var partnerRow);
partnerEchoMap[lid] = await BuildLabelPartnerEchoAsync(
@@ -310,7 +310,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
var labelCode = id?.Trim();
if (string.IsNullOrWhiteSpace(labelCode))
{
- throw new UserFriendlyException("标签Code不能为空");
+ throw new UserFriendlyException("labelCode is required.");
}
var db = _dbContext.SqlSugarClient;
@@ -318,7 +318,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode);
if (label is null)
{
- throw new UserFriendlyException("标签不存在");
+ throw new UserFriendlyException("Label not found.");
}
var template = await LabelTemplateQueryHelper.QueryProjected(db)
@@ -394,21 +394,21 @@ public class LabelAppService : ApplicationService, ILabelAppService
var labelName = input.LabelName?.Trim();
if (string.IsNullOrWhiteSpace(labelName))
{
- throw new UserFriendlyException("标签名称不能为空");
+ throw new UserFriendlyException("Label name is required.");
}
if (input.ProductIds is null || input.ProductIds.Count == 0)
{
- throw new UserFriendlyException("标签至少需要绑定一个产品");
+ throw new UserFriendlyException("A label must be bound to at least one product.");
}
if (string.IsNullOrWhiteSpace(input.TemplateCode))
{
- throw new UserFriendlyException("模板编码不能为空");
+ throw new UserFriendlyException("Template code is required.");
}
if (string.IsNullOrWhiteSpace(input.LabelCategoryId))
{
- throw new UserFriendlyException("标签分类Id不能为空");
+ throw new UserFriendlyException("Label category ID is required.");
}
await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId);
@@ -428,7 +428,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim());
if (template is null)
{
- throw new UserFriendlyException("模板不存在");
+ throw new UserFriendlyException("Template not found.");
}
// 唯一性校验(LabelCode)
@@ -436,7 +436,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.AnyAsync(x => !x.IsDeleted && x.LabelCode == labelCode);
if (exists)
{
- throw new UserFriendlyException("标签编码已存在");
+ throw new UserFriendlyException("Label code already exists.");
}
// 插入 fl_label
@@ -534,26 +534,26 @@ public class LabelAppService : ApplicationService, ILabelAppService
/// 批量导入入参
/// 成功/失败统计与行级错误
/// 导入完成(可能部分成功)
- /// 入参非法或模板不存在
+ /// 入参非法或Template not found.
/// 服务器错误
[UnitOfWork]
public async Task BatchCreateAsync(LabelBatchCreateInputVo input)
{
if (input?.Items is null || input.Items.Count == 0)
{
- throw new UserFriendlyException("批量导入行不能为空");
+ throw new UserFriendlyException("Batch import rows cannot be empty.");
}
const int maxRows = 500;
if (input.Items.Count > maxRows)
{
- throw new UserFriendlyException($"单次最多导入 {maxRows} 行");
+ throw new UserFriendlyException($"A maximum of {maxRows} rows can be imported per batch.");
}
var templateCode = input.TemplateCode?.Trim();
if (string.IsNullOrWhiteSpace(templateCode))
{
- throw new UserFriendlyException("模板编码不能为空");
+ throw new UserFriendlyException("Template code is required.");
}
var db = _dbContext.SqlSugarClient;
@@ -561,7 +561,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.FirstAsync(x => !x.IsDeleted && x.TemplateCode == templateCode);
if (template is null)
{
- throw new UserFriendlyException("模板不存在");
+ throw new UserFriendlyException("Template not found.");
}
var templateElements = await LabelBatchTemplateDefaultsHelper.LoadTemplateElementsAsync(db, template.Id);
@@ -662,7 +662,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
result.Errors.Add(new LabelBatchCreateErrorDto
{
RowNumber = 0,
- Message = $"标签已创建,但模板默认值保存失败:{ex.Message}"
+ Message = $"Label was created, but saving template defaults failed: {ex.Message}"
});
}
}
@@ -701,28 +701,28 @@ public class LabelAppService : ApplicationService, ILabelAppService
var labelCode = id?.Trim();
if (string.IsNullOrWhiteSpace(labelCode))
{
- throw new UserFriendlyException("标签Code不能为空");
+ throw new UserFriendlyException("labelCode is required.");
}
var label = await LabelQueryHelper.QueryProjected(_dbContext.SqlSugarClient)
.FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode);
if (label is null)
{
- throw new UserFriendlyException("标签不存在");
+ throw new UserFriendlyException("Label not found.");
}
if (input.ProductIds is null || input.ProductIds.Count == 0)
{
- throw new UserFriendlyException("标签至少需要绑定一个产品");
+ throw new UserFriendlyException("A label must be bound to at least one product.");
}
if (string.IsNullOrWhiteSpace(input.TemplateCode))
{
- throw new UserFriendlyException("模板编码不能为空");
+ throw new UserFriendlyException("Template code is required.");
}
if (string.IsNullOrWhiteSpace(input.LabelCategoryId))
{
- throw new UserFriendlyException("标签分类Id不能为空");
+ throw new UserFriendlyException("Label category ID is required.");
}
await EnsureLabelTypeExistsIfProvidedAsync(input.LabelTypeId);
@@ -742,7 +742,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.FirstAsync(x => !x.IsDeleted && x.TemplateCode == input.TemplateCode.Trim());
if (template is null)
{
- throw new UserFriendlyException("模板不存在");
+ throw new UserFriendlyException("Template not found.");
}
var oldCategoryId = label.LabelCategoryId;
@@ -877,7 +877,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
var labelCode = input?.LabelCode?.Trim();
if (string.IsNullOrWhiteSpace(labelCode))
{
- throw new UserFriendlyException("labelCode不能为空");
+ throw new UserFriendlyException("labelCode is required.");
}
var baseTime = input?.BaseTime ?? DateTime.Now;
@@ -886,7 +886,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.FirstAsync(x => !x.IsDeleted && x.LabelCode == labelCode);
if (label is null)
{
- throw new UserFriendlyException("标签不存在");
+ throw new UserFriendlyException("Label not found.");
}
// 选择预览产品
@@ -901,14 +901,14 @@ public class LabelAppService : ApplicationService, ILabelAppService
if (string.IsNullOrWhiteSpace(productId))
{
- throw new UserFriendlyException("该标签未绑定产品,无法预览");
+ throw new UserFriendlyException("This label has no bound product and cannot be previewed.");
}
var product = await _dbContext.SqlSugarClient.Queryable()
.FirstAsync(x => !x.IsDeleted && x.Id == productId);
if (product is null)
{
- throw new UserFriendlyException("预览产品不存在");
+ throw new UserFriendlyException("Preview product not found.");
}
// 取模板头 & elements
@@ -916,7 +916,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.FirstAsync(x => !x.IsDeleted && x.Id == label.TemplateId);
if (template is null)
{
- throw new UserFriendlyException("模板不存在");
+ throw new UserFriendlyException("Template not found.");
}
var elements = await _dbContext.SqlSugarClient.Queryable()
@@ -992,7 +992,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
{
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("预览/打印需要 locationId 以填充 Company 信息");
+ throw new UserFriendlyException("Preview/print requires locationId to fill Company information.");
}
partnerForCompany = await PartnerCompanyDisplayHelper.ResolvePartnerByLocationIdAsync(
@@ -1198,16 +1198,22 @@ public class LabelAppService : ApplicationService, ILabelAppService
partnerIds = !string.IsNullOrWhiteSpace(storedPartnerId)
? new List { storedPartnerId }
: await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(db, locationIds);
+ var persistedLocationIds = locationIds;
+ var regionIdsFromDb = !string.IsNullOrWhiteSpace(labelId)
+ ? await LabelRegionScopeHelper.GetRegionIdsForLabelAsync(db, labelId)
+ : new List();
var storedRegionScope = !string.IsNullOrWhiteSpace(labelId)
- ? await LabelRegionScopeHelper.BuildScopeDisplayAsync(db, labelId, appliedRegionType, locationIds)
+ ? await LabelRegionScopeHelper.BuildScopeDisplayAsync(
+ db, labelId, appliedRegionType, persistedLocationIds)
: new LabelRegionScopeHelper.LabelRegionScopeDisplay { RegionIds = new List() };
regionIdsForDto = storedRegionScope.RegionIds;
var collapsed = await ScopeAllEchoHelper.CollapseScopeIdsToAllSentinelAsync(
db,
partnerIds,
regionIdsForDto,
- locationIds,
- ScopeAllEchoHelper.ForLabelRegionScope(appliedRegionType, locationIds));
+ persistedLocationIds,
+ ScopeAllEchoHelper.ForLabelRegionScope(
+ appliedRegionType, persistedLocationIds, regionIdsFromDb));
if (string.IsNullOrWhiteSpace(storedPartnerId))
{
partnerIds = collapsed.PartnerIds;
@@ -1226,7 +1232,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
var locationDisplay = isDynamicAll
? LabelRegionScopeHelper.AllLocationsDisplay
: (await LabelRegionScopeHelper.BuildLocationDisplayAsync(
- db, appliedRegionType, locationIds)).Location;
+ db, appliedRegionType, locationIds, labelId)).Location;
var companyIdsEcho = partnerIds.Count == 1
&& !AllScopeBindingHelper.IsDeclaredAll(partnerIds[0])
@@ -1261,14 +1267,14 @@ public class LabelAppService : ApplicationService, ILabelAppService
var pid = partnerId.Trim();
if (LocationScopeBindingHelper.IsAllScopeSentinel(pid))
{
- throw new UserFriendlyException("标签适用 Company 不支持 ALL,请传单个具体 Company Id");
+ throw new UserFriendlyException("Label Company scope does not support ALL. Pass a single Company Id.");
}
if (merged.Count > 0
&& (merged.Count > 1
|| !string.Equals(merged[0], pid, StringComparison.OrdinalIgnoreCase)))
{
- throw new UserFriendlyException("partnerId 与 companyIds/partnerIds 不一致");
+ throw new UserFriendlyException("partnerId does not match companyIds/partnerIds.");
}
merged = new List { pid };
@@ -1276,13 +1282,13 @@ public class LabelAppService : ApplicationService, ILabelAppService
if (AllScopeBindingHelper.HasAllScopeSentinelSelection(merged))
{
- throw new UserFriendlyException("标签适用 Company 不支持 ALL,请传单个具体 Company Id");
+ throw new UserFriendlyException("Label Company scope does not support ALL. Pass a single Company Id.");
}
var concrete = LocationScopeBindingHelper.FilterConcreteScopeIds(merged);
if (concrete.Count > 1)
{
- throw new UserFriendlyException("标签适用 Company 仅支持单选(companyIds 最多传 1 个)");
+ throw new UserFriendlyException("Label Company scope supports only one selection (companyIds may contain at most one item).");
}
if (concrete.Count == 0)
@@ -1294,7 +1300,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.AnyAsync(x => !x.IsDeleted && x.Id == concrete[0]);
if (!exists)
{
- throw new UserFriendlyException("存在无效的 Company(partnerId/companyIds),请刷新后重试");
+ throw new UserFriendlyException("One or more Companies are invalid (partnerId/companyIds). Refresh and try again.");
}
return concrete[0];
@@ -1312,7 +1318,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
.AnyAsync(x => !x.IsDeleted && x.Id == id);
if (!exists)
{
- throw new UserFriendlyException("标签类型不存在");
+ throw new UserFriendlyException("Label type not found.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
index 69221e5..caa6d5c 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelCategoryAppService.cs
+++ b/美国版/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
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("标签分类不存在");
+ throw new UserFriendlyException("Label category not found.");
}
var dto = MapToGetOutput(entity);
@@ -174,7 +174,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
var name = input.CategoryName?.Trim();
if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("分类编码和名称不能为空");
+ throw new UserFriendlyException("Category code and name are required.");
}
var displayText = input.DisplayText?.Trim();
@@ -185,7 +185,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
.AnyAsync(x => !x.IsDeleted && (x.CategoryCode == code || x.CategoryName == name));
if (duplicated)
{
- throw new UserFriendlyException("分类编码或名称已存在");
+ throw new UserFriendlyException("Category code or name already exists.");
}
await PurgeSoftDeletedLabelCategoriesByCodeAsync(code);
@@ -225,14 +225,14 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("标签分类不存在");
+ throw new UserFriendlyException("Label category not found.");
}
var code = input.CategoryCode?.Trim();
var name = input.CategoryName?.Trim();
if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("分类编码和名称不能为空");
+ throw new UserFriendlyException("Category code and name are required.");
}
var displayText = input.DisplayText?.Trim();
@@ -243,7 +243,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
.AnyAsync(x => !x.IsDeleted && x.Id != id && (x.CategoryCode == code || x.CategoryName == name));
if (duplicated)
{
- throw new UserFriendlyException("分类编码或名称已存在");
+ throw new UserFriendlyException("Category code or name already exists.");
}
entity.CategoryCode = code;
@@ -296,7 +296,7 @@ public class LabelCategoryAppService : ApplicationService, ILabelCategoryAppServ
.AnyAsync(x => !x.IsDeleted && x.LabelCategoryId == id);
if (used)
{
- throw new UserFriendlyException("该标签分类已被标签引用,无法删除");
+ throw new UserFriendlyException("This label category is referenced by labels and cannot be deleted.");
}
await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync(
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs
index b4f32ea..fd7fae3 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelMultipleOptionAppService.cs
+++ b/美国版/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
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("多选项不存在");
+ throw new UserFriendlyException("Multiple option not found.");
}
var dto = MapToGetOutput(entity);
@@ -163,14 +163,14 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO
var name = input.OptionName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("多选项名称不能为空");
+ throw new UserFriendlyException("Multiple option name is required.");
}
var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input);
if (await IsMultipleOptionDuplicatedAsync(code, name, excludeId: null))
{
- throw new UserFriendlyException("多选项编码或名称已存在");
+ throw new UserFriendlyException("Multiple option code or name already exists.");
}
// 唯一索引含软删行:同编码已删除记录会挡住 INSERT,创建前物理清理
@@ -216,21 +216,21 @@ public class LabelMultipleOptionAppService : ApplicationService, ILabelMultipleO
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("多选项不存在");
+ throw new UserFriendlyException("Multiple option not found.");
}
var code = NormalizeOptionCode(input.OptionCode);
var name = input.OptionName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("多选项名称不能为空");
+ throw new UserFriendlyException("Multiple option name is required.");
}
var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveMultipleOptionScopeForSaveAsync(input);
if (await IsMultipleOptionDuplicatedAsync(code, name, excludeId: id))
{
- throw new UserFriendlyException("多选项编码或名称已存在");
+ throw new UserFriendlyException("Multiple option code or name already exists.");
}
entity.OptionCode = code;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTemplateAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTemplateAppService.cs
index 4983542..6132843 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTemplateAppService.cs
+++ b/美国版/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
.FirstAsync(x => !x.IsDeleted && x.TemplateCode == id);
if (template is null)
{
- throw new UserFriendlyException("模板不存在");
+ throw new UserFriendlyException("Template not found.");
}
var elements = await _dbContext.SqlSugarClient.Queryable()
@@ -251,18 +251,18 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
var name = input.TemplateName?.Trim();
if (string.IsNullOrWhiteSpace(code))
{
- throw new UserFriendlyException("模板编码不能为空");
+ throw new UserFriendlyException("Template code is required.");
}
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("模板名称不能为空");
+ throw new UserFriendlyException("Template name is required.");
}
var duplicated = await _dbContext.SqlSugarClient.Queryable()
.AnyAsync(x => !x.IsDeleted && x.TemplateCode == code);
if (duplicated)
{
- throw new UserFriendlyException("模板编码已存在");
+ throw new UserFriendlyException("Template code already exists.");
}
await PurgeSoftDeletedTemplatesByCodeAsync(code);
@@ -334,7 +334,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
.FirstAsync(x => !x.IsDeleted && x.TemplateCode == id);
if (template is null)
{
- throw new UserFriendlyException("模板不存在");
+ throw new UserFriendlyException("Template not found.");
}
var code = input.TemplateCode?.Trim();
@@ -345,7 +345,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
.AnyAsync(x => !x.IsDeleted && x.TemplateCode == code);
if (duplicated)
{
- throw new UserFriendlyException("模板编码已存在");
+ throw new UserFriendlyException("Template code already exists.");
}
}
@@ -418,7 +418,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
if (used)
{
- throw new UserFriendlyException("该模板已被标签引用,无法删除");
+ throw new UserFriendlyException("This template is referenced by labels and cannot be deleted.");
}
template.IsDeleted = true;
@@ -498,7 +498,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
var key = $"{productId}::{labelTypeId}";
if (!duplicateCheckSet.Add(key))
{
- throw new UserFriendlyException($"模板默认值绑定重复:产品[{productId}]与标签类型[{labelTypeId}]只能存在一条");
+ throw new UserFriendlyException($"Duplicate template default binding: only one row is allowed for product [{productId}] and label type [{labelTypeId}].");
}
}
@@ -514,12 +514,12 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
var labelTypeId = x.LabelTypeId?.Trim();
if (string.IsNullOrWhiteSpace(productId))
{
- throw new UserFriendlyException("模板默认值绑定中,产品Id不能为空");
+ throw new UserFriendlyException("Product Id is required in template default bindings.");
}
if (string.IsNullOrWhiteSpace(labelTypeId))
{
- throw new UserFriendlyException("模板默认值绑定中,标签类型Id不能为空");
+ throw new UserFriendlyException("Label type Id is required in template default bindings.");
}
var json = x.DefaultValues is null ? null : JsonSerializer.Serialize(x.DefaultValues);
@@ -604,7 +604,7 @@ public class LabelTemplateAppService : ApplicationService, ILabelTemplateAppServ
var normalizedName = elementName?.Trim();
if (string.IsNullOrWhiteSpace(normalizedName))
{
- throw new UserFriendlyException("组件名字不能为空");
+ throw new UserFriendlyException("Component name is required.");
}
return normalizedName;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs
index cc6bb63..5f02f51 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelTypeAppService.cs
+++ b/美国版/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
var entities = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
var ids = entities.Select(x => x.Id).ToList();
- var countMap = await BuildTypeLabelStatsMapAsync(ids, scopedLocationIds);
+ var countMap = await BuildTypeLabelStatsMapAsync(
+ ids,
+ scopedLocationIds,
+ scopedPartnerIds,
+ input.PartnerId,
+ input.GroupId,
+ input.LocationId);
var scopeMap = await BuildTypeConfiguredScopeMapAsync(entities);
var partnerScopeMap = await LabelEntityPartnerScopeHelper.BuildPartnerScopeDisplayMapAsync(
_dbContext.SqlSugarClient,
@@ -105,7 +111,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("标签类型不存在");
+ throw new UserFriendlyException("Label type not found.");
}
var dto = MapToGetOutput(entity);
@@ -162,7 +168,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
var name = input.TypeName?.Trim();
if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("类型编码和名称不能为空");
+ throw new UserFriendlyException("Type code and name are required.");
}
var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input);
@@ -171,7 +177,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
.AnyAsync(x => !x.IsDeleted && (x.TypeCode == code || x.TypeName == name));
if (duplicated)
{
- throw new UserFriendlyException("类型编码或名称已存在");
+ throw new UserFriendlyException("Type code or name already exists.");
}
// 唯一索引含软删行:同编码已删除记录会挡住 INSERT,创建前物理清理
@@ -209,14 +215,14 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("标签类型不存在");
+ throw new UserFriendlyException("Label type not found.");
}
var code = input.TypeCode?.Trim();
var name = input.TypeName?.Trim();
if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("类型编码和名称不能为空");
+ throw new UserFriendlyException("Type code and name are required.");
}
var (partnerScope, availabilityType, appliedRegionType, mergedLocationIds) = await ResolveTypeScopeForSaveAsync(input);
@@ -225,7 +231,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
.AnyAsync(x => !x.IsDeleted && x.Id != id && (x.TypeCode == code || x.TypeName == name));
if (duplicated)
{
- throw new UserFriendlyException("类型编码或名称已存在");
+ throw new UserFriendlyException("Type code or name already exists.");
}
entity.TypeCode = code;
@@ -272,7 +278,7 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
.AnyAsync(x => !x.IsDeleted && x.LabelTypeId == id);
if (used)
{
- throw new UserFriendlyException("该标签类型已被标签引用,无法删除");
+ throw new UserFriendlyException("This label type is referenced by labels and cannot be deleted.");
}
await LabelEntityPartnerScopeHelper.DeletePartnerScopeRowsAsync(
@@ -439,9 +445,16 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
await _dbContext.SqlSugarClient.Insertable(rows).ExecuteCommandAsync();
}
+ ///
+ /// 统计各类型下可见标签数量,范围与 Label 列表一致(Partner + Region/Location 动态命中)。
+ ///
private async Task> BuildTypeLabelStatsMapAsync(
List typeIds,
- List? scopedLocationIds)
+ List? scopedLocationIds,
+ List? scopedPartnerIds,
+ string? partnerId,
+ string? groupId,
+ string? locationId)
{
var result = new Dictionary(StringComparer.Ordinal);
if (typeIds.Count == 0)
@@ -449,11 +462,53 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
return result;
}
- var labelQuery = _dbContext.SqlSugarClient.Queryable()
+ var db = _dbContext.SqlSugarClient;
+ var regionSchema = await LabelRegionSchemaHelper.GetStatusAsync(db);
+ var labelQuery = db.Queryable()
.Where(x => !x.IsDeleted)
.Where(x => x.LabelTypeId != null && typeIds.Contains(x.LabelTypeId));
- labelQuery = ApplyLabelScopeOnLabels(labelQuery, scopedLocationIds);
+ labelQuery = LabelRegionScopeHelper.ApplyLabelPartnerListFilter(labelQuery, scopedPartnerIds);
+
+ var filterGroupId = groupId?.Trim();
+ var applyLocationFilter = LabelEntityListScopeHelper.ShouldApplyLocationAvailabilityFilter(
+ partnerId, groupId, locationId);
+
+ if (scopedLocationIds is not null && applyLocationFilter)
+ {
+ if (scopedLocationIds.Count == 0)
+ {
+ labelQuery = LabelRegionScopeHelper.ApplyLabelAllRegionOnlyFilter(
+ db, labelQuery, regionSchema);
+ }
+ else if (!string.IsNullOrWhiteSpace(filterGroupId))
+ {
+ labelQuery = LabelRegionScopeHelper.ApplyLabelRegionListFilter(
+ db, labelQuery, filterGroupId, scopedLocationIds, regionSchema);
+ }
+ else
+ {
+ labelQuery = LabelRegionScopeHelper.ApplyLabelLocationListFilter(
+ db, labelQuery, scopedLocationIds, regionSchema);
+ }
+ }
+ else if (!string.IsNullOrWhiteSpace(partnerId) && !applyLocationFilter)
+ {
+ if (scopedLocationIds is null)
+ {
+ // 管理员且未展开到门店:不过滤
+ }
+ else if (scopedLocationIds.Count == 0)
+ {
+ labelQuery = LabelRegionScopeHelper.ApplyLabelAllRegionOnlyFilter(
+ db, labelQuery, regionSchema);
+ }
+ else
+ {
+ labelQuery = LabelRegionScopeHelper.ApplyLabelLocationListFilter(
+ db, labelQuery, scopedLocationIds, regionSchema);
+ }
+ }
var rows = await labelQuery
.Select(x => new { x.LabelTypeId, x.CreationTime, x.LastModificationTime })
@@ -596,20 +651,6 @@ public class LabelTypeAppService : ApplicationService, ILabelTypeAppService
return result;
}
- private static ISugarQueryable ApplyLabelScopeOnLabels(
- ISugarQueryable labelQuery,
- List? scopedLocationIds)
- {
- if (scopedLocationIds is null)
- {
- return labelQuery;
- }
-
- return scopedLocationIds.Count == 0
- ? labelQuery.Where(_ => false)
- : labelQuery.Where(l => scopedLocationIds.Contains(l.LocationId));
- }
-
private sealed class TypeScopeData
{
public string Region { get; init; } = string.Empty;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LocationAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LocationAppService.cs
index 8ed4c81..796c2d9 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LocationAppService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LocationAppService.cs
@@ -13,6 +13,7 @@ using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Uow;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace FoodLabeling.Application.Services;
@@ -137,6 +138,7 @@ public class LocationAppService : ApplicationService, ILocationAppService
}
///
+ [UnitOfWork]
public async Task UpdateAsync(Guid id, [FromBody] LocationUpdateInputVo input)
{
await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext);
@@ -214,11 +216,22 @@ public class LocationAppService : ApplicationService, ILocationAppService
await _locationRepository.UpdateAsync(entity);
+ // inactive 时始终解绑 Team Member(幂等):避免已 inactive 再保存时跳过,或历史残留绑定清不掉
+ if (!entity.State)
+ {
+ await AccountStructureCascadeInactiveHelper.CascadeLocationInactiveAsync(
+ db,
+ id,
+ Clock.Now,
+ CurrentUser?.Id?.ToString());
+ }
+
var saved = await _locationRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false);
return await ToListDtoAsync(saved ?? entity);
}
///
+ [UnitOfWork]
public async Task DeleteAsync(Guid id)
{
await AccountManagementStructureHelper.EnsureCanMutateRegionAndLocationAsync(CurrentUser, _dbContext);
@@ -232,8 +245,14 @@ public class LocationAppService : ApplicationService, ILocationAppService
await AccountManagementStructureHelper.EnsureLocationPartnerAllowedForMutationAsync(
CurrentUser, _dbContext, entity.Partner);
- entity.IsDeleted = true;
- await _locationRepository.UpdateAsync(entity);
+ var db = _dbContext.SqlSugarClient;
+ var now = Clock.Now;
+ var modifierId = CurrentUser?.Id;
+ var userLocationModifierId = modifierId?.ToString();
+
+ await AccountStructureCascadeDeleteHelper.SoftDeleteLocationAsync(db, id, now, modifierId);
+ await AccountStructureCascadeDeleteHelper.SoftDeleteUserLocationBindingsForLocationAsync(
+ db, id, now, userLocationModifierId);
}
///
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PartnerAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PartnerAppService.cs
index e06f79a..54e21b0 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PartnerAppService.cs
+++ b/美国版/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
throw new UserFriendlyException("Partner not found.");
}
+ var wasActive = entity.State;
var oldName = entity.PartnerName;
var name = input.PartnerName?.Trim();
if (string.IsNullOrWhiteSpace(name))
@@ -156,12 +157,22 @@ public class PartnerAppService : ApplicationService, IPartnerAppService
entity.LastModifierId = CurrentUser?.Id?.ToString();
await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync();
+
+ if (AccountStructureCascadeInactiveHelper.IsBecomingInactive(wasActive, entity.State))
+ {
+ await AccountStructureCascadeInactiveHelper.CascadePartnerInactiveAsync(
+ _dbContext.SqlSugarClient,
+ partnerId,
+ Clock.Now,
+ CurrentUser?.Id);
+ }
+
return await GetAsync(id);
}
///
[UnitOfWork]
- public async Task DeleteAsync(Guid id)
+ public async Task DeleteAsync(Guid id, [FromQuery] bool confirmCascade = false)
{
if (id == Guid.Empty)
{
@@ -169,17 +180,45 @@ public class PartnerAppService : ApplicationService, IPartnerAppService
}
var partnerId = id.ToString();
- var entity = await _dbContext.SqlSugarClient.Queryable()
+ var db = _dbContext.SqlSugarClient;
+ var entity = await db.Queryable()
.FirstAsync(x => !x.IsDeleted && x.Id == partnerId);
if (entity is null)
{
throw new UserFriendlyException("Partner not found.");
}
- entity.IsDeleted = true;
- entity.LastModificationTime = Clock.Now;
- entity.LastModifierId = CurrentUser?.Id?.ToString();
- await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync();
+ var partnerName = entity.PartnerName?.Trim() ?? string.Empty;
+ var groupCount = await AccountStructureCascadeDeleteHelper.CountActiveGroupsByPartnerIdAsync(db, partnerId);
+ var locationCount = await AccountStructureCascadeDeleteHelper.CountActiveLocationsByPartnerNameAsync(
+ db, partnerName);
+
+ if ((groupCount > 0 || locationCount > 0) && !confirmCascade)
+ {
+ throw new UserFriendlyException(
+ AccountStructureCascadeDeleteHelper.BuildPartnerCascadeRequiredMessage(groupCount, locationCount));
+ }
+
+ var now = Clock.Now;
+ var modifierId = CurrentUser?.Id;
+ var modifierIdString = modifierId?.ToString();
+
+ if (confirmCascade && (groupCount > 0 || locationCount > 0))
+ {
+ if (locationCount > 0)
+ {
+ await AccountStructureCascadeDeleteHelper.SoftDeleteLocationsByPartnerNameAsync(
+ db, partnerName, now, modifierId, modifierIdString);
+ }
+
+ if (groupCount > 0)
+ {
+ await AccountStructureCascadeDeleteHelper.SoftDeleteGroupsByPartnerIdAsync(
+ db, partnerId, now, modifierIdString);
+ }
+ }
+
+ await AccountStructureCascadeDeleteHelper.SoftDeletePartnerAsync(db, partnerId, now, modifierIdString);
}
///
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PictureAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PictureAppService.cs
index 379a233..da530bd 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/PictureAppService.cs
+++ b/美国版/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
{
if (input.File is null || input.File.Length <= 0)
{
- throw new UserFriendlyException("请选择要上传的图片文件");
+ throw new UserFriendlyException("Please select an image file to upload.");
}
if (input.File.Length > MaxSizeBytes)
{
- throw new UserFriendlyException("图片大小不能超过5MB");
+ throw new UserFriendlyException("Image size cannot exceed 5 MB.");
}
var ext = Path.GetExtension(input.File.FileName ?? string.Empty);
if (string.IsNullOrWhiteSpace(ext) || !AllowedExtensions.Contains(ext))
{
- throw new UserFriendlyException("仅支持上传 jpg/jpeg/png/webp/gif 格式图片");
+ throw new UserFriendlyException("Only jpg/jpeg/png/webp/gif images are supported.");
}
var subDir = NormalizeSubDir(input.SubDir);
@@ -99,7 +99,7 @@ public class PictureAppService : ApplicationService, IPictureAppService
if (s.Contains("..", StringComparison.Ordinal))
{
- throw new UserFriendlyException("subDir 不能包含 ..");
+ throw new UserFriendlyException("subDir cannot contain ..");
}
return s;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductAppService.cs
index 9af7904..ecc1624 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductAppService.cs
+++ b/美国版/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
{
if (id == Guid.Empty)
{
- throw new UserFriendlyException("产品Id不能为空");
+ throw new UserFriendlyException("Product ID is required.");
}
var productId = id.ToString();
@@ -143,7 +143,7 @@ public class ProductAppService : ApplicationService, IProductAppService
if (entity is null)
{
- throw new UserFriendlyException("产品不存在");
+ throw new UserFriendlyException("Product not found.");
}
await EnsureProductVisibleToCurrentUserAsync(entity);
@@ -258,7 +258,7 @@ public class ProductAppService : ApplicationService, IProductAppService
var name = input.ProductName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("产品名称不能为空");
+ throw new UserFriendlyException("Product name is required.");
}
var code = input.ProductCode?.Trim();
@@ -272,7 +272,7 @@ public class ProductAppService : ApplicationService, IProductAppService
.AnyAsync(x => !x.IsDeleted && x.ProductCode == code);
if (duplicated)
{
- throw new UserFriendlyException("产品编码已存在");
+ throw new UserFriendlyException("Product code already exists.");
}
await PurgeSoftDeletedProductsByCodeAsync(code);
@@ -314,7 +314,7 @@ public class ProductAppService : ApplicationService, IProductAppService
{
if (id == Guid.Empty)
{
- throw new UserFriendlyException("产品Id不能为空");
+ throw new UserFriendlyException("Product ID is required.");
}
var productId = id.ToString();
@@ -322,7 +322,7 @@ public class ProductAppService : ApplicationService, IProductAppService
.FirstAsync(x => !x.IsDeleted && x.Id == productId);
if (entity is null)
{
- throw new UserFriendlyException("产品不存在");
+ throw new UserFriendlyException("Product not found.");
}
await EnsureProductVisibleToCurrentUserAsync(entity);
@@ -330,7 +330,7 @@ public class ProductAppService : ApplicationService, IProductAppService
var name = input.ProductName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("产品名称不能为空");
+ throw new UserFriendlyException("Product name is required.");
}
var codeInput = input.ProductCode?.Trim();
@@ -346,7 +346,7 @@ public class ProductAppService : ApplicationService, IProductAppService
.AnyAsync(x => !x.IsDeleted && x.Id != productId && x.ProductCode == code);
if (duplicated)
{
- throw new UserFriendlyException("产品编码已存在");
+ throw new UserFriendlyException("Product code already exists.");
}
}
@@ -379,7 +379,7 @@ public class ProductAppService : ApplicationService, IProductAppService
{
if (id == Guid.Empty)
{
- throw new UserFriendlyException("产品Id不能为空");
+ throw new UserFriendlyException("Product ID is required.");
}
var productId = id.ToString();
@@ -387,7 +387,7 @@ public class ProductAppService : ApplicationService, IProductAppService
.FirstAsync(x => !x.IsDeleted && x.Id == productId);
if (entity is null)
{
- throw new UserFriendlyException("产品不存在");
+ throw new UserFriendlyException("Product not found.");
}
await EnsureProductVisibleToCurrentUserAsync(entity);
@@ -404,19 +404,19 @@ public class ProductAppService : ApplicationService, IProductAppService
var dir = opt.TemplateDirectory?.Trim();
if (string.IsNullOrWhiteSpace(dir))
{
- throw new UserFriendlyException("未配置批量导入模板目录 FoodLabeling:BatchImport:TemplateDirectory");
+ throw new UserFriendlyException("Batch import template directory is not configured (FoodLabeling:BatchImport:TemplateDirectory).");
}
var fileName = opt.ProductTemplateFileName?.Trim();
if (string.IsNullOrWhiteSpace(fileName))
{
- throw new UserFriendlyException("未配置模板文件名 FoodLabeling:BatchImport:ProductTemplateFileName");
+ throw new UserFriendlyException("Product template file name is not configured (FoodLabeling:BatchImport:ProductTemplateFileName).");
}
var fullPath = Path.Combine(dir, fileName);
if (!File.Exists(fullPath))
{
- throw new UserFriendlyException($"模板文件不存在:{fullPath}");
+ throw new UserFriendlyException($"Template file not found: {fullPath}");
}
var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
@@ -466,19 +466,19 @@ public class ProductAppService : ApplicationService, IProductAppService
{
if (input?.File is null || input.File.Length == 0)
{
- throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)");
+ throw new UserFriendlyException("Please upload an Excel file (form field name: file).");
}
var opt = _batchImportOptions.Value;
if (input.File.Length > opt.MaxUploadBytes)
{
- throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB");
+ throw new UserFriendlyException($"File is too large. Maximum allowed size is {opt.MaxUploadBytes / 1024 / 1024} MB.");
}
var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant();
if (ext != ".xlsx")
{
- throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件");
+ throw new UserFriendlyException("Only .xlsx Excel files are supported.");
}
await using var uploadStream = input.File.OpenReadStream();
@@ -591,14 +591,14 @@ public class ProductAppService : ApplicationService, IProductAppService
{
if (input?.Items is null || input.Items.Count == 0)
{
- throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)");
+ throw new UserFriendlyException("Please submit at least one edit item (items cannot be empty).");
}
var opt = _batchImportOptions.Value;
var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems;
if (input.Items.Count > maxItems)
{
- throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交");
+ throw new UserFriendlyException($"A maximum of {maxItems} rows is allowed per bulk edit. Please submit in smaller batches.");
}
var effectiveCount = input.Items.Count(static x =>
@@ -608,7 +608,7 @@ public class ProductAppService : ApplicationService, IProductAppService
g != Guid.Empty);
if (effectiveCount == 0)
{
- throw new UserFriendlyException("没有有效的产品 Id(请为待保存行填写 Guid 格式 id)");
+ throw new UserFriendlyException("No valid product Id found. Provide a Guid-format id for rows to save.");
}
var result = new ProductBulkUpdateResultDto();
@@ -709,7 +709,7 @@ public class ProductAppService : ApplicationService, IProductAppService
{
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("登录已过期,请重新登录");
+ throw new UserFriendlyException("Session expired. Please sign in again.");
}
if (ReportsRoleHelper.IsAdminRole(CurrentUser))
@@ -726,7 +726,7 @@ public class ProductAppService : ApplicationService, IProductAppService
if (scopedLocationIds.Count == 0)
{
- throw new UserFriendlyException("无权访问该产品");
+ throw new UserFriendlyException("You do not have permission to access this product.");
}
if (string.Equals(entity.AvailabilityType, AllScopeBindingHelper.ScopeAll, StringComparison.OrdinalIgnoreCase))
@@ -765,7 +765,7 @@ public class ProductAppService : ApplicationService, IProductAppService
.ToListAsync();
if (!productLocationIds.Any(id => scopedLocationIds.Contains(id)))
{
- throw new UserFriendlyException("无权访问该产品");
+ throw new UserFriendlyException("You do not have permission to access this product.");
}
}
@@ -936,7 +936,7 @@ public class ProductAppService : ApplicationService, IProductAppService
var n = categoryName.Trim();
if (string.IsNullOrWhiteSpace(n))
{
- throw new UserFriendlyException("产品分类名称不能为空");
+ throw new UserFriendlyException("Product category name is required.");
}
var lowered = n.ToLowerInvariant();
@@ -946,12 +946,12 @@ public class ProductAppService : ApplicationService, IProductAppService
if (matches.Count == 0)
{
- throw new UserFriendlyException($"未找到产品分类「{n}」");
+ throw new UserFriendlyException($"Product category not found: {n}");
}
if (matches.Count > 1)
{
- throw new UserFriendlyException($"产品分类「{n}」存在多条记录,请在系统中使用唯一名称");
+ throw new UserFriendlyException($"Multiple product categories match \"{n}\". Use a unique name in the system.");
}
return matches[0].Id;
@@ -987,7 +987,7 @@ public class ProductAppService : ApplicationService, IProductAppService
var byId = byIdList.FirstOrDefault();
if (byId is null)
{
- throw new UserFriendlyException($"未找到门店 Id:{t}");
+ throw new UserFriendlyException($"Location Id not found: {t}");
}
return byId.Id.ToString();
@@ -1002,12 +1002,12 @@ public class ProductAppService : ApplicationService, IProductAppService
if (matches.Count == 0)
{
- throw new UserFriendlyException($"未找到门店:{t}");
+ throw new UserFriendlyException($"Location not found: {t}");
}
if (matches.Count > 1)
{
- throw new UserFriendlyException($"门店「{t}」存在多条匹配,请使用 Location Code 或 Guid");
+ throw new UserFriendlyException($"Multiple locations match \"{t}\". Use Location Code or Guid.");
}
return matches[0].Id.ToString();
@@ -1029,7 +1029,7 @@ public class ProductAppService : ApplicationService, IProductAppService
}
}
- throw new UserFriendlyException("无法生成唯一产品编码,请稍后重试或手动填写产品编码");
+ throw new UserFriendlyException("Unable to generate a unique product code. Try again later or enter a code manually.");
}
private static void ApplyProductAppearanceToEntity(FlProductDbEntity entity, ProductCreateInputVo input)
@@ -1118,13 +1118,13 @@ public class ProductAppService : ApplicationService, IProductAppService
if (AllScopeBindingHelper.HasAllScopeSentinelSelection(companyIds)
|| LocationScopeBindingHelper.IsAllScopeSentinel(input.PartnerId))
{
- throw new UserFriendlyException("产品适用 Company 不支持 ALL,请传单个具体 Company Id");
+ throw new UserFriendlyException("Product Company scope does not support ALL. Pass a single Company Id.");
}
var concreteCompanyIds = LocationScopeBindingHelper.FilterConcreteScopeIds(companyIds);
if (concreteCompanyIds.Count > 1)
{
- throw new UserFriendlyException("产品适用 Company 仅支持单选(companyIds 最多传 1 个)");
+ throw new UserFriendlyException("Product Company scope supports only one selection (companyIds may contain at most one item).");
}
var fromCompanyIds = concreteCompanyIds.Count == 1 ? concreteCompanyIds[0] : null;
@@ -1137,7 +1137,7 @@ public class ProductAppService : ApplicationService, IProductAppService
if (!string.IsNullOrWhiteSpace(fromCompanyIds)
&& !string.Equals(fromPartnerId, fromCompanyIds, StringComparison.OrdinalIgnoreCase))
{
- throw new UserFriendlyException("partnerId 与 companyIds/partnerIds 不一致");
+ throw new UserFriendlyException("partnerId does not match companyIds/partnerIds.");
}
return fromPartnerId;
@@ -1177,7 +1177,12 @@ public class ProductAppService : ApplicationService, IProductAppService
var regionHasAll = regionHasAllSentinel;
var declaredSpecified = AllScopeBindingHelper.IsDeclaredSpecified(input.AvailabilityType);
- if (!regionHasAll && groupIds.Count > 0 && explicitLocationIds.Count == 0 && !declaredSpecified)
+ var isScopedAllWithConcreteRegions = locationHasAll && groupIds.Count > 0 && !regionHasAllSentinel;
+ if (!regionHasAll
+ && groupIds.Count > 0
+ && explicitLocationIds.Count == 0
+ && !declaredSpecified
+ && !isScopedAllWithConcreteRegions)
{
var allRegions = await AllScopeBindingHelper.ResolveAllRegionIdsAsync(
_dbContext.SqlSugarClient, partnerContext);
@@ -1197,6 +1202,11 @@ public class ProductAppService : ApplicationService, IProductAppService
if (locationHasAll)
{
+ if (isScopedAllWithConcreteRegions)
+ {
+ regionHasAll = false;
+ }
+
if (regionHasAll)
{
return new ProductScopeSaveResult
@@ -1208,6 +1218,7 @@ public class ProductAppService : ApplicationService, IProductAppService
};
}
+ // Scoped ALL:部分 Region + Location ALL → SPECIFIED,不写门店快照(新区店靠 Region 动态匹配需 fl_product_region;此处展开区内门店快照)
var expandRegions = groupIds.Count > 0 ? groupIds : null;
var expanded = await LocationScopeBindingHelper.ExpandScopedAllLocationsForSaveAsync(
_dbContext.SqlSugarClient,
@@ -1402,7 +1413,7 @@ public class ProductAppService : ApplicationService, IProductAppService
|| AllScopeBindingHelper.HasAllScopeSentinelSelection(groupIds)
|| AllScopeBindingHelper.HasAllScopeSentinelSelection(locationIds))
{
- throw new UserFriendlyException("适用范围为全选(ALL),无需解析具体门店");
+ throw new UserFriendlyException("Scope is ALL; no specific locations need to be resolved.");
}
var concreteLocations = LocationScopeBindingHelper.FilterConcreteScopeIds(locationIds);
@@ -1420,7 +1431,7 @@ public class ProductAppService : ApplicationService, IProductAppService
locationIds);
if (merged.Count == 0)
{
- throw new UserFriendlyException("指定适用 Company、Region 或门店时,至少需要匹配到一个有效门店");
+ throw new UserFriendlyException("When specifying Company, Region, or Location scope, at least one valid location must match.");
}
await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductCategoryAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductCategoryAppService.cs
index b68fc0f..8f25dca 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductCategoryAppService.cs
+++ b/美国版/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
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("类别不存在");
+ throw new UserFriendlyException("Category not found.");
}
await EnsureCategoryVisibleToCurrentUserAsync(entity);
@@ -188,7 +188,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
var name = input.CategoryName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("类别名称不能为空");
+ throw new UserFriendlyException("Category name is required.");
}
var displayText = input.DisplayText?.Trim();
@@ -236,7 +236,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
.FirstAsync(x => x.Id == id && !x.IsDeleted);
if (entity is null)
{
- throw new UserFriendlyException("类别不存在");
+ throw new UserFriendlyException("Category not found.");
}
await EnsureCategoryVisibleToCurrentUserAsync(entity);
@@ -245,7 +245,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
var name = input.CategoryName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("类别名称不能为空");
+ throw new UserFriendlyException("Category name is required.");
}
var displayText = input.DisplayText?.Trim();
@@ -310,7 +310,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
.AnyAsync(x => !x.IsDeleted && x.CategoryId == id);
if (usedByProduct)
{
- throw new UserFriendlyException("该类别已被产品引用,无法删除");
+ throw new UserFriendlyException("This category is referenced by products and cannot be deleted.");
}
entity.IsDeleted = true;
@@ -452,7 +452,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
if (scopedLocationIds.Count == 0)
{
- throw new UserFriendlyException("无权访问该类别");
+ throw new UserFriendlyException("You do not have permission to access this category.");
}
if (string.Equals(entity.AvailabilityType, "ALL", StringComparison.OrdinalIgnoreCase))
@@ -464,7 +464,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
.AnyAsync(cl => cl.CategoryId == entity.Id && scopedLocationIds.Contains(cl.LocationId));
if (!visible)
{
- throw new UserFriendlyException("无权访问该类别");
+ throw new UserFriendlyException("You do not have permission to access this category.");
}
}
@@ -719,7 +719,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
{
if (await query.AnyAsync(x => x.CategoryName == name))
{
- throw new UserFriendlyException("类别名称已存在");
+ throw new UserFriendlyException("Category name already exists.");
}
return;
@@ -727,7 +727,7 @@ public class ProductCategoryAppService : ApplicationService, IProductCategoryApp
if (await query.AnyAsync(x => x.CategoryCode == code || x.CategoryName == name))
{
- throw new UserFriendlyException("类别编码或名称已存在");
+ throw new UserFriendlyException("Category code or name already exists.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductLocationAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductLocationAppService.cs
index 0bec691..b820c4f 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ProductLocationAppService.cs
+++ b/美国版/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
var locationId = id?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var hasAvailabilityColumn = await ProductScopeSchemaHelper.HasAvailabilityTypeColumnAsync(
@@ -292,7 +292,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
var locationId = input.LocationId?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var productIds = input.ProductIds?
@@ -303,20 +303,20 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
if (productIds.Count == 0)
{
- throw new UserFriendlyException("ProductIds至少1个");
+ throw new UserFriendlyException("At least one ProductId is required.");
}
// 校验门店存在
if (!Guid.TryParse(locationId, out var gid))
{
- throw new UserFriendlyException("门店Id格式不正确");
+ throw new UserFriendlyException("Invalid Location ID format.");
}
var locExists = await _dbContext.SqlSugarClient.Queryable()
.AnyAsync(x => !x.IsDeleted && x.Id == gid);
if (!locExists)
{
- throw new UserFriendlyException("门店不存在");
+ throw new UserFriendlyException("Location not found.");
}
// 校验产品存在
@@ -325,7 +325,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
.CountAsync();
if (productExistsCount != productIds.Count)
{
- throw new UserFriendlyException("产品不存在");
+ throw new UserFriendlyException("Product not found.");
}
// 去重:避免唯一键重复
@@ -358,7 +358,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
var locationId = id?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var productIds = input.ProductIds?
@@ -369,19 +369,19 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
if (productIds.Count == 0)
{
- throw new UserFriendlyException("ProductIds至少1个");
+ throw new UserFriendlyException("At least one ProductId is required.");
}
if (!Guid.TryParse(locationId, out var gid))
{
- throw new UserFriendlyException("门店Id格式不正确");
+ throw new UserFriendlyException("Invalid Location ID format.");
}
var locExists = await _dbContext.SqlSugarClient.Queryable()
.AnyAsync(x => !x.IsDeleted && x.Id == gid);
if (!locExists)
{
- throw new UserFriendlyException("门店不存在");
+ throw new UserFriendlyException("Location not found.");
}
var productExistsCount = await _dbContext.SqlSugarClient.Queryable()
@@ -389,7 +389,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
.CountAsync();
if (productExistsCount != productIds.Count)
{
- throw new UserFriendlyException("产品不存在");
+ throw new UserFriendlyException("Product not found.");
}
// 替换:先删后建
@@ -414,7 +414,7 @@ public class ProductLocationAppService : ApplicationService, IProductLocationApp
var locationId = id?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
await _dbContext.SqlSugarClient.Deleteable()
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacMenuAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacMenuAppService.cs
index 66868ba..3efe6c4 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacMenuAppService.cs
+++ b/美国版/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
.SingleAsync();
if (entity is null)
{
- throw new UserFriendlyException("权限不存在");
+ throw new UserFriendlyException("Permission not found.");
}
return new RbacMenuGetListOutputDto
@@ -80,7 +80,7 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService
var name = input.MenuName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("权限名称不能为空");
+ throw new UserFriendlyException("Permission name is required.");
}
var entity = new MenuDbEntity
@@ -114,13 +114,13 @@ public class RbacMenuAppService : ApplicationService, IRbacMenuAppService
.SingleAsync();
if (entity is null)
{
- throw new UserFriendlyException("权限不存在");
+ throw new UserFriendlyException("Permission not found.");
}
var name = input.MenuName?.Trim();
if (string.IsNullOrWhiteSpace(name))
{
- throw new UserFriendlyException("权限名称不能为空");
+ throw new UserFriendlyException("Permission name is required.");
}
entity.MenuName = name;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleAppService.cs
index b2d7086..7a54595 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleAppService.cs
+++ b/美国版/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
var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false);
if (entity is null)
{
- throw new UserFriendlyException("角色不存在");
+ throw new UserFriendlyException("Role not found.");
}
var menuIds = await _roleMenuRepository._DbQueryable
@@ -132,18 +132,18 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService
var roleCode = input.RoleCode?.Trim();
if (string.IsNullOrWhiteSpace(roleName))
{
- throw new UserFriendlyException("角色名称不能为空");
+ throw new UserFriendlyException("Role name is required.");
}
if (string.IsNullOrWhiteSpace(roleCode))
{
- throw new UserFriendlyException("角色编码不能为空");
+ throw new UserFriendlyException("Role code is required.");
}
var isExist = await _roleRepository.IsAnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName);
if (isExist)
{
- throw new UserFriendlyException("角色名称或编码已存在");
+ throw new UserFriendlyException("Role name or code already exists.");
}
var entity = new RoleAggregateRoot
@@ -173,19 +173,19 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService
var entity = await _roleRepository.GetSingleAsync(x => x.Id == id && x.IsDeleted == false);
if (entity is null)
{
- throw new UserFriendlyException("角色不存在");
+ throw new UserFriendlyException("Role not found.");
}
var roleName = input.RoleName?.Trim();
var roleCode = input.RoleCode?.Trim();
if (string.IsNullOrWhiteSpace(roleName))
{
- throw new UserFriendlyException("角色名称不能为空");
+ throw new UserFriendlyException("Role name is required.");
}
if (string.IsNullOrWhiteSpace(roleCode))
{
- throw new UserFriendlyException("角色编码不能为空");
+ throw new UserFriendlyException("Role code is required.");
}
var isExist = await _roleRepository._DbQueryable
@@ -193,7 +193,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService
.AnyAsync(x => x.RoleCode == roleCode || x.RoleName == roleName);
if (isExist)
{
- throw new UserFriendlyException("角色名称或编码已存在");
+ throw new UserFriendlyException("Role name or code already exists.");
}
entity.RoleName = roleName;
@@ -245,7 +245,7 @@ public class RbacRoleAppService : ApplicationService, IRbacRoleAppService
if (menuIds.Count == 0)
{
throw new UserFriendlyException(
- "accessPermissions 未匹配到任何菜单,请确认权限码与菜单 Router 一致,或先执行 menu_backfill_permission_code.sql 回填 Menu.PermissionCode");
+ "accessPermissions did not match any menus. Confirm permission codes match menu Router values, or run menu_backfill_permission_code.sql to backfill Menu.PermissionCode.");
}
await SetRoleMenusAsync(roleId, menuIds);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleMenuAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleMenuAppService.cs
index ff3dd07..b79f975 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/RbacRoleMenuAppService.cs
+++ b/美国版/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
var role = await _roleRepository.GetSingleAsync(x => x.Id == input.RoleId && x.IsDeleted == false);
if (role is null)
{
- throw new UserFriendlyException("角色不存在");
+ throw new UserFriendlyException("Role not found.");
}
var menuIds = input.MenuIds?.Distinct().ToList() ?? new List();
@@ -90,7 +90,7 @@ public class RbacRoleMenuAppService : ApplicationService, IRbacRoleMenuAppServic
var role = await _roleRepository.GetSingleAsync(x => x.Id == input.RoleId && x.IsDeleted == false);
if (role is null)
{
- throw new UserFriendlyException("角色不存在");
+ throw new UserFriendlyException("Role not found.");
}
var menuIds = input.MenuIds?.Distinct().ToList() ?? new List();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ReportsAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ReportsAppService.cs
index 915dceb..2ad1e39 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/ReportsAppService.cs
+++ b/美国版/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
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync(
@@ -167,12 +167,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService
QuestPDF.Settings.License = LicenseType.Community;
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync(
@@ -201,7 +201,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService
var count = await query.CountAsync();
if (count > ExportPdfMaxRows)
{
- throw new UserFriendlyException($"导出数据超过上限 {ExportPdfMaxRows} 条,请缩小筛选范围");
+ throw new UserFriendlyException($"Export exceeds the maximum of {ExportPdfMaxRows} rows. Narrow your filters and try again.");
}
var rows = await query.Take(ExportPdfMaxRows)
@@ -315,12 +315,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync(
@@ -363,7 +363,7 @@ public class ReportsAppService : ApplicationService, IReportsAppService
var count = await query.CountAsync();
if (count > ExportPdfMaxRows)
{
- throw new UserFriendlyException($"导出数据超过上限 {ExportPdfMaxRows} 条,请缩小筛选范围");
+ throw new UserFriendlyException($"Export exceeds the maximum of {ExportPdfMaxRows} rows. Narrow your filters and try again.");
}
var pageRows = await query.Take(ExportPdfMaxRows)
@@ -417,12 +417,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync(
@@ -494,12 +494,12 @@ public class ReportsAppService : ApplicationService, IReportsAppService
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync(
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TeamMemberAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TeamMemberAppService.cs
index 293c496..0af76f8 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TeamMemberAppService.cs
+++ b/美国版/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
var user = await _userRepository.GetByIdAsync(id);
if (user is null || user.IsDeleted)
{
- throw new UserFriendlyException("成员不存在");
+ throw new UserFriendlyException("Member not found.");
}
var userIdString = id.ToString();
@@ -301,7 +301,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
/// 更新请求体
/// 更新后的成员详情
/// 更新成功
- /// 参数不合法或成员不存在
+ /// 参数不合法或Member not found.
/// 服务器错误
public async Task UpdateAsync(Guid id, TeamMemberUpdateInputVo input)
{
@@ -320,7 +320,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
var user = await _userRepository.GetByIdAsync(id);
if (user is null || user.IsDeleted)
{
- throw new UserFriendlyException("成员不存在");
+ throw new UserFriendlyException("Member not found.");
}
user.Name = input.FullName.Trim();
@@ -515,19 +515,19 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
{
if (input?.File is null || input.File.Length == 0)
{
- throw new UserFriendlyException("请上传 Excel 文件(form 字段名:file)");
+ throw new UserFriendlyException("Please upload an Excel file (form field name: file).");
}
var opt = _batchImportOptions.Value;
if (input.File.Length > opt.MaxUploadBytes)
{
- throw new UserFriendlyException($"文件过大,最大允许 {opt.MaxUploadBytes / 1024 / 1024} MB");
+ throw new UserFriendlyException($"File is too large. Maximum allowed size is {opt.MaxUploadBytes / 1024 / 1024} MB.");
}
var ext = Path.GetExtension(input.File.FileName)?.ToLowerInvariant();
if (ext != ".xlsx")
{
- throw new UserFriendlyException("仅支持 .xlsx 格式的 Excel 文件");
+ throw new UserFriendlyException("Only .xlsx Excel files are supported.");
}
var roleMap = await BuildRoleNameToIdMapAsync();
@@ -589,14 +589,14 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
{
if (input?.Items is null || input.Items.Count == 0)
{
- throw new UserFriendlyException("请至少提交一条导入数据(items 不能为空)");
+ throw new UserFriendlyException("Please submit at least one import item (items cannot be empty).");
}
var opt = _batchImportOptions.Value;
var maxRows = opt.MaxImportRows <= 0 ? 5000 : opt.MaxImportRows;
if (input.Items.Count > maxRows)
{
- throw new UserFriendlyException($"单次批量导入最多允许 {maxRows} 条,请分批提交");
+ throw new UserFriendlyException($"A maximum of {maxRows} rows is allowed per batch import. Please submit in smaller batches.");
}
var defaultPassword = opt.TeamMemberImportDefaultPassword?.Trim() ?? string.Empty;
@@ -611,7 +611,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
if (string.IsNullOrEmpty(defaultPassword))
{
throw new UserFriendlyException(
- "未配置默认导入密码 FoodLabeling:BatchImport:TeamMemberImportDefaultPassword");
+ "Default import password is not configured (FoodLabeling:BatchImport:TeamMemberImportDefaultPassword).");
}
vo.Password = defaultPassword;
@@ -641,20 +641,20 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
{
if (input?.Items is null || input.Items.Count == 0)
{
- throw new UserFriendlyException("请至少提交一条编辑数据(items 不能为空)");
+ throw new UserFriendlyException("Please submit at least one edit item (items cannot be empty).");
}
var opt = _batchImportOptions.Value;
var maxItems = opt.MaxBulkUpdateItems <= 0 ? 500 : opt.MaxBulkUpdateItems;
if (input.Items.Count > maxItems)
{
- throw new UserFriendlyException($"单次批量编辑最多允许 {maxItems} 条,请分批提交");
+ throw new UserFriendlyException($"A maximum of {maxItems} rows is allowed per bulk edit. Please submit in smaller batches.");
}
var effectiveCount = input.Items.Count(static x => x is not null && x.Id != Guid.Empty);
if (effectiveCount == 0)
{
- throw new UserFriendlyException("没有有效的成员 Id(请为待保存行填写 id)");
+ throw new UserFriendlyException("No valid member Id found. Provide id for rows to save.");
}
var result = new TeamMemberBulkUpdateResultDto();
@@ -719,7 +719,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
.FirstAsync();
if (byId is null)
{
- throw new UserFriendlyException($"无效门店 Id:{key}");
+ throw new UserFriendlyException($"Invalid location Id: {key}");
}
result.Add(byId.Id.ToString());
@@ -731,7 +731,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
.FirstAsync();
if (byCode is null)
{
- throw new UserFriendlyException($"未找到门店 LocationCode:{key}(亦可填 location.Id Guid)");
+ throw new UserFriendlyException($"Location not found for LocationCode: {key} (you may also use location.Id Guid).");
}
result.Add(byCode.Id.ToString());
@@ -761,7 +761,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
.FirstAsync();
if (byId is null)
{
- throw new UserFriendlyException($"无效 Region Id:{key}");
+ throw new UserFriendlyException($"Invalid Region Id: {key}");
}
result.Add(byId.Id.Trim());
@@ -777,13 +777,13 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
if (matches.Count == 0)
{
- throw new UserFriendlyException($"未找到 Region:{key}(可填 fl_group.Id 或 GroupName)");
+ throw new UserFriendlyException($"Region not found: {key} (use fl_group.Id or GroupName).");
}
if (matches.Count > 1)
{
throw new UserFriendlyException(
- $"Region 名称「{key}」存在多条记录,请改用 fl_group.Id(Guid)");
+ $"Multiple regions match name \"{key}\". Use fl_group.Id (Guid) instead.");
}
result.Add(matches[0].Id.Trim());
@@ -1214,7 +1214,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
_dbContext.SqlSugarClient, partnerIds, null, null);
if (fromPartner.Count == 0)
{
- throw new UserFriendlyException("Company Admin 需绑定公司下门店,所选公司下暂无可用门店");
+ throw new UserFriendlyException("Company Admin must be bound to locations under the company; no locations are available under the selected Company.");
}
await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, fromPartner);
@@ -1234,8 +1234,8 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
{
throw new UserFriendlyException(
isCompanyAdmin
- ? "Company Admin 必须选择 Company,或指定 Region / 门店"
- : "成员必须至少分配一个门店(公司/区域/门店至少选一项)");
+ ? "Company Admin must select a Company, or specify Region / Location."
+ : "Member must be assigned at least one Location (select Company, Region, or Location).");
}
await LocationScopeBindingHelper.ValidateLocationIdsExistAsync(_dbContext.SqlSugarClient, merged);
@@ -1435,7 +1435,7 @@ public class TeamMemberAppService : ApplicationService, ITeamMemberAppService
.CountAsync();
if (validCount != wanted.Count)
{
- throw new UserFriendlyException("存在无效门店,请刷新后重试");
+ throw new UserFriendlyException("One or more locations are invalid. Refresh and try again.");
}
// 含已逻辑删除行:唯一键 UK_userlocation_user_location 覆盖全历史,不能对已删行再 INSERT
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppAuthAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppAuthAppService.cs
index 08d3c64..3eed67b 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppAuthAppService.cs
+++ b/美国版/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
/// 邮箱、密码;若系统开启验证码则需传 Uuid、Code
/// Token、RefreshToken 与绑定门店
/// 登录成功
- /// 参数或验证码错误
+ /// 参数或Invalid verification code.
/// 服务器错误
[AllowAnonymous]
public virtual async Task LoginAsync(UsAppLoginInputVo input)
{
if (string.IsNullOrWhiteSpace(input.Password) || string.IsNullOrWhiteSpace(input.Email))
{
- throw new UserFriendlyException("请输入合理数据!");
+ throw new UserFriendlyException("Please enter valid sign-in credentials.");
}
ValidationImageCaptcha(input.Uuid, input.Code);
@@ -105,7 +105,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
var user = await FindActiveUserByEmailAsync(input.Email.Trim());
if (user is null)
{
- throw new UserFriendlyException("登录失败!邮箱不存在!");
+ throw new UserFriendlyException("Sign-in failed: email does not exist.");
}
if (!UserPasswordHelper.VerifyPlainPassword(user, input.Password))
@@ -157,7 +157,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
{
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var list = await LoadBoundLocationsAsync(CurrentUser.Id.Value);
@@ -216,7 +216,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
await UsAppAuthScopeHelper.EnsureAppScopeCallerAsync(_dbContext.SqlSugarClient, CurrentUser);
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
return await UsAppAuthScopeHelper.SelectLocationAsync(
@@ -236,7 +236,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
/// 查询单个门店详情(Location 页):地址、门店电话、经营时间、店长(角色含 manager 的绑定用户)
///
///
- /// 仅当当前登录用户在 userlocation 中绑定该 locationId 时可查;否则返回业务异常。
+ /// 仅当当前登录用户在 userlocation 中绑定该 locationId 时可查;否则返回Business error.。
///
/// 店长:在同店绑定用户中,取 Role.RoleCode 或 Role.RoleName(忽略大小写)包含 manager 的第一条;
/// 若无匹配则店长姓名与电话均为「无」。
@@ -246,20 +246,20 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
/// 门店主键(Guid 字符串)
/// 与原型一致的展示字段
/// 成功
- /// 未登录、门店标识无效、未绑定或门店不存在
+ /// User is not signed in.、门店标识无效、未绑定或Location not found.
/// 服务器错误
[Authorize]
public virtual async Task GetLocationDetailAsync(string locationId)
{
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var lid = (locationId ?? string.Empty).Trim();
if (string.IsNullOrEmpty(lid) || !Guid.TryParse(lid, out var locationGuid))
{
- throw new UserFriendlyException("无效的门店标识");
+ throw new UserFriendlyException("Invalid location identifier.");
}
await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync(
@@ -273,7 +273,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
var loc = locRows.FirstOrDefault();
if (loc is null)
{
- throw new UserFriendlyException("门店不存在或已删除");
+ throw new UserFriendlyException("Location not found or has been removed.");
}
var (mgrName, mgrPhone) = await TryResolveStoreManagerAsync(lid);
@@ -296,14 +296,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
{
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var userId = CurrentUser.Id.Value;
var user = await _userRepository.GetByIdAsync(userId);
if (user is null || user.IsDeleted || !user.State)
{
- throw new UserFriendlyException("用户不存在或已停用");
+ throw new UserFriendlyException("User not found or disabled.");
}
// 避免 SqlSugar 在该环境下对 Role 关联表达式解析异常(Select 不支持),这里改用显式 SQL 查询角色。
@@ -341,12 +341,12 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var current = input.CurrentPassword ?? string.Empty;
@@ -355,17 +355,17 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
if (string.IsNullOrWhiteSpace(current) || string.IsNullOrWhiteSpace(newPwd) || string.IsNullOrWhiteSpace(confirm))
{
- throw new UserFriendlyException("请填写当前密码、新密码与确认密码");
+ throw new UserFriendlyException("Current password, new password, and confirmation are required.");
}
if (!string.Equals(newPwd, confirm, StringComparison.Ordinal))
{
- throw new UserFriendlyException("新密码与确认密码不一致");
+ throw new UserFriendlyException("New password and confirmation do not match.");
}
if (string.Equals(current, newPwd, StringComparison.Ordinal))
{
- throw new UserFriendlyException("新密码不能与当前密码相同");
+ throw new UserFriendlyException("New password must be different from the current password.");
}
ValidateAppPasswordComplexity(newPwd);
@@ -374,7 +374,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
var user = await _userRepository.GetByIdAsync(userId);
if (user is null || user.IsDeleted || !user.State)
{
- throw new UserFriendlyException("用户不存在或已停用");
+ throw new UserFriendlyException("User not found or disabled.");
}
if (!user.JudgePassword(current))
@@ -466,27 +466,27 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
{
if (password.Length < 8)
{
- throw new UserFriendlyException("新密码至少 8 位");
+ throw new UserFriendlyException("New password must be at least 8 characters.");
}
if (!password.Any(char.IsUpper))
{
- throw new UserFriendlyException("新密码需包含大写字母");
+ throw new UserFriendlyException("New password must contain an uppercase letter.");
}
if (!password.Any(char.IsLower))
{
- throw new UserFriendlyException("新密码需包含小写字母");
+ throw new UserFriendlyException("New password must contain a lowercase letter.");
}
if (!password.Any(char.IsDigit))
{
- throw new UserFriendlyException("新密码需包含至少一个数字");
+ throw new UserFriendlyException("New password must contain at least one digit.");
}
if (!password.Any(c => !char.IsLetterOrDigit(c)))
{
- throw new UserFriendlyException("新密码需包含至少一个特殊字符");
+ throw new UserFriendlyException("New password must contain at least one special character.");
}
}
@@ -499,7 +499,7 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService
if (!_captcha.Validate(uuid, code))
{
- throw new UserFriendlyException("验证码错误");
+ throw new UserFriendlyException("Invalid verification code.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs
index 1f79af9..af182b9 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs
+++ b/美国版/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
{
if (string.IsNullOrWhiteSpace(input.LocationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var locationId = input.LocationId.Trim();
@@ -334,7 +334,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
/// ```
///
/// 预览入参
- /// 顶部字段 + 预览模板结构
+ /// 顶部字段 + 预览模板结构(含 nutritionByElementId 营养成分 JSON)
/// 成功
/// 参数错误/数据不存在
/// 服务器错误
@@ -343,19 +343,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
var locationId = input.LocationId?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var labelCode = input.LabelCode?.Trim();
if (string.IsNullOrWhiteSpace(labelCode))
{
- throw new UserFriendlyException("labelCode不能为空");
+ throw new UserFriendlyException("labelCode is required.");
}
var labelRow = await _dbContext.SqlSugarClient
@@ -389,7 +389,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
if (labelRow is null)
{
- throw new UserFriendlyException("标签不存在或不可用");
+ throw new UserFriendlyException("Label not found or unavailable.");
}
var labelForScope = new FlLabelDbEntity
@@ -402,7 +402,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
if (!await LabelRegionScopeHelper.LabelAppliesToLocationAsync(
_dbContext.SqlSugarClient, labelForScope, locationId, storeGroupIds))
{
- throw new UserFriendlyException("该标签不属于当前门店");
+ throw new UserFriendlyException("This label does not belong to the current Location.");
}
var previewProductId = await ResolvePreviewProductIdAsync(labelRow.Id, input.ProductId);
@@ -500,11 +500,25 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
}
}
+ var nutritionByElementId = ExtractNutritionByElementId(
+ template.Elements,
+ templateProductDefaultValues);
+
if (templateProductDefaultValues is { Count: > 0 })
{
ApplyTemplateProductDefaultValuesToPreviewElements(template.Elements, templateProductDefaultValues);
}
+ if (nutritionByElementId.Count > 0)
+ {
+ ApplyNutritionFactsJsonToPreviewElements(template.Elements, nutritionByElementId);
+ foreach (var (elementId, fields) in nutritionByElementId)
+ {
+ templateProductDefaultValues ??= new Dictionary();
+ templateProductDefaultValues[elementId] = JsonSerializer.Serialize(fields);
+ }
+ }
+
return new UsAppLabelPreviewDto
{
LabelId = nextDailyLabelId,
@@ -520,7 +534,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
LabelLastEdited = labelRow.LastModificationTime ?? labelRow.CreationTime,
PreviewImageBase64Png = null,
Template = template,
- TemplateProductDefaultValues = templateProductDefaultValues
+ TemplateProductDefaultValues = templateProductDefaultValues,
+ NutritionByElementId = nutritionByElementId
};
}
@@ -542,19 +557,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
var locationId = input.LocationId?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var labelCode = input.LabelCode?.Trim();
if (string.IsNullOrWhiteSpace(labelCode))
{
- throw new UserFriendlyException("labelCode不能为空");
+ throw new UserFriendlyException("labelCode is required.");
}
var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity;
@@ -588,7 +603,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
if (labelRow is null)
{
- throw new UserFriendlyException("标签不存在或不可用");
+ throw new UserFriendlyException("Label not found or unavailable.");
}
await LabelRegionScopeHelper.EnsureLabelAppliesToLocationAsync(
@@ -733,19 +748,19 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
var locationId = input.LocationId?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var taskId = input.TaskId?.Trim();
if (string.IsNullOrWhiteSpace(taskId))
{
- throw new UserFriendlyException("taskId不能为空");
+ throw new UserFriendlyException("taskId is required.");
}
var quantity = input.PrintQuantity <= 0 ? 1 : input.PrintQuantity;
@@ -762,20 +777,20 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
var currentUserId = CurrentUser?.Id?.ToString();
if (string.IsNullOrWhiteSpace(currentUserId))
{
- throw new UserFriendlyException("未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var old = await _dbContext.SqlSugarClient.Queryable()
.FirstAsync(x => x.Id == taskId);
if (old is null)
{
- throw new UserFriendlyException("打印任务不存在");
+ throw new UserFriendlyException("Print task not found.");
}
// 已绑定该门店的账号可重打门店内任意历史任务(不限 CreatedBy)
if (!string.Equals(old.LocationId?.Trim(), locationId, StringComparison.OrdinalIgnoreCase))
{
- throw new UserFriendlyException("该任务不属于当前门店");
+ throw new UserFriendlyException("This task does not belong to the current Location.");
}
LabelTemplatePreviewDto? resolvedTemplate = null;
@@ -790,7 +805,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
if (resolvedTemplate is null)
{
- throw new UserFriendlyException("历史任务渲染快照解析失败,无法重打");
+ throw new UserFriendlyException("Failed to parse the historical task render snapshot; reprint is not available.");
}
var now = DateTime.Now;
@@ -948,7 +963,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
/// 分页查询入参
/// 分页打印日志
/// 成功
- /// 参数错误/未登录
+ /// 参数错误/User is not signed in.
/// 服务器错误
[Authorize]
[HttpPost]
@@ -956,18 +971,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationId = input.LocationId?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
var currentUserIdStr = CurrentUser.Id.Value.ToString();
@@ -1097,18 +1112,18 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
{
if (input is null)
{
- throw new UserFriendlyException("入参不能为空");
+ throw new UserFriendlyException("Request body is required.");
}
if (!CurrentUser.Id.HasValue)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
var locationId = input.LocationId?.Trim();
if (string.IsNullOrWhiteSpace(locationId))
{
- throw new UserFriendlyException("门店Id不能为空");
+ throw new UserFriendlyException("Location ID is required.");
}
await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync(
@@ -1319,6 +1334,10 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
switch (type)
{
+ case "NUTRITION":
+ case "NUTRITIONFACTS":
+ ApplyNutritionManualToConfig(cfg, ParseNutritionManualObject(stored));
+ break;
case "DATE":
case "TIME":
case "DURATION":
@@ -1373,6 +1392,297 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
}
}
+ private const string NutritionCompositeSep = "###nut###";
+
+ private static bool IsNutritionPreviewElement(LabelTemplateElementDto el)
+ {
+ var type = (el.ElementType ?? string.Empty).Trim().ToUpperInvariant();
+ if (type is "NUTRITION" or "NUTRITIONFACTS")
+ {
+ return true;
+ }
+
+ var typeAdd = (el.TypeAdd ?? string.Empty).Trim().ToUpperInvariant();
+ var name = (el.ElementName ?? string.Empty).Trim().ToUpperInvariant();
+ return typeAdd.Contains("NUTRITION", StringComparison.Ordinal)
+ || name.Contains("NUTRITION", StringComparison.Ordinal);
+ }
+
+ ///
+ /// 从标签/产品默认值中提取 Nutrition Facts JSON(elementId → 字段)。
+ ///
+ private static Dictionary> ExtractNutritionByElementId(
+ IList? elements,
+ Dictionary? defaults)
+ {
+ var result = new Dictionary>(StringComparer.Ordinal);
+ if (elements is null || elements.Count == 0 || defaults is not { Count: > 0 })
+ {
+ return result;
+ }
+
+ foreach (var el in elements)
+ {
+ if (!IsNutritionPreviewElement(el) || string.IsNullOrWhiteSpace(el.Id))
+ {
+ continue;
+ }
+
+ var manual = ResolveNutritionManualForElement(el, defaults);
+ if (manual.Count == 0)
+ {
+ continue;
+ }
+
+ result[el.Id.Trim()] = manual;
+ }
+
+ return result;
+ }
+
+ private static Dictionary ResolveNutritionManualForElement(
+ LabelTemplateElementDto el,
+ Dictionary defaults)
+ {
+ var stored = ResolveTemplateProductDefaultValueForElement(el, defaults);
+ var fromDirect = ParseNutritionManualObject(stored);
+ if (fromDirect.Count > 0)
+ {
+ return fromDirect;
+ }
+
+ var id = el.Id?.Trim() ?? string.Empty;
+ if (string.IsNullOrWhiteSpace(id))
+ {
+ return new Dictionary(StringComparer.Ordinal);
+ }
+
+ var prefix = id + NutritionCompositeSep;
+ var composite = new Dictionary(StringComparer.Ordinal);
+ foreach (var kv in defaults)
+ {
+ if (kv.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
+ {
+ composite[kv.Key[prefix.Length..]] = TemplateProductDefaultValueToStoredString(kv.Value) ?? string.Empty;
+ }
+ }
+
+ return composite;
+ }
+
+ private static Dictionary ParseNutritionManualObject(string? raw)
+ {
+ var result = new Dictionary(StringComparer.Ordinal);
+ if (string.IsNullOrWhiteSpace(raw))
+ {
+ return result;
+ }
+
+ var text = raw.Trim();
+ if (!text.StartsWith('{'))
+ {
+ return result;
+ }
+
+ try
+ {
+ using var doc = JsonDocument.Parse(text);
+ if (doc.RootElement.ValueKind != JsonValueKind.Object)
+ {
+ return result;
+ }
+
+ foreach (var prop in doc.RootElement.EnumerateObject())
+ {
+ var key = prop.Name.Trim();
+ if (string.IsNullOrWhiteSpace(key))
+ {
+ continue;
+ }
+
+ result[key] = prop.Value.ValueKind switch
+ {
+ JsonValueKind.String => prop.Value.GetString() ?? string.Empty,
+ JsonValueKind.Null => string.Empty,
+ JsonValueKind.True => "true",
+ JsonValueKind.False => "false",
+ JsonValueKind.Number => prop.Value.GetRawText(),
+ _ => prop.Value.GetRawText()
+ };
+ }
+ }
+ catch
+ {
+ return result;
+ }
+
+ return result;
+ }
+
+ private static void ApplyNutritionFactsJsonToPreviewElements(
+ IList? elements,
+ Dictionary> nutritionByElementId)
+ {
+ if (elements is null || elements.Count == 0 || nutritionByElementId.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var el in elements)
+ {
+ if (!IsNutritionPreviewElement(el) || string.IsNullOrWhiteSpace(el.Id))
+ {
+ continue;
+ }
+
+ if (!nutritionByElementId.TryGetValue(el.Id.Trim(), out var manual) || manual.Count == 0)
+ {
+ continue;
+ }
+
+ var cfg = ParsePreviewElementConfig(el.ConfigJson);
+ ApplyNutritionManualToConfig(cfg, manual);
+ el.ConfigJson = cfg;
+ }
+ }
+
+ private static void ApplyNutritionManualToConfig(
+ Dictionary cfg,
+ Dictionary manual)
+ {
+ if (manual.Count == 0)
+ {
+ return;
+ }
+
+ cfg["nutritionFactsJson"] = JsonSerializer.Serialize(manual);
+ foreach (var kv in manual)
+ {
+ var key = kv.Key?.Trim();
+ if (string.IsNullOrWhiteSpace(key))
+ {
+ continue;
+ }
+
+ cfg[key] = kv.Value ?? string.Empty;
+ }
+
+ if (TryPickNutritionField(manual, out var calories, "calories"))
+ {
+ cfg["calories"] = calories;
+ cfg["Calories"] = calories;
+ }
+
+ if (TryPickNutritionField(manual, out var servings, "servingsPerContainer", "servings"))
+ {
+ cfg["servingsPerContainer"] = servings;
+ cfg["servings"] = servings;
+ }
+
+ if (TryPickNutritionField(manual, out var servingSize, "servingSize", "serveSize"))
+ {
+ cfg["servingSize"] = servingSize;
+ cfg["serveSize"] = servingSize;
+ }
+
+ if (TryPickNutritionField(manual, out var fat, "fat", "totalFat"))
+ {
+ cfg["fat"] = fat;
+ cfg["totalFat"] = fat;
+ }
+
+ if (TryPickNutritionField(manual, out var carbs, "carbs", "totalCarbo", "totalCarbohydrate"))
+ {
+ cfg["carbs"] = carbs;
+ }
+
+ if (TryPickNutritionField(manual, out var sugars, "totalSugar", "sugars"))
+ {
+ cfg["totalSugar"] = sugars;
+ }
+
+ if (cfg.TryGetValue("fixedNutrients", out var fixedRaw) && fixedRaw is not null)
+ {
+ ApplyNutritionManualToFixedNutrients(cfg, manual);
+ }
+ }
+
+ private static bool TryPickNutritionField(
+ Dictionary manual,
+ out string value,
+ params string[] keys)
+ {
+ foreach (var key in keys)
+ {
+ foreach (var kv in manual)
+ {
+ if (string.Equals(kv.Key, key, StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrWhiteSpace(kv.Value))
+ {
+ value = kv.Value;
+ return true;
+ }
+ }
+ }
+
+ value = string.Empty;
+ return false;
+ }
+
+ private static void ApplyNutritionManualToFixedNutrients(
+ Dictionary cfg,
+ Dictionary manual)
+ {
+ try
+ {
+ var json = JsonSerializer.Serialize(cfg["fixedNutrients"]);
+ var rows = JsonSerializer.Deserialize>>(json);
+ if (rows is null || rows.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var row in rows)
+ {
+ if (!row.TryGetValue("key", out var keyObj))
+ {
+ continue;
+ }
+
+ var key = Convert.ToString(keyObj, CultureInfo.InvariantCulture)?.Trim();
+ if (string.IsNullOrWhiteSpace(key))
+ {
+ continue;
+ }
+
+ if (TryPickNutritionField(manual, out var amount, key, AliasForNutritionKey(key)))
+ {
+ row["value"] = amount;
+ }
+
+ if (TryPickNutritionField(manual, out var pct, $"{key}Percent"))
+ {
+ row["dailyValuePercent"] = pct;
+ }
+ }
+
+ cfg["fixedNutrients"] = rows;
+ }
+ catch
+ {
+ // keep original fixedNutrients when merge fails
+ }
+ }
+
+ private static string AliasForNutritionKey(string key) => key switch
+ {
+ "fat" => "totalFat",
+ "totalFat" => "fat",
+ "carbs" => "totalCarbo",
+ "totalSugar" => "sugars",
+ _ => key
+ };
+
private static string? ResolveTemplateProductDefaultValueForElement(
LabelTemplateElementDto el,
Dictionary defaults)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs
index e51810e..37d70fc 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs
+++ b/美国版/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
Task RestPasswordAsync(Guid userId, RestPasswordDto input);
///
- /// 根据信息查询用户,可能为空,代表该用户不存在或禁用
+ /// 根据信息查询用户,可能为空,代表用户不存在或已禁用
///
///
///
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs
index edad015..1bb57c7 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs
+++ b/美国版/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
var res = Regex.IsMatch(phone, @"^\d{11}$");
if (res == false)
{
- throw new UserFriendlyException("手机号码格式错误!请检查");
+ throw new UserFriendlyException("Invalid phone number format. Please check and try again.");
}
}
@@ -265,7 +265,7 @@ namespace Yi.Framework.Rbac.Application.Services
if (validationPhoneType == ValidationPhoneTypeEnum.Register &&
await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone))
{
- throw new UserFriendlyException("该手机号已被注册!");
+ throw new UserFriendlyException("This phone number is already registered.");
}
var value = await _phoneCache.GetAsync(new CaptchaPhoneCacheKey(validationPhoneType, input.Phone));
@@ -273,7 +273,7 @@ namespace Yi.Framework.Rbac.Application.Services
//防止暴刷
if (value is not null)
{
- throw new UserFriendlyException($"{input.Phone}已发送过验证码,10分钟后可重试");
+ throw new UserFriendlyException($"A verification code was already sent to {input.Phone}. Try again in 10 minutes.");
}
//生成一个4位数的验证码
@@ -306,7 +306,7 @@ namespace Yi.Framework.Rbac.Application.Services
return;
}
- throw new UserFriendlyException("验证码错误");
+ throw new UserFriendlyException("Invalid verification code.");
}
///
@@ -323,7 +323,7 @@ namespace Yi.Framework.Rbac.Application.Services
var entity = await _userRepository.GetFirstAsync(x => x.Phone == input.Phone);
if (entity is null)
{
- throw new UserFriendlyException("该手机号码未注册");
+ throw new UserFriendlyException("This phone number is not registered.");
}
await _accountManager.RestPasswordAsync(entity.Id, input.Password);
@@ -395,17 +395,17 @@ namespace Yi.Framework.Rbac.Application.Services
{
if (_rbacOptions.EnableRegister == false)
{
- throw new UserFriendlyException("该系统暂未开放注册功能");
+ throw new UserFriendlyException("Registration is not enabled for this system.");
}
if (input.Phone is null)
{
- throw new UserFriendlyException("手机号不能为空");
+ throw new UserFriendlyException("Phone number is required.");
}
//临时账号
if (input.UserName.StartsWith("ls_"))
{
- throw new UserFriendlyException("注册账号不能以ls_字符开头");
+ throw new UserFriendlyException("Registration account cannot start with ls_.");
}
if (_rbacOptions.EnableCaptcha)
@@ -442,7 +442,7 @@ namespace Yi.Framework.Rbac.Application.Services
var userId = _currentUser.Id;
if (userId is null)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
//此处优先从缓存中获取
@@ -459,7 +459,7 @@ namespace Yi.Framework.Rbac.Application.Services
.Where(x => x.State == true)
.FirstAsync();
- //该用户不存在
+ //该User not found.
if (user is null)
{
return null;
@@ -468,7 +468,7 @@ namespace Yi.Framework.Rbac.Application.Services
//注意用户名大小写数据库不敏感问题
if (userName is not null && !user.UserName.Equals(userName))
{
- throw new UserFriendlyException($"该用户名不存在或已禁用-{userName}");
+ throw new UserFriendlyException($"Username not found or disabled: {userName}");
}
var output = await _userManager.GetInfoAsync(user.Id);
@@ -487,7 +487,7 @@ namespace Yi.Framework.Rbac.Application.Services
var userId = _currentUser.Id;
if (_currentUser.Id is null)
{
- throw new AbpAuthorizationException("用户未登录");
+ throw new AbpAuthorizationException("User is not signed in.");
}
var data = await _userManager.GetInfoAsync(userId!.Value);
@@ -550,12 +550,12 @@ namespace Yi.Framework.Rbac.Application.Services
{
if (input.OldPassword.Equals(input.NewPassword))
{
- throw new UserFriendlyException("无效更新!输入的数据,新密码不能与老密码相同");
+ throw new UserFriendlyException("Invalid update: the new password cannot be the same as the current password.");
}
if (_currentUser.Id is null)
{
- throw new UserFriendlyException("用户未登录");
+ throw new UserFriendlyException("User is not signed in.");
}
await _accountManager.UpdatePasswordAsync(_currentUser.Id ?? Guid.Empty, input.NewPassword,
@@ -574,7 +574,7 @@ namespace Yi.Framework.Rbac.Application.Services
{
if (string.IsNullOrEmpty(input.Password))
{
- throw new UserFriendlyException("重置密码不能为空!");
+ throw new UserFriendlyException("Reset password cannot be empty.");
}
await _accountManager.RestPasswordAsync(userId, input.Password);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Authentication/AuthService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Authentication/AuthService.cs
index 3386af7..be3e3d2 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Authentication/AuthService.cs
+++ b/美国版/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
if (authEntity is null)
{
- throw new UserFriendlyException("第三方登录失败,请先注册后,在个人中心进行绑定该第三方后使用");
+ throw new UserFriendlyException("Third-party sign-in failed. Register first, then bind the provider in your profile.");
}
var accessToken = await _accountManager.GetTokenByUserIdAsync(authEntity.UserId);
@@ -77,7 +77,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication
var authEntityAny = await _repository.IsAnyAsync(x => x.OpenId == openId && x.AuthType == scheme);
if (authEntityAny)
{
- throw new UserFriendlyException("绑定失败,该第三方账号已被注册");
+ throw new UserFriendlyException("Binding failed: this third-party account is already registered.");
}
var authAggregateRoot = new AuthAggregateRoot(scheme, userId ?? Guid.Empty, openId, name);
@@ -90,7 +90,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication
{
if (HttpContext is null)
{
- throw new AggregateException("HttpContext 参数为空");
+ throw new AggregateException("HttpContext parameter is null.");
}
var authenticateResult = await HttpContext.AuthenticateAsync(scheme);
if (!authenticateResult.Succeeded)
@@ -178,7 +178,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication
if (isAny)
{
- throw new UserFriendlyException("该用户已有此应用授权");
+ throw new UserFriendlyException("This user already has authorization for this application.");
}
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs
index 2eb1024..0c41cdb 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/Monitor/MonitorCacheService.cs
+++ b/美国版/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
{
if (!EnableRedisCache)
{
- throw new UserFriendlyException("后端程序未使用Redis缓存,无法对Redis进行监控,可切换使用Redis");
+ throw new UserFriendlyException("Redis cache is not enabled; Redis monitoring is unavailable. Switch to Redis to enable monitoring.");
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/RoleService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/RoleService.cs
index 0c28e33..7f71720 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/RoleService.cs
+++ b/美国版/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
var count = await query.CountAsync();
if (count > exportPdfMaxRows)
{
- throw new UserFriendlyException($"导出数据超过上限 {exportPdfMaxRows} 条,请缩小筛选范围");
+ throw new UserFriendlyException($"Export exceeds the maximum of {exportPdfMaxRows} rows. Narrow your filters and try again.");
}
var rows = await query.OrderBy(x => x.OrderNum, OrderByType.Desc).Take(exportPdfMaxRows).ToListAsync();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/ConfigConst.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/ConfigConst.cs
index 5cdec63..dc43885 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/ConfigConst.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/ConfigConst.cs
@@ -2,5 +2,5 @@
public class ConfigConst
{
- public const string Exist = "该配置已经存在";
+ public const string Exist = "This configuration already exists.";
}
\ No newline at end of file
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DeptConst.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DeptConst.cs
index 830f1b5..7bb434f 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DeptConst.cs
+++ b/美国版/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
public class DeptConst
{
- public const string Exist = "该部门已经存在";
+ public const string Exist = "This department already exists.";
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DictionaryConst.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DictionaryConst.cs
index 90831f4..0dbb681 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DictionaryConst.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/DictionaryConst.cs
@@ -2,5 +2,5 @@
public class DictionaryConst
{
- public const string Exist = "该字典已经存在";
+ public const string Exist = "This dictionary entry already exists.";
}
\ No newline at end of file
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/PostConst.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/PostConst.cs
index 5c88d8d..2388a90 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/PostConst.cs
+++ b/美国版/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
public class PostConst
{
- public const string Exist = "该岗位已经存在";
+ public const string Exist = "This post already exists.";
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/RoleConst.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/RoleConst.cs
index 8cc4405..d4bfa4c 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/RoleConst.cs
+++ b/美国版/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
public class RoleConst
{
- public const string Exist = "该角色已经存在";
+ public const string Exist = "This role already exists.";
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/UserConst.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/UserConst.cs
index ba78c09..7c10c75 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Consts/UserConst.cs
+++ b/美国版/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
public class UserConst
{
- public const string Login_Error = "登录失败!用户名或密码错误!";
- public const string Login_User_No_Exist = "登录失败!用户名不存在!";
- public const string Login_Passworld_Error = "密码为空,添加失败!";
- public const string Create_Passworld_Error = "密码格式错误,长度需大于等于6位";
- public const string Exist = "用户已经存在,创建失败!";
- public const string State_Is_State = "该用户已被禁用,请联系管理员进行恢复";
- public const string No_Permission = "登录禁用!该用户分配无任何权限,无意义登录!";
- public const string No_Role = "登录禁用!该用户分配无任何角色,无意义登录!";
- public const string Name_Not_Allowed = "用户名被禁止";
- public const string Phone_Repeat = "手机号已重复";
+ public const string Login_Error = "Sign-in failed: incorrect username or password.";
+ public const string Login_User_No_Exist = "Sign-in failed: username does not exist.";
+ public const string Login_Passworld_Error = "Password is required.";
+ public const string Create_Passworld_Error = "Invalid password format. Password must be at least 6 characters.";
+ public const string Exist = "User already exists.";
+ public const string State_Is_State = "This account has been disabled. Contact an administrator.";
+ public const string No_Permission = "Sign-in disabled: this user has no permissions assigned.";
+ public const string No_Role = "Sign-in disabled: this user has no roles assigned.";
+ public const string Name_Not_Allowed = "Username is not allowed.";
+ public const string Phone_Repeat = "Phone number already in use.";
//子租户管理员
public const string Admin = "admin";
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Helpers/UserPasswordHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Helpers/UserPasswordHelper.cs
index fb8d291..274e204 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Helpers/UserPasswordHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Helpers/UserPasswordHelper.cs
@@ -18,7 +18,7 @@ public static class UserPasswordHelper
{
if (string.IsNullOrWhiteSpace(plainPassword))
{
- throw new UserFriendlyException("密码不能为空");
+ throw new UserFriendlyException("Password is required.");
}
user.EncryPassword ??= new EncryPasswordValueObject();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs
index 2a766a1..1ae7224 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs
+++ b/美国版/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
if (!user.JudgePassword(oldPassword))
{
- throw new UserFriendlyException("无效更新!原密码错误!");
+ throw new UserFriendlyException("Invalid update: current password is incorrect.");
}
UserPasswordHelper.ApplyPlainPassword(user, newPassword);
await _repository.UpdateAsync(user);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AliyunManger.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AliyunManger.cs
index 7036b24..d6c56bf 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AliyunManger.cs
+++ b/美国版/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
catch (Exception _error)
{
- _logger.LogError(_error, "阿里云短信发送错误:" + _error.Message);
- throw new UserFriendlyException("阿里云短信发送错误:" + _error.Message);
+ _logger.LogError(_error, "Aliyun SMS send error:" + _error.Message);
+ throw new UserFriendlyException("Aliyun SMS send error:" + _error.Message);
}
}
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/UserManager.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/UserManager.cs
index d826efa..c12cb72 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/UserManager.cs
+++ b/美国版/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
{
if (input.UserName == UserConst.Admin || input.UserName == UserConst.TenantAdmin)
{
- throw new UserFriendlyException("用户名无效注册!");
+ throw new UserFriendlyException("Invalid username for registration.");
}
if (input.UserName.Length < 2)
{
- throw new UserFriendlyException("账号名需大于等于2位!");
+ throw new UserFriendlyException("Account name must be at least 2 characters.");
}
// 正则表达式,匹配只包含数字和字母的字符串
@@ -158,7 +158,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
bool isMatch = Regex.IsMatch(input.UserName, pattern);
if (!isMatch)
{
- throw new UserFriendlyException("用户名不能包含除【字母】与【数字】与【_】的其他字符");
+ throw new UserFriendlyException("Username may contain only letters, digits, and underscore (_).");
}
}
@@ -235,7 +235,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
if (user is null)
{
//为了解决token前端缓存,后端数据库重新dbseed
- throw new UserFriendlyException($"数据错误,查询用户不存在,请重新登录");
+ throw new UserFriendlyException("Data error: user not found. Please sign in again.");
}
user.EncryPassword.Password = string.Empty;
user.EncryPassword.Salt = string.Empty;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
index b21fab3..60a6b23 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Application/Services/TestService.cs
@@ -48,7 +48,7 @@ namespace Yi.Abp.Application.Services
[HttpGet("error")]
public string GetError()
{
- throw new UserFriendlyException("业务异常");
+ throw new UserFriendlyException("Business error.");
throw new Exception("系统异常");
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
index bb6dd53..ac190b3 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
@@ -27,7 +27,6 @@
"Settings": {
"Test": "hello"
},
-
//数据库类型列表
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle", "PostgreSQL" ],