Content import: sync sections and articles (archive is the source of truth)

- importZip now updates titles/positions of existing chapters and sections and
  removes sections/articles of archived chapters that are missing in the archive
  (so restructured material no longer leaves stale sections behind); removed
  count is reported in ContentImportResult and in the admin flash message
- docs: note about import semantics in the class diagram and sequences
This commit is contained in:
2026-09-16 22:00:22 +03:00
parent d24e92005a
commit 1238265c8e
5 changed files with 54 additions and 4 deletions

View File

@@ -38,9 +38,11 @@ class ContentAdminController(
}
return try {
val result = api.importContent(token(session), file.originalFilename ?: "content.zip", file.bytes)
val removedNote = if (result.removed > 0) ", удалено устаревших: ${result.removed}" else ""
redirect.addFlashAttribute(
"notice",
"Импортировано: глав ${result.chapters}, разделов ${result.sections}, статей ${result.articles}, картинок ${result.assets}",
"Импортировано: глав ${result.chapters}, разделов ${result.sections}, " +
"статей ${result.articles}, картинок ${result.assets}$removedNote",
)
"redirect:/admin/content"
} catch (ex: ApiException) {

View File

@@ -365,6 +365,7 @@ data class ContentImportResultDto(
val sections: Int = 0,
val articles: Int = 0,
val assets: Int = 0,
val removed: Int = 0,
)
class DownloadDto(