mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 15:10:48 +08:00
Add update endpoints for tags and categories
This commit is contained in:
@@ -20,6 +20,21 @@ public class CategoryService {
|
||||
return categoryRepository.save(category);
|
||||
}
|
||||
|
||||
public Category updateCategory(Long id, String name, String describe, String icon) {
|
||||
Category category = categoryRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Category not found"));
|
||||
if (name != null) {
|
||||
category.setName(name);
|
||||
}
|
||||
if (describe != null) {
|
||||
category.setDescribe(describe);
|
||||
}
|
||||
if (icon != null) {
|
||||
category.setIcon(icon);
|
||||
}
|
||||
return categoryRepository.save(category);
|
||||
}
|
||||
|
||||
public void deleteCategory(Long id) {
|
||||
categoryRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,21 @@ public class TagService {
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
||||
public Tag updateTag(Long id, String name, String describe, String icon) {
|
||||
Tag tag = tagRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Tag not found"));
|
||||
if (name != null) {
|
||||
tag.setName(name);
|
||||
}
|
||||
if (describe != null) {
|
||||
tag.setDescribe(describe);
|
||||
}
|
||||
if (icon != null) {
|
||||
tag.setIcon(icon);
|
||||
}
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
||||
public void deleteTag(Long id) {
|
||||
tagRepository.deleteById(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user