feat : Get Tags Controller, Service, Repository Implement.
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package com.io.realworld.domain.aggregate.tag.controller;
|
||||||
|
|
||||||
|
import com.io.realworld.domain.aggregate.tag.dto.TagResponse;
|
||||||
|
import com.io.realworld.domain.aggregate.tag.service.TagService;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/tags")
|
||||||
|
public class TagController {
|
||||||
|
|
||||||
|
private final TagService tagService;
|
||||||
|
|
||||||
|
public TagController(TagService tagService) {
|
||||||
|
this.tagService = tagService;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Todo Response tags: {} ~
|
||||||
|
@GetMapping
|
||||||
|
public List<String> getTags(){
|
||||||
|
return tagService.getTags();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,4 +11,5 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface TagService {
|
public interface TagService {
|
||||||
void save(Article article);
|
void save(Article article);
|
||||||
|
List<String> getTags();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,9 @@ public class TagServiceImpl implements TagService {
|
|||||||
tagRepository.save(tag);
|
tagRepository.save(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTags() {
|
||||||
|
return tagRepository.findAll().stream().map(Tag::getTagName).distinct().collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user