Skip to content

Commit

Permalink
refactor(docs): DocsPopularInformationService 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
마현우 committed Apr 9, 2024
1 parent 83b057c commit 7951d53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.project.bumawiki.domain.docs.domain.repository.DocsRepository;
import com.project.bumawiki.domain.docs.presentation.dto.response.DocsPopularResponseDto;
import com.project.bumawiki.domain.docs.service.DocsPopularInformationService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/docs")
@RequiredArgsConstructor
@RequestMapping("/api/docs")
public class DocsPopularInformationController {
private final DocsPopularInformationService docsPopularInformationService;
private final DocsRepository docsRepository;

@GetMapping("/popular")
public ResponseEntity<List<DocsPopularResponseDto>> docsPopular() {
return ResponseEntity.ok(docsPopularInformationService.getDocsByPopular());
@ResponseStatus(HttpStatus.OK)
public List<DocsPopularResponseDto> docsPopular() {
return docsRepository.findByThumbsUpsDesc();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package com.project.bumawiki.domain.docs.presentation.dto.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.project.bumawiki.domain.docs.domain.type.DocsType;

public class DocsPopularResponseDto {
@JsonProperty
private final String title;
@JsonProperty
private final int enroll;
@JsonProperty
private final DocsType docsType;
@JsonProperty
private final long thumbsUpsCounts;
public record DocsPopularResponseDto(
String title,
Integer enroll,
DocsType docsType,
Long thumbsUpsCounts
) {

public DocsPopularResponseDto(String title, int enroll, DocsType docsType, long thumbsUpsCounts) {
public DocsPopularResponseDto(String title, Integer enroll, DocsType docsType, Long thumbsUpsCounts) {
this.title = title;
this.enroll = enroll;
this.docsType = docsType;
Expand Down

This file was deleted.

0 comments on commit 7951d53

Please sign in to comment.