using System.ComponentModel.DataAnnotations; using System.Text.Json; using Tiku.Application.Learning; using Tiku.Application.QuestionBanks; using Tiku.Domain.Common; using Tiku.Domain.Content; namespace Tiku.Api.Contracts; /// /// 学习Limit查询参数。 /// public sealed class LearningLimitQueryDto { /// /// 返回数量上限。 /// [Range(1, 500)] public int? Limit { get; set; } /// /// 状态。 /// [StringLength(50)] public string? Status { get; set; } /// /// 单元 ID。 /// public Guid? UnitId { get; set; } public LearningLimitFilter ToFilter() { return new LearningLimitFilter(Limit, Status, UnitId); } } /// /// 练习会话查询参数。 /// public sealed class PracticeSessionQueryDto { /// /// 练习会话 ID。 /// public Guid? PracticeSessionId { get; set; } /// /// 练习蓝图 ID。 /// public Guid? BlueprintId { get; set; } /// /// 模式。 /// [StringLength(50)] public string? Mode { get; set; } /// /// 状态。 /// [StringLength(50)] public string? Status { get; set; } /// /// 返回数量上限。 /// [Range(1, 200)] public int? Limit { get; set; } public PracticeSessionFilter ToFilter(Guid? routePracticeSessionId = null) { return new PracticeSessionFilter( routePracticeSessionId ?? PracticeSessionId, BlueprintId, Mode, Status, Limit); } } /// /// 创建练习会话请求 DTO。 /// public sealed class CreatePracticeSessionDto { /// /// 模式。 /// [StringLength(50)] public string? Mode { get; set; } /// /// 目标类型。 /// [StringLength(50)] public string? TargetType { get; set; } /// /// 目标 ID。 /// public Guid? TargetId { get; set; } /// /// 练习蓝图 ID。 /// public Guid? BlueprintId { get; set; } /// /// 题集 ID。 /// public Guid? CollectionId { get; set; } /// /// 内容入口 ID。 /// public Guid? EntryId { get; set; } /// /// 内容节点 ID。 /// public Guid? ContentNodeId { get; set; } /// /// 题目数量上限。 /// [Range(1, 500)] public int? QuestionLimit { get; set; } /// /// 时长,单位为分钟。 /// [Range(1, 1440)] public int? DurationMinutes { get; set; } /// /// 总分。 /// [Range(typeof(decimal), "0", "99999")] public decimal? TotalScore { get; set; } /// /// 扩展元数据。 /// public JsonElement Metadata { get; set; } = JsonDefaults.Object(); public PracticeSessionCommand ToCommand() { return new PracticeSessionCommand( Mode, TargetType, TargetId, BlueprintId, CollectionId, EntryId, ContentNodeId, QuestionLimit, DurationMinutes, TotalScore, Metadata); } } /// /// 提交练习会话请求 DTO。 /// public sealed class SubmitPracticeSessionDto { /// /// 练习会话 ID。 /// [Required] public Guid PracticeSessionId { get; set; } public PracticeSessionFilter ToFilter() { return new PracticeSessionFilter(PracticeSessionId); } } /// /// 提交答案请求 DTO。 /// public sealed class SubmitAnswerDto { /// /// 会话题目 ID。 /// [Required] public Guid SessionQuestionId { get; set; } /// /// 已选选项。 /// public IReadOnlyCollection? SelectedOptions { get; set; } /// /// 文字答案。 /// [StringLength(10000)] public string? AnswerText { get; set; } /// /// 主观题自评是否正确。 /// public bool? SelfJudgedCorrect { get; set; } public SubmitAnswerCommand ToCommand() { return new SubmitAnswerCommand( SessionQuestionId, SelectedOptions, AnswerText, SelfJudgedCorrect); } } /// /// 题目Action请求 DTO。 /// public sealed class QuestionActionDto { /// /// 题目 ID。 /// [Required] public Guid QuestionId { get; set; } /// /// 来源。 /// [Required] public QuestionSource Source { get; set; } = QuestionSource.Tenant; /// /// 是否收藏。 /// public bool? Favorite { get; set; } public QuestionActionCommand ToCommand() { return new QuestionActionCommand(new QuestionLocator(Source, QuestionId), Favorite); } } /// /// 单词Progress请求 DTO。 /// public sealed class WordProgressDto { /// /// 单词 ID。 /// [Required] public Guid WordId { get; set; } /// /// 状态。 /// [StringLength(50)] public string? Status { get; set; } /// /// 答对数量变化。 /// [Range(0, 100)] public int? CorrectDelta { get; set; } /// /// 答错数量变化。 /// [Range(0, 100)] public int? WrongDelta { get; set; } /// /// 下次复习时间。 /// public DateTimeOffset? NextReviewAt { get; set; } public WordProgressCommand ToCommand() { return new WordProgressCommand( WordId, Status, CorrectDelta, WrongDelta, NextReviewAt); } } /// /// 收藏单词请求 DTO。 /// public sealed class FavoriteWordDto { /// /// 单词 ID。 /// [Required] public Guid WordId { get; set; } /// /// 是否收藏。 /// public bool? Favorite { get; set; } /// /// 备注。 /// [StringLength(1000)] public string? Note { get; set; } public FavoriteWordCommand ToCommand() { return new FavoriteWordCommand(WordId, Favorite, Note); } } /// /// 单词Review请求 DTO。 /// public sealed class WordReviewDto { /// /// 单词 ID。 /// [Required] public Guid WordId { get; set; } /// /// 结果。 /// [StringLength(50)] public string? Result { get; set; } /// /// 下次复习时间。 /// public DateTimeOffset? NextReviewAt { get; set; } public WordReviewCommand ToCommand() { return new WordReviewCommand(WordId, Result, NextReviewAt); } }