-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
93 changed files
with
3,906 additions
and
60 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: server | ||
|
||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
- name: Ensure resource directory exists | ||
run: mkdir -p ./src/main/resources | ||
|
||
- name : injection-yml | ||
run : echo -E "${{ secrets.YML }}" > ./src/main/resources/application.yml | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Execute Gradle build and analyze | ||
run: ./gradlew jib | ||
|
||
- name: Run scripts in server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
host: ${{ secrets.HOST_DEV }} | ||
username: ${{ secrets.USERNAME }} | ||
script: ${{ secrets.SCRIPT }} |
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 |
---|---|---|
|
@@ -35,3 +35,6 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Setting File ### | ||
src/main/resources/application.yml |
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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/bbteam/budgetbuddies/apiPayload/ApiResponse.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,38 @@ | ||
package com.bbteam.budgetbuddies.apiPayload; | ||
|
||
import com.bbteam.budgetbuddies.apiPayload.code.BaseCode; | ||
import com.bbteam.budgetbuddies.apiPayload.code.status.SuccessStatus; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@JsonPropertyOrder({"isSuccess", "code", "message", "result"}) | ||
public class ApiResponse<T> { | ||
|
||
@JsonProperty("isSuccess") | ||
private final Boolean isSuccess; | ||
private final String code; | ||
private final String message; | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
private T result; | ||
|
||
|
||
// 성공한 경우 응답 생성 | ||
public static <T> ApiResponse<T> onSuccess(T result){ | ||
return new ApiResponse<>(true, SuccessStatus.OK.getCode() , SuccessStatus.OK.getMessage(), result); | ||
} | ||
|
||
public static <T> ApiResponse<T> of(BaseCode code, T result){ | ||
return new ApiResponse<>(true, code.getReasonHttpStatus().getCode() , code.getReasonHttpStatus().getMessage(), result); | ||
} | ||
|
||
|
||
// 실패한 경우 응답 생성 | ||
public static <T> ApiResponse<T> onFailure(String code, String message, T data){ | ||
return new ApiResponse<>(true, code, message, data); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/bbteam/budgetbuddies/apiPayload/code/BaseCode.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,10 @@ | ||
package com.bbteam.budgetbuddies.apiPayload.code; | ||
|
||
public interface BaseCode { | ||
ReasonHttpStatus getReasonHttpStatus(); | ||
|
||
interface ReasonHttpStatus { | ||
String getCode(); | ||
String getMessage(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/bbteam/budgetbuddies/apiPayload/code/BaseErrorCode.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,4 @@ | ||
package com.bbteam.budgetbuddies.apiPayload.code; | ||
|
||
public interface BaseErrorCode { | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/bbteam/budgetbuddies/apiPayload/code/status/SuccessStatus.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,14 @@ | ||
package com.bbteam.budgetbuddies.apiPayload.code.status; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum SuccessStatus { | ||
OK("200", "OK"); | ||
|
||
private final String code; | ||
private final String message; | ||
} | ||
|
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/bbteam/budgetbuddies/domain/calendar/controller/CalendarController.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,37 @@ | ||
package com.bbteam.budgetbuddies.domain.calendar.controller; | ||
|
||
import com.bbteam.budgetbuddies.domain.calendar.dto.CalendarDto; | ||
import com.bbteam.budgetbuddies.domain.calendar.service.CalendarService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.Parameters; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
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.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/calendar") | ||
public class CalendarController { | ||
|
||
private final CalendarService calendarService; | ||
@Operation(summary = "[User] 주머니 캘린더 API", description = "주머니 캘린더 화면에 필요한 API를 호출합니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "year", description = "호출할 연도입니다."), | ||
@Parameter(name = "month", description = "호출할 연도의 월입니다."), | ||
}) | ||
@GetMapping("/") | ||
public ResponseEntity<CalendarDto.CalendarMonthResponseDto> request( | ||
@RequestParam("year") Integer year, @RequestParam("month") Integer month | ||
) { | ||
CalendarDto.CalendarMonthResponseDto result = calendarService.find(year, month); | ||
return ResponseEntity.ok(result); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/bbteam/budgetbuddies/domain/calendar/converter/CalendarConverter.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,55 @@ | ||
package com.bbteam.budgetbuddies.domain.calendar.converter; | ||
|
||
import com.bbteam.budgetbuddies.domain.calendar.dto.CalendarDto; | ||
import com.bbteam.budgetbuddies.domain.discountinfo.entity.DiscountInfo; | ||
import com.bbteam.budgetbuddies.domain.supportinfo.entity.SupportInfo; | ||
|
||
import java.util.List; | ||
|
||
public class CalendarConverter { | ||
|
||
public static CalendarDto.CalendarMonthResponseDto toCalendarMonthResponseDto(CalendarDto.CalendarMonthInfoDto calendarMonthInfoDto, CalendarDto.CalendarMonthInfoDto recommendMonthInfoDto){ | ||
return CalendarDto.CalendarMonthResponseDto.builder() | ||
.calendarMonthInfoDto(calendarMonthInfoDto) | ||
.recommendMonthInfoDto(recommendMonthInfoDto) | ||
.build(); | ||
} | ||
|
||
public static CalendarDto.CalendarMonthInfoDto toCalendarMonthInfoDto(List<DiscountInfo> discountInfoList, | ||
List<SupportInfo> supportInfoList) { | ||
List<CalendarDto.CalendarDiscountInfoDto> discountInfoDtoList = discountInfoList.stream() | ||
.map(CalendarConverter::toCalendarDiscountInfoDto) | ||
.toList(); | ||
List<CalendarDto.CalendarSupportInfoDto> supportInfoDtoList = supportInfoList.stream() | ||
.map(CalendarConverter::toCalendarSupportInfoDto) | ||
.toList(); | ||
|
||
return CalendarDto.CalendarMonthInfoDto.builder() | ||
.discountInfoDtoList(discountInfoDtoList) | ||
.supportInfoDtoList(supportInfoDtoList) | ||
.build(); | ||
} | ||
|
||
public static CalendarDto.CalendarDiscountInfoDto toCalendarDiscountInfoDto(DiscountInfo discountInfo) { | ||
return CalendarDto.CalendarDiscountInfoDto.builder() | ||
.id(discountInfo.getId()) | ||
.title(discountInfo.getTitle()) | ||
.likeCount(discountInfo.getLikeCount()) | ||
.startDate(discountInfo.getStartDate()) | ||
.endDate(discountInfo.getEndDate()) | ||
.discountRate(discountInfo.getDiscountRate()) | ||
.build(); | ||
} | ||
|
||
public static CalendarDto.CalendarSupportInfoDto toCalendarSupportInfoDto(SupportInfo supportInfo) { | ||
return CalendarDto.CalendarSupportInfoDto.builder() | ||
.id(supportInfo.getId()) | ||
.title(supportInfo.getTitle()) | ||
.likeCount(supportInfo.getLikeCount()) | ||
.startDate(supportInfo.getStartDate()) | ||
.endDate(supportInfo.getEndDate()) | ||
.build(); | ||
} | ||
|
||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/bbteam/budgetbuddies/domain/calendar/dto/CalendarDto.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,48 @@ | ||
package com.bbteam.budgetbuddies.domain.calendar.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public class CalendarDto { | ||
|
||
@Getter | ||
@Builder | ||
public static class CalendarMonthResponseDto { | ||
CalendarMonthInfoDto calendarMonthInfoDto; | ||
CalendarMonthInfoDto recommendMonthInfoDto; | ||
} | ||
|
||
@Getter | ||
@Builder | ||
public static class CalendarMonthInfoDto { | ||
private List<CalendarDiscountInfoDto> discountInfoDtoList; | ||
private List<CalendarSupportInfoDto> supportInfoDtoList; | ||
} | ||
|
||
@Getter | ||
@Builder | ||
@EqualsAndHashCode | ||
public static class CalendarDiscountInfoDto { | ||
private Long id; | ||
private String title; | ||
private LocalDate startDate; | ||
private LocalDate endDate; | ||
private Integer likeCount; | ||
private Integer discountRate; | ||
} | ||
|
||
@Getter | ||
@Builder | ||
@EqualsAndHashCode | ||
public static class CalendarSupportInfoDto { | ||
private Long id; | ||
private String title; | ||
private LocalDate startDate; | ||
private LocalDate endDate; | ||
private Integer likeCount; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/bbteam/budgetbuddies/domain/calendar/service/CalendarService.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,9 @@ | ||
package com.bbteam.budgetbuddies.domain.calendar.service; | ||
|
||
import com.bbteam.budgetbuddies.domain.calendar.dto.CalendarDto; | ||
|
||
public interface CalendarService { | ||
|
||
CalendarDto.CalendarMonthResponseDto find(int year, int month); | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/bbteam/budgetbuddies/domain/calendar/service/CalendarServiceImpl.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,49 @@ | ||
package com.bbteam.budgetbuddies.domain.calendar.service; | ||
|
||
import com.bbteam.budgetbuddies.domain.calendar.converter.CalendarConverter; | ||
import com.bbteam.budgetbuddies.domain.calendar.dto.CalendarDto; | ||
import com.bbteam.budgetbuddies.domain.discountinfo.entity.DiscountInfo; | ||
import com.bbteam.budgetbuddies.domain.discountinfo.repository.DiscountInfoRepository; | ||
import com.bbteam.budgetbuddies.domain.supportinfo.entity.SupportInfo; | ||
import com.bbteam.budgetbuddies.domain.supportinfo.repository.SupportInfoRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class CalendarServiceImpl implements CalendarService{ | ||
|
||
private final DiscountInfoRepository discountInfoRepository; | ||
|
||
private final SupportInfoRepository supportInfoRepository; | ||
|
||
public CalendarDto.CalendarMonthResponseDto find(int year, int month){ | ||
LocalDate firstDay = LocalDate.of(year, month, 1); | ||
LocalDate lastDay = firstDay.withDayOfMonth(firstDay.lengthOfMonth()); | ||
CalendarDto.CalendarMonthResponseDto result = getCalendarMonthResponseDto(firstDay, lastDay); | ||
return result; | ||
} | ||
|
||
private CalendarDto.CalendarMonthResponseDto getCalendarMonthResponseDto(LocalDate firstDay, LocalDate lastDay) { | ||
CalendarDto.CalendarMonthInfoDto calendarMonthInfoDto = getCalendarMonthInfoDto(firstDay, lastDay); | ||
CalendarDto.CalendarMonthInfoDto recommendMonthInfoDto = getRecommendMonthInfoDto(firstDay, lastDay); | ||
return CalendarConverter.toCalendarMonthResponseDto(calendarMonthInfoDto, recommendMonthInfoDto); | ||
} | ||
|
||
private CalendarDto.CalendarMonthInfoDto getCalendarMonthInfoDto(LocalDate firstDay, LocalDate lastDay) { | ||
List<DiscountInfo> monthDiscountInfoList = discountInfoRepository.findByMonth(firstDay, lastDay); | ||
List<SupportInfo> monthSupportInfoList = supportInfoRepository.findByMonth(firstDay, lastDay); | ||
return CalendarConverter.toCalendarMonthInfoDto(monthDiscountInfoList, monthSupportInfoList); | ||
} | ||
|
||
private CalendarDto.CalendarMonthInfoDto getRecommendMonthInfoDto(LocalDate firstDay, LocalDate lastDay) { | ||
List<DiscountInfo> recommendDiscountInfoList = discountInfoRepository.findRecommendInfoByMonth(firstDay, lastDay); | ||
List<SupportInfo> recommendSupportInfoList = supportInfoRepository.findRecommendInfoByMonth(firstDay, lastDay); | ||
return CalendarConverter.toCalendarMonthInfoDto(recommendDiscountInfoList, recommendSupportInfoList); | ||
} | ||
} |
Oops, something went wrong.