Limit tags to two and integrate post publish

This commit is contained in:
Tim
2025-07-06 01:49:23 +08:00
parent 9e76b58cac
commit 1ba2da65fd
3 changed files with 57 additions and 8 deletions

View File

@@ -53,6 +53,9 @@ public class PostService {
if (tagIds == null || tagIds.isEmpty()) {
throw new IllegalArgumentException("At least one tag required");
}
if (tagIds.size() > 2) {
throw new IllegalArgumentException("At most two tags allowed");
}
User author = userRepository.findByUsername(username)
.orElseThrow(() -> new IllegalArgumentException("User not found"));
Category category = categoryRepository.findById(categoryId)