Skip to content

Commit

Permalink
refactor: CenterPosition, Path 중간 테이블 추가
Browse files Browse the repository at this point in the history
WalkRecord 과 oneToone, oneTomany를 위한 중간 테이블 추가

related to : #38
  • Loading branch information
jieunjin committed Oct 19, 2024
1 parent bba8157 commit 24e62d1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package buddyguard.mybuddyguard.walk.entity;

import jakarta.persistence.Column;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "WALK_RECORD_CENTER_POSITION")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class WalkRecordCenterPosition {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

// WalkRecord와 1:1 관계 설정
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "walk_record_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private WalkRecord walkRecord;

// 위도 정보
@Column(name = "latitude", nullable = false)
private Double latitude;

// 경도 정보
@Column(name = "longitude", nullable = false)
private Double longitude;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package buddyguard.mybuddyguard.walk.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "WALK_RECORD_PATH")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class WalkRecordPath {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

// 경로의 위도
@Column(name = "latitude", nullable = false)
private Double latitude;

// 경로의 경도
@Column(name = "longitude", nullable = false)
private Double longitude;
}

0 comments on commit 24e62d1

Please sign in to comment.