Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import inha.gdgoc.domain.manito.dto.request.ManitoVerifyRequest;
import inha.gdgoc.domain.manito.dto.response.ManitoVerifyResponse;
import inha.gdgoc.domain.manito.entity.ManitoAssignment;
import inha.gdgoc.domain.manito.service.ManitoUserService;
import inha.gdgoc.global.dto.response.ApiResponse;
import jakarta.validation.Valid;
Expand All @@ -21,8 +22,13 @@ public class ManitoVerifyController {

@PostMapping("/verify")
public ResponseEntity<ApiResponse<ManitoVerifyResponse, Void>> verify(@Valid @RequestBody ManitoVerifyRequest request) {
String cipher = manitoUserService.verifyAndGetCipher(request.sessionCode(), request.studentId(), request.pin());
ManitoAssignment assignment = manitoUserService.verifyAndGetAssignment(request.sessionCode(), request.studentId(), request.pin());

return ResponseEntity.ok(ApiResponse.ok("마니또 정보 조회 성공", new ManitoVerifyResponse(cipher)));
String cipher = assignment.getEncryptedManitto();
String ownerName = assignment.getName();

ManitoVerifyResponse response = new ManitoVerifyResponse(cipher, ownerName);

return ResponseEntity.ok(ApiResponse.ok("마니또 정보 조회 성공", response));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package inha.gdgoc.domain.manito.dto.response;

/**
* 마니또 검증 성공 시, 클라이언트에서 복호화할 암호문을 내려주는 DTO
* 마니또 검증 성공 시, 클라이언트에서 복호화할 암호문과
* 요청자(=giver)의 이름을 내려주는 DTO
*/
public record ManitoVerifyResponse(

String encryptedManito
String encryptedManito,
String ownerName
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ public class ManitoUserService {
private final PasswordEncoder passwordEncoder;
private final ManitoPinPolicy manitoPinPolicy;

/**
* pin 검증 후 암호문 반환
*/
@Transactional(readOnly = true)
public String verifyAndGetCipher(String sessionCode, String studentId, String pinPlain) {

log.info("[MANITO] >>> verifyAndGetCipher CALLED (sessionCode={}, studentId={})", sessionCode, studentId);
public ManitoAssignment verifyAndGetAssignment(String sessionCode, String studentId, String pinPlain) {

ManitoSession session = sessionRepository.findByCode(sessionCode)
.orElseThrow(() -> new BusinessException(GlobalErrorCode.RESOURCE_NOT_FOUND, "세션 코드가 올바르지 않습니다."));
Expand All @@ -48,7 +43,6 @@ public String verifyAndGetCipher(String sessionCode, String studentId, String pi
if (assignment.getEncryptedManitto() == null || assignment.getEncryptedManitto().isBlank()) {
throw new BusinessException(GlobalErrorCode.RESOURCE_NOT_FOUND, "아직 마니또 암호문이 업로드되지 않았습니다. 관리자에게 문의하세요.");
}

return assignment.getEncryptedManitto();
return assignment;
}
}
Loading