Skip to content

Commit

Permalink
[refactor/InhaBas#179] SignUpSchedule refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
whitem4rk committed Nov 28, 2023
1 parent 1cb13a4 commit 9064ace
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.inhabas.api.auth.domain.oauth2.member.domain.entity.Member;
import com.inhabas.api.domain.BaseEntity;
import com.inhabas.api.domain.questionaire.domain.Questionnaire;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -15,22 +16,22 @@
public class Answer extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "NO")
private Integer no;
private Long id;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "USER_STUDENT_ID", foreignKey = @ForeignKey(name = "FK_ANSWER_OF_MEMBER"))
@JoinColumn(name = "USER_ID", foreignKey = @ForeignKey(name = "FK_ANSWER_OF_MEMBER"))
private Member member;

@Column(name = "QUESTION_NO", nullable = false)
private Integer questionNo;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "QUESTIONNAIRE_ID", foreignKey = @ForeignKey(name = "FK_ANSWER_OF_QUESTION_ID"))
private Questionnaire questionnaire;

@Column(name = "CONTENT", nullable = false, length = 1000)
private String content;

public Answer(Member member, Integer questionNo, String content) {
public Answer(Member member, Questionnaire questionnaire, String content) {
this.member = member;
this.questionNo = questionNo;
this.questionnaire = questionnaire;
this.content = content;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.inhabas.api.domain.member.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Positive;

@Data @NoArgsConstructor
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AnswerDto {

@Positive
private Integer questionNo;
private Long questionId;

@Length(max = 1000)
private String content;

public AnswerDto(Integer questionNo, String content) {
this.questionNo = questionNo;
this.content = content;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.inhabas.api.domain.member.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.MemberType;
import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.StudentId;
Expand All @@ -9,10 +8,12 @@
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Positive;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
public class SignUpDto {

Expand All @@ -27,9 +28,6 @@ public class SignUpDto {
@Pattern(regexp = "^(010)-\\d{4}-\\d{4}$")
private String phoneNumber;

@Email
private String email;

@JsonUnwrapped
@NotNull @Positive
private StudentId studentId;
Expand All @@ -38,11 +36,10 @@ public class SignUpDto {
private MemberType memberType;

@Builder
public SignUpDto(String name, String major, String phoneNumber, String email, StudentId studentId, MemberType memberType) {
public SignUpDto(String name, String major, String phoneNumber, StudentId studentId, MemberType memberType) {
this.name = name;
this.major = major;
this.phoneNumber = phoneNumber;
this.email = email;
this.studentId = studentId;
this.memberType = memberType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
* Be cautious not to make multi schedule or remove all the schedules. Do offer really necessary api.
*/
@Entity @Getter
@Table(name = "signup_schedule")
@Table(name = "SIGNUP_SCHEDULE")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class SignUpSchedule {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Long id;

@Column(name = "generation", nullable = false)
@Column(name = "GENERATION", nullable = false)
private Integer generation;

@Column(name = "signup_start", nullable = false)
@Column(name = "SIGNUP_START", nullable = false)
private LocalDateTime signupStartDate;

@Column(name = "signup_end", nullable = false)
@Column(name = "SIGNUP_END", nullable = false)
private LocalDateTime signupEndDate;

@Column(name = "interview_start", nullable = false)
@Column(name = "INTERVIEW_START", nullable = false)
private LocalDateTime interviewStartDate;

@Column(name = "interview_end", nullable = false)
@Column(name = "INTERVIEW_END", nullable = false)
private LocalDateTime interviewEndDate;

@Column(name = "result_announce_date", nullable = false)
@Column(name = "RESULT_ANNOUNCE_DATE", nullable = false)
private LocalDateTime resultAnnounceDate;

public SignUpSchedule(Integer generation, LocalDateTime signupStartDate, LocalDateTime signupEndDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.inhabas.api.domain.signUpSchedule.domain.entity.SignUpSchedule;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

Expand All @@ -11,10 +12,11 @@

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SignUpScheduleDto {

@NotNull
private Integer id;
private Long id;

@NotNull @Positive
private Integer generation;
Expand All @@ -39,18 +41,6 @@ public class SignUpScheduleDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime resultAnnounceDate;


public SignUpScheduleDto(Integer id, Integer generation, LocalDateTime signupStartDate, LocalDateTime signupEndDate,
LocalDateTime interviewStartDate, LocalDateTime interviewEndDate, LocalDateTime resultAnnounceDate) {
this.id = id;
this.generation = generation;
this.signupStartDate = signupStartDate;
this.signupEndDate = signupEndDate;
this.interviewStartDate = interviewStartDate;
this.interviewEndDate = interviewEndDate;
this.resultAnnounceDate = resultAnnounceDate;
}

public static SignUpScheduleDto from(SignUpSchedule signUpSchedule) {
return new SignUpScheduleDto(
signUpSchedule.getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.inhabas.api.domain.signUpSchedule.dto.SignUpScheduleDto;
import com.inhabas.api.domain.signUpSchedule.domain.SignUpScheduler;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -12,33 +14,39 @@

import javax.validation.Valid;

@Tag(name="회원가입 일정")
@Tag(name="회원가입 일정", description = "회원가입 일정 조회, 수정 / 회장만")
@RestController
@RequestMapping("/signUp/schedule")
@RequiredArgsConstructor
public class SignUpScheduleController {

private final SignUpScheduler signUpScheduler;


@Operation(summary = "회원가입 관련 일정을 조회한다.",
description = "일정은 하나만 반환한다.")
@ApiResponse(responseCode = "200", content = {
@Content(schema = @Schema(implementation = SignUpScheduleDto.class))
})
@GetMapping
@Operation(summary = "회원가입 관련 일정을 조회한다.")
@ApiResponse(responseCode = "200")
public ResponseEntity<SignUpScheduleDto> getSignUpSchedule() {

return ResponseEntity.ok(signUpScheduler.getSchedule());

}

@PutMapping
@Operation(summary = "회원가입 관련 일정을 수정한다.")
@ApiResponses({
@ApiResponse(responseCode = "204"),
@ApiResponse(responseCode = "401", description = "회장만 변경 가능하다.")
@ApiResponse(responseCode = "403", description = "권한이 없습니다.")
})
@PutMapping
public ResponseEntity<?> updateSignUpSchedule(@Valid @RequestBody SignUpScheduleDto signUpScheduleDto) {

signUpScheduler.updateSchedule(signUpScheduleDto);

return ResponseEntity.noContent().build();

}

}

0 comments on commit 9064ace

Please sign in to comment.