Skip to content

Commit

Permalink
Merge pull request #17 from tukcomCD2024/backend/feature/schedule-db
Browse files Browse the repository at this point in the history
스케쥴 관련 테이블 db 엔티티 수정
  • Loading branch information
Dayon-Hong authored Feb 13, 2024
2 parents b6ca3bd + 1ee5710 commit 25411c6
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 95 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.isp.backend.domain.image.entity;

import com.isp.backend.domain.schedules.entity.MySchedule;
import com.isp.backend.global.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
Expand All @@ -18,9 +17,9 @@ public class Image extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id ;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "my_schedule_id", nullable = false)
private MySchedule mySchedule;
// @ManyToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "schedules_id", nullable = false)
// private Schedules schedules;

@Column(name = "image_name")
private String imageName ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.isp.backend.domain.receipt.entity;

import com.isp.backend.domain.schedules.entity.MySchedule;
import com.isp.backend.domain.schedules.entity.Schedules;
import com.isp.backend.global.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
Expand All @@ -18,9 +18,9 @@ public class Receipt extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id ;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "schedule_id", nullable = false)
private MySchedule mySchedule;
// @ManyToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "schedule_id", nullable = false)
// private Schedules schedules;

@Column(name = "title")
private String title ;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.isp.backend.domain.schedule.controller;

public class ScheduleController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.isp.backend.domain.schedule.entity;

import com.isp.backend.domain.schedules.entity.Schedules;
import com.isp.backend.global.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.sql.Timestamp;

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

@Id
@Column(name="id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id ;

@Column(name = "todo")
private String todo ;

@Column(name = "num")
private int num ;

@Column(name = "date")
private String date ;

// Schedules 엔티티의 필드를 참조하도록 수정
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "schedules_id", nullable = false)
private Schedules schedules;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.isp.backend.domain.schedule.repository;

import com.isp.backend.domain.schedule.entity.Schedule;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ScheduleRepository extends JpaRepository<Schedule, String> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
@RestController
@RequestMapping("/api/schedules")
@RequiredArgsConstructor
public class ScheduleController {
public class SchedulesController {
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package com.isp.backend.domain.schedules.entity;

import com.isp.backend.domain.member.entity.Member;
import com.isp.backend.domain.travelPlace.entity.TravelPlace;
import com.isp.backend.domain.schedule.entity.Schedule;
import com.isp.backend.global.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.util.ArrayList;
import java.util.List;


@Getter
@AllArgsConstructor
@Entity
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name="my_schedule")
public class MySchedule extends BaseEntity {
@Table(name="schedules")
public class Schedules extends BaseEntity {

@Id
@Column(name="id", unique = true, nullable = false)
Expand All @@ -30,8 +31,8 @@ public class MySchedule extends BaseEntity {
private Member member;

@Builder.Default
@OneToMany(mappedBy = "mySchedule", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TravelPlace> travelPlaces = new ArrayList<>();
@OneToMany(mappedBy = "schedules", cascade = CascadeType.ALL)
private List<Schedule> schedules = new ArrayList<>();

// FK 연결 필요
@Column(name = "booking_id")
Expand All @@ -49,4 +50,5 @@ public class MySchedule extends BaseEntity {
@Builder.Default
@Column(name = "activated", nullable = false)
private boolean activated = true;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class SharedSchedule extends BaseEntity {
private Long id ;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "my_schedule_id", nullable = false)
private MySchedule mySchedule;
@JoinColumn(name = "schedule_id", nullable = false)
private Schedules schedules;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.isp.backend.domain.schedules.repository;

import com.isp.backend.domain.schedules.entity.Schedules;
import org.springframework.data.jpa.repository.JpaRepository;

public interface SchedulesRepository extends JpaRepository<Schedules, String> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

@RequiredArgsConstructor
@Service
public class ScheduleService {
public class SchedulesService {
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class BaseEntity {

@PrePersist
public void onPrePersist() {
this.createdAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
this.createdAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm"));
this.updatedAt = this.createdAt;
}

@PreUpdate
public void onPreUpdate(){
this.updatedAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
this.updatedAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm"));
}
}

0 comments on commit 25411c6

Please sign in to comment.