feat(album): add cover picture functionality to albums and enhance album management API

This commit is contained in:
shiyu
2025-06-09 15:12:50 +08:00
parent 9d9393f9ce
commit e55f311c04
24 changed files with 1496 additions and 251 deletions

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Foxel.Models.DataBase;
@@ -14,5 +15,9 @@ public class Album : BaseModel
[Required]
public User User { get; set; }
public int? CoverPictureId { get; set; }
[ForeignKey("CoverPictureId")]
public Picture? CoverPicture { get; set; }
public ICollection<Picture>? Pictures { get; set; }
}

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace Foxel.Models.Request.Album
{
public class AlbumCreateRequest
{
[Required(ErrorMessage = "相册名称不能为空")]
[StringLength(100, ErrorMessage = "相册名称长度不能超过100个字符")]
public string Name { get; set; } = string.Empty;
[StringLength(500, ErrorMessage = "相册描述长度不能超过500个字符")]
public string? Description { get; set; }
public int? CoverPictureId { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
namespace Foxel.Models.Request.Album
{
public class AlbumUpdateRequest
{
[StringLength(100, ErrorMessage = "相册名称长度不能超过100个字符")]
public string? Name { get; set; }
[StringLength(500, ErrorMessage = "相册描述长度不能超过500个字符")]
public string? Description { get; set; }
public int? CoverPictureId { get; set; }
}
}

View File

@@ -10,4 +10,7 @@ public record CreateAlbumRequest
[StringLength(500)]
public string? Description { get; set; }
public int? CoverPictureId { get; set; }
}

View File

@@ -7,9 +7,11 @@ public record AlbumResponse
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public int PictureCount { get; set; } = 0;
public int UserId { get; set; }
public string? Username { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public string? CoverPicturePath { get; set; }
public string? CoverPictureThumbnailPath { get; set; }
public int PictureCount { get; set; }
}