fix: 관리자 이미지 대체 흐름 보정
This commit is contained in:
@@ -822,6 +822,7 @@ router.post('/custom-items/:itemId/replace', requireAdmin, async (req, res) => {
|
||||
|
||||
const sourceItem = await findLibraryItemForReplacement(req.params.itemId)
|
||||
if (!sourceItem?.src) return res.status(404).json({ error: 'source_not_found' })
|
||||
if (sourceItem.sourceType !== 'user') return res.status(400).json({ error: 'user_item_required' })
|
||||
|
||||
const targetItem = await findLibraryItemForReplacement(parsed.data.targetItemId, parsed.data.targetSourceType)
|
||||
if (!targetItem?.src) return res.status(404).json({ error: 'target_not_found' })
|
||||
@@ -835,6 +836,10 @@ router.post('/custom-items/:itemId/replace', requireAdmin, async (req, res) => {
|
||||
toLabel: targetItem.label || '',
|
||||
})
|
||||
|
||||
const sourceCustomItems = await findCustomItemsByIds([sourceItem.id])
|
||||
await deleteCustomItems([sourceItem.id])
|
||||
await removeCustomItemFiles(sourceCustomItems)
|
||||
|
||||
res.json({
|
||||
ok: true,
|
||||
updatedRows: result.updatedRows || 0,
|
||||
|
||||
Reference in New Issue
Block a user