diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsLabelReportOutputDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsLabelReportOutputDto.cs index aacfd87..b413c7a 100644 --- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsLabelReportOutputDto.cs +++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Reports/ReportsLabelReportOutputDto.cs @@ -26,11 +26,11 @@ public class ReportsLabelReportSummaryDto /// 相对上一同长周期变化率(百分比,如 20.1 表示 +20.1%) public decimal TotalLabelsPrintedChangeRate { get; set; } - public string MostPrintedCategoryName { get; set; } = "无"; + public string? MostPrintedCategoryName { get; set; } public int MostPrintedCategoryCount { get; set; } - public string TopProductName { get; set; } = "无"; + public string? TopProductName { get; set; } public int TopProductCount { get; set; } @@ -43,9 +43,9 @@ public class ReportsLabelReportSummaryDto public class ReportsCategoryCountDto { - public string CategoryId { get; set; } = string.Empty; + public string? CategoryId { get; set; } - public string CategoryName { get; set; } = "无"; + public string? CategoryName { get; set; } public int Count { get; set; } } @@ -59,11 +59,11 @@ public class ReportsDailyCountDto public class ReportsTopProductRowDto { - public string ProductId { get; set; } = string.Empty; + public string? ProductId { get; set; } - public string ProductName { get; set; } = "无"; + public string? ProductName { get; set; } - public string CategoryName { get; set; } = "无"; + public string? CategoryName { get; set; } public int TotalPrinted { get; set; } 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 1218b35..8640cec 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 @@ -368,8 +368,8 @@ public class ReportsAppService : ApplicationService, IReportsAppService .OrderByDescending(x => x.Cnt) .Select(x => new ReportsCategoryCountDto { - CategoryId = x.Id ?? string.Empty, - CategoryName = string.IsNullOrWhiteSpace(x.CategoryName) ? "无" : x.CategoryName.Trim(), + CategoryId = string.IsNullOrWhiteSpace(x.Id) ? null : x.Id.Trim(), + CategoryName = string.IsNullOrWhiteSpace(x.CategoryName) ? null : x.CategoryName.Trim(), Count = x.Cnt }) .ToList(); @@ -379,9 +379,9 @@ public class ReportsAppService : ApplicationService, IReportsAppService var pct = totalCur <= 0 ? 0m : Math.Round(x.Cnt * 100m / totalCur, 2); return new ReportsTopProductRowDto { - ProductId = x.Id ?? string.Empty, - ProductName = string.IsNullOrWhiteSpace(x.ProductName) ? "无" : x.ProductName.Trim(), - CategoryName = string.IsNullOrWhiteSpace(x.CategoryName) ? "无" : x.CategoryName!.Trim(), + ProductId = string.IsNullOrWhiteSpace(x.Id) ? null : x.Id.Trim(), + ProductName = string.IsNullOrWhiteSpace(x.ProductName) ? null : x.ProductName.Trim(), + CategoryName = string.IsNullOrWhiteSpace(x.CategoryName) ? null : x.CategoryName!.Trim(), TotalPrinted = x.Cnt, UsagePercent = pct }; @@ -394,9 +394,9 @@ public class ReportsAppService : ApplicationService, IReportsAppService TotalLabelsPrinted = totalCur, TotalLabelsPrintedPrevPeriod = totalPrev, TotalLabelsPrintedChangeRate = CalcChangeRate(totalCur, totalPrev), - MostPrintedCategoryName = topCat is null ? "无" : (topCat.CategoryName?.Trim() ?? "无"), + MostPrintedCategoryName = string.IsNullOrWhiteSpace(topCat?.CategoryName) ? null : topCat.CategoryName.Trim(), MostPrintedCategoryCount = topCat?.Cnt ?? 0, - TopProductName = topProd is null ? "无" : (topProd.ProductName?.Trim() ?? "无"), + TopProductName = string.IsNullOrWhiteSpace(topProd?.ProductName) ? null : topProd.ProductName.Trim(), TopProductCount = topProd?.Cnt ?? 0, AvgDailyPrints = avgDaily, AvgDailyPrintsPrevPeriod = avgDailyPrev, 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 44ebf48..4afa3f5 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 @@ -214,11 +214,14 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService throw new UserFriendlyException("用户不存在或已停用"); } - var roleRows = await _dbContext.SqlSugarClient.Queryable((ur, r) => ur.RoleId == r.Id) - .Where((ur, r) => ur.UserId == userId && !r.IsDeleted && r.State) - .OrderBy((ur, r) => r.OrderNum) - .Select((ur, r) => new { r.RoleName, r.RoleCode }) - .ToListAsync(); + // 避免 SqlSugar 在该环境下对 Role 关联表达式解析异常(Select 不支持),这里改用显式 SQL 查询角色。 + var roleRows = await _dbContext.SqlSugarClient.Ado.SqlQueryAsync( + @"SELECT r.RoleName, r.RoleCode + FROM UserRole ur + INNER JOIN Role r ON ur.RoleId = r.Id + WHERE ur.UserId = @UserId AND r.IsDeleted = 0 AND r.State = 1 + ORDER BY r.OrderNum ASC", + new { UserId = userId }); var roleNames = roleRows.Select(x => x.RoleName?.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)).ToList(); var roleDisplay = roleNames.Count == 0 ? "无" : string.Join(", ", roleNames); @@ -338,22 +341,19 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService return ("无", "无"); } - var rows = await _dbContext.SqlSugarClient.Queryable( - (u, ur, r) => u.Id == ur.UserId && ur.RoleId == r.Id) - .Where((u, ur, r) => userGuids.Contains(u.Id) && !u.IsDeleted && u.State) - .Where((u, ur, r) => !r.IsDeleted && r.State) - .Where((u, ur, r) => - SqlFunc.ToLower(r.RoleCode).Contains("manager") || - SqlFunc.ToLower(r.RoleName).Contains("manager")) - .OrderBy((u, ur, r) => u.Name) - .Select((u, ur, r) => new - { - u.Name, - u.Nick, - u.UserName, - u.Phone - }) - .ToListAsync(); + var rows = await _dbContext.SqlSugarClient.Ado.SqlQueryAsync( + @"SELECT u.Name, u.Nick, u.UserName, u.Phone + FROM User u + INNER JOIN UserRole ur ON u.Id = ur.UserId + INNER JOIN Role r ON ur.RoleId = r.Id + WHERE u.IsDeleted = 0 + AND u.State = 1 + AND r.IsDeleted = 0 + AND r.State = 1 + AND (LOWER(r.RoleCode) LIKE '%manager%' OR LOWER(r.RoleName) LIKE '%manager%') + AND u.Id IN (@UserIds) + ORDER BY u.Name ASC", + new { UserIds = userGuids }); var row = rows.FirstOrDefault(); if (row is null) @@ -520,4 +520,22 @@ public class UsAppAuthAppService : ApplicationService, IUsAppAuthAppService return segments.Count == 0 ? "无" : string.Join(", ", segments); } + + private sealed class MyProfileRoleRow + { + public string? RoleName { get; set; } + + public string? RoleCode { get; set; } + } + + private sealed class LocationManagerRow + { + public string? Name { get; set; } + + public string? Nick { get; set; } + + public string? UserName { get; set; } + + public long? Phone { get; set; } + } } diff --git a/项目相关文档/美国版App登录接口说明.md b/项目相关文档/美国版App登录接口说明.md index 9da9fa1..1e57ff8 100644 --- a/项目相关文档/美国版App登录接口说明.md +++ b/项目相关文档/美国版App登录接口说明.md @@ -233,19 +233,19 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ### HTTP - **方法**:`GET` -- **路径**:`/api/app/us-app-auth/location-detail`(以 Swagger 中 `UsAppAuth` → `GetLocationDetail` 为准;`locationId` 一般为 **Query** 参数) +- **路径**:`/api/app/us-app-auth/location-detail/{locationId}`(以 Swagger 中 `UsAppAuth` → `GetLocationDetail` 为准) - **鉴权**:需要登录(`Authorization: Bearer {token}`) ### 请求参数 | 参数名 | 位置 | 类型 | 必填 | 说明 | |--------|------|------|------|------| -| `locationId` | Query | string | 是 | 门店主键,Guid 字符串(与 `locations[].id` 一致) | +| `locationId` | Path | string | 是 | 门店主键,Guid 字符串(与 `locations[].id` 一致) | ### 传参示例 ```http -GET /api/app/us-app-auth/location-detail?locationId=a2696b9e-2277-11f1-b4c6-00163e0c7c4f HTTP/1.1 +GET /api/app/us-app-auth/location-detail/a2696b9e-2277-11f1-b4c6-00163e0c7c4f HTTP/1.1 Host: localhost:19001 Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ```