This commit is contained in:
dirgantarasiahaan
2023-06-05 09:36:43 +07:00
parent abc89d32d0
commit 180575ce4f
24 changed files with 747 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
package com.iconplus.smartproc.controller;
import com.iconplus.smartproc.model.request.RksDaftarIsiRequest;
import com.iconplus.smartproc.model.request.RksIsiRequest;
import com.iconplus.smartproc.model.request.RksTemplateRequest;
import com.iconplus.smartproc.model.response.ListRksDaftarIsiResponse;
import com.iconplus.smartproc.model.response.ListRksIsiResponse;
import com.iconplus.smartproc.model.response.RksDaftarIsiResponse;
import com.iconplus.smartproc.model.response.RksTemplateResponse;
import com.iconplus.smartproc.service.rks.GetListRksDaftarIsiService;
import com.iconplus.smartproc.service.rks.GetListRksIsiService;
import com.iconplus.smartproc.service.rks.PostCreateRksDaftarIsiService;
import com.iconplus.smartproc.service.rks.PostCreateRksTemplateService;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "${fe.server}", allowCredentials = "true")
@RestController
@RequestMapping("/api/rks")
public class RksController {
private final GetListRksDaftarIsiService getListRksDaftarIsiService;
private final PostCreateRksDaftarIsiService postCreateRksDaftarIsiService;
private final GetListRksIsiService getListRksIsiService;
private final PostCreateRksTemplateService postCreateRksTemplateService;
public RksController(GetListRksDaftarIsiService getListRksDaftarIsiService,
PostCreateRksDaftarIsiService postCreateRksDaftarIsiService,
GetListRksIsiService getListRksIsiService,
PostCreateRksTemplateService postCreateRksTemplateService) {
this.getListRksDaftarIsiService = getListRksDaftarIsiService;
this.postCreateRksDaftarIsiService = postCreateRksDaftarIsiService;
this.getListRksIsiService = getListRksIsiService;
this.postCreateRksTemplateService = postCreateRksTemplateService;
}
@GetMapping("/daftar-isi")
public ListRksDaftarIsiResponse getAllRksDaftarIsi(@RequestParam(name = "page", defaultValue = "1") Integer page,
@RequestParam(name = "size", defaultValue = "5") Integer size){
Pageable pageable = PageRequest.of((page - 1), size);
RksDaftarIsiRequest rksDaftarIsiRequest = RksDaftarIsiRequest.builder()
.pageable(pageable)
.build();
return getListRksDaftarIsiService.execute(rksDaftarIsiRequest);
}
@PostMapping("/daftar-isi")
public RksDaftarIsiResponse createRksDaftarIsi(@RequestBody RksDaftarIsiRequest rksDaftarIsiRequest) {
return postCreateRksDaftarIsiService.execute(rksDaftarIsiRequest);
}
@GetMapping("/daftar-isi/{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);
}
@PostMapping("/template")
public RksTemplateResponse createRksTemplate(@RequestBody RksTemplateRequest rksTemplateRequest) {
return postCreateRksTemplateService.execute(rksTemplateRequest);
}
}