Test all Java
This commit is contained in:
		| @@ -1,65 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import com.iconplus.smartproc.model.entity.JenisKontrak; | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.repository.JenisKontrakRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.JenisKontrakRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListJenisKontrakResponse; | ||||
| import com.iconplus.smartproc.model.response.JenisKontrakResponse; | ||||
| import com.iconplus.smartproc.repository.JenisKontrakRepository; | ||||
| import com.iconplus.smartproc.service.jeniskontrak.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/jeniskontrak") | ||||
| public class JenisKontrakController { | ||||
| 	@Autowired | ||||
| 	private JenisKontrakRepository jeniskontrakRepository; | ||||
|  | ||||
| 	//get all data | ||||
| 	@GetMapping | ||||
| 	public List<JenisKontrak> getAllJeniskontraks(){ | ||||
| 		return jeniskontrakRepository.findAll(); | ||||
| 	} | ||||
|         @Autowired | ||||
|         private JenisKontrakRepository jeniskontrakRepository; | ||||
|  | ||||
| 	// create | ||||
| 	@PostMapping | ||||
| 	public JenisKontrak createJeniskontrak(@RequestBody JenisKontrak jeniskontrak) { | ||||
| 		return jeniskontrakRepository.save(jeniskontrak); | ||||
| 	} | ||||
|         private final GetListJenisKontrakService getListJenisKontrakService; | ||||
|         private final GetJenisKontrakByIdService getJenisKontrakByIdService; | ||||
|         private final PostCreateJenisKontrakService postCreateJenisKontrakService; | ||||
|         private final PutUpdateJenisKontrakService putUpdateJenisKontrakService; | ||||
|         private final DeleteJenisKontrakService deleteJenisKontrakService; | ||||
|  | ||||
| 	// get jeniskontrak by id rest api | ||||
| 	@GetMapping("/{id}") | ||||
| 	public ResponseEntity<JenisKontrak> getJeniskontrakById(@PathVariable Long id) { | ||||
| 		JenisKontrak jeniskontrak = jeniskontrakRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Jeniskontrak not exist with id :" + id)); | ||||
| 		return ResponseEntity.ok(jeniskontrak); | ||||
| 	} | ||||
|         public JenisKontrakController(GetListJenisKontrakService getListJenisKontrakService, | ||||
| 									   GetJenisKontrakByIdService getJenisKontrakByIdService, | ||||
|                                        PostCreateJenisKontrakService postCreateJenisKontrakService, | ||||
|                                        PutUpdateJenisKontrakService putUpdateJenisKontrakService, | ||||
|                                        DeleteJenisKontrakService deleteJenisKontrakService) { | ||||
|             this.getListJenisKontrakService = getListJenisKontrakService; | ||||
|             this.getJenisKontrakByIdService = getJenisKontrakByIdService; | ||||
|             this.postCreateJenisKontrakService = postCreateJenisKontrakService; | ||||
|             this.putUpdateJenisKontrakService = putUpdateJenisKontrakService; | ||||
|             this.deleteJenisKontrakService = deleteJenisKontrakService; | ||||
|         } | ||||
|  | ||||
| 	// update jeniskontrak rest api | ||||
| 	@PutMapping("/{id}") | ||||
| 	public ResponseEntity<JenisKontrak> updateJeniskontrak(@PathVariable Long id, @RequestBody JenisKontrak jenisKontrakDetails){ | ||||
| 		JenisKontrak jeniskontrak = jeniskontrakRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Jeniskontrak not exist with id :" + id)); | ||||
|  | ||||
| 		jeniskontrak.setJenisKontrak(jenisKontrakDetails.getJenisKontrak()); | ||||
| 		jeniskontrak.setKeterangan(jenisKontrakDetails.getKeterangan()); | ||||
|         @GetMapping | ||||
|         public GetListJenisKontrakResponse getListJenisKontrak(@RequestParam(name = "search", required = false) String search, | ||||
|                                                                  @RequestParam(name = "page", defaultValue = "1") Integer page, | ||||
|                                                                  @RequestParam(name = "size", defaultValue = "5") Integer size){ | ||||
|  | ||||
| 		JenisKontrak updatedJenisKontrak = jeniskontrakRepository.save(jeniskontrak); | ||||
| 		return ResponseEntity.ok(updatedJenisKontrak); | ||||
| 	} | ||||
|             Pageable pageable = PageRequest.of((page - 1), size); | ||||
|             JenisKontrakRequest jenisKontrakRequest = JenisKontrakRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
| 	// delete jeniskontrak rest api | ||||
| 	@DeleteMapping("/{id}") | ||||
| 	public ResponseEntity<Map<String, Boolean>> deleteJeniskontrak(@PathVariable Long id){ | ||||
| 		JenisKontrak jeniskontrak = jeniskontrakRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Jeniskontrak not exist with id :" + id)); | ||||
|             return getListJenisKontrakService.execute(jenisKontrakRequest); | ||||
|         } | ||||
|  | ||||
| 		jeniskontrakRepository.delete(jeniskontrak); | ||||
| 		Map<String, Boolean> response = new HashMap<>(); | ||||
| 		response.put("deleted", Boolean.TRUE); | ||||
| 		return ResponseEntity.ok(response); | ||||
| 	} | ||||
| } | ||||
|         @PostMapping | ||||
|         public JenisKontrakResponse createJenisKontrak(@RequestBody JenisKontrakRequest jenisKontrakRequest) { | ||||
|             return postCreateJenisKontrakService.execute(jenisKontrakRequest); | ||||
|         } | ||||
|  | ||||
|         @GetMapping("/{id}") | ||||
|         public JenisKontrakResponse getJenisKontrakById(@PathVariable Long id) { | ||||
|             return getJenisKontrakByIdService.execute(JenisKontrakRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public JenisKontrakResponse updateJeniskontrak(@PathVariable Long id, | ||||
|                                                          @RequestBody JenisKontrakRequest jenisKontrakRequest){ | ||||
|             jenisKontrakRequest.setId(id); | ||||
|             return putUpdateJenisKontrakService.execute(jenisKontrakRequest); | ||||
|         } | ||||
|  | ||||
|         @DeleteMapping("/{id}") | ||||
|         public EmptyResponse deleteJenisKontrak(@PathVariable Long id) { | ||||
|             return deleteJenisKontrakService.execute(JenisKontrakRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -1,65 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import com.iconplus.smartproc.model.entity.JenisPengadaan; | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.repository.JenisPengadaanRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.JenisPengadaanRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListJenisPengadaanResponse; | ||||
| import com.iconplus.smartproc.model.response.JenisPengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.JenisPengadaanRepository; | ||||
| import com.iconplus.smartproc.service.jenispengadaan.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/jenispengadaan") | ||||
| public class JenisPengadaanController { | ||||
|  | ||||
|         @Autowired | ||||
|         private JenisPengadaanRepository jenispengadaanRepository; | ||||
|  | ||||
|         //get all data | ||||
|         private final GetListJenisPengadaanService getListJenisPengadaanService; | ||||
|         private final GetJenisPengadaanByIdService getJenisPengadaanByIdService; | ||||
|         private final PostCreateJenisPengadaanService postCreateJenisPengadaanService; | ||||
|         private final PutUpdateJenisPengadaanService putUpdateJenisPengadaanService; | ||||
|         private final DeleteJenisPengadaanService deleteJenisPengadaanService; | ||||
|  | ||||
|         public JenisPengadaanController(GetListJenisPengadaanService getListJenisPengadaanService, | ||||
| 									   GetJenisPengadaanByIdService getJenisPengadaanByIdService, | ||||
|                                        PostCreateJenisPengadaanService postCreateJenisPengadaanService, | ||||
|                                        PutUpdateJenisPengadaanService putUpdateJenisPengadaanService, | ||||
|                                        DeleteJenisPengadaanService deleteJenisPengadaanService) { | ||||
|             this.getListJenisPengadaanService = getListJenisPengadaanService; | ||||
|             this.getJenisPengadaanByIdService = getJenisPengadaanByIdService; | ||||
|             this.postCreateJenisPengadaanService = postCreateJenisPengadaanService; | ||||
|             this.putUpdateJenisPengadaanService = putUpdateJenisPengadaanService; | ||||
|             this.deleteJenisPengadaanService = deleteJenisPengadaanService; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @GetMapping | ||||
|         public List<JenisPengadaan> getAllJenispengadaans(){ | ||||
|             return jenispengadaanRepository.findAll(); | ||||
|         public GetListJenisPengadaanResponse getListJenisPengadaan(@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); | ||||
|             JenisPengadaanRequest jenisPengadaanRequest = JenisPengadaanRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
|             return getListJenisPengadaanService.execute(jenisPengadaanRequest); | ||||
|         } | ||||
|  | ||||
|         // create | ||||
|         @PostMapping | ||||
|         public JenisPengadaan createJenispengadaan(@RequestBody JenisPengadaan jenispengadaan) { | ||||
|             return jenispengadaanRepository.save(jenispengadaan); | ||||
|         public JenisPengadaanResponse createJenisPengadaan(@RequestBody JenisPengadaanRequest jenisPengadaanRequest) { | ||||
|             return postCreateJenisPengadaanService.execute(jenisPengadaanRequest); | ||||
|         } | ||||
|  | ||||
|         // get jenispengadaan by id rest api | ||||
|         @GetMapping("/{id}") | ||||
|         public ResponseEntity<JenisPengadaan> getJenispengadaanById(@PathVariable Long id) { | ||||
|             JenisPengadaan jenispengadaan = jenispengadaanRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Jenispengadaan not exist with id :" + id)); | ||||
|             return ResponseEntity.ok(jenispengadaan); | ||||
|         public JenisPengadaanResponse getJenisPengadaanById(@PathVariable Long id) { | ||||
|             return getJenisPengadaanByIdService.execute(JenisPengadaanRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|         // update jenispengadaan rest api | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public ResponseEntity<JenisPengadaan> updateJenispengadaan(@PathVariable Long id, @RequestBody JenisPengadaan jenisPengadaanDetails){ | ||||
|             JenisPengadaan jenispengadaan = jenispengadaanRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Jenispengadaan not exist with id :" + id)); | ||||
|  | ||||
|             jenispengadaan.setJenisPengadaan(jenisPengadaanDetails.getJenisPengadaan()); | ||||
|             jenispengadaan.setKeterangan(jenisPengadaanDetails.getKeterangan()); | ||||
|  | ||||
|             JenisPengadaan updatedJenisPengadaan =  jenispengadaanRepository.save(jenispengadaan); | ||||
|             return ResponseEntity.ok(updatedJenisPengadaan); | ||||
|         public JenisPengadaanResponse updateJenisPengadaan(@PathVariable Long id, | ||||
|                                                          @RequestBody JenisPengadaanRequest jenisPengadaanRequest){ | ||||
|             jenisPengadaanRequest.setId(id); | ||||
|             return putUpdateJenisPengadaanService.execute(jenisPengadaanRequest); | ||||
|         } | ||||
|  | ||||
|         // delete jenispengadaan rest api | ||||
|         @DeleteMapping("/{id}") | ||||
|         public ResponseEntity<Map<String, Boolean>> deleteJenispengadaan(@PathVariable Long id){ | ||||
|             JenisPengadaan jenispengadaan = jenispengadaanRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Supposmatrix not exist with id :" + id)); | ||||
|  | ||||
|             jenispengadaanRepository.delete(jenispengadaan); | ||||
|             Map<String, Boolean> response = new HashMap<>(); | ||||
|             response.put("deleted", Boolean.TRUE); | ||||
|             return ResponseEntity.ok(response); | ||||
|         public EmptyResponse deleteJenisPengadaan(@PathVariable Long id) { | ||||
|             return deleteJenisPengadaanService.execute(JenisPengadaanRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -1,69 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import com.iconplus.smartproc.model.entity.Lokasi; | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.repository.LokasiRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.LokasiRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListLokasiResponse; | ||||
| import com.iconplus.smartproc.model.response.LokasiResponse; | ||||
| import com.iconplus.smartproc.repository.LokasiRepository; | ||||
| import com.iconplus.smartproc.service.lokasi.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/lokasi") | ||||
| public class LokasiController { | ||||
|  | ||||
|         @Autowired | ||||
|         private LokasiRepository lokasiRepository; | ||||
|  | ||||
|         //get all data | ||||
|         private final GetListLokasiService getListLokasiService; | ||||
|         private final GetLokasiByIdService getLokasiByIdService; | ||||
|         private final PostCreateLokasiService postCreateLokasiService; | ||||
|         private final PutUpdateLokasiService putUpdateLokasiService; | ||||
|         private final DeleteLokasiService deleteLokasiService; | ||||
|  | ||||
|         public LokasiController(GetListLokasiService getListLokasiService, | ||||
|                                        GetLokasiByIdService getLokasiByIdService, | ||||
|                                        PostCreateLokasiService postCreateLokasiService, | ||||
|                                        PutUpdateLokasiService putUpdateLokasiService, | ||||
|                                        DeleteLokasiService deleteLokasiService) { | ||||
|             this.getListLokasiService = getListLokasiService; | ||||
|             this.getLokasiByIdService = getLokasiByIdService; | ||||
|             this.postCreateLokasiService = postCreateLokasiService; | ||||
|             this.putUpdateLokasiService = putUpdateLokasiService; | ||||
|             this.deleteLokasiService = deleteLokasiService; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @GetMapping | ||||
|         public List<Lokasi> getAllLokasis(){ | ||||
|             return lokasiRepository.findAll(); | ||||
|         public GetListLokasiResponse getListLokasi(@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); | ||||
|             LokasiRequest lokasiRequest = LokasiRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
|             return getListLokasiService.execute(lokasiRequest); | ||||
|         } | ||||
|  | ||||
|         // create | ||||
|         @PostMapping | ||||
|         public Lokasi createLokasi(@RequestBody Lokasi lokasi) { | ||||
|             return lokasiRepository.save(lokasi); | ||||
|         public LokasiResponse createLokasi(@RequestBody LokasiRequest lokasiRequest) { | ||||
|             return postCreateLokasiService.execute(lokasiRequest); | ||||
|         } | ||||
|  | ||||
|         // get lokasi by id rest api | ||||
|         @GetMapping("/{id}") | ||||
|         public ResponseEntity<Lokasi> getLokasiById(@PathVariable Long id) { | ||||
|             Lokasi lokasi = lokasiRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Lokasi not exist with id :" + id)); | ||||
|             return ResponseEntity.ok(lokasi); | ||||
|         public LokasiResponse getLokasiById(@PathVariable Long id) { | ||||
|             return getLokasiByIdService.execute(LokasiRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|         // update lokasi rest api | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public ResponseEntity<Lokasi> updateSumberdana(@PathVariable Long id, @RequestBody Lokasi lokasiDetails){ | ||||
|             Lokasi lokasi = lokasiRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Lokasi not exist with id :" + id)); | ||||
|  | ||||
|             lokasi.setLokasi(lokasiDetails.getLokasi()); | ||||
|             lokasi.setKeterangan(lokasiDetails.getKeterangan()); | ||||
|  | ||||
|             Lokasi updatedLokasi =  lokasiRepository.save(lokasi); | ||||
|             return ResponseEntity.ok(updatedLokasi); | ||||
|         public LokasiResponse updateLokasi(@PathVariable Long id, | ||||
|                                                          @RequestBody LokasiRequest LokasiRequest){ | ||||
|             LokasiRequest.setId(id); | ||||
|             return putUpdateLokasiService.execute(LokasiRequest); | ||||
|         } | ||||
|  | ||||
|         // delete lokasi rest api | ||||
|         @DeleteMapping("/{id}") | ||||
|         public ResponseEntity<Map<String, Boolean>> deleteLokasi(@PathVariable Long id){ | ||||
|             Lokasi lokasi = lokasiRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Lokasi not exist with id :" + id)); | ||||
|  | ||||
|             lokasiRepository.delete(lokasi); | ||||
|             Map<String, Boolean> response = new HashMap<>(); | ||||
|             response.put("deleted", Boolean.TRUE); | ||||
|             return ResponseEntity.ok(response); | ||||
|         public EmptyResponse deleteLokasi(@PathVariable Long id) { | ||||
|             return deleteLokasiService.execute(LokasiRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,68 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import com.iconplus.smartproc.model.entity.MetodePengadaan; | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.repository.MetodePengadaanRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.MetodePengadaanRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListMetodePengadaanResponse; | ||||
| import com.iconplus.smartproc.model.response.MetodePengadaanResponse; | ||||
| import com.iconplus.smartproc.repository.MetodePengadaanRepository; | ||||
| import com.iconplus.smartproc.service.metodepengadaan.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/metodepengadaan") | ||||
| public class MetodePengadaanController { | ||||
| 	@Autowired | ||||
| 	private MetodePengadaanRepository metodepengadaanRepository; | ||||
|  | ||||
| 	//get all data | ||||
| 	@GetMapping | ||||
| 	public List<MetodePengadaan> getAllMetodepengadaans(){ | ||||
| 		return metodepengadaanRepository.findAll(); | ||||
| 	} | ||||
|         @Autowired | ||||
|         private MetodePengadaanRepository metodepengadaanRepository; | ||||
|  | ||||
| 	// create | ||||
| 	@PostMapping | ||||
| 	public MetodePengadaan createMetodepengadaan(@RequestBody MetodePengadaan metodepengadaan) { | ||||
| 		return metodepengadaanRepository.save(metodepengadaan); | ||||
| 	} | ||||
|         private final GetListMetodePengadaanService getListMetodePengadaanService; | ||||
|         private final GetMetodePengadaanByIdService getMetodePengadaanByIdService; | ||||
|         private final PostCreateMetodePengadaanService postCreateMetodePengadaanService; | ||||
|         private final PutUpdateMetodePengadaanService putUpdateMetodePengadaanService; | ||||
|         private final DeleteMetodePengadaanService deleteMetodePengadaanService; | ||||
|  | ||||
| 	// get metodepengadaan by id rest api | ||||
| 	@GetMapping("/{id}") | ||||
| 	public ResponseEntity<MetodePengadaan> getMetodepengadaanById(@PathVariable Long id) { | ||||
| 		MetodePengadaan metodepengadaan = metodepengadaanRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Metodepengadaan not exist with id :" + id)); | ||||
| 		return ResponseEntity.ok(metodepengadaan); | ||||
| 	} | ||||
|         public MetodePengadaanController(GetListMetodePengadaanService getListMetodePengadaanService, | ||||
|                                        GetMetodePengadaanByIdService getMetodePengadaanByIdService, | ||||
|                                        PostCreateMetodePengadaanService postCreateMetodePengadaanService, | ||||
|                                        PutUpdateMetodePengadaanService putUpdateMetodePengadaanService, | ||||
|                                        DeleteMetodePengadaanService deleteMetodePengadaanService) { | ||||
|             this.getListMetodePengadaanService = getListMetodePengadaanService; | ||||
|             this.getMetodePengadaanByIdService = getMetodePengadaanByIdService; | ||||
|             this.postCreateMetodePengadaanService = postCreateMetodePengadaanService; | ||||
|             this.putUpdateMetodePengadaanService = putUpdateMetodePengadaanService; | ||||
|             this.deleteMetodePengadaanService = deleteMetodePengadaanService; | ||||
|         } | ||||
|  | ||||
| 	// update metodepengadaan rest api | ||||
| 	@PutMapping("/{id}") | ||||
| 	public ResponseEntity<MetodePengadaan> updateMetodepengadaan(@PathVariable Long id, @RequestBody MetodePengadaan metodePengadaanDetails){ | ||||
| 		MetodePengadaan metodepengadaan = metodepengadaanRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Metodepengadaan not exist with id :" + id)); | ||||
|  | ||||
| 		metodepengadaan.setMetodePengadaan(metodePengadaanDetails.getMetodePengadaan()); | ||||
| 		metodepengadaan.setKeterangan(metodePengadaanDetails.getKeterangan()); | ||||
|         @GetMapping | ||||
|         public GetListMetodePengadaanResponse getListMetodePengadaan(@RequestParam(name = "search", required = false) String search, | ||||
|                                                                  @RequestParam(name = "page", defaultValue = "1") Integer page, | ||||
|                                                                  @RequestParam(name = "size", defaultValue = "5") Integer size){ | ||||
|  | ||||
| 		MetodePengadaan updatedMetodePengadaan = metodepengadaanRepository.save(metodepengadaan); | ||||
| 		return ResponseEntity.ok(updatedMetodePengadaan); | ||||
| 	} | ||||
|             Pageable pageable = PageRequest.of((page - 1), size); | ||||
|             MetodePengadaanRequest metodePengadaanRequest = MetodePengadaanRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
| 	// delete metodepengadaan rest api | ||||
| 	@DeleteMapping("/{id}") | ||||
| 	public ResponseEntity<Map<String, Boolean>> deleteMetodepengadaan(@PathVariable Long id){ | ||||
| 		MetodePengadaan metodepengadaan = metodepengadaanRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Metodepengadaan not exist with id :" + id)); | ||||
|             return getListMetodePengadaanService.execute(metodePengadaanRequest); | ||||
|         } | ||||
|  | ||||
| 		metodepengadaanRepository.delete(metodepengadaan); | ||||
| 		Map<String, Boolean> response = new HashMap<>(); | ||||
| 		response.put("deleted", Boolean.TRUE); | ||||
| 		return ResponseEntity.ok(response); | ||||
| 	} | ||||
|         @PostMapping | ||||
|         public MetodePengadaanResponse createMetodePengadaan(@RequestBody MetodePengadaanRequest metodePengadaanRequest) { | ||||
|             return postCreateMetodePengadaanService.execute(metodePengadaanRequest); | ||||
|         } | ||||
|  | ||||
|         @GetMapping("/{id}") | ||||
|         public MetodePengadaanResponse getMetodePengadaanById(@PathVariable Long id) { | ||||
|             return getMetodePengadaanByIdService.execute(MetodePengadaanRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public MetodePengadaanResponse updateMetodepengadaan(@PathVariable Long id, | ||||
|                                                          @RequestBody MetodePengadaanRequest metodePengadaanRequest){ | ||||
|             metodePengadaanRequest.setId(id); | ||||
|             return putUpdateMetodePengadaanService.execute(metodePengadaanRequest); | ||||
|         } | ||||
|  | ||||
|         @DeleteMapping("/{id}") | ||||
|         public EmptyResponse deleteMetodePengadaan(@PathVariable Long id) { | ||||
|             return deleteMetodePengadaanService.execute(MetodePengadaanRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,68 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import com.iconplus.smartproc.model.entity.MetodePenyampaian; | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.repository.MetodePenyampaianRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.MetodePenyampaianRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListMetodePenyampaianResponse; | ||||
| import com.iconplus.smartproc.model.response.MetodePenyampaianResponse; | ||||
| import com.iconplus.smartproc.repository.MetodePenyampaianRepository; | ||||
| import com.iconplus.smartproc.service.metodepenyampaian.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/metodepenyampaian") | ||||
| public class MetodePenyampaianController { | ||||
| 	@Autowired | ||||
| 	private MetodePenyampaianRepository metodepenyampaianRepository; | ||||
|  | ||||
| 	//get all data | ||||
| 	@GetMapping | ||||
| 	public List<MetodePenyampaian> getAllMetodepenyampaians(){ | ||||
| 		return metodepenyampaianRepository.findAll(); | ||||
| 	} | ||||
|         @Autowired | ||||
|         private MetodePenyampaianRepository metodepenyampaianRepository; | ||||
|  | ||||
| 	// create | ||||
| 	@PostMapping | ||||
| 	public MetodePenyampaian createMetodepenyampaian(@RequestBody MetodePenyampaian metodepenyampaian) { | ||||
| 		return metodepenyampaianRepository.save(metodepenyampaian); | ||||
| 	} | ||||
|         private final GetListMetodePenyampaianService getListMetodePenyampaianService; | ||||
|         private final GetMetodePenyampaianByIdService getMetodePenyampaianByIdService; | ||||
|         private final PostCreateMetodePenyampaianService postCreateMetodePenyampaianService; | ||||
|         private final PutUpdateMetodePenyampaianService putUpdateMetodePenyampaianService; | ||||
|         private final DeleteMetodePenyampaianService deleteMetodePenyampaianService; | ||||
|  | ||||
| 	// get metodepenyampaian by id rest api | ||||
| 	@GetMapping("/{id}") | ||||
| 	public ResponseEntity<MetodePenyampaian> getMetodepenyampaianById(@PathVariable Long id) { | ||||
| 		MetodePenyampaian metodepenyampaian = metodepenyampaianRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Metodepenyampaian not exist with id :" + id)); | ||||
| 		return ResponseEntity.ok(metodepenyampaian); | ||||
| 	} | ||||
|         public MetodePenyampaianController(GetListMetodePenyampaianService getListMetodePenyampaianService, | ||||
|                                        GetMetodePenyampaianByIdService getMetodePenyampaianByIdService, | ||||
|                                        PostCreateMetodePenyampaianService postCreateMetodePenyampaianService, | ||||
|                                        PutUpdateMetodePenyampaianService putUpdateMetodePenyampaianService, | ||||
|                                        DeleteMetodePenyampaianService deleteMetodePenyampaianService) { | ||||
|             this.getListMetodePenyampaianService = getListMetodePenyampaianService; | ||||
|             this.getMetodePenyampaianByIdService = getMetodePenyampaianByIdService; | ||||
|             this.postCreateMetodePenyampaianService = postCreateMetodePenyampaianService; | ||||
|             this.putUpdateMetodePenyampaianService = putUpdateMetodePenyampaianService; | ||||
|             this.deleteMetodePenyampaianService = deleteMetodePenyampaianService; | ||||
|         } | ||||
|  | ||||
| 	// update metodepenyampaian rest api | ||||
| 	@PutMapping("/{id}") | ||||
| 	public ResponseEntity<MetodePenyampaian> updateMetodepenyampaian(@PathVariable Long id, @RequestBody MetodePenyampaian metodePenyampaianDetails){ | ||||
| 		MetodePenyampaian metodepenyampaian = metodepenyampaianRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Metodepenyampaian not exist with id :" + id)); | ||||
|  | ||||
| 		metodepenyampaian.setMetodePenyampaian(metodePenyampaianDetails.getMetodePenyampaian()); | ||||
| 		metodepenyampaian.setKeterangan(metodePenyampaianDetails.getKeterangan()); | ||||
|         @GetMapping | ||||
|         public GetListMetodePenyampaianResponse getListMetodePenyampaian(@RequestParam(name = "search", required = false) String search, | ||||
|                                                                  @RequestParam(name = "page", defaultValue = "1") Integer page, | ||||
|                                                                  @RequestParam(name = "size", defaultValue = "5") Integer size){ | ||||
|  | ||||
| 		MetodePenyampaian updatedMetodePenyampaian = metodepenyampaianRepository.save(metodepenyampaian); | ||||
| 		return ResponseEntity.ok(updatedMetodePenyampaian); | ||||
| 	} | ||||
|             Pageable pageable = PageRequest.of((page - 1), size); | ||||
|             MetodePenyampaianRequest metodePenyampaianRequest = MetodePenyampaianRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
| 	// delete metodepenyampaian rest api | ||||
| 	@DeleteMapping("/{id}") | ||||
| 	public ResponseEntity<Map<String, Boolean>> deleteMetodepenyampaian(@PathVariable Long id){ | ||||
| 		MetodePenyampaian metodepenyampaian = metodepenyampaianRepository.findById(id) | ||||
| 				.orElseThrow(() -> new ResourceNotFoundException("Metodepenyampaian not exist with id :" + id)); | ||||
|             return getListMetodePenyampaianService.execute(metodePenyampaianRequest); | ||||
|         } | ||||
|  | ||||
| 		metodepenyampaianRepository.delete(metodepenyampaian); | ||||
| 		Map<String, Boolean> response = new HashMap<>(); | ||||
| 		response.put("deleted", Boolean.TRUE); | ||||
| 		return ResponseEntity.ok(response); | ||||
| 	} | ||||
|         @PostMapping | ||||
|         public MetodePenyampaianResponse createMetodePenyampaian(@RequestBody MetodePenyampaianRequest metodePenyampaianRequest) { | ||||
|             return postCreateMetodePenyampaianService.execute(metodePenyampaianRequest); | ||||
|         } | ||||
|  | ||||
|         @GetMapping("/{id}") | ||||
|         public MetodePenyampaianResponse getMetodePenyampaianById(@PathVariable Long id) { | ||||
|             return getMetodePenyampaianByIdService.execute(MetodePenyampaianRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public MetodePenyampaianResponse updateMetodepenyampaian(@PathVariable Long id, | ||||
|                                                          @RequestBody MetodePenyampaianRequest metodePenyampaianRequest){ | ||||
|             metodePenyampaianRequest.setId(id); | ||||
|             return putUpdateMetodePenyampaianService.execute(metodePenyampaianRequest); | ||||
|         } | ||||
|  | ||||
|         @DeleteMapping("/{id}") | ||||
|         public EmptyResponse deleteMetodePenyampaian(@PathVariable Long id) { | ||||
|             return deleteMetodePenyampaianService.execute(MetodePenyampaianRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
|  | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.RolesRequest; | ||||
| import com.iconplus.smartproc.model.response.GetRolesResponse; | ||||
| import com.iconplus.smartproc.model.response.GetListRolesResponse; | ||||
| import com.iconplus.smartproc.model.response.RolesResponse; | ||||
| import com.iconplus.smartproc.repository.RolesRepository; | ||||
| import com.iconplus.smartproc.service.roles.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| @@ -14,28 +17,32 @@ import org.springframework.web.bind.annotation.*; | ||||
| @RequestMapping("/api/roles") | ||||
| public class RolesController { | ||||
|  | ||||
|         private final GetRolesService getRolesService; | ||||
|         private final PostCreateRoleService postCreateRoleService; | ||||
|         private final GetRoleByIdService getRoleByIdService; | ||||
|         private final PutUpdateRoleService putUpdateRoleService; | ||||
|         private final DeleteRoleService deleteRoleService; | ||||
|         @Autowired | ||||
|         private RolesRepository rolesRepository; | ||||
|  | ||||
|         public RolesController(GetRolesService getRolesService, | ||||
|                                PostCreateRoleService postCreateRoleService, | ||||
|                                GetRoleByIdService getRoleByIdService, | ||||
|                                PutUpdateRoleService putUpdateRoleService, | ||||
|                                DeleteRoleService deleteRoleService) { | ||||
|             this.getRolesService = getRolesService; | ||||
|             this.postCreateRoleService = postCreateRoleService; | ||||
|             this.getRoleByIdService = getRoleByIdService; | ||||
|             this.putUpdateRoleService = putUpdateRoleService; | ||||
|             this.deleteRoleService = deleteRoleService; | ||||
|         private final GetListRolesService getListRolesService; | ||||
|         private final GetRolesByIdService getRolesByIdService; | ||||
|         private final PostCreateRolesService postCreateRolesService; | ||||
|         private final PutUpdateRolesService putUpdateRolesService; | ||||
|         private final DeleteRolesService deleteRolesService; | ||||
|  | ||||
|         public RolesController(GetListRolesService getListRolesService, | ||||
|                                GetRolesByIdService getRolesByIdService, | ||||
|                                PostCreateRolesService postCreateRolesService, | ||||
|                                PutUpdateRolesService putUpdateRolesService, | ||||
|                                DeleteRolesService deleteRolesService) { | ||||
|             this.getListRolesService = getListRolesService; | ||||
|             this.getRolesByIdService = getRolesByIdService; | ||||
|             this.postCreateRolesService = postCreateRolesService; | ||||
|             this.putUpdateRolesService = putUpdateRolesService; | ||||
|             this.deleteRolesService = deleteRolesService; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @GetMapping | ||||
|         public GetRolesResponse getRoles(@RequestParam(name = "search", required = false) String search, | ||||
|                                          @RequestParam(name = "page", defaultValue = "1") Integer page, | ||||
|                                          @RequestParam(name = "size", defaultValue = "5") Integer size){ | ||||
|         public GetListRolesResponse getListRoles(@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); | ||||
|             RolesRequest rolesRequest = RolesRequest.builder() | ||||
| @@ -43,30 +50,32 @@ public class RolesController { | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
|             return getRolesService.execute(rolesRequest); | ||||
|             return getListRolesService.execute(rolesRequest); | ||||
|         } | ||||
|  | ||||
|         @PostMapping | ||||
|         public RolesResponse createRoles(@RequestBody RolesRequest rolesRequest) { | ||||
|             return postCreateRoleService.execute(rolesRequest); | ||||
|             return postCreateRolesService.execute(rolesRequest); | ||||
|         } | ||||
|  | ||||
|         @GetMapping("/{id}") | ||||
|         public RolesResponse getRolesById(@PathVariable Long id) { | ||||
|             return getRoleByIdService.execute(RolesRequest.builder() | ||||
|             return getRolesByIdService.execute(RolesRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public RolesResponse updateRoles(@PathVariable Long id, @RequestBody RolesRequest rolesRequest){ | ||||
|         public RolesResponse updateRoles(@PathVariable Long id, | ||||
|                                                          @RequestBody RolesRequest rolesRequest){ | ||||
|             rolesRequest.setId(id); | ||||
|             return putUpdateRoleService.execute(rolesRequest); | ||||
|             return putUpdateRolesService.execute(rolesRequest); | ||||
|         } | ||||
|  | ||||
|         @DeleteMapping("/{id}") | ||||
|         public EmptyResponse deleteRoles(@PathVariable Long id){ | ||||
|             return deleteRoleService.execute(RolesRequest.builder() | ||||
|         public EmptyResponse deleteRoles(@PathVariable Long id) { | ||||
|             return deleteRolesService.execute(RolesRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|   | ||||
| @@ -1,78 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.PathVariable; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.PutMapping; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.model.entity.SumberDana; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.SumberDanaRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListSumberDanaResponse; | ||||
| import com.iconplus.smartproc.model.response.SumberDanaResponse; | ||||
| import com.iconplus.smartproc.repository.SumberDanaRepository; | ||||
| import com.iconplus.smartproc.service.sumberdana.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/sumberdana") | ||||
| public class SumberDanaController { | ||||
|  | ||||
|         @Autowired | ||||
|         private SumberDanaRepository sumberdanaRepository; | ||||
|  | ||||
|         //get all data | ||||
|         private final GetListSumberDanaService getListSumberDanaService; | ||||
|         private final GetSumberDanaByIdService getSumberDanaByIdService; | ||||
|         private final PostCreateSumberDanaService postCreateSumberDanaService; | ||||
|         private final PutUpdateSumberDanaService putUpdateSumberDanaService; | ||||
|         private final DeleteSumberDanaService deleteSumberDanaService; | ||||
|  | ||||
|         public SumberDanaController(GetListSumberDanaService getListSumberDanaService, | ||||
|                                        GetSumberDanaByIdService getSumberDanaByIdService, | ||||
|                                        PostCreateSumberDanaService postCreateSumberDanaService, | ||||
|                                        PutUpdateSumberDanaService putUpdateSumberDanaService, | ||||
|                                        DeleteSumberDanaService deleteSumberDanaService) { | ||||
|             this.getListSumberDanaService = getListSumberDanaService; | ||||
|             this.getSumberDanaByIdService = getSumberDanaByIdService; | ||||
|             this.postCreateSumberDanaService = postCreateSumberDanaService; | ||||
|             this.putUpdateSumberDanaService = putUpdateSumberDanaService; | ||||
|             this.deleteSumberDanaService = deleteSumberDanaService; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @GetMapping | ||||
|         public List<SumberDana> getAllSumberdanas(){ | ||||
|             return sumberdanaRepository.findAll(); | ||||
|         public GetListSumberDanaResponse getListSumberDana(@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); | ||||
|             SumberDanaRequest sumberDanaRequest = SumberDanaRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
|             return getListSumberDanaService.execute(sumberDanaRequest); | ||||
|         } | ||||
|  | ||||
|         // create | ||||
|         @PostMapping | ||||
|         public SumberDana createSumberdana(@RequestBody SumberDana sumberdana) { | ||||
|             return sumberdanaRepository.save(sumberdana); | ||||
|         public SumberDanaResponse createSumberDana(@RequestBody SumberDanaRequest sumberDanaRequest) { | ||||
|             return postCreateSumberDanaService.execute(sumberDanaRequest); | ||||
|         } | ||||
|  | ||||
|         // get sumberdana by id rest api | ||||
|         @GetMapping("/{id}") | ||||
|         public ResponseEntity<SumberDana> getSumberdanaById(@PathVariable Long id) { | ||||
|             SumberDana sumberdana = sumberdanaRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Sumberdana not exist with id :" + id)); | ||||
|             return ResponseEntity.ok(sumberdana); | ||||
|         public SumberDanaResponse getSumberDanaById(@PathVariable Long id) { | ||||
|             return getSumberDanaByIdService.execute(SumberDanaRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|         // update sumberdana rest api | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public ResponseEntity<SumberDana> updateSumberdana(@PathVariable Long id, @RequestBody SumberDana sumberDanaDetails){ | ||||
|             SumberDana sumberdana = sumberdanaRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Sumberdana not exist with id :" + id)); | ||||
|  | ||||
|             sumberdana.setSumberDana(sumberDanaDetails.getSumberDana()); | ||||
|             sumberdana.setKeterangan(sumberDanaDetails.getKeterangan()); | ||||
|  | ||||
|             SumberDana updatedSumberDana =  sumberdanaRepository.save(sumberdana); | ||||
|             return ResponseEntity.ok(updatedSumberDana); | ||||
|         public SumberDanaResponse updateSumberdana(@PathVariable Long id, | ||||
|                                                          @RequestBody SumberDanaRequest sumberDanaRequest){ | ||||
|             sumberDanaRequest.setId(id); | ||||
|             return putUpdateSumberDanaService.execute(sumberDanaRequest); | ||||
|         } | ||||
|  | ||||
|         // delete sumberdana rest api | ||||
|         @DeleteMapping("/{id}") | ||||
|         public ResponseEntity<Map<String, Boolean>> deleteSumberdana(@PathVariable Long id){ | ||||
|             SumberDana sumberdana = sumberdanaRepository.findById(id) | ||||
|                     .orElseThrow(() -> new ResourceNotFoundException("Sumberdana not exist with id :" + id)); | ||||
|  | ||||
|             sumberdanaRepository.delete(sumberdana); | ||||
|             Map<String, Boolean> response = new HashMap<>(); | ||||
|             response.put("deleted", Boolean.TRUE); | ||||
|             return ResponseEntity.ok(response); | ||||
|         public EmptyResponse deleteSumberDana(@PathVariable Long id) { | ||||
|             return deleteSumberDanaService.execute(SumberDanaRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,74 +1,82 @@ | ||||
| package com.iconplus.smartproc.controller; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.CrossOrigin; | ||||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.PathVariable; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.PutMapping; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import com.iconplus.smartproc.exception.ResourceNotFoundException; | ||||
| import com.iconplus.smartproc.model.entity.SupplyPositioningMatrix; | ||||
| import com.iconplus.smartproc.helper.model.EmptyResponse; | ||||
| import com.iconplus.smartproc.model.request.SupplyPositioningMatrixRequest; | ||||
| import com.iconplus.smartproc.model.response.GetListSupplyPositioningMatrixResponse; | ||||
| import com.iconplus.smartproc.model.response.SupplyPositioningMatrixResponse; | ||||
| import com.iconplus.smartproc.repository.SupplyPositioningMatrixRepository; | ||||
| import com.iconplus.smartproc.service.supplypositioningmatrix.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") | ||||
| @RestController | ||||
| @RequestMapping("/api/supplypositioningmatrix") | ||||
| public class SupplyPositioningMatrixController { | ||||
|     @Autowired | ||||
|     private SupplyPositioningMatrixRepository supplypositioningmatrixRepository; | ||||
|  | ||||
|     //get all data | ||||
|     @GetMapping | ||||
|     public List<SupplyPositioningMatrix> getAllSupplypositioningmatrix(){ | ||||
|         return supplypositioningmatrixRepository.findAll(); | ||||
|     } | ||||
|         @Autowired | ||||
|         private SupplyPositioningMatrixRepository supplypositioningmatrixRepository; | ||||
|  | ||||
|     // create | ||||
|     @PostMapping | ||||
|     public SupplyPositioningMatrix createSupplypositioningmatrix(@RequestBody SupplyPositioningMatrix supplypositioningmatrix) { | ||||
|         return supplypositioningmatrixRepository.save(supplypositioningmatrix); | ||||
|     } | ||||
|         private final GetListSupplyPositioningMatrixService getListSupplyPositioningMatrixService; | ||||
|         private final GetSupplyPositioningMatrixByIdService getSupplyPositioningMatrixByIdService; | ||||
|         private final PostCreateSupplyPositioningMatrixService postCreateSupplyPositioningMatrixService; | ||||
|         private final PutUpdateSupplyPositioningMatrixService putUpdateSupplyPositioningMatrixService; | ||||
|         private final DeleteSupplyPositioningMatrixService deleteSupplyPositioningMatrixService; | ||||
|  | ||||
|     // get supplypositioningmatrix by id rest api | ||||
|     @GetMapping("/{id}") | ||||
|     public ResponseEntity<SupplyPositioningMatrix> getSupplypositioningmatrixById(@PathVariable Long id) { | ||||
|         SupplyPositioningMatrix supplypositioningmatrix = supplypositioningmatrixRepository.findById(id) | ||||
|                 .orElseThrow(() -> new ResourceNotFoundException("Supplypositioningmatrix not exist with id :" + id)); | ||||
|         return ResponseEntity.ok(supplypositioningmatrix); | ||||
|     } | ||||
|         public SupplyPositioningMatrixController(GetListSupplyPositioningMatrixService getListSupplyPositioningMatrixService, | ||||
|                                        GetSupplyPositioningMatrixByIdService getSupplyPositioningMatrixByIdService, | ||||
|                                        PostCreateSupplyPositioningMatrixService postCreateSupplyPositioningMatrixService, | ||||
|                                        PutUpdateSupplyPositioningMatrixService putUpdateSupplyPositioningMatrixService, | ||||
|                                        DeleteSupplyPositioningMatrixService deleteSupplyPositioningMatrixService) { | ||||
|             this.getListSupplyPositioningMatrixService = getListSupplyPositioningMatrixService; | ||||
|             this.getSupplyPositioningMatrixByIdService = getSupplyPositioningMatrixByIdService; | ||||
|             this.postCreateSupplyPositioningMatrixService = postCreateSupplyPositioningMatrixService; | ||||
|             this.putUpdateSupplyPositioningMatrixService = putUpdateSupplyPositioningMatrixService; | ||||
|             this.deleteSupplyPositioningMatrixService = deleteSupplyPositioningMatrixService; | ||||
|         } | ||||
|  | ||||
|     // update jenispengadaan rest api | ||||
|     @PutMapping("/{id}") | ||||
|     public ResponseEntity<SupplyPositioningMatrix> updateSupplypositioningmatrix(@PathVariable Long id, @RequestBody SupplyPositioningMatrix supplyPositioningMatrixDetails){ | ||||
|         SupplyPositioningMatrix supplypositioningmatrix = supplypositioningmatrixRepository.findById(id) | ||||
|                 .orElseThrow(() -> new ResourceNotFoundException("Supplypositioningmatrix not exist with id :" + id)); | ||||
|  | ||||
|         supplypositioningmatrix.setSupplyPositioningMatrix(supplyPositioningMatrixDetails.getSupplyPositioningMatrix()); | ||||
|         supplypositioningmatrix.setKeterangan(supplyPositioningMatrixDetails.getKeterangan()); | ||||
|         @GetMapping | ||||
|         public GetListSupplyPositioningMatrixResponse getListSupplyPositioningMatrix(@RequestParam(name = "search", required = false) String search, | ||||
|                                                                  @RequestParam(name = "page", defaultValue = "1") Integer page, | ||||
|                                                                  @RequestParam(name = "size", defaultValue = "5") Integer size){ | ||||
|  | ||||
|         SupplyPositioningMatrix updatedSupplyPositioningMatrix = supplypositioningmatrixRepository.save(supplypositioningmatrix); | ||||
|         return ResponseEntity.ok(updatedSupplyPositioningMatrix); | ||||
|     } | ||||
|             Pageable pageable = PageRequest.of((page - 1), size); | ||||
|             SupplyPositioningMatrixRequest supplyPositioningMatrixRequest = SupplyPositioningMatrixRequest.builder() | ||||
|                     .search(search) | ||||
|                     .pageable(pageable) | ||||
|                     .build(); | ||||
|  | ||||
|     // delete jenispengadaan rest api | ||||
|     @DeleteMapping("/{id}") | ||||
|     public ResponseEntity<Map<String, Boolean>> deleteSupplypositioningmatrix(@PathVariable Long id){ | ||||
|         SupplyPositioningMatrix supplypositioningmatrix = supplypositioningmatrixRepository.findById(id) | ||||
|                 .orElseThrow(() -> new ResourceNotFoundException("Unit inisiator not exist with id :" + id)); | ||||
|             return getListSupplyPositioningMatrixService.execute(supplyPositioningMatrixRequest); | ||||
|         } | ||||
|  | ||||
|         supplypositioningmatrixRepository.delete(supplypositioningmatrix); | ||||
|         Map<String, Boolean> response = new HashMap<>(); | ||||
|         response.put("deleted", Boolean.TRUE); | ||||
|         return ResponseEntity.ok(response); | ||||
|     } | ||||
|         @PostMapping | ||||
|         public SupplyPositioningMatrixResponse createSupplyPositioningMatrix(@RequestBody SupplyPositioningMatrixRequest supplyPositioningMatrixRequest) { | ||||
|             return postCreateSupplyPositioningMatrixService.execute(supplyPositioningMatrixRequest); | ||||
|         } | ||||
|  | ||||
|         @GetMapping("/{id}") | ||||
|         public SupplyPositioningMatrixResponse getSupplyPositioningMatrixById(@PathVariable Long id) { | ||||
|             return getSupplyPositioningMatrixByIdService.execute(SupplyPositioningMatrixRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         @PutMapping("/{id}") | ||||
|         public SupplyPositioningMatrixResponse updateSupplyPositioningmatrix(@PathVariable Long id, | ||||
|                                                          @RequestBody SupplyPositioningMatrixRequest supplyPositioningMatrixRequest){ | ||||
|             supplyPositioningMatrixRequest.setId(id); | ||||
|             return putUpdateSupplyPositioningMatrixService.execute(supplyPositioningMatrixRequest); | ||||
|         } | ||||
|  | ||||
|         @DeleteMapping("/{id}") | ||||
|         public EmptyResponse deleteSupplyPositioningMatrix(@PathVariable Long id) { | ||||
|             return deleteSupplyPositioningMatrixService.execute(SupplyPositioningMatrixRequest.builder() | ||||
|                     .id(id) | ||||
|                     .build()); | ||||
|         } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user