-
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.
[RELEASE] v1.0.4 릴리즈
- Loading branch information
Showing
20 changed files
with
197 additions
and
137 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
14 changes: 14 additions & 0 deletions
14
dateroad-api/src/main/java/org/dateroad/course/dto/CourseWithPlacesAndTagsDto.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 org.dateroad.course.dto; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
import org.dateroad.place.domain.CoursePlace; | ||
import org.dateroad.tag.domain.CourseTag; | ||
|
||
|
||
@Builder | ||
public record CourseWithPlacesAndTagsDto(List<CoursePlace> coursePlaces, List<CourseTag> courseTags) { | ||
public static CourseWithPlacesAndTagsDto of(List<CoursePlace> coursePlaces, List<CourseTag> courseTags) { | ||
return CourseWithPlacesAndTagsDto.builder().coursePlaces(coursePlaces).courseTags(courseTags).build(); | ||
} | ||
} |
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
17 changes: 3 additions & 14 deletions
17
dateroad-api/src/main/java/org/dateroad/course/service/CoursePlaceService.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 |
---|---|---|
@@ -1,35 +1,24 @@ | ||
package org.dateroad.course.service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import org.dateroad.course.dto.request.CoursePlaceGetReq; | ||
import org.dateroad.date.domain.Course; | ||
import org.dateroad.place.domain.CoursePlace; | ||
import org.dateroad.place.repository.CoursePlaceRepository; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class CoursePlaceService { | ||
private final CoursePlaceRepository coursePlaceRepository; | ||
|
||
public float findTotalDurationByCourseId(final Long id) { | ||
return coursePlaceRepository.findTotalDurationByCourseId(id); | ||
} | ||
|
||
public void createCoursePlace(final List<CoursePlaceGetReq> places, final Course course) { | ||
List<CoursePlace> coursePlaces = places.stream() | ||
public List<CoursePlace> createCoursePlace(final List<CoursePlaceGetReq> places, final Course course) { | ||
return places.stream() | ||
.map(placeReq -> CoursePlace.create( | ||
placeReq.getTitle(), | ||
placeReq.getDuration(), | ||
course, | ||
placeReq.getSequence() | ||
)) | ||
.collect(Collectors.toList()); | ||
coursePlaceRepository.saveAll(coursePlaces); | ||
.toList(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
dateroad-api/src/main/java/org/dateroad/course/service/CourseRollbackService.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,33 @@ | ||
package org.dateroad.course.service; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.dateroad.code.FailureCode; | ||
import org.dateroad.exception.DateRoadException; | ||
import org.springframework.data.domain.Range; | ||
import org.springframework.data.redis.connection.stream.Consumer; | ||
import org.springframework.data.redis.connection.stream.PendingMessage; | ||
import org.springframework.data.redis.connection.stream.PendingMessages; | ||
import org.springframework.data.redis.connection.stream.RecordId; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Slf4j | ||
public class CourseRollbackService { | ||
private final RedisTemplate<String, String> redistemplateForCluster; | ||
|
||
public void rollbackCourse(final RecordId recordId) { | ||
PendingMessages pendingMessage = redistemplateForCluster.opsForStream().pending( | ||
"coursePoint", Consumer.from("coursePointGroup", "instance-1"), Range.unbounded(), 100L | ||
); | ||
for (PendingMessage message : pendingMessage) { | ||
if(message.getId() == recordId){ | ||
redistemplateForCluster.opsForStream().acknowledge("coursePoint", "coursePointGroup", recordId); | ||
throw new DateRoadException(FailureCode.COURSE_CREATE_ERROR); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.