Skip to content

Commit

Permalink
Merge pull request #224 from ASAP-as-soon-as-possible/feat/#233
Browse files Browse the repository at this point in the history
#233 [feat] 회의 확정 시 회의 시간 UPDATE 로직 수정
  • Loading branch information
KWY0218 authored Oct 10, 2023
2 parents 61de882 + 5f778bf commit 566821b
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class MeetingConfirmRequestDto {
@NotNull(message = "회의 진행 월이 입력되지 않았습니다.")
private String month;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.asap.server.controller.dto.request;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class UserRequestDto {
private Long id;
private String name;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/asap/server/domain/Meeting.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Entity
@Getter
@Builder
@AllArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Meeting extends AuditingTimeEntity {
@Id
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/asap/server/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class User extends AuditingTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/asap/server/service/MeetingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ public void confirmMeeting(

userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers());

LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay());
deleteMeetingTimes(meeting);

LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay());
LocalTime startTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getStartTime().getTime());
LocalTime endTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getEndTime().getTime());

LocalDateTime fixedStartDateTime = LocalDateTime.of(fixedDate, startTime);
LocalDateTime fixedEndDateTime = LocalDateTime.of(fixedDate, endTime);

meeting.setConfirmedDateTime(fixedStartDateTime, fixedEndDateTime);

deleteMeetingTimes(meeting);
meetingRepository.save(meeting);
}

private void deleteMeetingTimes(final Meeting meeting) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.asap.server.service.meeting;

import com.asap.server.controller.dto.request.MeetingConfirmRequestDto;
import com.asap.server.controller.dto.request.UserRequestDto;
import com.asap.server.domain.Meeting;
import com.asap.server.domain.Place;
import com.asap.server.domain.User;
import com.asap.server.domain.enums.Duration;
import com.asap.server.domain.enums.PlaceType;
import com.asap.server.domain.enums.Role;
import com.asap.server.domain.enums.TimeSlot;
import com.asap.server.service.MeetingService;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import java.util.List;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@Transactional
public class ConfirmMeetingMethodTest {
@Autowired
private MeetingService meetingService;
@Autowired
private EntityManager em;

@Test
@DisplayName("회의 확정시 ConfirmedDateTime 은 Update 된다.")
void setConfirmDateTimeTest() {
// given
final Place place = Place.builder()
.placeType(PlaceType.OFFLINE)
.build();
final Meeting meeting = Meeting.builder()
.title("회의 테스트")
.password("0000")
.additionalInfo("")
.duration(Duration.HALF)
.place(place)
.build();
final User user = User.builder()
.meeting(meeting)
.name("강원용")
.role(Role.HOST)
.isFixed(false)
.build();
meeting.setHost(user);

em.persist(meeting);
em.persist(user);
em.flush();
em.clear();

final UserRequestDto userDto = UserRequestDto.builder()
.id(user.getId())
.name(user.getName())
.build();
final MeetingConfirmRequestDto body = MeetingConfirmRequestDto.builder()
.month("09")
.day("07")
.dayOfWeek("월")
.startTime(TimeSlot.SLOT_6_00)
.endTime(TimeSlot.SLOT_6_30)
.users(List.of(userDto))
.build();

// when
meetingService.confirmMeeting(body, meeting.getId(), user.getId());

// then
final Meeting result = em.find(Meeting.class, meeting.getId());
assertThat(result.isConfirmedMeeting()).isTrue();
}

}

0 comments on commit 566821b

Please sign in to comment.