fix: 사진/티저 업로드·삭제 시 앨범 캐시 무효화 누락 수정
photos.js, teasers.js에서 invalidateAlbumCache 호출 추가. 앨범 생성 후 사진/티저 추가 시 캐시된 빈 데이터가 반환되던 문제 해결. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ce41fc1a60
commit
9e3a71e156
2 changed files with 12 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import {
|
|||
deleteAlbumPhoto,
|
||||
uploadAlbumVideo,
|
||||
} from '../../services/image.js';
|
||||
import { invalidateAlbumCache } from '../../services/album.js';
|
||||
import { withTransaction } from '../../utils/transaction.js';
|
||||
import { notFound } from '../../utils/error.js';
|
||||
import { logActivity } from '../../utils/log.js';
|
||||
|
|
@ -12,7 +13,7 @@ import { logActivity } from '../../utils/log.js';
|
|||
* GET: 공개, POST/DELETE: 인증 필요
|
||||
*/
|
||||
export default async function photosRoutes(fastify) {
|
||||
const { db } = fastify;
|
||||
const { db, redis } = fastify;
|
||||
|
||||
/**
|
||||
* GET /api/albums/:albumId/photos
|
||||
|
|
@ -196,6 +197,9 @@ export default async function photosRoutes(fastify) {
|
|||
|
||||
await connection.commit();
|
||||
|
||||
// 앨범 캐시 무효화
|
||||
await invalidateAlbumCache(redis, parseInt(albumId));
|
||||
|
||||
logActivity(db, { actor: 'admin', action: 'upload', category: 'album', targetType: 'photo', targetId: parseInt(albumId), summary: `사진 업로드: ${uploadedPhotos.length}장 (앨범 ${albumId})` });
|
||||
|
||||
reply.raw.write(`data: ${JSON.stringify({
|
||||
|
|
@ -248,6 +252,9 @@ export default async function photosRoutes(fastify) {
|
|||
await connection.query('DELETE FROM album_photo_members WHERE photo_id = ?', [photoId]);
|
||||
await connection.query('DELETE FROM album_photos WHERE id = ?', [photoId]);
|
||||
|
||||
// 앨범 캐시 무효화
|
||||
await invalidateAlbumCache(redis, parseInt(albumId));
|
||||
|
||||
logActivity(db, { actor: 'admin', action: 'delete', category: 'album', targetType: 'photo', targetId: parseInt(photoId), summary: `사진 삭제: 앨범 ${albumId}` });
|
||||
return { message: '사진이 삭제되었습니다.' };
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {
|
|||
deleteAlbumPhoto,
|
||||
deleteAlbumVideo,
|
||||
} from '../../services/image.js';
|
||||
import { invalidateAlbumCache } from '../../services/album.js';
|
||||
import { withTransaction } from '../../utils/transaction.js';
|
||||
import { notFound } from '../../utils/error.js';
|
||||
import { logActivity } from '../../utils/log.js';
|
||||
|
|
@ -11,7 +12,7 @@ import { logActivity } from '../../utils/log.js';
|
|||
* GET: 공개, DELETE: 인증 필요
|
||||
*/
|
||||
export default async function teasersRoutes(fastify) {
|
||||
const { db } = fastify;
|
||||
const { db, redis } = fastify;
|
||||
|
||||
/**
|
||||
* GET /api/albums/:albumId/teasers
|
||||
|
|
@ -79,6 +80,8 @@ export default async function teasersRoutes(fastify) {
|
|||
|
||||
await connection.query('DELETE FROM album_teasers WHERE id = ?', [teaserId]);
|
||||
|
||||
await invalidateAlbumCache(redis, parseInt(albumId));
|
||||
|
||||
logActivity(db, { actor: 'admin', action: 'delete', category: 'album', targetType: 'teaser', targetId: parseInt(teaserId), summary: `티저 삭제: 앨범 ${albumId}` });
|
||||
return { message: '티저가 삭제되었습니다.' };
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue