-
Notifications
You must be signed in to change notification settings - Fork 2
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 #171 from teamterning/develop
[🔀 merge] [2차] 코드 리펙토링 사항 적용 (10)
- Loading branch information
Showing
11 changed files
with
173 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: DOCKER-CD | ||
on: | ||
pull_request: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/terning/terningserver/controller/BannerController.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,30 @@ | ||
package org.terning.terningserver.controller; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import org.terning.terningserver.controller.swagger.BannerSwagger; | ||
import org.terning.terningserver.dto.Banner.BannerListResponseDto; | ||
import org.terning.terningserver.exception.dto.SuccessResponse; | ||
import org.terning.terningserver.exception.enums.SuccessMessage; | ||
import org.terning.terningserver.service.BannerService; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class BannerController implements BannerSwagger{ | ||
|
||
private final BannerService bannerService; | ||
|
||
@GetMapping("/search/banners") | ||
public ResponseEntity<SuccessResponse<BannerListResponseDto>> getBanners() { | ||
return ResponseEntity.ok( | ||
SuccessResponse.of(SuccessMessage.SUCCESS_GET_BANNERS, bannerService.getBanners()) | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/org/terning/terningserver/controller/swagger/BannerSwagger.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,18 @@ | ||
package org.terning.terningserver.controller.swagger; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
import org.terning.terningserver.dto.Banner.BannerListResponseDto; | ||
import org.terning.terningserver.exception.dto.SuccessResponse; | ||
|
||
@Tag(name= "Banner", description = "탐색 > 배너 조회 관련 API") | ||
public interface BannerSwagger { | ||
|
||
@Operation(summary = "배너 조회", description = "탐색 > 배너를 조회하는 API") | ||
ResponseEntity<SuccessResponse<BannerListResponseDto>> getBanners(); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/terning/terningserver/domain/Banner.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,27 @@ | ||
package org.terning.terningserver.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class Banner { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
private String imageUrl; | ||
|
||
private String link; | ||
|
||
private int priority; | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/terning/terningserver/dto/Banner/BannerListResponseDto.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,25 @@ | ||
package org.terning.terningserver.dto.Banner; | ||
|
||
import org.terning.terningserver.domain.Banner; | ||
|
||
import java.util.List; | ||
|
||
public record BannerListResponseDto( | ||
List<BannerDetailResponseDto> banners | ||
) { | ||
|
||
public record BannerDetailResponseDto( | ||
String imageUrl, | ||
String link | ||
) { | ||
public static BannerDetailResponseDto of(final Banner banner) { | ||
return new BannerDetailResponseDto(banner.getImageUrl(), banner.getLink()); | ||
} | ||
} | ||
|
||
public static BannerListResponseDto of(final List<Banner> banners) { | ||
return new BannerListResponseDto( | ||
banners.stream().map(BannerDetailResponseDto::of).toList() | ||
); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/org/terning/terningserver/repository/Banner/BannerRepository.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,11 @@ | ||
package org.terning.terningserver.repository.Banner; | ||
|
||
import org.springframework.data.repository.Repository; | ||
import org.terning.terningserver.domain.Banner; | ||
|
||
import java.util.List; | ||
|
||
public interface BannerRepository extends Repository<Banner, Long> { | ||
|
||
List<Banner> findAllByOrderByPriority(); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/terning/terningserver/service/BannerService.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,8 @@ | ||
package org.terning.terningserver.service; | ||
|
||
import org.terning.terningserver.dto.Banner.BannerListResponseDto; | ||
|
||
public interface BannerService { | ||
|
||
public BannerListResponseDto getBanners(); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/terning/terningserver/service/BannerServiceImpl.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,23 @@ | ||
package org.terning.terningserver.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.terning.terningserver.domain.Banner; | ||
import org.terning.terningserver.dto.Banner.BannerListResponseDto; | ||
import org.terning.terningserver.repository.Banner.BannerRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BannerServiceImpl implements BannerService { | ||
|
||
private final BannerRepository bannerRepository; | ||
|
||
public BannerListResponseDto getBanners() { | ||
List<Banner> banners = bannerRepository.findAllByOrderByPriority(); | ||
return BannerListResponseDto.of(banners); | ||
} | ||
} |
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