Skip to content

Commit

Permalink
[feat] #95 record_memo 기능 구현 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
myhyun0002 committed Feb 9, 2023
1 parent 2ddcb2d commit 5ecb79a
Show file tree
Hide file tree
Showing 18 changed files with 584 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
@RestController
@RequiredArgsConstructor
@Api(tags = {"Result Memo Api"})
@RequestMapping("/record/{script-interview-id}/memo")
@RequestMapping("/record/{script-or-interview}/{script_id-or-interview_id}/memo")
public class MemoController {

private final MemoService memoService;

@PostMapping("/new")
public ResponseTemplate<MemoResponseDto.createBody> createMemo(@PathVariable("script-interview-id") Long script_interview_id,
@RequestBody @Validated MemoRequestDto.createRequest request){
return memoService.createMemo(script_interview_id,request);
public ResponseTemplate<MemoResponseDto.createBody> createMemo(
@PathVariable("script-or-interview") String script_or_interview,
@PathVariable("script_id-or-interview_id") long id,
@RequestBody @Validated MemoRequestDto.createRequest request){
return memoService.createMemo(script_or_interview,id,request);
}

@PutMapping("/edit/{memo-id}")
Expand All @@ -29,9 +31,19 @@ public ResponseTemplate<MemoResponseDto.updateBody> updateMemo(@PathVariable("me
return memoService.updateMemo(memo_id,request);
}

@GetMapping("/{memo-id}")
public ResponseTemplate<MemoResponseDto.updateBody> getMemo(@PathVariable("memo-id") Long memo_id){
return memoService.getMemo(memo_id);
@DeleteMapping("/delete/{memo-id}")
public String deleteMemo(@PathVariable("memo-id") long memo_id){
return memoService.deleteByMemoId(memo_id);
}

// @GetMapping("/script/{script-id}")
// public ResponseTemplate<MemoResponseDto.updateBody> getMemo(@PathVariable("memo-id") Long memo_id){
// return memoService.getMemo(memo_id);
// }
//
// @GetMapping("/interview/{script-id}")
// public ResponseTemplate<MemoResponseDto.updateBody> getMemo(@PathVariable("memo-id") Long memo_id){
// return memoService.getMemo(memo_id);
// }

}
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
package com.example.umc3_teamproject.controller;
import com.example.umc3_teamproject.domain.dto.request.RecordScriptRequestDto;
import com.example.umc3_teamproject.domain.dto.request.ScriptRequestDto;
import com.example.umc3_teamproject.domain.dto.response.RecordScriptResponseDto;
import com.example.umc3_teamproject.domain.dto.response.ScriptResponseDto;
import com.example.umc3_teamproject.domain.item.RecordScript;
import com.example.umc3_teamproject.domain.item.Script;
import com.example.umc3_teamproject.repository.RecordRespository;
import com.example.umc3_teamproject.repository.ScriptRepository;
import com.example.umc3_teamproject.service.RecordScriptService;
import com.example.umc3_teamproject.service.ScriptService;

import com.example.umc3_teamproject.config.resTemplate.ResponseException;
import com.example.umc3_teamproject.config.resTemplate.ResponseTemplate;
import com.example.umc3_teamproject.domain.dto.request.ForumRequestDto;
import com.example.umc3_teamproject.domain.dto.request.RecordRequestDto;
import com.example.umc3_teamproject.domain.dto.response.ForumResponseDto;
import com.example.umc3_teamproject.domain.dto.response.RecordMemoResponseDto;
import com.example.umc3_teamproject.domain.dto.response.RecordResponseDto;
import com.example.umc3_teamproject.service.RecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import reactor.netty.http.server.HttpServerRequest;

import java.util.Optional;
import java.io.IOException;
import java.util.List;

@Slf4j
@RestController // Json 형태로 객체 데이터를 반환 (@Controller + @ResponseBody)
@RequestMapping("/script")
@RestController
@RequiredArgsConstructor
@Api(tags = {"Record Api"})
@Api(tags = {"Forum Api"})
@RequestMapping("/record/{script-or-interview}/{script_id-or-interview_id}")
public class RecordController {

private final RecordScriptService recordscriptService;
private final RecordRespository recordscriptRepository;

private final RecordScriptResponseDto recordscriptResponseDto;


@PostMapping("/addRecord")
public ResponseEntity<?> recordScript(@RequestBody RecordScriptRequestDto.Register record_script ){
private final RecordService recordService;

return recordscriptService.recordScript(record_script);
@ApiOperation(value = "record 저장", notes = "결과를 저장한다.")
@PostMapping("/new")
public ResponseTemplate<RecordResponseDto.Body> createRecord(
@PathVariable("script-or-interview") String script_or_interview,
@PathVariable("script_id-or-interview_id") long id,
@Validated @RequestBody RecordRequestDto.createRecordRequest request) throws IOException, ResponseException {
return recordService.createRecord(script_or_interview,id,request);
}



@GetMapping("/record/{id}")
public ResponseEntity<?> readRecordScriptById(@PathVariable("id") Long id) {


Optional<RecordScript> optionalProduct=recordscriptRepository.findById(id);
if (optionalProduct.isPresent()) {
RecordScript record_script1 = optionalProduct.get();
return recordscriptResponseDto.success(record_script1);
}
return null;
@ApiOperation(value = "결과 페이지 생성", notes = "결과를 보여준다.")
@GetMapping("")
public ResponseTemplate<RecordMemoResponseDto.Body> getRecord(
@PathVariable("script-or-interview") String script_or_interview,
@PathVariable("script_id-or-interview_id") long id) throws IOException, ResponseException {
return recordService.getRecord(script_or_interview, id);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.umc3_teamproject.controller;
import com.example.umc3_teamproject.domain.dto.request.RecordScriptRequestDto;
import com.example.umc3_teamproject.domain.dto.response.RecordScriptResponseDto;
import com.example.umc3_teamproject.domain.item.RecordScript;
import com.example.umc3_teamproject.repository.RecordRespository;
import com.example.umc3_teamproject.service.RecordScriptService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;

@Slf4j
@RestController // Json 형태로 객체 데이터를 반환 (@Controller + @ResponseBody)
@RequestMapping("/script")
@RequiredArgsConstructor
@Api(tags = {"Record Api"})
public class RecordScriptController {

private final RecordScriptService recordscriptService;
private final RecordRespository recordscriptRepository;

private final RecordScriptResponseDto recordscriptResponseDto;


@PostMapping("/addRecord")
public ResponseEntity<?> recordScript(@RequestBody RecordScriptRequestDto.Register record_script ){

return recordscriptService.recordScript(record_script);
}



@GetMapping("/record/{id}")
public ResponseEntity<?> readRecordScriptById(@PathVariable("id") Long id) {


Optional<RecordScript> optionalProduct=recordscriptRepository.findById(id);
if (optionalProduct.isPresent()) {
RecordScript record_script1 = optionalProduct.get();
return recordscriptResponseDto.success(record_script1);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ public class MemoRequestDto {
@AllArgsConstructor
@NoArgsConstructor
public static class createRequest {
@NotNull(message = "script 또는 interview 둘 중에 하나 기입하시면 됩니다.(해당 메모가 script인지 interview인지 구분하기 위함.")
private String type;

@NotNull(message = "메모 내용을 넣어주세요. 비어있으면 안됩니다.")
private String memo;
}

@Data
@AllArgsConstructor
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.umc3_teamproject.domain.dto.request;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

public class RecordRequestDto {

@Data
@AllArgsConstructor
@NoArgsConstructor
public static class createRecordRequest {
private double score1;
private double score2;
private double score3;
private double score4;
private double score5;
private int elapsed_minute;
private int elapsed_second;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public class MemoResponseDto {
@AllArgsConstructor
@NoArgsConstructor
public static class createBody {
private String script_interview_type;
private Long script_interview_id;
private Long memo_id;
private int result_count;
private String memo;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.umc3_teamproject.domain.dto.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

public class RecordMemoResponseDto {
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Body {
// sciprt와 intervie 구분
private int result_count;
private double mean;
private int total_elapsed_minute;
private int toal_elapsed_second;
private List<RecordResponseDto.Body> records;
private List<MemoResponseDto.createBody> memoList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.umc3_teamproject.domain.dto.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

public class RecordResponseDto {

@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Body {

// sciprt와 intervie 구분
private int result_count;
private double mean;
private double score1;
private double score2;
private double score3;
private double score4;
private double score5;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public class Interview extends BaseEntity {
@Column
private String type;

@Column
private int result_count;

@Column
private int total_elapsed_minute;

@Column
private int total_elapsed_second;

@Column
private boolean deleted;

Expand Down
26 changes: 11 additions & 15 deletions src/main/java/com/example/umc3_teamproject/domain/item/Memo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,22 @@ public class Memo {
@Column(name = "record_memo_id")
private Long id;

@OneToOne(fetch= FetchType.LAZY)
@JoinColumn(name="script_id",unique = true)
private Script script;
private String type;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "interview_id",unique = true)
private Interview interview;
// 해당 script와 interview의 id
private long script_interview_id;

// 회차 저장
private int result_count;

// 메모 저장
private String memo;

// 비즈니스 로직
public void createMemo(Script script, Interview interview, String memo){
if(script != null){
this.script = script;
}

if(interview != null){
this.interview = interview;
}

public void createMemo(String type,long script_interview_id, int result_count,String memo){
this.type = type;
this.script_interview_id = script_interview_id;
this.result_count = result_count;
this.memo = memo;
}

Expand Down
Loading

0 comments on commit 5ecb79a

Please sign in to comment.