mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 22:21:09 +08:00
Add optional small icon for categories and tags
This commit is contained in:
@@ -19,13 +19,13 @@ public class CategoryController {
|
||||
|
||||
@PostMapping
|
||||
public CategoryDto create(@RequestBody CategoryRequest req) {
|
||||
Category c = categoryService.createCategory(req.getName(), req.getDescribe(), req.getIcon());
|
||||
Category c = categoryService.createCategory(req.getName(), req.getDescribe(), req.getIcon(), req.getSmallIcon());
|
||||
return toDto(c);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public CategoryDto update(@PathVariable Long id, @RequestBody CategoryRequest req) {
|
||||
Category c = categoryService.updateCategory(id, req.getName(), req.getDescribe(), req.getIcon());
|
||||
Category c = categoryService.updateCategory(id, req.getName(), req.getDescribe(), req.getIcon(), req.getSmallIcon());
|
||||
return toDto(c);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class CategoryController {
|
||||
dto.setId(c.getId());
|
||||
dto.setName(c.getName());
|
||||
dto.setIcon(c.getIcon());
|
||||
dto.setSmallIcon(c.getSmallIcon());
|
||||
dto.setDescribe(c.getDescribe());
|
||||
return dto;
|
||||
}
|
||||
@@ -75,6 +76,7 @@ public class CategoryController {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -83,6 +85,7 @@ public class CategoryController {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -19,13 +19,13 @@ public class TagController {
|
||||
|
||||
@PostMapping
|
||||
public TagDto create(@RequestBody TagRequest req) {
|
||||
Tag tag = tagService.createTag(req.getName(), req.getDescribe(), req.getIcon());
|
||||
Tag tag = tagService.createTag(req.getName(), req.getDescribe(), req.getIcon(), req.getSmallIcon());
|
||||
return toDto(tag);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public TagDto update(@PathVariable Long id, @RequestBody TagRequest req) {
|
||||
Tag tag = tagService.updateTag(id, req.getName(), req.getDescribe(), req.getIcon());
|
||||
Tag tag = tagService.updateTag(id, req.getName(), req.getDescribe(), req.getIcon(), req.getSmallIcon());
|
||||
return toDto(tag);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class TagController {
|
||||
dto.setId(tag.getId());
|
||||
dto.setName(tag.getName());
|
||||
dto.setIcon(tag.getIcon());
|
||||
dto.setSmallIcon(tag.getSmallIcon());
|
||||
dto.setDescribe(tag.getDescribe());
|
||||
return dto;
|
||||
}
|
||||
@@ -75,6 +76,7 @@ public class TagController {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -83,6 +85,7 @@ public class TagController {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -21,6 +21,9 @@ public class Category {
|
||||
@Column(nullable = false)
|
||||
private String icon;
|
||||
|
||||
@Column
|
||||
private String smallIcon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String describe;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ public class Tag {
|
||||
@Column
|
||||
private String icon;
|
||||
|
||||
@Column
|
||||
private String smallIcon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String describe;
|
||||
}
|
||||
|
||||
@@ -12,15 +12,16 @@ import java.util.List;
|
||||
public class CategoryService {
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
public Category createCategory(String name, String describe, String icon) {
|
||||
public Category createCategory(String name, String describe, String icon, String smallIcon) {
|
||||
Category category = new Category();
|
||||
category.setName(name);
|
||||
category.setDescribe(describe);
|
||||
category.setIcon(icon);
|
||||
category.setSmallIcon(smallIcon);
|
||||
return categoryRepository.save(category);
|
||||
}
|
||||
|
||||
public Category updateCategory(Long id, String name, String describe, String icon) {
|
||||
public Category updateCategory(Long id, String name, String describe, String icon, String smallIcon) {
|
||||
Category category = categoryRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Category not found"));
|
||||
if (name != null) {
|
||||
@@ -32,6 +33,9 @@ public class CategoryService {
|
||||
if (icon != null) {
|
||||
category.setIcon(icon);
|
||||
}
|
||||
if (smallIcon != null) {
|
||||
category.setSmallIcon(smallIcon);
|
||||
}
|
||||
return categoryRepository.save(category);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,16 @@ import java.util.List;
|
||||
public class TagService {
|
||||
private final TagRepository tagRepository;
|
||||
|
||||
public Tag createTag(String name, String describe, String icon) {
|
||||
public Tag createTag(String name, String describe, String icon, String smallIcon) {
|
||||
Tag tag = new Tag();
|
||||
tag.setName(name);
|
||||
tag.setDescribe(describe);
|
||||
tag.setIcon(icon);
|
||||
tag.setSmallIcon(smallIcon);
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
||||
public Tag updateTag(Long id, String name, String describe, String icon) {
|
||||
public Tag updateTag(Long id, String name, String describe, String icon, String smallIcon) {
|
||||
Tag tag = tagRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Tag not found"));
|
||||
if (name != null) {
|
||||
@@ -32,6 +33,9 @@ public class TagService {
|
||||
if (icon != null) {
|
||||
tag.setIcon(icon);
|
||||
}
|
||||
if (smallIcon != null) {
|
||||
tag.setSmallIcon(smallIcon);
|
||||
}
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user