using System.ComponentModel.DataAnnotations; using System.Text.Json; using Tiku.Application.Assets; namespace Tiku.Api.Contracts; /// /// 视频Search查询参数。 /// public sealed class VideoSearchQueryDto { /// /// 关键字。 /// [StringLength(100)] public string? Keyword { get; set; } /// /// 科目 ID。 /// public Guid? SubjectId { get; set; } /// /// 返回数量上限。 /// [Range(1, 200)] public int? Limit { get; set; } public VideoSearchQuery ToQuery() => new(Keyword, SubjectId, Limit); } /// /// 视频Play请求 DTO。 /// public sealed class VideoPlayDto { /// /// 视频 ID。 /// [Required] public Guid VideoId { get; set; } /// /// 题目 ID。 /// public Guid? QuestionId { get; set; } public VideoPlayCommand ToCommand() => new(VideoId, QuestionId); } /// /// 视频Progress请求 DTO。 /// public sealed class VideoProgressDto { /// /// 视频 ID。 /// [Required] public Guid VideoId { get; set; } /// /// 题目 ID。 /// public Guid? QuestionId { get; set; } /// /// 播放位置,单位为秒。 /// [Range(0, int.MaxValue)] public int PositionSeconds { get; set; } /// /// 时长,单位为秒。 /// [Range(0, int.MaxValue)] public int? DurationSeconds { get; set; } /// /// 已观看时长,单位为秒。 /// [Range(0, int.MaxValue)] public int? WatchedSeconds { get; set; } /// /// 是否已完成。 /// public bool? IsCompleted { get; set; } /// /// 扩展元数据。 /// public JsonElement Metadata { get; set; } = JsonSerializer.SerializeToElement(new { }); public VideoProgressCommand ToCommand() { return new VideoProgressCommand( VideoId, QuestionId, PositionSeconds, DurationSeconds, WatchedSeconds, IsCompleted, Metadata); } } /// /// 题目视频查询参数。 /// public sealed class QuestionVideoQueryDto { /// /// 题目 ID。 /// public Guid? QuestionId { get; set; } /// /// 题目 ID 列表。 /// [MaxLength(100)] public IReadOnlyCollection? QuestionIds { get; set; } /// /// 返回数量上限。 /// [Range(1, 500)] public int? Limit { get; set; } public QuestionVideoQuery ToQuery() => new(QuestionId, QuestionIds, Limit); }