mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 22:21:09 +08:00
Fix post controller test setup
This commit is contained in:
@@ -17,7 +17,7 @@ public class CategoryController {
|
||||
|
||||
@PostMapping
|
||||
public CategoryDto create(@RequestBody CategoryRequest req) {
|
||||
Category c = categoryService.createCategory(req.getName());
|
||||
Category c = categoryService.createCategory(req.getName(), req.getDescribe(), req.getIcon());
|
||||
return toDto(c);
|
||||
}
|
||||
|
||||
@@ -42,17 +42,23 @@ public class CategoryController {
|
||||
CategoryDto dto = new CategoryDto();
|
||||
dto.setId(c.getId());
|
||||
dto.setName(c.getName());
|
||||
dto.setIcon(c.getIcon());
|
||||
dto.setDescribe(c.getDescribe());
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class CategoryRequest {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class CategoryDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class TagController {
|
||||
|
||||
@PostMapping
|
||||
public TagDto create(@RequestBody TagRequest req) {
|
||||
Tag tag = tagService.createTag(req.getName());
|
||||
Tag tag = tagService.createTag(req.getName(), req.getDescribe(), req.getIcon());
|
||||
return toDto(tag);
|
||||
}
|
||||
|
||||
@@ -42,17 +42,23 @@ public class TagController {
|
||||
TagDto dto = new TagDto();
|
||||
dto.setId(tag.getId());
|
||||
dto.setName(tag.getName());
|
||||
dto.setIcon(tag.getIcon());
|
||||
dto.setDescribe(tag.getDescribe());
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class TagRequest {
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class TagDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String describe;
|
||||
private String icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ public class Category {
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String icon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String describe;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ public class Tag {
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
private String icon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String describe;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ import java.util.List;
|
||||
public class CategoryService {
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
public Category createCategory(String name) {
|
||||
public Category createCategory(String name, String describe, String icon) {
|
||||
Category category = new Category();
|
||||
category.setName(name);
|
||||
category.setDescribe(describe);
|
||||
category.setIcon(icon);
|
||||
return categoryRepository.save(category);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,11 @@ import java.util.List;
|
||||
public class TagService {
|
||||
private final TagRepository tagRepository;
|
||||
|
||||
public Tag createTag(String name) {
|
||||
public Tag createTag(String name, String describe, String icon) {
|
||||
Tag tag = new Tag();
|
||||
tag.setName(name);
|
||||
tag.setDescribe(describe);
|
||||
tag.setIcon(icon);
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user