Skip to content

Commit

Permalink
Merge pull request #648 from woowacourse-teams/develop
Browse files Browse the repository at this point in the history
Release v1.5.0
  • Loading branch information
InKyoJeong authored Oct 12, 2022
2 parents a566cd6 + c5437aa commit aeeb2a3
Show file tree
Hide file tree
Showing 74 changed files with 1,642 additions and 465 deletions.
4 changes: 4 additions & 0 deletions back/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ dependencies {
// WebClient
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.projectreactor:reactor-spring:1.0.1.RELEASE'

// actuator for monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
}

asciidoctor.doFirst {
Expand Down
2 changes: 1 addition & 1 deletion back/src/docs/asciidoc/crew.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ include::{snippets}/find-crew-sheets-notFoundCrew/http-response.adoc[]

=== 코치가 크루의 면담시트 조회 성공

operation::find-crew-reservations[]
operation::find-crew-sheets[]

=== 코치가 크루의 면담시트 조회 실패

Expand Down
1 change: 1 addition & 0 deletions back/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
* link:schedule.html[Schedule]
* link:reservation.html[Reservation]
* link:crew.html[Crew]
* link:question.html[Question]
22 changes: 22 additions & 0 deletions back/src/docs/asciidoc/question.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
= Question
:toc: left
:toclevels: 2
:sectlinks:
:source-highlighter: highlightjs

[[home]]
== home

* link:index.html[목록으로 가기]

== 시트 질문 조회

=== 시트 질문 조회 성공

operation::find-questions[]

== 시트 질문 수정

=== 시트 질문 수정 성공

operation::update-questions[]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.woowacourse.teatime.auth.controller.dto.LoginResponse;
import com.woowacourse.teatime.auth.infrastructure.JwtTokenProvider;
import com.woowacourse.teatime.auth.infrastructure.OpenIdAuth;
import com.woowacourse.teatime.teatime.controller.dto.request.SheetQuestionUpdateDto;
import com.woowacourse.teatime.teatime.controller.dto.request.SheetQuestionUpdateRequest;
import com.woowacourse.teatime.teatime.domain.Coach;
import com.woowacourse.teatime.teatime.domain.Crew;
import com.woowacourse.teatime.teatime.repository.CoachRepository;
Expand Down Expand Up @@ -86,12 +86,12 @@ private Coach saveCoachAndDefaultQuestions(UserInfoDto userInfo) {
userInfo.getEmail(),
userInfo.getImage()));

List<SheetQuestionUpdateDto> defaultQuestionDtos = List.of(
new SheetQuestionUpdateDto(1, DEFAULT_QUESTION_1),
new SheetQuestionUpdateDto(2, DEFAULT_QUESTION_2),
new SheetQuestionUpdateDto(3, DEFAULT_QUESTION_3));
List<SheetQuestionUpdateRequest> defaultQuestionDtos = List.of(
new SheetQuestionUpdateRequest(1, DEFAULT_QUESTION_1, true),
new SheetQuestionUpdateRequest(2, DEFAULT_QUESTION_2, true),
new SheetQuestionUpdateRequest(3, DEFAULT_QUESTION_3, true));

