115 lines
5.6 KiB
Java
115 lines
5.6 KiB
Java
package com.iconplus.smartproc.controller;
|
|
|
|
import com.iconplus.smartproc.helper.model.EmptyRequest;
|
|
import com.iconplus.smartproc.helper.model.EmptyResponse;
|
|
import com.iconplus.smartproc.model.request.DrpApprovalRequest;
|
|
import com.iconplus.smartproc.model.request.DrpRekomendasiRequest;
|
|
import com.iconplus.smartproc.model.request.ListDrpApprovalRequest;
|
|
import com.iconplus.smartproc.model.response.*;
|
|
import com.iconplus.smartproc.service.approval.*;
|
|
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/drp/approval")
|
|
public class ApprovalDrpController {
|
|
|
|
private GetListUserVpService getListUserVpService;
|
|
private GetListUserDirekturKomiteService getListUserDirekturKomiteService;
|
|
private PostCreateDrpApprovalService postCreateDrpApprovalService;
|
|
private GetListApprovalDrpServie getListApprovalDrpServie;
|
|
private PostDrpRekomendasiService postDrpRekomendasiService;
|
|
private PostDrpApprovalExecutionService postDrpApprovalExecutionService;
|
|
private GetApprovalService getApprovalService;
|
|
private GetListRekomendasiService getListRekomendasiService;
|
|
private GetHistoryApprovalService getHistoryApprovalService;
|
|
public ApprovalDrpController(GetListUserVpService getListUserVpService,
|
|
GetListUserDirekturKomiteService getListUserDirekturKomiteService,
|
|
PostCreateDrpApprovalService postCreateDrpApprovalService,
|
|
GetListApprovalDrpServie getListApprovalDrpServie,
|
|
PostDrpRekomendasiService postDrpRekomendasiService,
|
|
PostDrpApprovalExecutionService postDrpApprovalExecutionService,
|
|
GetApprovalService getApprovalService,
|
|
GetListRekomendasiService getListRekomendasiService,
|
|
GetHistoryApprovalService getHistoryApprovalService) {
|
|
this.getListUserVpService = getListUserVpService;
|
|
this.getListUserDirekturKomiteService = getListUserDirekturKomiteService;
|
|
this.postCreateDrpApprovalService = postCreateDrpApprovalService;
|
|
this.getListApprovalDrpServie = getListApprovalDrpServie;
|
|
this.postDrpRekomendasiService = postDrpRekomendasiService;
|
|
this.postDrpApprovalExecutionService = postDrpApprovalExecutionService;
|
|
this.getApprovalService = getApprovalService;
|
|
this.getListRekomendasiService = getListRekomendasiService;
|
|
this.getHistoryApprovalService = getHistoryApprovalService;
|
|
}
|
|
|
|
@GetMapping("/vp")
|
|
public GetListUserApprovalResponse getUserVp(EmptyRequest emptyRequest) {
|
|
return getListUserVpService.execute(emptyRequest);
|
|
}
|
|
|
|
@GetMapping("direktur-komite")
|
|
public GetListUserApprovalResponse getUserDirekturKomite(EmptyRequest emptyRequest) {
|
|
return getListUserDirekturKomiteService.execute(emptyRequest);
|
|
}
|
|
|
|
@PostMapping
|
|
public EmptyResponse createDrpHasApproval(@RequestBody ListDrpApprovalRequest listDrpApprovalRequest) {
|
|
return postCreateDrpApprovalService.execute(listDrpApprovalRequest);
|
|
}
|
|
|
|
@GetMapping
|
|
public GetListDrpApprovalResponse getListDrpApprovalResponse(@RequestParam(name = "search", required = false) String search,
|
|
@RequestParam(name = "page", defaultValue = "1") Integer page,
|
|
@RequestParam(name = "size", defaultValue = "5") Integer size) {
|
|
|
|
Pageable pageable = PageRequest.of((page - 1), size);
|
|
DrpApprovalRequest drpApprovalRequest = DrpApprovalRequest.builder()
|
|
.search(search)
|
|
.pageable(pageable)
|
|
.build();
|
|
return getListApprovalDrpServie.execute(drpApprovalRequest);
|
|
|
|
}
|
|
|
|
@PostMapping("/rekomendasi")
|
|
public DrpRekomendasiResponse drpRekomendasiResponse(@RequestBody DrpRekomendasiRequest drpRekomendasiRequest) {
|
|
return postDrpRekomendasiService.execute(drpRekomendasiRequest);
|
|
}
|
|
|
|
@PostMapping("/execution")
|
|
public EmptyResponse drpApprovalExecution(@RequestBody DrpApprovalRequest drpApprovalRequest) {
|
|
return postDrpApprovalExecutionService.execute(drpApprovalRequest);
|
|
}
|
|
|
|
@GetMapping("/jenis-pengadaan/{id}")
|
|
public DrpApprovalResponse getDrpApproval(@PathVariable(name = "id") Long id) {
|
|
return getApprovalService.execute(DrpApprovalRequest.builder()
|
|
.jenisPengadaanId(id)
|
|
.build());
|
|
}
|
|
|
|
@GetMapping("/rekomendasi/jenis-pengadaan/{id}")
|
|
public GetListDrpRekomendasiResponse getListRekomendasi(@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);
|
|
DrpRekomendasiRequest drpRekomendasiRequest = DrpRekomendasiRequest.builder()
|
|
.jenisPengadaanId(id)
|
|
.pageable(pageable)
|
|
.build();
|
|
|
|
return getListRekomendasiService.execute(drpRekomendasiRequest);
|
|
}
|
|
|
|
@GetMapping("/{id}/history")
|
|
public GetListDrpApprovalHistoryResponse getListDrpApprovalResponse(@PathVariable(name = "id") Long id) {
|
|
return getHistoryApprovalService.execute(DrpApprovalRequest.builder()
|
|
.drpId(id)
|
|
.build());
|
|
}
|
|
}
|