Post detail page

This commit is contained in:
2025-08-04 01:46:26 +08:00
parent db5d631049
commit 1a05f16299
9 changed files with 133 additions and 8 deletions

View File

@@ -183,7 +183,7 @@ async function fetchUser() {
console.log('[Fetch] Using the API to load user data.')
try {
const resp = await fetch(`/api/accounts/${route.params.name}`)
const resp = await fetch(`/api/accounts/${route.params.slug}`)
user.value = await resp.json()
} catch (err) {
console.error(err)

View File

@@ -43,13 +43,11 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay
{
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
var subs = await db.WalletSubscriptions
var subscription = await db.WalletSubscriptions
.Where(s => s.AccountId == currentUser.Id && s.IsActive)
.Where(s => EF.Functions.ILike(s.Identifier, prefix + "%"))
.OrderByDescending(s => s.BegunAt)
.ToListAsync();
if (subs.Count == 0) return NotFound();
var subscription = subs.FirstOrDefault(s => s.IsAvailable);
.FirstOrDefaultAsync();
if (subscription is null) return NotFound();
return Ok(subscription);

View File

@@ -400,9 +400,9 @@ public class SubscriptionService(
.OrderByDescending(s => s.BegunAt)
.FirstOrDefaultAsync();
// Cache the result if found (with 30 minutes expiry)
// Cache the result if found (with 5 minutes expiry)
if (subscription != null)
await cache.SetAsync(cacheKey, subscription, TimeSpan.FromMinutes(30));
await cache.SetAsync(cacheKey, subscription, TimeSpan.FromMinutes(5));
return subscription;
}