questionService.updateQuestions(coach.getId(), defaultQuestionDtos);
questionService.update(coach.getId(), defaultQuestionDtos);
return coach;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.woowacourse.teatime.auth.support.CrewAuthenticationPrincipal;
import com.woowacourse.teatime.teatime.controller.dto.request.CrewUpdateProfileRequest;
import com.woowacourse.teatime.teatime.controller.dto.request.SheetAnswerUpdateRequest;
import com.woowacourse.teatime.teatime.controller.dto.response.CoachFindCrewHistoryResponse;
import com.woowacourse.teatime.teatime.controller.dto.response.CoachFindCrewSheetResponse;
import com.woowacourse.teatime.teatime.controller.dto.response.CrewFindOwnCanceledSheetResponse;
import com.woowacourse.teatime.teatime.controller.dto.response.CrewFindOwnHistoryResponse;
Expand Down Expand Up @@ -60,7 +59,8 @@ public ResponseEntity<CrewFindOwnSheetResponse> findOwnSheets(@CrewAuthenticatio
public ResponseEntity<CrewFindOwnCanceledSheetResponse> findOwnCanceledSheets(
@CrewAuthenticationPrincipal Long crewId,
@PathVariable @NotNull Long originReservationId) {
CrewFindOwnCanceledSheetResponse response = sheetService.findOwnCanceledSheetByCrew(crewId, originReservationId);
CrewFindOwnCanceledSheetResponse response = sheetService.findOwnCanceledSheetByCrew(crewId,
originReservationId);
return ResponseEntity.ok(response);
}

Expand All @@ -82,8 +82,8 @@ public ResponseEntity<Void> updateSheetAnswer(@CrewAuthenticationPrincipal Long
}

@PutMapping("/me/profile")
public ResponseEntity<Void> updateProfile(
@CrewAuthenticationPrincipal Long crewId, @Valid @RequestBody CrewUpdateProfileRequest request) {
public ResponseEntity<Void> updateProfile(@CrewAuthenticationPrincipal Long crewId,
@Valid @RequestBody CrewUpdateProfileRequest request) {
crewService.updateProfile(crewId, request);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.woowacourse.teatime.teatime.controller;

import com.woowacourse.teatime.auth.support.CoachAuthenticationPrincipal;
import com.woowacourse.teatime.teatime.controller.dto.request.SheetQuestionUpdateRequest;
import com.woowacourse.teatime.teatime.controller.dto.response.SheetQuestionsResponse;
import com.woowacourse.teatime.teatime.service.QuestionService;
import java.util.List;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/v2/questions")
public class QuestionController {

private final QuestionService questionService;

@GetMapping
public ResponseEntity<SheetQuestionsResponse> get(@CoachAuthenticationPrincipal Long coachId) {
SheetQuestionsResponse response = questionService.get(coachId);
return ResponseEntity.ok(response);
}

@PutMapping
public ResponseEntity<Void> update(
@CoachAuthenticationPrincipal Long coachId, @Valid @RequestBody List<SheetQuestionUpdateRequest> request) {
questionService.update(coachId, request);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ public class SheetAnswerUpdateDto {

@NotBlank
private String answerContent;

@NotNull
private Boolean isRequired;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class SheetQuestionUpdateDto {
public class SheetQuestionUpdateRequest {

@NotNull
private Integer questionNumber;

@NotBlank
private String questionContent;

@NotNull
private Boolean isRequired;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static com.woowacourse.teatime.teatime.domain.SheetStatus.WRITING;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.woowacourse.teatime.teatime.domain.Coach;
import com.woowacourse.teatime.teatime.domain.Crew;
import com.woowacourse.teatime.teatime.domain.Reservation;
import com.woowacourse.teatime.teatime.domain.Schedule;
import com.woowacourse.teatime.teatime.domain.Sheet;
Expand All @@ -22,19 +22,19 @@ public class CoachFindCrewSheetResponse {

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "Asia/Seoul")
private LocalDateTime dateTime;
private String coachName;
private String coachImage;
private String crewName;
private String crewImage;
private SheetStatus status;
private List<SheetDto> sheets;

public static CoachFindCrewSheetResponse of(Reservation reservation, List<Sheet> sheets) {
Schedule schedule = reservation.getSchedule();
Coach coach = schedule.getCoach();
Crew crew = reservation.getCrew();
if (WRITING.equals(reservation.getSheetStatus())) {
return new CoachFindCrewSheetResponse(schedule.getLocalDateTime(), coach.getName(), coach.getImage(),
return new CoachFindCrewSheetResponse(schedule.getLocalDateTime(), crew.getName(), crew.getImage(),
reservation.getSheetStatus(), SheetDto.generateEmptySheet(sheets));
}
return new CoachFindCrewSheetResponse(schedule.getLocalDateTime(), coach.getName(), coach.getImage(),
return new CoachFindCrewSheetResponse(schedule.getLocalDateTime(), crew.getName(), crew.getImage(),
reservation.getSheetStatus(), SheetDto.from(sheets));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ public class SheetDto {
private Integer questionNumber;
private String questionContent;
private String answerContent;
private Boolean isRequired;

private SheetDto(Sheet sheet) {
this.questionNumber = sheet.getNumber();
this.questionContent = sheet.getQuestionContent();
this.answerContent = sheet.getAnswerContent();
this.isRequired = sheet.getIsRequired();
}

private SheetDto(CanceledSheet sheet) {
this.questionNumber = sheet.getNumber();
this.questionContent = sheet.getQuestionContent();
this.answerContent = sheet.getAnswerContent();
this.isRequired = sheet.getIsRequired();
}

public static List<SheetDto> from(List<Sheet> sheets) {
Expand All @@ -42,7 +45,7 @@ public static List<SheetDto> fromCanceled(List<CanceledSheet> sheets) {

public static List<SheetDto> generateEmptySheet(List<Sheet> sheets) {
return sheets.stream()
.map(sheet -> new Sheet(sheet.getReservation(), sheet.getNumber(), sheet.getQuestionContent()))
.map(sheet -> new Sheet(sheet.getReservation(), sheet.getNumber(), sheet.getQuestionContent(), sheet.getIsRequired()))
.map(SheetDto::new)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.woowacourse.teatime.teatime.controller.dto.response;

import com.woowacourse.teatime.teatime.domain.Question;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SheetQuestionResponse {

private Integer questionNumber;

private String questionContent;

private Boolean isRequired;

public static SheetQuestionResponse from(Question question) {
return new SheetQuestionResponse(
question.getNumber(),
question.getContent(),
question.getIsRequired());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.woowacourse.teatime.teatime.controller.dto.response;

import com.woowacourse.teatime.teatime.domain.Question;
import java.util.List;
import java.util.stream.Collectors;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class SheetQuestionsResponse {

private List<SheetQuestionResponse> questions;

public static SheetQuestionsResponse from(List<Question> savedQuestions) {
return new SheetQuestionsResponse(savedQuestions.stream()
.map(SheetQuestionResponse::from)
.collect(Collectors.toList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ private CanceledReservation(Long originId, Coach coach, Crew crew, LocalDateTime

public static CanceledReservation from(Reservation reservation) {
return new CanceledReservation(
reservation.getId(), reservation.getCoach(), reservation.getCrew(), reservation.getScheduleDateTime());
reservation.getId(),
reservation.getCoach(),
reservation.getCrew(),
reservation.getScheduleDateTime()
);
}

public boolean isSameCrew(Long crewId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ public class CanceledSheet {
@Lob
private String answerContent;

@Column(nullable = false)
private Boolean isRequired;

private CanceledSheet(CanceledReservation canceledReservation, Integer number, String questionContent,
String answerContent) {
String answerContent, Boolean isRequired) {
this.canceledReservation = canceledReservation;
this.number = number;
this.questionContent = questionContent;
this.answerContent = answerContent;
this.isRequired = isRequired;
}

public static CanceledSheet from(CanceledReservation canceledReservation, Sheet sheet) {
return new CanceledSheet(
canceledReservation,
sheet.getNumber(),
sheet.getQuestionContent(),
sheet.getAnswerContent());
sheet.getAnswerContent(),
sheet.getIsRequired());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ public class Question {
@Column(nullable = false)
private String content;

public Question(Coach coach, Integer number, String content) {
@Column(nullable = false)
private Boolean isRequired;

public Question(Coach coach, Integer number, String content, Boolean isRequired) {
this.coach = coach;
this.number = number;
this.content = content;
this.isRequired = isRequired;
}

@Override
Expand All @@ -46,7 +50,8 @@ public boolean equals(Object o) {
}
Question question = (Question) o;
return Objects.equals(getCoach(), question.getCoach()) && Objects.equals(getNumber(), question.getNumber())
&& Objects.equals(getContent(), question.getContent());
&& Objects.equals(getContent(), question.getContent()) && Objects.equals(getIsRequired(),
question.getIsRequired());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,25 @@ public class Sheet {
@Column(nullable = false)
private String questionContent;

@Column(nullable = false)
private Boolean isRequired;

@Lob
private String answerContent;

public Sheet(Reservation reservation, Integer number, String questionContent) {
this.reservation = reservation;
this.number = number;
this.questionContent = questionContent;
this.isRequired = true;
this.answerContent = null;
}

public Sheet(Reservation reservation, Integer number, String questionContent, Boolean isRequired) {
this.reservation = reservation;
this.number = number;
this.questionContent = questionContent;
this.isRequired = isRequired;
this.answerContent = null;
}

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

public interface QuestionRepository extends JpaRepository<Question, Long> {

List<Question> findAllByCoachId(Long coachId);
List<Question> findAllByCoachIdOrderByNumber(Long coachId);
}
Loading

0 comments on commit aeeb2a3

Please sign in to comment.