-
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
…_interview interview record 저장
- Loading branch information
Showing
9 changed files
with
231 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
37 changes: 37 additions & 0 deletions
37
src/main/java/com/example/umc3_teamproject/controller/RecordInterviewController.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,37 @@ | ||
package com.example.umc3_teamproject.controller; | ||
|
||
|
||
import com.example.umc3_teamproject.domain.dto.request.RecordInterviewRequestDto; | ||
import com.example.umc3_teamproject.domain.dto.request.RecordScriptRequestDto; | ||
import com.example.umc3_teamproject.domain.dto.response.RecordInterviewResponseDto; | ||
import com.example.umc3_teamproject.domain.dto.response.RecordScriptResponseDto; | ||
import com.example.umc3_teamproject.repository.RecordInterviewRepository; | ||
import com.example.umc3_teamproject.repository.RecordRespository; | ||
import com.example.umc3_teamproject.service.RecordInterviewService; | ||
import com.example.umc3_teamproject.service.RecordScriptService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Slf4j | ||
@RestController // Json 형태로 객체 데이터를 반환 (@Controller + @ResponseBody) | ||
@RequestMapping("/interview") | ||
@RequiredArgsConstructor | ||
|
||
public class RecordInterviewController { | ||
|
||
private final RecordInterviewService recordinterviewService; | ||
|
||
|
||
|
||
@PostMapping("/addRecord") | ||
public ResponseEntity<?> recordInterview(@RequestBody RecordInterviewRequestDto.Register record_interview ){ | ||
|
||
return recordinterviewService.recordInterview(record_interview); | ||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/example/umc3_teamproject/domain/dto/request/RecordInterviewRequestDto.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,34 @@ | ||
package com.example.umc3_teamproject.domain.dto.request; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
public class RecordInterviewRequestDto { | ||
@Getter | ||
@Setter | ||
public static class Register { | ||
|
||
@NotNull(message = "user id는 필수 입력값입니다.") | ||
private Long memberId; | ||
|
||
@NotNull(message = "record는 필수 입력값입니다.") | ||
private Float record; | ||
|
||
@NotNull(message = "interview id는 필수 입력값입니다.") | ||
private Long interviewId; | ||
|
||
|
||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class Update { | ||
|
||
@NotNull(message = "record는 필수 입력값입니다.") | ||
private Float record; | ||
|
||
|
||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ain/java/com/example/umc3_teamproject/domain/dto/response/RecordInterviewResponseDto.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,40 @@ | ||
package com.example.umc3_teamproject.domain.dto.response; | ||
|
||
import com.example.umc3_teamproject.domain.item.RecordInterview; | ||
import com.example.umc3_teamproject.repository.MemberRepository; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class RecordInterviewResponseDto { | ||
@Autowired | ||
MemberRepository memberRepository; | ||
|
||
@Getter | ||
@Builder | ||
private static class Body { | ||
|
||
private String result; | ||
|
||
private Long memberId; | ||
private Long interviewId; | ||
|
||
private Float record; | ||
|
||
} | ||
|
||
public ResponseEntity<?> success(RecordInterview record_interview) { | ||
|
||
RecordInterviewResponseDto.Body body = RecordInterviewResponseDto.Body.builder() | ||
.result("success") | ||
.memberId(record_interview.getMemberId().getId()) | ||
.interviewId(record_interview.getInterviewId().getInterviewId()) | ||
.record(record_interview.getRecord()) | ||
.build(); | ||
return ResponseEntity.ok(body); | ||
} | ||
|
||
} |
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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/example/umc3_teamproject/domain/item/RecordInterview.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,45 @@ | ||
package com.example.umc3_teamproject.domain.item; | ||
|
||
import com.example.umc3_teamproject.domain.Member; | ||
import com.fasterxml.jackson.annotation.JsonIdentityReference; | ||
import com.fasterxml.jackson.annotation.JsonManagedReference; | ||
import lombok.*; | ||
import org.hibernate.annotations.Where; | ||
|
||
import javax.persistence.*; | ||
|
||
import static javax.persistence.FetchType.LAZY; | ||
|
||
@Builder | ||
@Entity | ||
@Table(name="record_interview") | ||
@Where(clause = "deleted = false") | ||
@JsonIdentityReference(alwaysAsId = true) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Setter | ||
@Getter | ||
|
||
public class RecordInterview { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
@JsonManagedReference | ||
private Member memberId; | ||
|
||
|
||
@ManyToOne(fetch = LAZY) | ||
@JoinColumn(name = "interviewId") | ||
@JsonManagedReference | ||
private Interview interviewId; | ||
|
||
|
||
|
||
@Column | ||
private Float record; | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/example/umc3_teamproject/repository/RecordInterviewRepository.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,12 @@ | ||
package com.example.umc3_teamproject.repository; | ||
|
||
import com.example.umc3_teamproject.domain.item.RecordInterview; | ||
import com.example.umc3_teamproject.domain.item.RecordScript; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface RecordInterviewRepository extends JpaRepository<RecordInterview, Long>, CrudRepository<RecordInterview, Long> { | ||
Optional<RecordInterview> findById(Long id); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/example/umc3_teamproject/service/RecordInterviewService.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,52 @@ | ||
package com.example.umc3_teamproject.service; | ||
|
||
import com.example.umc3_teamproject.domain.Member; | ||
import com.example.umc3_teamproject.domain.dto.request.RecordInterviewRequestDto; | ||
import com.example.umc3_teamproject.domain.dto.response.RecordInterviewResponseDto; | ||
import com.example.umc3_teamproject.domain.item.Interview; | ||
import com.example.umc3_teamproject.domain.item.RecordInterview; | ||
import com.example.umc3_teamproject.domain.item.RecordScript; | ||
import com.example.umc3_teamproject.repository.*; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RecordInterviewService { | ||
@Autowired | ||
private final MemberRepository memberRepository; | ||
@Autowired | ||
private final InterviewRepository interviewRepository; | ||
@Autowired | ||
private final RecordInterviewRepository recordinterviewRepository; | ||
|
||
private final RecordInterviewResponseDto recordinterviewResponse; | ||
|
||
|
||
public ResponseEntity<?> recordInterview(RecordInterviewRequestDto.Register record_interview1) { | ||
|
||
Member interview_member = memberRepository.getUser(record_interview1.getMemberId()); | ||
Interview record1_interview = interviewRepository.getById(record_interview1.getInterviewId()); | ||
|
||
|
||
RecordInterview record_interview= RecordInterview.builder() | ||
.memberId(interview_member) | ||
.interviewId(record1_interview) | ||
.record(record_interview1.getRecord()) | ||
.build(); | ||
recordinterviewRepository.save(record_interview); | ||
return recordinterviewResponse.success(record_interview); | ||
} | ||
@Transactional | ||
public void saveItem(RecordInterview recordInterview) { | ||
|
||
recordinterviewRepository.save(recordInterview); | ||
|
||
|
||
} | ||
|
||
} |