Revert "Return structured category and tag data in change logs"

This reverts commit fe167aa0b9.
This commit is contained in:
Tim
2025-09-08 14:44:08 +08:00
parent 06368a6cf1
commit 6a5d00f086
2 changed files with 8 additions and 45 deletions

View File

@@ -5,7 +5,6 @@ import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@@ -19,10 +18,10 @@ public class PostChangeLogDto {
private String newTitle;
private String oldContent;
private String newContent;
private CategoryDto oldCategory;
private CategoryDto newCategory;
private List<TagDto> oldTags;
private List<TagDto> newTags;
private String oldCategory;
private String newCategory;
private String oldTags;
private String newTags;
private Boolean oldClosed;
private Boolean newClosed;
private LocalDateTime oldPinnedAt;

View File

@@ -1,15 +1,9 @@
package com.openisle.mapper;
import com.openisle.dto.CategoryDto;
import com.openisle.dto.PostChangeLogDto;
import com.openisle.dto.TagDto;
import com.openisle.model.*;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class PostChangeLogMapper {
public PostChangeLogDto toDto(PostChangeLog log) {
@@ -28,41 +22,11 @@ public class PostChangeLogMapper {
dto.setOldContent(c.getOldContent());
dto.setNewContent(c.getNewContent());
} else if (log instanceof PostCategoryChangeLog cat) {
if (cat.getOldCategory() != null) {
CategoryDto oldCat = new CategoryDto();
oldCat.setName(cat.getOldCategory());
dto.setOldCategory(oldCat);
}
if (cat.getNewCategory() != null) {
CategoryDto newCat = new CategoryDto();
newCat.setName(cat.getNewCategory());
dto.setNewCategory(newCat);
}
dto.setOldCategory(cat.getOldCategory());
dto.setNewCategory(cat.getNewCategory());
} else if (log instanceof PostTagChangeLog tag) {
if (tag.getOldTags() != null && !tag.getOldTags().isBlank()) {
List<TagDto> oldTags = Arrays.stream(tag.getOldTags().split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(name -> {
TagDto t = new TagDto();
t.setName(name);
return t;
})
.collect(Collectors.toList());
dto.setOldTags(oldTags);
}
if (tag.getNewTags() != null && !tag.getNewTags().isBlank()) {
List<TagDto> newTags = Arrays.stream(tag.getNewTags().split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(name -> {
TagDto t = new TagDto();
t.setName(name);
return t;
})
.collect(Collectors.toList());
dto.setNewTags(newTags);
}
dto.setOldTags(tag.getOldTags());
dto.setNewTags(tag.getNewTags());
} else if (log instanceof PostClosedChangeLog cl) {
dto.setOldClosed(cl.isOldClosed());
dto.setNewClosed(cl.isNewClosed());