-
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.
Merge pull request #145 from Link-MIND/test
[Merge] Test merge
- Loading branch information
Showing
10 changed files
with
100 additions
and
31 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
8 changes: 4 additions & 4 deletions
8
linkmind/src/main/java/com/app/toaster/controller/response/toast/WeekSiteDto.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,9 +1,9 @@ | ||
package com.app.toaster.controller.response.toast; | ||
|
||
import com.app.toaster.domain.Toast; | ||
import com.app.toaster.domain.Link; | ||
|
||
public record WeekSiteDto(Long toastId, String toastTitle, String toastImg, String toastLink) { | ||
public static WeekSiteDto of(Toast toast){ | ||
return new WeekSiteDto(toast.getId(), toast.getTitle(), toast.getThumbnailUrl(), toast.getLinkUrl()); | ||
public record WeekSiteDto(Long linkId, String linkTitle, String toastImg, String toastLink) { | ||
public static WeekSiteDto of(Link link){ | ||
return new WeekSiteDto(link.getId(), link.getTitle(), link.getThumbnailUrl(), link.getLinkUrl()); | ||
} | ||
} |
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 com.app.toaster.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonRootName; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Link { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long Id; | ||
|
||
private String title; | ||
|
||
@Column(columnDefinition = "TEXT") | ||
private String linkUrl; | ||
|
||
@Column(columnDefinition = "TEXT") | ||
private String thumbnailUrl; | ||
|
||
@Builder | ||
public Link(String title, String linkUrl, String thumbnailUrl) { | ||
this.title = title; | ||
this.linkUrl = linkUrl; | ||
this.thumbnailUrl = thumbnailUrl; | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
linkmind/src/main/java/com/app/toaster/infrastructure/LinkRepository.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,16 @@ | ||
package com.app.toaster.infrastructure; | ||
|
||
import com.app.toaster.domain.Link; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface LinkRepository extends JpaRepository<Link, Long> { | ||
|
||
@Query("SELECT e FROM Link e ORDER BY FUNCTION('RAND') FETCH FIRST 3 ROWS ONLY") | ||
List<Link> findRandom3Links(); | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
linkmind/src/main/java/com/app/toaster/service/link/LinkService.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,26 @@ | ||
package com.app.toaster.service.link; | ||
|
||
import com.app.toaster.controller.response.toast.WeekSiteDto; | ||
import com.app.toaster.infrastructure.LinkRepository; | ||
import jakarta.persistence.criteria.CriteriaBuilder; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Random; | ||
import java.util.Set; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class LinkService { | ||
|
||
private final LinkRepository linkRepository; | ||
public List<WeekSiteDto> getWeekLinks(){ | ||
|
||
return linkRepository.findRandom3Links().stream().map(WeekSiteDto::of).toList(); | ||
} | ||
|
||
|
||
|
||
} |
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