Lớp ShortUrlRepo
là repository chuyên biệt kế thừa từ GenericRepo<ShortUrl>
, cung cấp các thao tác tùy chỉnh cho thực thể ShortUrl
. Dưới đây là phần giải thích chi tiết theo từng cụm dòng mã:
ShortUrlRepo
Method | Chức năng chính |
---|---|
GetByOriginalUrlAsync |
Kiểm tra URL gốc |
GetByShortCodeAsync |
Lấy URL từ mã rút gọn |
GetPaginatedAsync |
Phân trang danh sách |
GetFilteredAsync |
Lọc nâng cao |
GetStatsPerTeamAsync |
Thống kê theo nhóm |
SearchAsync |
Tìm kiếm nhanh |
ExistsByShortCodeAsync |
Kiểm tra trùng mã |
GenerateTitleFromUrl |
Sinh tiêu đề từ URL |
ExportToExcelAsync |
Xuất Excel |
ImportFromExcelAsync |
Nhập từ Excel |
public ShortUrlRepo(AppDbContext context, IOptions<ShortUrlSettings> options) : base(context)
GenericRepo
để kế thừa các thao tác cơ bản.AppDbContext
vào _context
.BaseDomain
) để phục vụ sinh ShortenedUrl
.public async Task<ShortUrl?> GetByOriginalUrlAsync(string originalUrl)
OriginalUrl
khớp với tham số.null
nếu không tìm thấy.