Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨[Feature/adult thumbnail-228] 성인용 웹툰 썸네일 적용 #229

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/kr/co/antoon/aws/application/AwsS3Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import kr.co.antoon.aws.domain.vo.AdultThumbnailType;
import kr.co.antoon.aws.domain.vo.AntDefaultImageName;
import kr.co.antoon.aws.domain.vo.S3Category;
import kr.co.antoon.error.exception.aws.FileUploadInvalidException;
Expand Down Expand Up @@ -55,6 +56,11 @@ public String randomProfileImage() {
return amazonS3Client.getUrl(bucketName, fileName).toString();
}

public String adultThumbnailImage(AdultThumbnailType type) {
var fileName = S3Category.ADULT_THUMBNAIL + "/" + type + ".png";
return amazonS3Client.getUrl(bucketName, fileName).toString();
}

public static String buildFileName(S3Category category, String originalFileName) {
var fileExtenstionIndex = originalFileName.lastIndexOf(FILE_EXTENSION_SEPARATOR);
var fileExtension = originalFileName.substring(fileExtenstionIndex);
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/kr/co/antoon/aws/domain/vo/AdultThumbnailType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package kr.co.antoon.aws.domain.vo;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum AdultThumbnailType {
KAKAO("카카오 웹툰"),
NAVER("네이버 웹툰"),
DETAIL("상세 조회"),
RANK("랭킹 조회"),
;

private final String description;
}
1 change: 1 addition & 0 deletions src/main/java/kr/co/antoon/aws/domain/vo/S3Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum S3Category {
VOTE("투표"),
TEST("업로드 테스트용"),
ANT_DEFAULT("기본 개미 이미지"),
ADULT_THUMBNAIL("성인용 웹툰 썸네일")
;

private final String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public WebtoonCrawlingDto crawling() {
thumbnail,
genres,
Double.parseDouble(score),
day
day,
0
)
);
// log.info("[Kakao Webtoon Crawling] title-> {} / score -> {}", title, score);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public WebtoonCrawlingDto crawling() {

// log.info("[Naver Webtoon Crawling] title-> {} / url -> {}", title, url);

// TODO: 18세 연령가, 12세 연령가, 전체 연령가 이렇게 저장되는데 숫자만 저장하도록 split
// TODO: 여기서 성인용 웹툰 썸네일을 19금 썸네일로 대체할지, 아님 기존 썸네일 저장하고, 조회할 때 19금 썸네일로 할지
var age = innerElement.select("span.age").text().split("연령가")[0].split("세")[0];
return new WebtoonCrawlingDto.WebtoonCrawlingDetail(
title,
content,
Expand All @@ -71,7 +74,8 @@ public WebtoonCrawlingDto crawling() {
finalThumbnail,
genres,
Double.parseDouble(score),
day
day,
Integer.parseInt(age)
);
}).toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public record WebtoonCrawlingDetail(
String thumbnail,
List<String> genre,
Double score,
String day
String day,
int age
) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public static WebtoonDto toWebtoonDto(List<WebtoonNativeDto> webtoon) {
getDifferencePercentage(webtoon.get(0).getGraphScore(), webtoon.get(0).getScoreGap()),
status(webtoon.get(0).getRecommendationStatus()),
webtoon.get(0).getRanking(),
characters
characters,
webtoon.get(0).get
);
}

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/kr/co/antoon/webtoon/domain/Webtoon.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ public class Webtoon extends BaseEntity {
@Enumerated(EnumType.STRING)
private ActiveStatus status;

@Column(nullable = false)
private int age;


@Builder
public Webtoon(String title, String content, String webtoonUrl, String thumbnail, Platform platform) {
public Webtoon(String title, String content, String webtoonUrl, String thumbnail, Platform platform, int age) {
this.title = title;
this.content = content;
this.webtoonUrl = webtoonUrl;
this.thumbnail = thumbnail;
this.platform = platform;
this.age = age;
publish();
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/kr/co/antoon/webtoon/dto/WebtoonDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public record WebtoonDto(
double scoreGapPercent,
RecommendationStatus recommendationStatus,
Integer ranking,
Set<CharacterDto> characters
Set<CharacterDto> characters,
int age
) {
public record GenreDto(
Long webtoonGenreId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ public interface WebtoonNativeDto {
String getCharacterName();

String getCharacterImageUrl();

int getAge();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface WebtoonRepository extends JpaRepository<Webtoon, Long>, JpaSpec
long countByStatus(ActiveStatus status);

@Query(value = """
select w.id as webtoonId, w.title, w.content, w.webtoon_url as webtoonUrl, w.thumbnail, w.platform, w.status,
select w.id as webtoonId, w.title, w.content, w.webtoon_url as webtoonUrl, w.thumbnail, w.platform, w.status, w.age
wg.id as webtoonGenreId, wg.genre_category as genreCategory,
wpd.id as webtoonPublishDayId, wpd.day,
ww.id as webtoonWriterId, ww.name,
Expand Down