Skip to content

Commit 3b9c9d1

Browse files
authored
Merge pull request #270 from THIP-TextHip/develop
[chore] 운영서버로 배포 - 25/08/21
2 parents 97cbee0 + 8004dff commit 3b9c9d1

156 files changed

Lines changed: 1659 additions & 2265 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/konkuk/thip/comment/adapter/out/persistence/repository/CommentQueryRepositoryImpl.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import konkuk.thip.comment.application.port.out.dto.CommentQueryDto;
88
import konkuk.thip.comment.application.port.out.dto.QCommentQueryDto;
99
import konkuk.thip.common.entity.StatusType;
10-
import konkuk.thip.user.adapter.out.jpa.QAliasJpaEntity;
1110
import konkuk.thip.user.adapter.out.jpa.QUserJpaEntity;
1211
import lombok.RequiredArgsConstructor;
1312
import org.springframework.stereotype.Repository;
@@ -24,7 +23,6 @@ public class CommentQueryRepositoryImpl implements CommentQueryRepository {
2423

2524
private final QCommentJpaEntity comment = QCommentJpaEntity.commentJpaEntity;
2625
private final QUserJpaEntity commentCreator = QUserJpaEntity.userJpaEntity;
27-
private final QAliasJpaEntity aliasOfCommentCreator = QAliasJpaEntity.aliasJpaEntity;
2826
private final QCommentJpaEntity parentComment = new QCommentJpaEntity("parentComment");
2927
private final QUserJpaEntity parentCommentCreator = new QUserJpaEntity("parentCommentCreator");
3028

@@ -34,10 +32,8 @@ public List<CommentQueryDto> findRootCommentsWithDeletedByCreatedAtDesc(Long pos
3432
QCommentQueryDto proj = new QCommentQueryDto(
3533
comment.commentId,
3634
commentCreator.userId,
37-
aliasOfCommentCreator.imageUrl,
35+
commentCreator.alias,
3836
commentCreator.nickname,
39-
aliasOfCommentCreator.value,
40-
aliasOfCommentCreator.color,
4137
comment.createdAt,
4238
comment.content,
4339
comment.likeCount,
@@ -58,7 +54,6 @@ public List<CommentQueryDto> findRootCommentsWithDeletedByCreatedAtDesc(Long pos
5854
.select(proj)
5955
.from(comment)
6056
.leftJoin(comment.userJpaEntity, commentCreator)
61-
.leftJoin(commentCreator.aliasForUserJpaEntity, aliasOfCommentCreator)
6257
.where(whereClause)
6358
.orderBy(comment.createdAt.desc())
6459
.limit(size + 1) // size + 1 개 조회
@@ -79,10 +74,8 @@ public List<CommentQueryDto> findAllActiveChildCommentsByCreatedAtAsc(Long rootC
7974
comment.parent.commentId,
8075
parentCommentCreator.nickname,
8176
commentCreator.userId,
82-
aliasOfCommentCreator.imageUrl,
77+
commentCreator.alias,
8378
commentCreator.nickname,
84-
aliasOfCommentCreator.value,
85-
aliasOfCommentCreator.color,
8679
comment.createdAt,
8780
comment.content,
8881
comment.likeCount,
@@ -97,7 +90,6 @@ public List<CommentQueryDto> findAllActiveChildCommentsByCreatedAtAsc(Long rootC
9790
.leftJoin(comment.parent, parentComment)
9891
.leftJoin(parentComment.userJpaEntity, parentCommentCreator)
9992
.leftJoin(comment.userJpaEntity, commentCreator)
100-
.leftJoin(commentCreator.aliasForUserJpaEntity, aliasOfCommentCreator)
10193
.where(
10294
comment.parent.commentId.in(parentIds), // parentIds 하위의 모든 자식 댓글 조회
10395
comment.status.eq(StatusType.ACTIVE) // 자식 댓글은 ACTIVE인 것만 조회
@@ -141,10 +133,8 @@ public Map<Long, List<CommentQueryDto>> findAllActiveChildCommentsByCreatedAtAsc
141133
comment.parent.commentId,
142134
parentCommentCreator.nickname,
143135
commentCreator.userId,
144-
aliasOfCommentCreator.imageUrl,
136+
commentCreator.alias,
145137
commentCreator.nickname,
146-
aliasOfCommentCreator.value,
147-
aliasOfCommentCreator.color,
148138
comment.createdAt,
149139
comment.content,
150140
comment.likeCount,
@@ -159,7 +149,6 @@ public Map<Long, List<CommentQueryDto>> findAllActiveChildCommentsByCreatedAtAsc
159149
.leftJoin(comment.parent, parentComment)
160150
.leftJoin(parentComment.userJpaEntity, parentCommentCreator)
161151
.leftJoin(comment.userJpaEntity, commentCreator)
162-
.leftJoin(commentCreator.aliasForUserJpaEntity, aliasOfCommentCreator)
163152
.where(
164153
comment.parent.commentId.in(parentIds), // parentIds 하위의 모든 자식 댓글 조회
165154
comment.status.eq(StatusType.ACTIVE) // 자식 댓글은 ACTIVE인 것만 조회
@@ -193,10 +182,8 @@ public CommentQueryDto findRootCommentId(Long rootCommentId) {
193182
QCommentQueryDto proj = new QCommentQueryDto(
194183
comment.commentId,
195184
commentCreator.userId,
196-
aliasOfCommentCreator.imageUrl,
185+
commentCreator.alias,
197186
commentCreator.nickname,
198-
aliasOfCommentCreator.value,
199-
aliasOfCommentCreator.color,
200187
comment.createdAt,
201188
comment.content,
202189
comment.likeCount,
@@ -207,7 +194,6 @@ public CommentQueryDto findRootCommentId(Long rootCommentId) {
207194
.select(proj)
208195
.from(comment)
209196
.join(comment.userJpaEntity, commentCreator)
210-
.join(commentCreator.aliasForUserJpaEntity, aliasOfCommentCreator)
211197
.where(
212198
comment.commentId.eq(rootCommentId),
213199
comment.status.eq(StatusType.ACTIVE)
@@ -223,10 +209,8 @@ public CommentQueryDto findChildCommentId(Long rootCommentId, Long replyCommentI
223209
comment.parent.commentId,
224210
parentCommentCreator.nickname,
225211
commentCreator.userId,
226-
aliasOfCommentCreator.imageUrl,
212+
commentCreator.alias,
227213
commentCreator.nickname,
228-
aliasOfCommentCreator.value,
229-
aliasOfCommentCreator.color,
230214
comment.createdAt,
231215
comment.content,
232216
comment.likeCount,
@@ -239,7 +223,6 @@ public CommentQueryDto findChildCommentId(Long rootCommentId, Long replyCommentI
239223
.join(comment.parent, parentComment)
240224
.join(parentComment.userJpaEntity, parentCommentCreator)
241225
.join(comment.userJpaEntity, commentCreator)
242-
.join(commentCreator.aliasForUserJpaEntity, aliasOfCommentCreator)
243226
.where(
244227
comment.parent.commentId.eq(rootCommentId),
245228
parentComment.status.eq(StatusType.ACTIVE),

src/main/java/konkuk/thip/comment/application/port/out/dto/CommentQueryDto.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.querydsl.core.annotations.QueryProjection;
44
import jakarta.annotation.Nullable;
5+
import konkuk.thip.user.domain.value.Alias;
56

67
import java.time.LocalDateTime;
78

@@ -23,7 +24,22 @@ public record CommentQueryDto(
2324
* child comment
2425
*/
2526
@QueryProjection
26-
public CommentQueryDto {}
27+
public CommentQueryDto (
28+
Long commentId,
29+
Long parentCommentId,
30+
String parentCommentCreatorNickname,
31+
Long creatorId,
32+
Alias creatorAlias,
33+
String creatorNickname,
34+
LocalDateTime createdAt, // 댓글 작성 시각
35+
String content,
36+
int likeCount,
37+
Boolean isDeleted
38+
) {
39+
this(commentId, parentCommentId, parentCommentCreatorNickname, creatorId, creatorAlias.getImageUrl(),
40+
creatorNickname, creatorAlias.getValue(), creatorAlias.getColor(),
41+
createdAt, content, likeCount, isDeleted);
42+
}
2743

2844
/**
2945
* root comment
@@ -32,16 +48,15 @@ public record CommentQueryDto(
3248
public CommentQueryDto (
3349
Long commentId,
3450
Long creatorId,
35-
String creatorProfileImageUrl,
51+
Alias creatorAlias,
3652
String creatorNickname,
37-
String alias,
38-
String aliasColor,
3953
LocalDateTime createdAt, // 댓글 작성 시각
4054
String content,
4155
int likeCount,
4256
boolean isDeleted
4357
) {
44-
this(commentId, null, null, creatorId, creatorProfileImageUrl, creatorNickname,
45-
alias, aliasColor, createdAt, content, likeCount, isDeleted);
58+
this(commentId, null, null, creatorId, creatorAlias.getImageUrl(),
59+
creatorNickname, creatorAlias.getValue(), creatorAlias.getColor(),
60+
createdAt, content, likeCount, isDeleted);
4661
}
4762
}

src/main/java/konkuk/thip/common/exception/code/ErrorCode.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ public enum ErrorCode implements ResponseCode {
159159
FEED_ALREADY_SAVED(HttpStatus.BAD_REQUEST, 160006, "사용자가 이미 저장한 피드입니다."),
160160
FEED_NOT_SAVED_CANNOT_DELETE(HttpStatus.BAD_REQUEST, 160007, "사용자가 저장하지 않은 피드는 저장삭제 할 수 없습니다."),
161161
FEED_CAN_NOT_SHOW_PRIVATE_ONE(HttpStatus.BAD_REQUEST, 160008, "비공개 피드는 피드 작성자 이외에는 조회할 수 없습니다."),
162+
TAG_SHOULD_BE_UNIQUE(HttpStatus.BAD_REQUEST, 160009, "피드에 등록된 태그는 중복될 수 없습니다."),
163+
TAG_LIST_SIZE_OVERFLOW(HttpStatus.BAD_REQUEST, 160010, "등록 가능한 태그 개수를 초과하였습니다."),
164+
165+
166+
/**
167+
* 165000: ContentList error
168+
*/
169+
CONTENT_LIST_SIZE_OVERFLOW(HttpStatus.BAD_REQUEST, 165000, "컨텐츠 리스트의 크기가 초과되었습니다. 최대 3개까지 가능합니다."),
170+
CONTENT_NOT_FOUND(HttpStatus.BAD_REQUEST, 165001, "해당 이미지는 이 피드에 존재하지 않습니다:"),
162171

163172
/**
164173
* 170000 : Image File error

src/main/java/konkuk/thip/common/swagger/SwaggerResponseDescription.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ public enum SwaggerResponseDescription {
180180
BOOK_NOT_FOUND,
181181
TAG_NOT_FOUND,
182182
TAG_NAME_NOT_MATCH,
183-
INVALID_FEED_COMMAND,
183+
CONTENT_LIST_SIZE_OVERFLOW,
184+
TAG_SHOULD_BE_UNIQUE,
185+
TAG_LIST_SIZE_OVERFLOW,
184186
BOOK_NAVER_API_PARSING_ERROR,
185187
BOOK_NAVER_API_ISBN_NOT_FOUND,
186188
EMPTY_FILE_EXCEPTION,
@@ -193,7 +195,9 @@ public enum SwaggerResponseDescription {
193195
BOOK_NOT_FOUND,
194196
TAG_NOT_FOUND,
195197
TAG_NAME_NOT_MATCH,
196-
INVALID_FEED_COMMAND,
198+
CONTENT_LIST_SIZE_OVERFLOW,
199+
TAG_SHOULD_BE_UNIQUE,
200+
TAG_LIST_SIZE_OVERFLOW,
197201
FEED_ACCESS_FORBIDDEN
198202
))),
199203
CHANGE_FEED_SAVED_STATE(new LinkedHashSet<>(Set.of(
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package konkuk.thip.common.util;
2+
3+
import konkuk.thip.feed.domain.value.Tag;
4+
import konkuk.thip.room.domain.value.Category;
5+
import konkuk.thip.user.domain.value.Alias;
6+
7+
import java.util.Collections;
8+
import java.util.EnumMap;
9+
import java.util.List;
10+
import java.util.Map;
11+
12+
public final class EnumMappings {
13+
14+
private EnumMappings() {}
15+
16+
private static final Map<Alias, Category> aliasToCategory;
17+
private static final Map<Category, List<Tag>> categoryToTags;
18+
19+
// 역방향 인덱스
20+
private static final Map<Category, Alias> categoryToAlias;
21+
private static final Map<Tag, Category> tagToCategory;
22+
23+
static {
24+
// Alias -> Category
25+
EnumMap<Alias, Category> a2c = new EnumMap<>(Alias.class);
26+
a2c.put(Alias.WRITER, Category.LITERATURE); // 문학가
27+
a2c.put(Alias.SCIENTIST, Category.SCIENCE_IT); // 과학자
28+
a2c.put(Alias.SOCIOLOGIST, Category.SOCIAL_SCIENCE); // 사회학
29+
a2c.put(Alias.ARTIST, Category.ART); // 예술가
30+
a2c.put(Alias.PHILOSOPHER, Category.HUMANITY); // 철학자
31+
aliasToCategory = Collections.unmodifiableMap(a2c);
32+
33+
// Category -> Tags
34+
EnumMap<Category, List<Tag>> c2t = new EnumMap<>(Category.class);
35+
c2t.put(Category.LITERATURE, List.of( // 문학
36+
Tag.KOREAN_NOVEL, Tag.FOREIGN_NOVEL, Tag.CLASSIC_LITERATURE, Tag.ESSAY, Tag.POETRY,
37+
Tag.PLAY, Tag.DETECTIVE_NOVEL, Tag.FANTASY_NOVEL, Tag.ROMANCE_NOVEL, Tag.LITERARY_THEORY
38+
));
39+
c2t.put(Category.SCIENCE_IT, List.of( // 과학·IT
40+
Tag.GENERAL_SCIENCE, Tag.PHYSICS, Tag.CHEMISTRY, Tag.BIOLOGY, Tag.ASTRONOMY,
41+
Tag.EARTH_SCIENCE, Tag.MATHEMATICS, Tag.GENERAL_ENGINEERING,
42+
Tag.COMPUTER_ENGINEERING, Tag.PROGRAMMING, Tag.IT_GENERAL
43+
));
44+
c2t.put(Category.SOCIAL_SCIENCE, List.of( // 사회과학
45+
Tag.SOCIOLOGY, Tag.LAW, Tag.GENERAL_POLITICS, Tag.POLITICAL_SCIENCE,
46+
Tag.ECONOMICS, Tag.BUSINESS_ADMIN, Tag.JURISPRUDENCE, Tag.EDUCATION,
47+
Tag.PSYCHOLOGY, Tag.MEDIA, Tag.INTERNATIONAL_RELATIONS, Tag.SOCIAL_ISSUES,
48+
Tag.MARKETING, Tag.INVESTMENT, Tag.STARTUP, Tag.GENERAL_ECONOMY
49+
));
50+
c2t.put(Category.HUMANITY, List.of( // 인문학
51+
Tag.PHILOSOPHY, Tag.HISTORY, Tag.RELIGION, Tag.CLASSICS, Tag.LINGUISTICS,
52+
Tag.CULTURAL_ANTHROPOLOGY, Tag.HUMANISTIC_ESSAY, Tag.EASTERN_PHILOSOPHY,
53+
Tag.WESTERN_PHILOSOPHY, Tag.WORLD_HISTORY, Tag.KOREAN_HISTORY,
54+
Tag.HISTORICAL_ESSAY, Tag.ANCIENT_HISTORY, Tag.MODERN_HISTORY
55+
));
56+
c2t.put(Category.ART, List.of(
57+
Tag.ART, Tag.MUSIC, Tag.MOVIE, Tag.PHOTO, Tag.DANCE,
58+
Tag.THEATER, Tag.DESIGN, Tag.ARCHITECTURE, Tag.GENERAL_ART
59+
));
60+
categoryToTags = Collections.unmodifiableMap(c2t);
61+
62+
// ------------역방향 인덱스------------
63+
// Category -> Alias
64+
EnumMap<Category, Alias> c2a = new EnumMap<>(Category.class);
65+
aliasToCategory.forEach((alias, category) -> {
66+
Alias prev = c2a.put(category, alias);
67+
if (prev != null && prev != alias) {
68+
throw new IllegalStateException("Category에 두 개 이상의 Alias 매핑: " + category);
69+
}
70+
});
71+
categoryToAlias = Collections.unmodifiableMap(c2a);
72+
73+
// Tag -> Category (각 Tag는 정확히 하나의 Category)
74+
EnumMap<Tag, Category> t2c = new EnumMap<>(Tag.class);
75+
categoryToTags.forEach((category, tags) -> {
76+
for (Tag tag : tags) {
77+
Category prev = t2c.put(tag, category);
78+
if (prev != null && prev != category) {
79+
throw new IllegalStateException(
80+
"Tag가 둘 이상의 Category에 매핑됨: " + tag + " (" + prev + " vs " + category + ")"
81+
);
82+
}
83+
}
84+
});
85+
tagToCategory = Collections.unmodifiableMap(t2c);
86+
}
87+
88+
// ----------- Public API -----------
89+
90+
/** Alias -> Category */
91+
public static Category categoryFrom(Alias alias) {
92+
return aliasToCategory.get(alias);
93+
}
94+
95+
/** Category -> Tags */
96+
public static List<Tag> tagsFrom(Category category) {
97+
return categoryToTags.getOrDefault(category, List.of());
98+
}
99+
100+
/** Category -> Alias */
101+
public static Alias aliasFrom(Category category) {
102+
return categoryToAlias.get(category);
103+
}
104+
105+
/** Tag -> Category */
106+
public static Category categoryFrom(Tag tag) {
107+
return tagToCategory.get(tag);
108+
}
109+
110+
public static Map<Category, List<Tag>> getCategoryToTags() {
111+
return Collections.unmodifiableMap(categoryToTags);
112+
}
113+
114+
public static Map<Alias, Category> getAliasToCategory() {
115+
return Collections.unmodifiableMap(aliasToCategory);
116+
}
117+
}

src/main/java/konkuk/thip/config/AwsS3ImageUrlInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import jakarta.annotation.PostConstruct;
44
import konkuk.thip.common.exception.BusinessException;
55
import konkuk.thip.config.properties.AwsS3Properties;
6-
import konkuk.thip.room.domain.Category;
7-
import konkuk.thip.user.domain.Alias;
6+
import konkuk.thip.room.domain.value.Category;
7+
import konkuk.thip.user.domain.value.Alias;
88
import lombok.RequiredArgsConstructor;
99
import org.springframework.stereotype.Component;
1010

src/main/java/konkuk/thip/feed/adapter/out/jpa/ContentJpaEntity.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)