-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from goormthon-Univ/feature/16
[3/19] ์ฝ๋ ๋ฆฌํํ ๋ง ๋ฐ Top3Tags ์กฐํ ๊ธฐ๋ฅ ์์ฑ
- Loading branch information
Showing
13 changed files
with
253 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/beotkkot/qtudy/controller/tag/TagApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.beotkkot.qtudy.controller.tag; | ||
|
||
import com.beotkkot.qtudy.dto.response.tags.GetTop3TagsDto; | ||
import com.beotkkot.qtudy.service.tag.TagService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class TagApiController { | ||
private final TagService tagService; | ||
|
||
@GetMapping("/tag/top3") | ||
public ResponseEntity<? super GetTop3TagsDto> getTop3Tags() { | ||
ResponseEntity<? super GetTop3TagsDto> response = tagService.getTop3Tags(); | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/beotkkot/qtudy/dto/object/TagListItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.beotkkot.qtudy.dto.object; | ||
|
||
import com.beotkkot.qtudy.domain.tags.Tags; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class TagListItem { | ||
private String name; | ||
private int count; | ||
|
||
public static TagListItem of(Tags tag) { | ||
|
||
return TagListItem.builder() | ||
.name(tag.getName()) | ||
.count(tag.getCount()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/beotkkot/qtudy/dto/response/tags/GetTop3TagsDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.beotkkot.qtudy.dto.response.tags; | ||
|
||
import com.beotkkot.qtudy.common.ResponseCode; | ||
import com.beotkkot.qtudy.common.ResponseMessage; | ||
import com.beotkkot.qtudy.dto.object.TagListItem; | ||
import com.beotkkot.qtudy.dto.response.ResponseDto; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class GetTop3TagsDto extends ResponseDto { | ||
private List<TagListItem> top3List; | ||
|
||
public GetTop3TagsDto(List<TagListItem> TagListItem) { | ||
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS); | ||
this.top3List = TagListItem; | ||
} | ||
|
||
public static ResponseEntity<GetTop3TagsDto> success(List<TagListItem> top3List) { | ||
GetTop3TagsDto result = new GetTop3TagsDto(top3List); | ||
return ResponseEntity.status(HttpStatus.OK).body(result); | ||
} | ||
|
||
public static ResponseEntity<ResponseDto> notExistedPost(){ | ||
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_POST, ResponseMessage.NOT_EXISTED_POST); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.