mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-21 22:41:05 +08:00
Fix reserved word columns and update field names
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(), req.getSmallIcon());
|
||||
Category c = categoryService.createCategory(req.getName(), req.getDescription(), 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(), req.getSmallIcon());
|
||||
Category c = categoryService.updateCategory(id, req.getName(), req.getDescription(), req.getIcon(), req.getSmallIcon());
|
||||
return toDto(c);
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ public class CategoryController {
|
||||
dto.setName(c.getName());
|
||||
dto.setIcon(c.getIcon());
|
||||
dto.setSmallIcon(c.getSmallIcon());
|
||||
dto.setDescribe(c.getDescribe());
|
||||
dto.setDescription(c.getDescription());
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class CategoryRequest {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class CategoryController {
|
||||
private static class CategoryDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String describe;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ public class TagController {
|
||||
|
||||
@PostMapping
|
||||
public TagDto create(@RequestBody TagRequest req) {
|
||||
Tag tag = tagService.createTag(req.getName(), req.getDescribe(), req.getIcon(), req.getSmallIcon());
|
||||
Tag tag = tagService.createTag(req.getName(), req.getDescription(), 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(), req.getSmallIcon());
|
||||
Tag tag = tagService.updateTag(id, req.getName(), req.getDescription(), req.getIcon(), req.getSmallIcon());
|
||||
return toDto(tag);
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ public class TagController {
|
||||
dto.setName(tag.getName());
|
||||
dto.setIcon(tag.getIcon());
|
||||
dto.setSmallIcon(tag.getSmallIcon());
|
||||
dto.setDescribe(tag.getDescribe());
|
||||
dto.setDescription(tag.getDescription());
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class TagRequest {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class TagController {
|
||||
private static class TagDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String describe;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ public class Category {
|
||||
@Column
|
||||
private String smallIcon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String describe;
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Notification {
|
||||
@Column
|
||||
private Boolean approved;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Column(name = "is_read", nullable = false)
|
||||
private boolean read = false;
|
||||
|
||||
@Column(nullable = false)
|
||||
|
||||
@@ -24,6 +24,6 @@ public class Tag {
|
||||
@Column
|
||||
private String smallIcon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String describe;
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
}
|
||||
|
||||
@@ -12,23 +12,23 @@ import java.util.List;
|
||||
public class CategoryService {
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
public Category createCategory(String name, String describe, String icon, String smallIcon) {
|
||||
public Category createCategory(String name, String description, String icon, String smallIcon) {
|
||||
Category category = new Category();
|
||||
category.setName(name);
|
||||
category.setDescribe(describe);
|
||||
category.setDescription(description);
|
||||
category.setIcon(icon);
|
||||
category.setSmallIcon(smallIcon);
|
||||
return categoryRepository.save(category);
|
||||
}
|
||||
|
||||
public Category updateCategory(Long id, String name, String describe, String icon, String smallIcon) {
|
||||
public Category updateCategory(Long id, String name, String description, String icon, String smallIcon) {
|
||||
Category category = categoryRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Category not found"));
|
||||
if (name != null) {
|
||||
category.setName(name);
|
||||
}
|
||||
if (describe != null) {
|
||||
category.setDescribe(describe);
|
||||
if (description != null) {
|
||||
category.setDescription(description);
|
||||
}
|
||||
if (icon != null) {
|
||||
category.setIcon(icon);
|
||||
|
||||
@@ -12,23 +12,23 @@ import java.util.List;
|
||||
public class TagService {
|
||||
private final TagRepository tagRepository;
|
||||
|
||||
public Tag createTag(String name, String describe, String icon, String smallIcon) {
|
||||
public Tag createTag(String name, String description, String icon, String smallIcon) {
|
||||
Tag tag = new Tag();
|
||||
tag.setName(name);
|
||||
tag.setDescribe(describe);
|
||||
tag.setDescription(description);
|
||||
tag.setIcon(icon);
|
||||
tag.setSmallIcon(smallIcon);
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
||||
public Tag updateTag(Long id, String name, String describe, String icon, String smallIcon) {
|
||||
public Tag updateTag(Long id, String name, String description, String icon, String smallIcon) {
|
||||
Tag tag = tagRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Tag not found"));
|
||||
if (name != null) {
|
||||
tag.setName(name);
|
||||
}
|
||||
if (describe != null) {
|
||||
tag.setDescribe(describe);
|
||||
if (description != null) {
|
||||
tag.setDescription(description);
|
||||
}
|
||||
if (icon != null) {
|
||||
tag.setIcon(icon);
|
||||
|
||||
Reference in New Issue
Block a user