-
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.
Showing
65 changed files
with
567 additions
and
795 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
54 changes: 54 additions & 0 deletions
54
dateroad-api/src/main/java/org/dateroad/Image/service/ImageService.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,54 @@ | ||
package org.dateroad.Image.service; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import lombok.RequiredArgsConstructor; | ||
import org.dateroad.code.FailureCode; | ||
import org.dateroad.date.domain.Course; | ||
import org.dateroad.exception.DateRoadException; | ||
import org.dateroad.image.domain.Image; | ||
import org.dateroad.image.repository.ImageRepository; | ||
import org.dateroad.s3.S3Service; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class ImageService { | ||
private final ImageRepository imageRepository; | ||
private final S3Service s3Service; | ||
@Value("${s3.bucket.path}") | ||
private String path; | ||
@Value("${cloudfront.domain}") | ||
private String cachePath; | ||
|
||
public List<Image> saveImages(final List<MultipartFile> images, final Course course) { | ||
AtomicInteger sequence = new AtomicInteger(); | ||
List<Image> courseimages = images.stream() | ||
.map(img -> { | ||
try { | ||
return Image.create( | ||
course, | ||
cachePath + s3Service.uploadImage(path, img).get(), | ||
sequence.getAndIncrement() | ||
); | ||
} catch (IOException | ExecutionException | InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
}) | ||
.toList(); | ||
return imageRepository.saveAll(courseimages); | ||
} | ||
|
||
public Image findFirstByCourseOrderBySequenceAsc(Course course) { | ||
return imageRepository.findFirstByCourseOrderBySequenceAsc(course) | ||
.orElseThrow( | ||
() -> new DateRoadException(FailureCode.COURSE_THUMBNAIL_NOT_FOUND) | ||
); | ||
} | ||
} |
22 changes: 5 additions & 17 deletions
22
dateroad-api/src/main/java/org/dateroad/advertisment/dto/response/AdvGetAllRes.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,23 @@ | ||
package org.dateroad.advertisment.dto.response; | ||
|
||
import java.util.List; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.dateroad.advertisement.domain.AdTagType; | ||
import org.dateroad.advertisement.domain.Advertisment; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record AdvGetAllRes( | ||
List<AdvertismentDtoRes> advertismentDtoResList | ||
) { | ||
public static AdvGetAllRes of(List<AdvertismentDtoRes> advertismentDtoResList) { | ||
return AdvGetAllRes.builder() | ||
.advertismentDtoResList(advertismentDtoResList) | ||
.build(); | ||
} | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record AdvertismentDtoRes( | ||
Long advertismentId, | ||
String thumbnail, | ||
String title, | ||
AdTagType tag | ||
) { | ||
){ | ||
public static AdvertismentDtoRes of(Advertisment advertisment) { | ||
return AdvertismentDtoRes.builder() | ||
.advertismentId(advertisment.getId()) | ||
.thumbnail(advertisment.getThumbnail()) | ||
.title(advertisment.getTitle()) | ||
.tag(advertisment.getTag()) | ||
.build(); | ||
return new AdvertismentDtoRes(advertisment.getId(), advertisment.getTitle(), advertisment.getThumbnail(), advertisment.getTag()); | ||
} | ||
} | ||
public static AdvGetAllRes of(List<AdvertismentDtoRes> advertismentDtoResList) { | ||
return new AdvGetAllRes(advertismentDtoResList); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
dateroad-api/src/main/java/org/dateroad/config/AsyncConfig.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,12 @@ | ||
package org.dateroad.config; | ||
|
||
import java.util.concurrent.Executor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
@Configuration | ||
@EnableAsync | ||
public class AsyncConfig { | ||
} |
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
51 changes: 51 additions & 0 deletions
51
dateroad-api/src/main/java/org/dateroad/course/dto/request/CourseCreateReq.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,51 @@ | ||
package org.dateroad.course.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
|
||
@Getter | ||
@Builder(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class CourseCreateReq { | ||
private String title; | ||
|
||
@DateTimeFormat(pattern = "yyyy.MM.dd") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
private LocalDate date; | ||
|
||
@DateTimeFormat(pattern = "HH:mm") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") | ||
private LocalTime startAt; | ||
|
||
private String country; | ||
|
||
private String city; | ||
|
||
private String description; | ||
|
||
private int cost; | ||
|
||
public static CourseCreateReq of(final String title,final LocalDate date,final LocalTime startAt, | ||
final String country,final String city,final String description, | ||
int cost) { | ||
return CourseCreateReq.builder() | ||
.title(title) | ||
.date(date) | ||
.startAt(startAt) | ||
.country(country) | ||
.city(city) | ||
.description(description) | ||
.cost(cost) | ||
.build(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
dateroad-api/src/main/java/org/dateroad/course/dto/request/CoursePlaceGetReq.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,27 @@ | ||
package org.dateroad.course.dto.request; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Builder(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class CoursePlaceGetReq { | ||
private String title; | ||
private float duration; | ||
private int sequence; | ||
|
||
public static CoursePlaceGetReq of(String title, float duration, int sequence) { | ||
return CoursePlaceGetReq.builder() | ||
.title(title) | ||
.duration(duration) | ||
.sequence(sequence) | ||
.build(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
dateroad-api/src/main/java/org/dateroad/course/dto/request/TagCreateReq.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,24 @@ | ||
package org.dateroad.course.dto.request; | ||
|
||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.dateroad.tag.domain.DateTagType; | ||
|
||
@Getter | ||
@Setter | ||
@Builder(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class TagCreateReq{ | ||
private DateTagType tag; | ||
|
||
public static TagCreateReq of(DateTagType tag) { | ||
return TagCreateReq.builder() | ||
.tag(tag).build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
dateroad-api/src/main/java/org/dateroad/course/dto/response/CourseCreateRes.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,15 @@ | ||
package org.dateroad.course.dto.response; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
|
||
@Builder(access = AccessLevel.PROTECTED) | ||
public record CourseCreateRes( | ||
Long courseId | ||
) { | ||
public static CourseCreateRes of(Long courseId) { | ||
return CourseCreateRes.builder() | ||
.courseId(courseId) | ||
.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
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
Oops, something went wrong.