-
Notifications
You must be signed in to change notification settings - Fork 0
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 #58 from ecolink-JOIN/meeting-delete
[Feat] 회차 삭제 API 개발
- Loading branch information
Showing
21 changed files
with
196 additions
and
53 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
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
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
41 changes: 41 additions & 0 deletions
41
...n/java/com/join/core/meeting/controller/specification/MeetingControllerSpecification.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,41 @@ | ||
package com.join.core.meeting.controller.specification; | ||
|
||
import com.join.core.auth.domain.UserPrincipal; | ||
import com.join.core.common.response.ApiResponse; | ||
import com.join.core.meeting.dto.request.MeetingAppendRequest; | ||
import com.join.core.meeting.dto.response.MeetingResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
import java.util.List; | ||
|
||
public interface MeetingControllerSpecification { | ||
|
||
@Tag(name = "${swagger.tag.meeting}") | ||
@Operation(summary = "회차 추가 - 인증 필수", | ||
description = "회차 추가 - 인증 필수", | ||
security = {@SecurityRequirement(name = "session-token")}) | ||
ApiResponse<Void> append(@AuthenticationPrincipal UserPrincipal principal, | ||
@Valid @RequestBody MeetingAppendRequest request, | ||
@PathVariable String studyToken | ||
); | ||
|
||
@Tag(name = "${swagger.tag.meeting}") | ||
@Operation(summary = "회차 리스트 조회", | ||
description = "회차 리스트 조회", | ||
security = {@SecurityRequirement(name = "session-token")}) | ||
ApiResponse<List<MeetingResponse>> getMeetingDetails(@PathVariable String studyToken); | ||
|
||
@Tag(name = "${swagger.tag.meeting}") | ||
@Operation(summary = "회차 삭제 - 인증 필수", | ||
description = "회차 삭제 - 인증 필수", | ||
security = {@SecurityRequirement(name = "session-token")}) | ||
ApiResponse<Void> delete(@AuthenticationPrincipal UserPrincipal principal, | ||
@PathVariable String studyToken, | ||
@PathVariable Long meetingId); | ||
} |
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
50 changes: 50 additions & 0 deletions
50
src/main/java/com/join/core/meeting/domain/MeetingDeleteService.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,50 @@ | ||
package com.join.core.meeting.domain; | ||
|
||
import com.join.core.common.exception.ErrorCode; | ||
import com.join.core.common.exception.impl.NoPermissionException; | ||
import com.join.core.study.domain.Study; | ||
import com.join.core.study.service.StudyReader; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MeetingDeleteService { | ||
|
||
private final MeetingReader meetingReader; | ||
private final StudyReader studyReader; | ||
private final MeetingDeleter meetingDeleter; | ||
|
||
@Transactional | ||
public void delete(Long avatarId, String studyToken, Long meetingId) { | ||
|
||
Study study = studyReader.getStudyByToken(studyToken); | ||
|
||
if (!study.isWriter(avatarId)) { | ||
throw new NoPermissionException(ErrorCode.UNAUTHORIZED_ACCESS); | ||
} | ||
|
||
Meeting meetingToDelete = meetingReader.getMeetingById(meetingId); | ||
|
||
meetingDeleter.delete(meetingToDelete); | ||
|
||
List<Meeting> remainingMeetings = meetingReader.getMeetingsByStudy(study) | ||
.stream() | ||
.filter(meeting -> !meeting.getId().equals(meetingId)) | ||
.sorted(Comparator.comparing(meeting -> | ||
LocalDateTime.of(meeting.getStudyDate(), meeting.getStTime()))) | ||
.toList(); | ||
|
||
IntStream.range(0, remainingMeetings.size()).forEach(index -> { | ||
Meeting meeting = remainingMeetings.get(index); | ||
meeting.updateMeetingNo(index + 1); | ||
}); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/join/core/meeting/domain/MeetingDeleter.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,6 @@ | ||
package com.join.core.meeting.domain; | ||
|
||
public interface MeetingDeleter { | ||
void delete(Meeting meeting); | ||
|
||
} |
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/com/join/core/meeting/domain/MeetingReader.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 com.join.core.meeting.domain; | ||
|
||
import com.join.core.study.domain.Study; | ||
|
||
import java.util.List; | ||
|
||
public interface MeetingReader { | ||
List<Meeting> getMeetingsByStudy(Study study); | ||
Meeting getMeetingById(Long meetingId); | ||
|
||
} |
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,6 @@ | ||
package com.join.core.meeting.domain; | ||
|
||
public interface MeetingStore { | ||
void store(Meeting meeting); | ||
|
||
} |
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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/join/core/meeting/repository/MeetingDeleterImpl.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 com.join.core.meeting.repository; | ||
|
||
import com.join.core.meeting.domain.Meeting; | ||
import com.join.core.meeting.domain.MeetingDeleter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class MeetingDeleterImpl implements MeetingDeleter { | ||
|
||
private final MeetingRepository meetingRepository; | ||
|
||
@Override | ||
public void delete(Meeting meeting) { | ||
meetingRepository.delete(meeting); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/join/core/meeting/repository/MeetingStoreImpl.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
11 changes: 0 additions & 11 deletions
11
src/main/java/com/join/core/meeting/service/MeetingReader.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/main/java/com/join/core/meeting/service/MeetingStore.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.