-
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.
- Loading branch information
1 parent
92642a6
commit e058f36
Showing
13 changed files
with
95 additions
and
5 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
15 changes: 15 additions & 0 deletions
15
moodoodle-api/src/main/java/zzangdol/emotion/business/EmotionMapper.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 zzangdol.emotion.business; | ||
|
||
import zzangdol.emotion.domain.Emotion; | ||
import zzangdol.emotion.presentation.dto.response.EmotionResponse; | ||
|
||
public class EmotionMapper { | ||
|
||
public static EmotionResponse toEmotionResponse(Emotion emotion) { | ||
return EmotionResponse.builder() | ||
.name(emotion.getName()) | ||
.imageUrl(emotion.getImageUrl()) | ||
.build(); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
moodoodle-api/src/main/java/zzangdol/emotion/presentation/dto/response/EmotionResponse.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,17 @@ | ||
package zzangdol.emotion.presentation.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class EmotionResponse { | ||
|
||
private String name; | ||
private String imageUrl; | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
moodoodle-domain/src/main/java/zzangdol/emotion/dao/querydsl/EmotionQueryRepository.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,10 @@ | ||
package zzangdol.emotion.dao.querydsl; | ||
|
||
import java.util.List; | ||
import zzangdol.emotion.domain.Emotion; | ||
|
||
public interface EmotionQueryRepository { | ||
|
||
List<Emotion> findRandomEmotions(int limit); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
moodoodle-domain/src/main/java/zzangdol/emotion/dao/querydsl/EmotionQueryRepositoryImpl.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 zzangdol.emotion.dao.querydsl; | ||
|
||
import static zzangdol.emotion.domain.QEmotion.emotion; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
import zzangdol.emotion.domain.Emotion; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class EmotionQueryRepositoryImpl implements EmotionQueryRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Emotion> findRandomEmotions(int limit) { | ||
return queryFactory.selectFrom(emotion) | ||
.orderBy(com.querydsl.core.types.dsl.Expressions.numberTemplate(Double.class, "function('RAND')").asc()) | ||
.limit(limit) | ||
.fetch(); | ||
} | ||
} |
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