Skip to content

Commit

Permalink
Merge pull request #172 from teamterning/staging
Browse files Browse the repository at this point in the history
[🎉 deploy] 터닝 운영서버 배포
  • Loading branch information
JungYoonShin authored Nov 2, 2024
2 parents 13f5b68 + 9acb3ee commit e60506d
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 0 deletions.
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())
);
}
}
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 src/main/java/org/terning/terningserver/domain/Banner.java
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;

}
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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@Getter
@AllArgsConstructor
public enum SuccessMessage {

// 홈 화면
SUCCESS_GET_ANNOUNCEMENTS(200, "인턴 공고 불러오기를 성공했습니다"),
SUCCESS_GET_UPCOMING_ANNOUNCEMENTS(200, "곧 마감인 인턴 공고 요청을 성공했습니다"),
Expand Down Expand Up @@ -35,6 +36,7 @@ public enum SuccessMessage {
SUCCESS_GET_MOST_VIEWED_ANNOUNCEMENTS(200, "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다"),
SUCCESS_GET_MOST_SCRAPPED_ANNOUNCEMENTS(200, "탐색 > 스크랩 수 많은 공고를 조회하는데 성공했습니다"),
SUCCESS_GET_SEARCH_ANNOUNCEMENTS(200, "검색에 성공했습니다"),
SUCCESS_GET_BANNERS(200, "탐색 뷰 > 배너 조회에 성공했습니다"),

// 인턴 공고
SUCCESS_GET_INTERNSHIP_DETAIL(200, "공고 상세 정보 불러오기에 성공했습니다"),
Expand All @@ -57,6 +59,7 @@ public enum SuccessMessage {
SUCCESS_GET_PROFILE(200, "마이페이지 > 프로필 정보 불러오기를 성공했습니다"),
SUCCESS_UPDATE_PROFILE(200, "프로필 수정에 성공했습니다");


private final int status;
private final String message;

Expand Down
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();
}
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();
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public List<MonthlyListResponseDto> getMonthlyScrapsAsList(Long userId, int year
))
.toList();
}

@Override
public List<DailyScrapResponseDto> getDailyScraps(Long userId, LocalDate date) {
return scrapRepository.findScrapsByUserIdAndDeadlineOrderByDeadline(userId, date).stream()
Expand Down

0 comments on commit e60506d

Please sign in to comment.