add rks isi

This commit is contained in:
dirgantarasiahaan
2023-06-06 09:31:11 +07:00
parent f0f7a76f7c
commit 4877b84de0
11 changed files with 297 additions and 14 deletions

View File

@@ -19,16 +19,28 @@ public class RksDaftarIsiController {
private final GetListRksIsiService getListRksIsiService;
private final DeleteRksDaftarIsiService deleteRksDaftarIsiService;
private final PutUpdateRksDaftarIsiService putUpdateRksDaftarIsiService;
private final GetListRksParentService getListRksParentService;
private final PostCreateRksIsiService postCreateRksIsiService;
private final DeleteRksIsiService deleteRksIsiService;
private final PutEditRksIsiService putEditRksIsiService;
public RksDaftarIsiController(GetListRksDaftarIsiService getListRksDaftarIsiService,
PostCreateRksDaftarIsiService postCreateRksDaftarIsiService,
GetListRksIsiService getListRksIsiService,
DeleteRksDaftarIsiService deleteRksDaftarIsiService,
PutUpdateRksDaftarIsiService putUpdateRksDaftarIsiService) {
PutUpdateRksDaftarIsiService putUpdateRksDaftarIsiService,
GetListRksParentService getListRksParentService,
PostCreateRksIsiService postCreateRksIsiService,
DeleteRksIsiService deleteRksIsiService,
PutEditRksIsiService putEditRksIsiService) {
this.getListRksDaftarIsiService = getListRksDaftarIsiService;
this.postCreateRksDaftarIsiService = postCreateRksDaftarIsiService;
this.getListRksIsiService = getListRksIsiService;
this.deleteRksDaftarIsiService = deleteRksDaftarIsiService;
this.putUpdateRksDaftarIsiService = putUpdateRksDaftarIsiService;
this.getListRksParentService = getListRksParentService;
this.postCreateRksIsiService = postCreateRksIsiService;
this.deleteRksIsiService = deleteRksIsiService;
this.putEditRksIsiService = putEditRksIsiService;
}
@@ -50,19 +62,6 @@ public class RksDaftarIsiController {
return postCreateRksDaftarIsiService.execute(rksDaftarIsiRequest);
}
@GetMapping("/{id}/isi")
public ListRksIsiResponse getListRksIsi(@PathVariable(name = "id") Long id,
@RequestParam(name = "page", defaultValue = "1") Integer page,
@RequestParam(name = "size", defaultValue = "5") Integer size) {
Pageable pageable = PageRequest.of((page - 1), size);
RksIsiRequest rksIsiRequest = RksIsiRequest.builder()
.rksDaftarIsiId(id)
.pageable(pageable)
.build();
return getListRksIsiService.execute(rksIsiRequest);
}
@PutMapping("/{id}")
public RksDaftarIsiResponse editRksDaftarIsi(@PathVariable(name = "id") Long id,
@RequestBody RksDaftarIsiRequest rksDaftarIsiRequest) {
@@ -78,4 +77,46 @@ public class RksDaftarIsiController {
}
// perlu enhance
@GetMapping("/{id}/isi")
public ListRksIsiResponse getListRksIsi(@PathVariable(name = "id") Long id,
@RequestParam(name = "page", defaultValue = "1") Integer page,
@RequestParam(name = "size", defaultValue = "5") Integer size) {
Pageable pageable = PageRequest.of((page - 1), size);
RksIsiRequest rksIsiRequest = RksIsiRequest.builder()
.rksDaftarIsiId(id)
.pageable(pageable)
.build();
return getListRksIsiService.execute(rksIsiRequest);
}
@GetMapping("/{id}/parent")
public ListRksIsiResponse getParentRksIsi(@PathVariable(name = "id") Long id) {
return getListRksParentService.execute(RksIsiRequest.builder()
.rksDaftarIsiId(id)
.build());
}
@PostMapping("/{id}/isi")
public RksIsiResponse createRksIsi(@PathVariable(name = "id") Long id,
@RequestBody RksIsiRequest rksIsiRequest) {
rksIsiRequest.setRksDaftarIsiId(id);
return postCreateRksIsiService.execute(rksIsiRequest);
}
@PutMapping("/isi/{id}")
public RksIsiResponse editRksIsi(@PathVariable(name = "id") Long id,
@RequestBody RksIsiRequest rksIsiRequest) {
rksIsiRequest.setId(id);
return putEditRksIsiService.execute(rksIsiRequest);
}
@DeleteMapping("/isi/{id}")
public EmptyResponse deleteRksIsi(@PathVariable(name = "id") Long id) {
return deleteRksIsiService.execute(RksIsiRequest.builder()
.id(id)
.build());
}
}