feat: add student engagement endpoints

This commit is contained in:
xiong
2026-07-26 18:39:55 +08:00
parent 387b85342a
commit 89e1f2a4df
5 changed files with 547 additions and 0 deletions

View File

@@ -11,6 +11,17 @@ public sealed class ProfileQueryDto
[Range(1, 20)]
public int? Limit { get; set; }
[StringLength(32)]
public string? Status { get; set; }
[StringLength(50)]
public string? Type { get; set; }
[StringLength(50)]
public string? Category { get; set; }
public bool IncludeLocked { get; set; }
}
public sealed class UpdateProfileDto
@@ -43,3 +54,60 @@ public sealed class UpdateProfileDto
RecentActivities);
}
}
public sealed class NotificationStatusDto
{
[Required]
[MinLength(1)]
[MaxLength(100)]
public IReadOnlyCollection<Guid> NotificationIds { get; set; } = [];
[StringLength(32)]
public string? Status { get; set; }
public UpdateNotificationStatusCommand ToCommand()
{
return new UpdateNotificationStatusCommand(NotificationIds, Status);
}
}
public sealed class SubmitFeedbackDto
{
public Guid? QuestionId { get; set; }
[StringLength(50)]
public string? Type { get; set; }
[StringLength(100)]
public string? Category { get; set; }
[StringLength(200)]
public string? Title { get; set; }
[Required]
[StringLength(5000)]
public string Description { get; set; } = string.Empty;
[StringLength(32)]
public string? Priority { get; set; }
[StringLength(200)]
public string? Contact { get; set; }
public JsonElement Attachments { get; set; } = JsonSerializer.SerializeToElement(Array.Empty<object>());
public JsonElement Metadata { get; set; } = JsonSerializer.SerializeToElement(new { });
public SubmitFeedbackCommand ToCommand()
{
return new SubmitFeedbackCommand(
QuestionId,
Type,
Category,
Title,
Description,
Priority,
Contact,
Attachments,
Metadata);
}
}

View File

@@ -55,6 +55,71 @@ public sealed class ProfileController(
cancellationToken));
}
[HttpGet("notifications")]
[EndpointSummary("查询用户通知")]
[ProducesResponseType<ProfileNotificationList>(StatusCodes.Status200OK)]
public async Task<ActionResult<ProfileNotificationList>> Notifications(
[FromQuery] ProfileQueryDto query,
CancellationToken cancellationToken)
{
return Ok(await profileService.GetNotificationsAsync(
ResolveActor(),
new ProfileNotificationQuery(query.Status, query.Limit),
cancellationToken));
}
[HttpPost("notifications/status")]
[EndpointSummary("更新通知状态")]
[ProducesResponseType<ProfileNotificationList>(StatusCodes.Status200OK)]
public async Task<ActionResult<ProfileNotificationList>> UpdateNotificationStatus(
NotificationStatusDto request,
CancellationToken cancellationToken)
{
return Ok(await profileService.UpdateNotificationStatusAsync(
ResolveActor(),
request.ToCommand(),
cancellationToken));
}
[HttpGet("badges")]
[EndpointSummary("查询徽章列表")]
[ProducesResponseType<BadgeList>(StatusCodes.Status200OK)]
public async Task<ActionResult<BadgeList>> Badges(
[FromQuery] ProfileQueryDto query,
CancellationToken cancellationToken)
{
return Ok(await profileService.GetBadgesAsync(
ResolveActor(),
new BadgeQuery(query.IncludeLocked, query.Category, query.Limit),
cancellationToken));
}
[HttpGet("feedbacks")]
[EndpointSummary("查询反馈记录")]
[ProducesResponseType<IReadOnlyCollection<FeedbackItem>>(StatusCodes.Status200OK)]
public async Task<ActionResult<IReadOnlyCollection<FeedbackItem>>> Feedbacks(
[FromQuery] ProfileQueryDto query,
CancellationToken cancellationToken)
{
return Ok(await profileService.GetFeedbacksAsync(
ResolveActor(),
new FeedbackQuery(query.Status, query.Type, query.Limit),
cancellationToken));
}
[HttpPost("feedbacks")]
[EndpointSummary("提交意见反馈")]
[ProducesResponseType<FeedbackItem>(StatusCodes.Status200OK)]
public async Task<ActionResult<FeedbackItem>> SubmitFeedback(
SubmitFeedbackDto request,
CancellationToken cancellationToken)
{
return Ok(await profileService.SubmitFeedbackAsync(
ResolveActor(),
request.ToCommand(),
cancellationToken));
}
private ProfileActor ResolveActor()
{
if (currentTenant.TenantId is null || currentUser.UserId is null)