fix(#248): add @Schema(REQUIRED) to TagTreeNodeDTO, improve mergeTags log, add comments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -210,6 +210,8 @@ public class DocumentController {
|
|||||||
if (!"ASC".equalsIgnoreCase(dir) && !"DESC".equalsIgnoreCase(dir)) {
|
if (!"ASC".equalsIgnoreCase(dir) && !"DESC".equalsIgnoreCase(dir)) {
|
||||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "dir must be ASC or DESC");
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "dir must be ASC or DESC");
|
||||||
}
|
}
|
||||||
|
// tagOp is a raw String at the HTTP boundary; any value other than "OR" (case-insensitive)
|
||||||
|
// defaults to AND, which matches the frontend default and keeps old clients working.
|
||||||
TagOperator operator = "OR".equalsIgnoreCase(tagOp) ? TagOperator.OR : TagOperator.AND;
|
TagOperator operator = "OR".equalsIgnoreCase(tagOp) ? TagOperator.OR : TagOperator.AND;
|
||||||
return ResponseEntity.ok(documentService.searchDocuments(q, from, to, senderId, receiverId, tags, tagQ, status, sort, dir, operator));
|
return ResponseEntity.ok(documentService.searchDocuments(q, from, to, senderId, receiverId, tags, tagQ, status, sort, dir, operator));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import java.util.UUID;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
public record TagTreeNodeDTO(
|
public record TagTreeNodeDTO(
|
||||||
UUID id,
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) UUID id,
|
||||||
String name,
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) String name,
|
||||||
String color,
|
String color,
|
||||||
int documentCount,
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) int documentCount,
|
||||||
List<TagTreeNodeDTO> children,
|
List<TagTreeNodeDTO> children,
|
||||||
@Schema(description = "Parent tag ID, null for root tags") UUID parentId) {}
|
@Schema(description = "Parent tag ID, null for root tags") UUID parentId) {}
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ public class TagService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Tag mergeTags(UUID sourceId, UUID targetId) {
|
public Tag mergeTags(UUID sourceId, UUID targetId) {
|
||||||
log.info("Merging tag {} into {}", sourceId, targetId);
|
|
||||||
validateNotSelf(sourceId, targetId);
|
validateNotSelf(sourceId, targetId);
|
||||||
getById(sourceId);
|
Tag source = getById(sourceId);
|
||||||
Tag target = getById(targetId);
|
Tag target = getById(targetId);
|
||||||
|
log.info("Merging tag '{}' ({}) into '{}' ({})", source.getName(), sourceId, target.getName(), targetId);
|
||||||
validateNotDescendant(sourceId, targetId);
|
validateNotDescendant(sourceId, targetId);
|
||||||
transferDocuments(sourceId, targetId);
|
transferDocuments(sourceId, targetId);
|
||||||
tagRepository.reparentChildren(sourceId, targetId);
|
tagRepository.reparentChildren(sourceId, targetId);
|
||||||
@@ -145,6 +145,8 @@ public class TagService {
|
|||||||
/**
|
/**
|
||||||
* Returns all tags assembled into a tree with document counts per node.
|
* Returns all tags assembled into a tree with document counts per node.
|
||||||
* Uses a single aggregate query to avoid N+1 behaviour.
|
* Uses a single aggregate query to avoid N+1 behaviour.
|
||||||
|
* NOTE: document counts are global per tag, not scoped to any search filter.
|
||||||
|
* The tree endpoint is only used for the admin sidebar, so this is intentional.
|
||||||
*/
|
*/
|
||||||
public List<TagTreeNodeDTO> getTagTree() {
|
public List<TagTreeNodeDTO> getTagTree() {
|
||||||
List<Tag> all = tagRepository.findAll();
|
List<Tag> all = tagRepository.findAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user