-
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.
Browse files
Browse the repository at this point in the history
[feat] - Plan CRU
- Loading branch information
Showing
22 changed files
with
591 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.team20.t4.plan; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
public class AppointmentPost { | ||
|
||
private RegisterHistory registerHistory; | ||
private Long postId; | ||
} |
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,13 @@ | ||
package com.team20.t4.plan; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
public class AppointmentTimeVO { | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
private LocalDateTime appointmentTime; | ||
} |
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,17 @@ | ||
package com.team20.t4.plan; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum FoodType { | ||
|
||
KOREAN("한식"), | ||
JAPANESE("일식"), | ||
WESTERN("양식"), | ||
CHINESE("중식"); | ||
|
||
|
||
private String value; | ||
} |
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,18 @@ | ||
package com.team20.t4.plan; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
public enum Gu { | ||
|
||
JONGRO("종로구"); | ||
|
||
|
||
|
||
private String definition; | ||
|
||
/** | ||
* | ||
*종로구 중구 용산구 성동구 광진구 동대문구 중랑구 성북구 강북구 도봉구 노원구 은평구 서대문구 마포구 양천구 강서구 구로구 금천구 영등포구 동작구 관악구 서초구 강남구 송파구 강동구 | ||
* */ | ||
} |
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,9 @@ | ||
package com.team20.t4.plan; | ||
|
||
import javax.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public class Location { | ||
|
||
private Gu gu; | ||
} |
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,80 @@ | ||
package com.team20.t4.plan; | ||
|
||
import com.team20.t4.member.domain.Member; | ||
import com.team20.t4.post.Post; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.Max; | ||
import javax.validation.constraints.Min; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Entity | ||
public class Plan { | ||
|
||
@Id @Column(name = "plan_pk") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "lead_pk", nullable = false) | ||
private Member lead; | ||
|
||
@OneToOne(mappedBy = "plan", cascade = CascadeType.PERSIST) | ||
private Post post; | ||
|
||
@Column(name = "num_of_participants", nullable = false) | ||
@Min(1) @Max(10) | ||
private Integer numOfParticipants; | ||
|
||
@Setter | ||
@Column(name = "appointment_time", nullable = false) | ||
private LocalDateTime appointmentTime; | ||
|
||
@Setter | ||
@Column(name = "food_type", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private FoodType foodType; | ||
|
||
@Setter | ||
@Column(name = "restaurant", nullable = false) | ||
private String restaurant; | ||
|
||
@Setter | ||
@Embedded | ||
@Column(name = "location", nullable = false) | ||
private Location location; | ||
|
||
@OneToMany(mappedBy = "plan") | ||
private List<RegisterHistory> registerHistories = new ArrayList<>(); | ||
|
||
@Setter | ||
@Column(name = "progress", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private Progress progress; | ||
|
||
@Builder | ||
public Plan(Member lead, | ||
Post post, | ||
Integer numOfParticipants, | ||
LocalDateTime appointmentTime, | ||
FoodType foodType, | ||
String restaurant, | ||
Location location) { | ||
this.lead = lead; | ||
this.post = post; | ||
this.numOfParticipants = numOfParticipants; | ||
this.appointmentTime = appointmentTime; | ||
this.foodType = foodType; | ||
this.restaurant = restaurant; | ||
this.location = location; | ||
this.progress = Progress.RECRUITING; | ||
} | ||
} |
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,45 @@ | ||
package com.team20.t4.plan; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class PlanController { | ||
|
||
private final PlanService planService; | ||
|
||
@GetMapping("/appointments/{memberId}") | ||
public List<AppointmentPost> listMemberAppointments (@PathVariable Long memberId) { | ||
return planService.listMyAppointments(memberId); | ||
} | ||
|
||
|
||
@PostMapping("/plan/time/{planId}") | ||
public Long updateAppointmentTime(@PathVariable Long planId, @RequestBody AppointmentTimeVO newAppointmentTime) { | ||
return planService.updateAppointmentTime(planId, newAppointmentTime.getAppointmentTime()); | ||
} | ||
|
||
/**아래 메소드 지우고 Post 수정할 때 PlanService.updatePlan() 같이 호출해도 됨*/ | ||
@PostMapping("/plan/{planId}") | ||
public Long updatePlan(@PathVariable Long planId, @RequestBody PlanUpdateRequestDto dto) { | ||
return planService.updatePlan(planId, dto); | ||
} | ||
|
||
@PostMapping("/plan/progress/{planId}") | ||
public Long updateProgress(@PathVariable Long planId, @RequestBody Progress progress) { | ||
return planService.updateProgressState(planId, progress); | ||
} | ||
|
||
@PostMapping("/registerHistory/new") | ||
public Long sendAppointmentRequest(@RequestBody RegisterHistorySaveRequestDto dto) { | ||
return planService.sendAppointmentRequest(dto); | ||
} | ||
|
||
@PostMapping("/registerHistory/state/{registerHistoryId}") | ||
public Long updateState(@PathVariable Long registerHistoryId, @RequestBody State state) { | ||
return planService.response(registerHistoryId, state); | ||
} | ||
} |
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,48 @@ | ||
package com.team20.t4.plan; | ||
|
||
|
||
import com.team20.t4.member.domain.Member; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
public class PlanInfoResponseDto { | ||
|
||
private Member lead; | ||
private Integer numOfParticipants; | ||
private LocalDateTime appointmentTime; | ||
private FoodType foodType; | ||
private String restaurant; | ||
private Location location; | ||
|
||
@Builder | ||
public PlanInfoResponseDto(Member lead, | ||
Integer numOfParticipants, | ||
LocalDateTime appointmentTime, | ||
FoodType foodType, | ||
String restaurant, | ||
Location location) { | ||
this.lead = lead; | ||
this.numOfParticipants = numOfParticipants; | ||
this.appointmentTime = appointmentTime; | ||
this.foodType = foodType; | ||
this.restaurant = restaurant; | ||
this.location = location; | ||
} | ||
|
||
public static PlanInfoResponseDto of(Plan plan) { | ||
return PlanInfoResponseDto.builder() | ||
.lead(plan.getLead()) | ||
.numOfParticipants(plan.getNumOfParticipants()) | ||
.appointmentTime(plan.getAppointmentTime()) | ||
.foodType(plan.getFoodType()) | ||
.restaurant(plan.getRestaurant()) | ||
.location(plan.getLocation()) | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.team20.t4.plan; | ||
|
||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PlanRepository extends JpaRepository<Plan, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.team20.t4.plan; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; | ||
import com.team20.t4.member.domain.Member; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor | ||
public class PlanSaveRequestDto { | ||
|
||
private Progress progress; | ||
|
||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
@JsonDeserialize(using = LocalDateDeserializer.class) | ||
private LocalDateTime appointmentTime; | ||
private Location location; | ||
private String restaurant; | ||
private FoodType foodType; | ||
private Integer numOfParticipants; | ||
|
||
@Builder | ||
public PlanSaveRequestDto(Progress progress, LocalDateTime appointmentTime, Location location, String restaurant, FoodType foodType, Integer numOfParticipants) { | ||
this.progress = progress; | ||
this.appointmentTime = appointmentTime; | ||
this.location = location; | ||
this.restaurant = restaurant; | ||
this.foodType = foodType; | ||
this.numOfParticipants = numOfParticipants; | ||
} | ||
|
||
public Plan toEntity() | ||
{ | ||
return Plan.builder() | ||
.appointmentTime(appointmentTime) | ||
.location(location) | ||
.restaurant(restaurant) | ||
.foodType(foodType) | ||
.numOfParticipants(numOfParticipants) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.