Enhance app management with 'IsRecommended' feature
- Added 'IsRecommended' property to app-related data models, allowing apps to be marked as recommended. - Updated API endpoints for creating and updating apps to include 'IsRecommended' in request bodies. - Modified database schema to accommodate the new 'IsRecommended' field. - Enhanced frontend components to display recommended apps with a star icon and updated forms to manage this property. - Improved sorting logic in app listings to prioritize recommended apps. - Updated documentation to reflect changes in API and data models.
This commit is contained in:
@@ -10,7 +10,8 @@ public sealed record AdminAppDto(
|
||||
string? Description,
|
||||
string? IconUrl,
|
||||
int SortOrder,
|
||||
bool IsEnabled
|
||||
bool IsEnabled,
|
||||
bool IsRecommended
|
||||
)
|
||||
{
|
||||
public static AdminAppDto FromDomain(ClientApp app) =>
|
||||
@@ -22,6 +23,7 @@ public sealed record AdminAppDto(
|
||||
app.Description,
|
||||
app.IconUrl,
|
||||
app.SortOrder,
|
||||
app.IsEnabled
|
||||
app.IsEnabled,
|
||||
app.IsRecommended
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@ public sealed record CreateAppCommand(
|
||||
OsPlatform OperatingSystem,
|
||||
string? Description,
|
||||
string? IconUrl,
|
||||
int SortOrder
|
||||
int SortOrder,
|
||||
bool IsRecommended
|
||||
) : ICommand<Result<AdminAppDto>>;
|
||||
|
||||
@@ -19,7 +19,8 @@ public sealed class CreateAppCommandHandler(IAppDbContext dbContext)
|
||||
command.OperatingSystem,
|
||||
command.Description,
|
||||
command.IconUrl,
|
||||
command.SortOrder
|
||||
command.SortOrder,
|
||||
command.IsRecommended
|
||||
);
|
||||
|
||||
dbContext.ClientApps.Add(app);
|
||||
|
||||
@@ -12,5 +12,6 @@ public sealed record UpdateAppCommand(
|
||||
string? Description,
|
||||
string? IconUrl,
|
||||
int SortOrder,
|
||||
bool IsEnabled
|
||||
bool IsEnabled,
|
||||
bool IsRecommended
|
||||
) : ICommand<Result<AdminAppDto>>;
|
||||
|
||||
@@ -27,7 +27,8 @@ public sealed class UpdateAppCommandHandler(IAppDbContext dbContext)
|
||||
command.Description,
|
||||
command.IconUrl,
|
||||
command.SortOrder,
|
||||
command.IsEnabled
|
||||
command.IsEnabled,
|
||||
command.IsRecommended
|
||||
);
|
||||
|
||||
return Result.Success(AdminAppDto.FromDomain(app));
|
||||
|
||||
@@ -7,9 +7,17 @@ public sealed record ClientAppDto(
|
||||
string Name,
|
||||
string DownloadUrl,
|
||||
string? Description,
|
||||
string? IconUrl
|
||||
string? IconUrl,
|
||||
bool IsRecommended
|
||||
)
|
||||
{
|
||||
public static ClientAppDto FromDomain(ClientApp app) =>
|
||||
new(app.Id, app.Name, app.DownloadUrl.ToString(), app.Description, app.IconUrl);
|
||||
new(
|
||||
app.Id,
|
||||
app.Name,
|
||||
app.DownloadUrl.ToString(),
|
||||
app.Description,
|
||||
app.IconUrl,
|
||||
app.IsRecommended
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ public sealed class ListAppsQueryHandler(IAppDbContext dbContext)
|
||||
var apps = await dbContext
|
||||
.ClientApps.AsNoTracking()
|
||||
.Where(a => a.IsEnabled)
|
||||
.OrderBy(a => a.SortOrder)
|
||||
.OrderByDescending(a => a.IsRecommended)
|
||||
.ThenBy(a => a.SortOrder)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var grouped = apps.GroupBy(a => a.OperatingSystem)
|
||||
|
||||
Reference in New Issue
Block a user