feat : Get Tags Controller, Service, Repository Implement.

This commit is contained in:
minseokkang
2022-10-31 17:51:37 +09:00
parent b69eb8860d
commit 9465325b05
3 changed files with 32 additions and 0 deletions

View File

@@ -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();
}
}

View File

@@ -11,4 +11,5 @@ import java.util.List;
public interface TagService {
void save(Article article);
List<String> getTags();
}

View File

@@ -26,4 +26,9 @@ public class TagServiceImpl implements TagService {
tagRepository.save(tag);
}
}
@Override
public List<String> getTags() {
return tagRepository.findAll().stream().map(Tag::getTagName).distinct().collect(Collectors.toList());
}
}