-
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
7fb62b2
commit 8e2dce2
Showing
2 changed files
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package server.sopt.carrot.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Image { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String imageUrl; | ||
|
||
@OneToOne | ||
Product product; | ||
|
||
@Builder | ||
public Image(String imageUrl, Product product) { | ||
this.imageUrl = imageUrl; | ||
this.product = product; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
carrot/src/main/java/server/sopt/carrot/repo/ImageRepository.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 server.sopt.carrot.repo; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import server.sopt.carrot.entity.Image; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ImageRepository extends JpaRepository<Image, Long> { | ||
Optional<Image> findByProduct_Id(Long proudctId); | ||
} |