#31 loan: delete judgement

This commit is contained in:
haerong22
2023-03-28 00:42:02 +09:00
parent 07abdbdf45
commit f063e89ea2
4 changed files with 35 additions and 0 deletions

View File

@@ -39,4 +39,12 @@ public class JudgementController extends AbstractController {
) {
return ok(judgementService.update(judgementId, request));
}
@DeleteMapping("/{judgementId}")
public ResponseDto<Void> delete(
@PathVariable Long judgementId
) {
judgementService.delete(judgementId);
return ok();
}
}

View File

@@ -11,4 +11,6 @@ public interface JudgementService {
JudgementDto.Response getJudgementOfApplication(Long applicationId);
JudgementDto.Response update(Long judgementId, JudgementDto.Request request);
void delete(Long judgementId);
}

View File

@@ -68,6 +68,16 @@ public class JudgementServiceImpl implements JudgementService {
return modelMapper.map(judgement, JudgementDto.Response.class);
}
@Override
public void delete(Long judgementId) {
Judgement judgement = judgementRepository.findById(judgementId)
.orElseThrow(() -> new BaseException(ResultType.SYSTEM_ERROR));
judgement.setIsDeleted(true);
judgementRepository.save(judgement);
}
private boolean isPresentApplication(Long applicationId) {
return applicationRepository.findById(applicationId).isPresent();
}

View File

@@ -115,4 +115,19 @@ class JudgementServiceImplTest {
assertThat(actual.getName()).isSameAs(request.getName());
assertThat(actual.getApprovalAmount()).isSameAs(request.getApprovalAmount());
}
@Test
void Should_DeletedJudgementEntity_When_RequestDeleteExistJudgementInfo() {
Judgement entity = Judgement.builder()
.judgementId(1L)
.build();
when(judgementRepository.findById(1L)).thenReturn(Optional.ofNullable(entity));
when(judgementRepository.save(ArgumentMatchers.any(Judgement.class))).thenReturn(entity);
judgementService.delete(1L);
assertThat(entity.getIsDeleted()).isTrue();
}
}