-
Notifications
You must be signed in to change notification settings - Fork 0
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] #2 공동구매
- Loading branch information
Showing
16 changed files
with
268 additions
and
48 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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/example/DayClassBack/controller/PartyController.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,48 @@ | ||
package com.example.DayClassBack.controller; | ||
|
||
import com.example.DayClassBack.dto.Response; | ||
import com.example.DayClassBack.dto.request.PartyRequestDto; | ||
import com.example.DayClassBack.enums.WriteType; | ||
import com.example.DayClassBack.service.Helper; | ||
import com.example.DayClassBack.service.PartyService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.Errors; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/homebody/party") | ||
@RestController | ||
public class PartyController { | ||
|
||
private final PartyService partyService; | ||
private final Response response; | ||
|
||
@PostMapping("/gather") | ||
public ResponseEntity<?> writeGather(@Validated PartyRequestDto.WriteGather write, Errors errors) { | ||
// validation check | ||
if (errors.hasErrors()) { | ||
return response.invalidFields(Helper.refineErrors(errors)); | ||
} | ||
write.setWriteType(WriteType.Gather); | ||
write.set_completed(true); | ||
|
||
return partyService.writeGather(write); | ||
} | ||
|
||
@PostMapping("/rental") | ||
public ResponseEntity<?> writeRental(@Validated PartyRequestDto.WriteRental write, Errors errors) { | ||
// validation check | ||
if (errors.hasErrors()) { | ||
return response.invalidFields(Helper.refineErrors(errors)); | ||
} | ||
write.setWriteType(WriteType.Rental); | ||
write.set_completed(true); | ||
return partyService.writeRental(write); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/com/example/DayClassBack/controller/SubscribeController.java
This file was deleted.
Oops, something went wrong.
94 changes: 80 additions & 14 deletions
94
src/main/java/com/example/DayClassBack/dto/request/PartyRequestDto.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 |
---|---|---|
@@ -1,44 +1,110 @@ | ||
package com.example.DayClassBack.dto.request; | ||
|
||
import com.example.DayClassBack.entity.Users; | ||
import com.example.DayClassBack.enums.Ott; | ||
import com.example.DayClassBack.enums.WriteType; | ||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
// import javax.validation.constraints.Pattern; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
public class PartyRequestDto { | ||
|
||
@Getter | ||
@Setter | ||
public static class Write { | ||
public static class WriteGather { | ||
|
||
@NotEmpty(message = "title은 필수 입력값입니다.") | ||
@NotNull(message = "필수 입력값입니다.") | ||
private Long user_id; | ||
// private Users users; | ||
|
||
// @NotEmpty(message = "필수 입력값입니다.") | ||
// private Type type; | ||
|
||
@NotNull(message = "필수 입력값입니다.") // @NotEmpty 사용 시 error | ||
private int number_of_people; // https://sjparkk-dev1og.tistory.com/m/145 | ||
|
||
@NotNull(message = "필수 입력값입니다.") | ||
private int cost; | ||
|
||
@NotNull(message = "ott는 필수 입력값입니다.") | ||
private Ott ott; | ||
|
||
// @NotEmpty(message = "필수 입력값입니다.") | ||
// private boolean is_completed; | ||
|
||
@NotNull(message = "title은 필수 입력값입니다.") | ||
// @Pattern(regexp = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}$", message = "이메일 형식에 맞지 않습니다.") | ||
private String title; | ||
|
||
@NotEmpty(message = "content는 필수 입력값입니다.") | ||
// @NotEmpty(message = "content는 필수 입력값입니다.") | ||
// @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[~!@#$%^&*()+|=])[A-Za-z\\d~!@#$%^&*()+|=]{8,16}$", message = "비밀번호는 8~16자 영문 대 소문자, 숫자, 특수문자를 사용하세요.") | ||
private String content; | ||
// private String content; | ||
|
||
@NotNull (message = "start_date은 필수 입력값입니다.") | ||
@DateTimeFormat(pattern = "yyyy.MM.dd") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
private LocalDate start_date; | ||
|
||
// @NotNull (message = "start_date은 필수 입력값입니다.") | ||
@DateTimeFormat(pattern = "yyyy.MM.dd") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
private LocalDate end_date; | ||
|
||
private WriteType writeType; | ||
|
||
private boolean is_completed; | ||
|
||
//type.setWriteType(WriteType.Gather); | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class WriteRental { | ||
|
||
@NotEmpty(message = "필수 입력값입니다.") | ||
private int number_of_people; | ||
@NotNull(message = "필수 입력값입니다.") | ||
private Users users; | ||
|
||
@NotEmpty(message = "필수 입력값입니다.") | ||
private LocalDateTime start_date; | ||
// @NotEmpty(message = "필수 입력값입니다.") | ||
// private Type type; | ||
|
||
@NotEmpty(message = "필수 입력값입니다.") | ||
private LocalDateTime end_date; | ||
// @NotEmpty(message = "필수 입력값입니다.") | ||
// private int number_of_people; | ||
|
||
@NotEmpty(message = "필수 입력값입니다.") | ||
@NotNull(message = "필수 입력값입니다.") | ||
private int cost; | ||
|
||
@NotEmpty(message = "ott는 필수 입력값입니다.") | ||
@NotNull(message = "ott는 필수 입력값입니다.") | ||
private Ott ott; | ||
|
||
@NotEmpty(message = "o필수 입력값입니다.") | ||
// @NotEmpty(message = "필수 입력값입니다.") | ||
// private boolean is_completed; | ||
|
||
@NotNull(message = "title은 필수 입력값입니다.") | ||
// @Pattern(regexp = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}$", message = "이메일 형식에 맞지 않습니다.") | ||
private String title; | ||
|
||
// @NotEmpty(message = "content는 필수 입력값입니다.") | ||
// @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[~!@#$%^&*()+|=])[A-Za-z\\d~!@#$%^&*()+|=]{8,16}$", message = "비밀번호는 8~16자 영문 대 소문자, 숫자, 특수문자를 사용하세요.") | ||
// private String content; | ||
|
||
//@NotNull (message = "start_date은 필수 입력값입니다.") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
private LocalDate start_date; | ||
|
||
// @NotNull (message = "start_date은 필수 입력값입니다.") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
private LocalDate end_date; | ||
|
||
private WriteType writeType; | ||
private boolean is_completed; | ||
|
||
|
||
} | ||
|
||
} |
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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/example/DayClassBack/dto/response/UserResponseDto.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
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
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
2 changes: 1 addition & 1 deletion
2
.../com/example/DayClassBack/enums/Type.java → ...example/DayClassBack/enums/WriteType.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.example.DayClassBack.enums; | ||
|
||
public enum Type { | ||
public enum WriteType { | ||
Gather, // 모집 | ||
Rental // 대여 | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/example/DayClassBack/repository/PartyRepository.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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.example.DayClassBack.repository; | ||
|
||
import com.example.DayClassBack.entity.Party; | ||
import com.example.DayClassBack.entity.Users; | ||
import org.apache.catalina.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface PartyRepository extends JpaRepository<Party, Long> { | ||
Optional<Party> findById(Long id); | ||
} |
Oops, something went wrong.