-
Notifications
You must be signed in to change notification settings - Fork 1
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 MEME-UMC/develop
[Develop] Reservation, Available Time Refactoring 내용 Main 반영
- Loading branch information
Showing
23 changed files
with
286 additions
and
105 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
39 changes: 39 additions & 0 deletions
39
src/main/java/umc/meme/shop/domain/artist/dto/request/AvailableTimeRequestDto.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,39 @@ | ||
package umc.meme.shop.domain.artist.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import umc.meme.shop.global.enums.DayOfWeek; | ||
import umc.meme.shop.global.enums.Times; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AvailableTimeRequestDto { | ||
private Long userId; | ||
private List<AvailableTimeDto> availableTimeDtoList; | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class AvailableTimeDto { | ||
private Date date; //날짜 | ||
private DayOfWeek dayOfWeek; //요일 | ||
private Times times; | ||
|
||
public static AvailableTimeDto from(Date date, DayOfWeek dayOfWeek, Times times){ | ||
return AvailableTimeDto.builder() | ||
.date(date) | ||
.dayOfWeek(dayOfWeek) | ||
.times(times) | ||
.build(); | ||
} | ||
|
||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/umc/meme/shop/domain/artist/dto/response/AvailableTimeDto.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,31 @@ | ||
package umc.meme.shop.domain.artist.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import umc.meme.shop.domain.artist.entity.AvailableTime; | ||
import umc.meme.shop.global.enums.DayOfWeek; | ||
import umc.meme.shop.global.enums.Times; | ||
|
||
import java.util.Date; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AvailableTimeDto { | ||
private Long availableTimeId; | ||
private Date date; //날짜 | ||
private DayOfWeek dayOfWeek; //요일 | ||
private Times times; | ||
|
||
static public AvailableTimeDto from(AvailableTime availableTime){ | ||
return AvailableTimeDto.builder() | ||
.availableTimeId(availableTime.getAvailableTimeId()) | ||
.date(availableTime.getDate()) | ||
.dayOfWeek(availableTime.getDayOfWeek()) | ||
.times(availableTime.getTimes()) | ||
.build(); | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
src/main/java/umc/meme/shop/domain/artist/entity/AvailableTime.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,63 @@ | ||
package umc.meme.shop.domain.artist.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import umc.meme.shop.domain.artist.dto.request.AvailableTimeRequestDto; | ||
import umc.meme.shop.domain.reservation.entity.Reservation; | ||
import umc.meme.shop.global.enums.DayOfWeek; | ||
import umc.meme.shop.global.enums.Times; | ||
|
||
import java.util.Date; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
public class AvailableTime { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "available_time_id") | ||
private Long availableTimeId; | ||
|
||
@Column(nullable = false) | ||
private Date date; //날짜 | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private DayOfWeek dayOfWeek; //요일 | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private Times times; //시간 | ||
|
||
@Column(nullable = false, columnDefinition = "TINYINT(1) default 0") | ||
private boolean isReservated; //해당 시간대 예약 여부 | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private Artist artist; | ||
|
||
@OneToOne(mappedBy = "availableTime", fetch = FetchType.LAZY) | ||
private Reservation reservation; | ||
|
||
public void updateIsReservated(boolean isReservated){ | ||
this.isReservated = isReservated; | ||
} | ||
|
||
public void updateReservation(Reservation reservation){this.reservation = reservation;} | ||
|
||
public void updateArtist(Artist artist){this.artist = artist;} | ||
|
||
public static AvailableTime from(AvailableTimeRequestDto.AvailableTimeDto request){ | ||
return AvailableTime.builder() | ||
.date(request.getDate()) | ||
.dayOfWeek(request.getDayOfWeek()) | ||
.times(request.getTimes()) | ||
.build(); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/umc/meme/shop/domain/artist/repository/AvailableTimeRepository.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,7 @@ | ||
package umc.meme.shop.domain.artist.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import umc.meme.shop.domain.artist.entity.AvailableTime; | ||
|
||
public interface AvailableTimeRepository extends JpaRepository<AvailableTime, Long> { | ||
} |
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
Oops, something went wrong.