Skip to content

Commit

Permalink
Merge pull request #19 from KAKAO-TOUR-API-CONTEST/develop
Browse files Browse the repository at this point in the history
[FEAT] album, photos entity mapping
  • Loading branch information
femmefatalehaein authored Sep 1, 2024
2 parents 2441b42 + e8ec248 commit 908c872
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/com/example/ai_jeju/domain/Album.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.ai_jeju.domain;


import jakarta.persistence.*;
import lombok.*;

@Table(name="album")
@NoArgsConstructor(access= AccessLevel.PROTECTED) //기본생성자
@Getter
@Entity
@AllArgsConstructor // 모든 필드를 초기화하는 생성자
@Builder // 빌더 패턴
public class Album {

@Id
@OneToOne
@JoinColumn(name = "album_id") // FK를 설정
private Child child;

}
25 changes: 25 additions & 0 deletions src/main/java/com/example/ai_jeju/domain/Photo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.ai_jeju.domain;

import jakarta.persistence.*;
import lombok.*;

@Table(name="photos")
@NoArgsConstructor(access= AccessLevel.PROTECTED) //기본생성자
@Getter
@Entity
@AllArgsConstructor // 모든 필드를 초기화하는 생성자
@Builder // 빌더 패턴
public class Photo {

@Id
@Column(name = "photo_id")
private Long photoId;

@Column(name = "img_src")
private String imgSrc;

@ManyToOne
@JoinColumn(name = "album_id")
private Album album;

}
13 changes: 13 additions & 0 deletions src/main/java/com/example/ai_jeju/repository/AlbumRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.ai_jeju.repository;

import com.example.ai_jeju.domain.Album;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface AlbumRepository extends JpaRepository<Album, Long> {


}

0 comments on commit 908c872

Please sign in to comment.