Files
TakeoutSaaS.AdminApi/src/Application/TakeoutSaaS.Application/App/Tenants/Queries/GetTenantsAnnouncementsQuery.cs
MSuMshk 755b61a044 fix: 修复公告模块核心问题并完善功能
主要修复内容:
1. 修复 RowVersion 并发控制
   - 配置 EF Core RowVersion 映射为 bytea 类型
   - 添加 PostgreSQL 触发器自动生成 RowVersion
   - 在更新/发布/撤销操作中添加 RowVersion 校验
   - 移除 Application 层对 EF Core 的直接依赖

2. 修复 API 路由和校验问题
   - 添加平台公告列表路由的版本化别名
   - 租户公告接口添加 X-Tenant-Id 必填校验,返回 400
   - 生效时间校验返回 422 而非 500
   - 修复 FluentValidation 异常命名冲突

3. 实现关键词搜索功能
   - 在查询参数中添加 keyword 字段
   - 使用 PostgreSQL ILIKE 实现大小写不敏感搜索
   - 支持标题和内容字段的模糊匹配

4. 数据库迁移
   - 新增 RowVersion 触发器迁移文件
   - 回填现有公告记录的 RowVersion
2025-12-26 09:16:07 +08:00

63 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using MediatR;
using TakeoutSaaS.Application.App.Tenants.Dto;
using TakeoutSaaS.Domain.Tenants.Enums;
using TakeoutSaaS.Shared.Abstractions.Results;
namespace TakeoutSaaS.Application.App.Tenants.Queries;
/// <summary>
/// 分页查询租户公告。
/// </summary>
public sealed record GetTenantsAnnouncementsQuery : IRequest<PagedResult<TenantAnnouncementDto>>
{
/// <summary>
/// 租户 ID雪花算法
/// </summary>
public long TenantId { get; init; }
/// <summary>
/// 公告类型筛选。
/// </summary>
public TenantAnnouncementType? AnnouncementType { get; init; }
/// <summary>
/// 公告状态筛选。
/// </summary>
public AnnouncementStatus? Status { get; init; }
/// <summary>
/// 关键词搜索(标题/内容)。
/// </summary>
public string? Keyword { get; init; }
/// <summary>
/// 是否筛选启用状态。
/// </summary>
public bool? IsActive { get; init; }
/// <summary>
/// 生效开始时间筛选UTC
/// </summary>
public DateTime? EffectiveFrom { get; init; }
/// <summary>
/// 生效结束时间筛选UTC
/// </summary>
public DateTime? EffectiveTo { get; init; }
/// <summary>
/// 仅返回当前有效期内的公告。
/// </summary>
public bool? OnlyEffective { get; init; }
/// <summary>
/// 页码(从 1 开始)。
/// </summary>
public int Page { get; init; } = 1;
/// <summary>
/// 每页条数。
/// </summary>
public int PageSize { get; init; } = 20;
}