#31 loan: delete application
This commit is contained in:
@@ -34,4 +34,12 @@ public class ApplicationController extends AbstractController {
|
|||||||
) {
|
) {
|
||||||
return ok(applicationService.update(applicationId, request));
|
return ok(applicationService.update(applicationId, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{applicationId}")
|
||||||
|
public ResponseDto<Void> delete(
|
||||||
|
@PathVariable Long applicationId
|
||||||
|
) {
|
||||||
|
applicationService.delete(applicationId);
|
||||||
|
return ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ public interface ApplicationService {
|
|||||||
ApplicationDto.Response get(Long applicationId);
|
ApplicationDto.Response get(Long applicationId);
|
||||||
|
|
||||||
ApplicationDto.Response update(Long applicationId, ApplicationDto.Request request);
|
ApplicationDto.Response update(Long applicationId, ApplicationDto.Request request);
|
||||||
|
|
||||||
|
void delete(Long applicationId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,14 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
|
|
||||||
return modelMapper.map(application, ApplicationDto.Response.class);
|
return modelMapper.map(application, ApplicationDto.Response.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Long applicationId) {
|
||||||
|
Application application = applicationRepository.findById(applicationId)
|
||||||
|
.orElseThrow(() -> new BaseException(ResultType.SYSTEM_ERROR));
|
||||||
|
|
||||||
|
application.setIsDeleted(true);
|
||||||
|
|
||||||
|
applicationRepository.save(application);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,4 +93,20 @@ class ApplicationServiceTest {
|
|||||||
assertThat(actual.getApplicationId()).isSameAs(findId);
|
assertThat(actual.getApplicationId()).isSameAs(findId);
|
||||||
assertThat(actual.getHopeAmount()).isSameAs(request.getHopeAmount());
|
assertThat(actual.getHopeAmount()).isSameAs(request.getHopeAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void Should_DeletedApplicationEntity_When_RequestDeleteExistApplicationInfo() {
|
||||||
|
Long targetId = 1L;
|
||||||
|
|
||||||
|
Application entity = Application.builder()
|
||||||
|
.applicationId(1L)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
when(applicationRepository.save(ArgumentMatchers.any(Application.class))).thenReturn(entity);
|
||||||
|
when(applicationRepository.findById(targetId)).thenReturn(Optional.ofNullable(entity));
|
||||||
|
|
||||||
|
applicationService.delete(targetId);
|
||||||
|
|
||||||
|
assertThat(entity.getIsDeleted()).isTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user