Skip to content

Commit

Permalink
Merge pull request #911 from woowacourse-teams/develop
Browse files Browse the repository at this point in the history
[ALL] Release v1.6.0
  • Loading branch information
pilyang authored Jan 3, 2024
2 parents 6fa332d + 1610626 commit 2f87582
Show file tree
Hide file tree
Showing 85 changed files with 2,572 additions and 433 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![](https://img.shields.io/badge/-teamby.team-important?style=flat&logo=airplayvideo&logoColor=white&labelColor=black&color=%233145FF)](https://teamby.team/)
[![](https://img.shields.io/badge/-Tech%20Blog-important?style=flat&logo=angellist&logoColor=balck&labelColor=black&color=white)
](https://team-by-team.github.io/)
[![](https://img.shields.io/badge/release-v1.5.2-critical?style=flat&logo=github&logoColor=balck&labelColor=black&color=white)
[![](https://img.shields.io/badge/release-v1.6.0-critical?style=flat&logo=github&logoColor=balck&labelColor=black&color=white)
](https://github.com/woowacourse-teams/2023-team-by-team/releases)

# 팀바팀
Expand Down Expand Up @@ -120,16 +120,16 @@
</tr>
<tr>
<td align="center">
<img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/8f0149f0-822b-400f-a827-af58ca57e489'>
<img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/bdd33938-1838-4b34-86f1-7cee4d8a37dc'>
</td>
</tr>
</table>

| 팀 캘린더 |피드 |
| 팀 캘린더 |채팅 |
| :---------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------: |
| <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/4b578b01-4412-49ee-921b-cdb126c252fe'> | <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/40e8927a-8d13-4fb9-a8f4-9f9745753d23'> |
| <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/f223d8bc-9bb4-482d-acf1-34db66eb93e0'> | <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/7440e842-3c81-4b5f-ba54-5a2787561e31'> |
| <b>팀 링크</b> | <b>팀 생성 및 팀 참가</b> |
| <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/2ae57d8a-daeb-40b1-97b9-be497ba3bb68'> | <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/36222b93-3b06-4f41-a20f-c3a8df0bdfa7'> |
| <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/767f9240-04e3-43c4-8b10-d2ed14606be6'> | <img src='https://github.com/woowacourse-teams/2023-team-by-team/assets/79538610/203982f5-1fc4-4d08-aa53-e6f1d5f76ab0'> |

<p align="center">
<a href='https://sites.google.com/woowahan.com/woowacourse-demo-5th/%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8/%ED%8C%80%EB%B0%94%ED%8C%80'>팀바팀을 더 자세히 알고 싶다면, 여기로!</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public ResponseEntity<ErrorResponse> handleCustomForbiddenException(final Runtim

@ExceptionHandler(value = {
ScheduleException.SpanWrongOrderException.class,
ScheduleException.dateFormatException.class,
TeamPlaceInviteCodeException.LengthException.class,
TeamPlaceException.NameLengthException.class,
TeamPlaceException.NameBlankException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import team.teamby.teambyteam.member.domain.vo.Email;
import team.teamby.teambyteam.member.exception.MemberException;
import team.teamby.teambyteam.schedule.application.dto.SchedulesWithTeamPlaceIdResponse;
import team.teamby.teambyteam.schedule.application.parser.LocalDateParser;
import team.teamby.teambyteam.schedule.domain.CalendarPeriod;
import team.teamby.teambyteam.schedule.domain.Schedule;
import team.teamby.teambyteam.schedule.domain.ScheduleRepository;
import team.teamby.teambyteam.teamplace.domain.TeamPlace;

import java.time.LocalDate;
import java.util.List;

@Service
Expand All @@ -23,6 +25,7 @@ public class MyCalendarScheduleService {

private final MemberRepository memberRepository;
private final ScheduleRepository scheduleRepository;
private final LocalDateParser localDateParser;

@Transactional(readOnly = true)
public SchedulesWithTeamPlaceIdResponse findScheduleInPeriod(
Expand Down Expand Up @@ -66,4 +69,29 @@ public SchedulesWithTeamPlaceIdResponse findScheduleInPeriod(

return SchedulesWithTeamPlaceIdResponse.of(dailySchedules);
}

@Transactional(readOnly = true)
public SchedulesWithTeamPlaceIdResponse findScheduleInPeriod(
final MemberEmailDto memberEmailDto,
final String startDateString,
final String endDateString
) {
final Member member = memberRepository.findByEmail(new Email(memberEmailDto.email()))
.orElseThrow(() -> new MemberException.MemberNotFoundException(memberEmailDto.email()));

final List<Long> participatedTeamPlaceIds = member.getTeamPlaces()
.stream()
.map(TeamPlace::getId)
.toList();

final LocalDate startDate = localDateParser.parse(startDateString);
final LocalDate endDate = localDateParser.parse(endDateString);

final CalendarPeriod period = CalendarPeriod.of(startDate, endDate);

final List<Schedule> dailySchedules = scheduleRepository.findAllByTeamPlaceIdAndPeriod(
participatedTeamPlaceIds, period.startDateTime(), period.endDatetime());

return SchedulesWithTeamPlaceIdResponse.of(dailySchedules);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import team.teamby.teambyteam.schedule.application.event.ScheduleDeleteEvent;
import team.teamby.teambyteam.schedule.application.event.ScheduleUpdateEvent;
import team.teamby.teambyteam.schedule.application.event.ScheduleUpdateEventDto;
import team.teamby.teambyteam.schedule.application.parser.LocalDateParser;
import team.teamby.teambyteam.schedule.domain.CalendarPeriod;
import team.teamby.teambyteam.schedule.domain.Schedule;
import team.teamby.teambyteam.schedule.domain.ScheduleRepository;
Expand All @@ -22,6 +23,7 @@
import team.teamby.teambyteam.teamplace.domain.TeamPlaceRepository;
import team.teamby.teambyteam.teamplace.exception.TeamPlaceException;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

Expand All @@ -34,6 +36,7 @@ public class TeamCalendarScheduleService {
private final ScheduleRepository scheduleRepository;
private final TeamPlaceRepository teamPlaceRepository;
private final ApplicationEventPublisher applicationEventPublisher;
private final LocalDateParser localDateParser;

public Long register(final ScheduleRegisterRequest scheduleRegisterRequest, final Long teamPlaceId) {
checkTeamPlaceExist(teamPlaceId);
Expand Down Expand Up @@ -87,7 +90,7 @@ private boolean isNotScheduleOfTeam(final Long teamPlaceId, final Schedule sched
}

@Transactional(readOnly = true)
public SchedulesResponse findScheduleInPeriod(final Long teamPlaceId, final int targetYear, final int targetMonth) {
public SchedulesResponse findScheduleInMonth(final Long teamPlaceId, final int targetYear, final int targetMonth) {
checkTeamPlaceExist(teamPlaceId);

final CalendarPeriod period = CalendarPeriod.of(targetYear, targetMonth);
Expand All @@ -98,7 +101,7 @@ public SchedulesResponse findScheduleInPeriod(final Long teamPlaceId, final int
}

@Transactional(readOnly = true)
public SchedulesResponse findScheduleInPeriod(
public SchedulesResponse findScheduleInDay(
final Long teamPlaceId,
final int targetYear,
final int targetMonth,
Expand All @@ -113,6 +116,24 @@ public SchedulesResponse findScheduleInPeriod(
return SchedulesResponse.of(dailySchedules);
}

@Transactional(readOnly = true)
public SchedulesResponse findScheduleInPeriod(
final Long teaPlaceId,
final String startDateString,
final String endDateString
) {
checkTeamPlaceExist(teaPlaceId);

final LocalDate startDate = localDateParser.parse(startDateString);
final LocalDate endDate = localDateParser.parse(endDateString);
final CalendarPeriod period = CalendarPeriod.of(startDate, endDate);

final List<Schedule> schedules = scheduleRepository.
findAllByTeamPlaceIdAndPeriod(teaPlaceId, period.startDateTime(), period.endDatetime());

return SchedulesResponse.of(schedules);
}

public void update(final ScheduleUpdateRequest scheduleUpdateRequest, final Long teamPlaceId, final Long scheduleId) {
checkTeamPlaceExist(teamPlaceId);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package team.teamby.teambyteam.schedule.application.parser;

import org.springframework.stereotype.Component;
import team.teamby.teambyteam.schedule.exception.ScheduleException;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

@Component
public class LocalDateParser {

private static final DateTimeFormatter DATE_PARAM_FORMAT = DateTimeFormatter.ofPattern("yyyyMMdd");

public LocalDate parse(final String yearMonthDay) {
try {
return LocalDate.parse(yearMonthDay, DATE_PARAM_FORMAT);
} catch (final DateTimeParseException e) {
throw new ScheduleException.dateFormatException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package team.teamby.teambyteam.schedule.domain;

import team.teamby.teambyteam.schedule.exception.ScheduleException;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
* 캘린더 일정
* 일정에 해당하려면 startDateTime <= PERIOD < endDateTime
*
* @param startDateTime inclusive DateTime
* @param endDatetime exclusive DateTime
*/
public record CalendarPeriod(
LocalDateTime startDateTime,
LocalDateTime endDatetime
Expand All @@ -26,4 +35,21 @@ public static CalendarPeriod of(final int year, final int month, final int day)

return new CalendarPeriod(LocalDateTime.of(dailyDate, START_TIME_OF_DAY), LocalDateTime.of(nextDay, START_TIME_OF_DAY));
}

public static CalendarPeriod of(final LocalDate startDate, final LocalDate endDate) {
validateOrder(startDate, endDate);
return new CalendarPeriod(
LocalDateTime.of(startDate, START_TIME_OF_DAY),
LocalDateTime.of(endDate.plusDays(NEXT_DAY_OFFSET), START_TIME_OF_DAY)
);
}

private static void validateOrder(final LocalDate startDate, final LocalDate endDate) {
if (endDate.isBefore(startDate)) {
throw new ScheduleException.SpanWrongOrderException(
LocalDateTime.of(startDate, START_TIME_OF_DAY),
LocalDateTime.of(endDate, START_TIME_OF_DAY)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public ScheduleException(final String message) {
super(message);
}

public ScheduleException(String message, Throwable cause) {
super(message, cause);
}

public static class ScheduleNotFoundException extends ScheduleException {
public ScheduleNotFoundException(final Long scheduleId) {
super(String.format("조회한 일정이 존재하지 않습니다. - request info { schedule_id : %d }", scheduleId));
Expand All @@ -31,9 +35,14 @@ public SpanWrongOrderException(final LocalDateTime startDateTime, final LocalDat
}

public static class TitleBlankException extends ScheduleException {

public TitleBlankException() {
super("일정의 제목은 빈 칸일 수 없습니다.");
}
}

public static class dateFormatException extends ScheduleException {
public dateFormatException(final Exception e) {
super("잘못된 날짜 입력 형식입니다.", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,15 @@ public ResponseEntity<SchedulesWithTeamPlaceIdResponse> findDailySchedule(

return ResponseEntity.ok(responseBody);
}

@GetMapping(value = "/schedules", params = {"startDate", "endDate"})
public ResponseEntity<SchedulesWithTeamPlaceIdResponse> findDailySchedule(
@AuthPrincipal final MemberEmailDto memberEmailDto,
@RequestParam(value = "startDate") final String startDate,
@RequestParam(value = "endDate") final String endDate
) {
final SchedulesWithTeamPlaceIdResponse responseBody = myCalendarScheduleService.findScheduleInPeriod(memberEmailDto, startDate, endDate);

return ResponseEntity.ok(responseBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public ResponseEntity<ScheduleResponse> findSpecificSchedule(
}

@GetMapping(value = "/{teamPlaceId}/calendar/schedules", params = {"year", "month"})
public ResponseEntity<SchedulesResponse> findSchedulesInPeriod(
public ResponseEntity<SchedulesResponse> findScheduleInMonth(
@PathVariable final Long teamPlaceId,
@RequestParam final Integer year,
@RequestParam final Integer month
) {
final SchedulesResponse responseBody = teamCalendarScheduleService.findScheduleInPeriod(teamPlaceId, year, month);
final SchedulesResponse responseBody = teamCalendarScheduleService.findScheduleInMonth(teamPlaceId, year, month);

return ResponseEntity.ok(responseBody);
}
Expand All @@ -55,7 +55,18 @@ public ResponseEntity<SchedulesResponse> findDailySchedule(
@RequestParam final Integer month,
@RequestParam final Integer day
) {
final SchedulesResponse response = teamCalendarScheduleService.findScheduleInPeriod(teamPlaceId, year, month, day);
final SchedulesResponse response = teamCalendarScheduleService.findScheduleInDay(teamPlaceId, year, month, day);

return ResponseEntity.ok(response);
}

@GetMapping(value = "/{teamPlaceId}/calendar/schedules", params = {"startDate", "endDate"})
public ResponseEntity<SchedulesResponse> findDailySchedule(
@PathVariable final Long teamPlaceId,
@RequestParam(value = "startDate") final String startDate,
@RequestParam(value = "endDate") final String endDate
) {
final SchedulesResponse response = teamCalendarScheduleService.findScheduleInPeriod(teamPlaceId, startDate, endDate);

return ResponseEntity.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ public static ExtractableResponse<Response> FIND_PERIOD_SCHEDULE_REQUEST(final S
.extract();
}

public static ExtractableResponse<Response> FIND_PERIOD_SCHEDULE_REQUEST(
final String token,
final String startDate,
final String endDate
) {
return RestAssured.given().log().all()
.header(new Header(HttpHeaders.AUTHORIZATION, JWT_PREFIX + token))
.queryParam("startDate", startDate)
.queryParam("endDate", endDate)
.when().log().all()
.get("/api/my-calendar/schedules")
.then().log().all()
.extract();
}

public static ExtractableResponse<Response> FIND_DAILY_SCHEDULE_REQUEST(final String token, final Integer year, final Integer month, final Integer day) {
return RestAssured.given().log().all()
.header(new Header(HttpHeaders.AUTHORIZATION, JWT_PREFIX + token))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public static ExtractableResponse<Response> FIND_PERIOD_SCHEDULE_REQUEST(final S
.extract();
}

public static ExtractableResponse<Response> FIND_PERIOD_SCHEDULE_REQUEST(final String token, final Long teamPlaceId, final String startDate, final String endDate) {
return RestAssured.given().log().all()
.header(new Header(HttpHeaders.AUTHORIZATION, JWT_PREFIX + token))
.pathParam("teamPlaceId", teamPlaceId)
.queryParam("startDate", startDate)
.queryParam("endDate", endDate)
.when().log().all()
.get("/api/team-place/{teamPlaceId}/calendar/schedules")
.then().log().all()
.extract();
}

public static ExtractableResponse<Response> FIND_DAILY_SCHEDULE_REQUEST(final String token, final Long teamPlaceId, final int year, final int month, final int day) {
return RestAssured.given().log().all()
.header(new Header(HttpHeaders.AUTHORIZATION, JWT_PREFIX + token))
Expand Down
Loading

0 comments on commit 2f87582

Please sign in to comment.