diff --git a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ApotekerRestController.java b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ApotekerRestController.java index 4f5b61648c232375554a1c84c37e5c39b305251e..cb32f23d90d5290f8afbeb749884cbb5e3ae5dd3 100644 --- a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ApotekerRestController.java +++ b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ApotekerRestController.java @@ -5,6 +5,7 @@ import apap.tk.rumahSehat.service.ApotekerServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -22,13 +23,13 @@ public class ApotekerRestController { private ApotekerServiceImpl apotekerService; @PostMapping(value = "/add") - private ApotekerModel createApoteker(@Valid @RequestBody ApotekerModel apoteker, BindingResult bindingResult) { + private ApotekerModel createApoteker(@Valid @RequestBody ApotekerModel apoteker, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Apoteker."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Apoteker."); + log.info(authentication.getName() + " added new Apoteker."); return apotekerService.addApoteker(apoteker); } } diff --git a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/AppointmentRestController.java b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/AppointmentRestController.java index b44fe7e521bfa12991518f814ce842ef5f3ebf5b..f93cacc8d3fe88e541efd70d8e790846220d3515 100644 --- a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/AppointmentRestController.java +++ b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/AppointmentRestController.java @@ -6,6 +6,7 @@ import apap.tk.rumahSehat.service.AppointmentServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -20,7 +21,7 @@ public class AppointmentRestController { private AppointmentServiceImpl appointmentService; @PostMapping(value = "/add") - private AppointmentModel createAppointment(@Valid @RequestBody AppointmentModel appointment, BindingResult bindingResult) { + private AppointmentModel createAppointment(@Valid @RequestBody AppointmentModel appointment, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Appointment."); throw new ResponseStatusException( @@ -33,14 +34,14 @@ public class AppointmentRestController { HttpStatus.BAD_REQUEST, "Create Failed"); } else { - log.info("User added new Appointment."); + log.info(authentication.getName() + " added new Appointment."); return appointmentBaru; } } } @GetMapping(value = "/viewAll") - private List<AppointmentModel> retrieveListAppointment() { - log.info("User accessed all Appointment."); + private List<AppointmentModel> retrieveListAppointment(Authentication authentication) { + log.info(authentication.getName() + " accessed all Appointment."); return appointmentService.findAllAppointment(); } } diff --git a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/DokterRestController.java b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/DokterRestController.java index 4dffdabfc00caf4db26c8b4415977146a7ae341f..2b05935974ac6f48fceef811fbd061f83b14b421 100644 --- a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/DokterRestController.java +++ b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/DokterRestController.java @@ -5,6 +5,7 @@ import apap.tk.rumahSehat.service.DokterServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -20,26 +21,26 @@ public class DokterRestController { private DokterServiceImpl dokterService; @PostMapping(value = "/add") - private DokterModel createDokter(@Valid @RequestBody DokterModel dokter, BindingResult bindingResult) { + private DokterModel createDokter(@Valid @RequestBody DokterModel dokter, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Dokter."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Dokter."); + log.info(authentication.getName() + " added new Dokter."); return dokterService.addDokter(dokter); } } @GetMapping(value = "/viewAll") - private List<DokterModel> retrieveListDokter() { - log.info("User accessed all Dokter."); + private List<DokterModel> retrieveListDokter(Authentication authentication) { + log.info(authentication.getName() + " accessed all Dokter."); return dokterService.findAllDokter(); } @GetMapping(value = "/{uuid}") - private HashMap<String, String> retrieveNamaDokter(@PathVariable("uuid") String uuid) { - log.info("User accessed name Dokter " + uuid +"."); + private HashMap<String, String> retrieveNamaDokter(@PathVariable("uuid") String uuid, Authentication authentication) { + log.info(authentication.getName() + " accessed name Dokter " + uuid +"."); return dokterService.getDokterName(uuid); } @@ -64,20 +65,20 @@ public class DokterRestController { @PathVariable("uuid4") String uuid4, @PathVariable("uuid5") String uuid5, @PathVariable("uuid6") String uuid6, - @PathVariable("uuid7") String uuid7) { - log.info("User accessed pendapatan Dokter."); + @PathVariable("uuid7") String uuid7, Authentication authentication) { + log.info(authentication.getName() + " accessed pendapatan Dokter."); return dokterService.getJumlahAppointment(uuid0, uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7); } @GetMapping(value = "/pendapatan-bulan/{bulan}/{tahun}/{uuid}") - private List retrievePendapatanBulanan(@PathVariable("bulan") int bulan, @PathVariable("tahun") int tahun, @PathVariable("uuid") String uuid) { - log.info("User accessed pendapatan bulanan Dokter."); + private List retrievePendapatanBulanan(@PathVariable("bulan") int bulan, @PathVariable("tahun") int tahun, @PathVariable("uuid") String uuid, Authentication authentication) { + log.info(authentication.getName() + " accessed pendapatan bulanan Dokter."); return dokterService.getPendapatanBulan(bulan, tahun, uuid); } @GetMapping(value = "/pendapatan-tahun/{tahun}/{uuid}") - private List retrievePendapatanTahunan(@PathVariable("tahun") int tahun, @PathVariable("uuid") String uuid) { - log.info("User accessed pendapatan tahunan Dokter."); + private List retrievePendapatanTahunan(@PathVariable("tahun") int tahun, @PathVariable("uuid") String uuid, Authentication authentication) { + log.info(authentication.getName() + " accessed pendapatan tahunan Dokter."); return dokterService.getPendapatanTahunan(tahun, uuid); } } diff --git a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/PasienRestController.java b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/PasienRestController.java index 09036f391e35ee2720cbd467919e2365fdf7b42f..1289afd8c5a2fb6cd40885235291e59242a2bf0d 100644 --- a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/PasienRestController.java +++ b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/PasienRestController.java @@ -6,6 +6,7 @@ import apap.tk.rumahSehat.service.PasienServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -21,7 +22,7 @@ public class PasienRestController { private PasienServiceImpl pasienService; @PostMapping(value = "/add") - private PasienModel createPasien(@Valid @RequestBody PasienModel pasien, BindingResult bindingResult) { + private PasienModel createPasien(@Valid @RequestBody PasienModel pasien, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Pasien."); throw new ResponseStatusException( @@ -31,27 +32,27 @@ public class PasienRestController { throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Pasien Role must be PASIEN"); } else{ - log.info("User added new Pasien."); + log.info(authentication.getName() + " added new Pasien."); return pasienService.addPasien(pasien); } } @GetMapping(value = "/viewAll") - private List<PasienModel> retrieveListPasien() { - log.info("User accessed all Pasien."); + private List<PasienModel> retrieveListPasien(Authentication authentication) { + log.info(authentication.getName() + " accessed all Pasien."); return pasienService.findAllPasien(); } @GetMapping(value = "/view/{username}") - private PasienModel retrieveCurrentPasien(@PathVariable("username") String username) { - log.info("User accessed username Pasien " + username +"."); + private PasienModel retrieveCurrentPasien(@PathVariable("username") String username, Authentication authentication) { + log.info(authentication.getName() + " accessed username Pasien " + username +"."); return pasienService.findPasienByUsername(username); } @PutMapping(value = "view/topup/{username}") - private PasienModel topUpSaldo(@PathVariable("username") String username, @RequestBody PasienModel pasien) { + private PasienModel topUpSaldo(@PathVariable("username") String username, @RequestBody PasienModel pasien, Authentication authentication) { try { - log.info("User topup saldo"); + log.info(authentication.getName() + " topup saldo"); return pasienService.topUp(pasien); } catch (NoSuchElementException e) { log.info("Pasien with username: " + username + "not found."); diff --git a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ResepRestController.java b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ResepRestController.java index a406cfe93b4ac664344f70d134f4ace7c316134d..6ca1ee1aa18a3986f09ff377ef424a46ec8fb038 100644 --- a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ResepRestController.java +++ b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/ResepRestController.java @@ -6,6 +6,7 @@ import apap.tk.rumahSehat.service.ResepServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -20,20 +21,20 @@ public class ResepRestController { private ResepServiceImpl resepService; @PostMapping(value = "/add") - private ResepModel createResep(@Valid @RequestBody ResepModel resep, BindingResult bindingResult) { + private ResepModel createResep(@Valid @RequestBody ResepModel resep, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Resep."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Resep."); + log.info(authentication.getName() + " added new Resep."); return resepService.addResep(resep); } } @GetMapping(value = "/get-jumlah/{id}") - private List<JumlahModel> retrieveJumlah(@PathVariable("id") Long id) { - log.info("User accessed all Jumlah for Resep " + id + "."); + private List<JumlahModel> retrieveJumlah(@PathVariable("id") Long id, Authentication authentication) { + log.info(authentication.getName() + " accessed all Jumlah for Resep " + id + "."); ResepModel resep = resepService.findResepById(id); return resep.getListJumlah(); } diff --git a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/TagihanRestController.java b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/TagihanRestController.java index 723e87204418799381b1cda2dc390c27815f9a7c..64722382443cee8e8106a5e99247a1b612867631 100644 --- a/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/TagihanRestController.java +++ b/rumahSehat/src/main/java/apap/tk/rumahSehat/controller/restController/TagihanRestController.java @@ -5,6 +5,7 @@ import apap.tk.rumahSehat.service.TagihanServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -19,30 +20,30 @@ public class TagihanRestController { private TagihanServiceImpl tagihanService; @PostMapping(value = "/add") - private TagihanModel createTagihan(@Valid @RequestBody TagihanModel tagihan, BindingResult bindingResult) { + private TagihanModel createTagihan(@Valid @RequestBody TagihanModel tagihan, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Tagihan."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Tagihan."); + log.info(authentication.getName() + " added new Tagihan."); return tagihanService.addTagihan(tagihan); } } @GetMapping(value = "/viewAll") - private List<TagihanModel> retrieveListTagihan() { - log.info("User accessed all Tagihan."); + private List<TagihanModel> retrieveListTagihan(Authentication authentication) { + log.info(authentication.getName() + " accessed all Tagihan."); return tagihanService.findAllTagihan(); } @GetMapping(value = "/viewAll/{pasien}") - private List<TagihanModel> retrieveListTagihanOfPasien(@PathVariable("pasien") String pasien) { - log.info("User accessed all Tagihan for Pasien " + pasien + "."); + private List<TagihanModel> retrieveListTagihanOfPasien(@PathVariable("pasien") String pasien, Authentication authentication) { + log.info(authentication.getName() + " accessed all Tagihan for Pasien " + pasien + "."); return tagihanService.findTagihanOfPasien(pasien); } @PutMapping(value = "/pay/{pasien}/{tagihan}") - private TagihanModel updateTagihan(@PathVariable("pasien") String pasien, @PathVariable("tagihan") String tagihan) { - log.info("User update Tagihan " + tagihan + "."); + private TagihanModel updateTagihan(@PathVariable("pasien") String pasien, @PathVariable String tagihan, Authentication authentication) { + log.info(authentication.getName() + " update Tagihan " + tagihan + "."); return tagihanService.payTagihan(pasien, tagihan); } } diff --git a/rumahSehat_jwt/.gradle/7.5.1/executionHistory/executionHistory.lock b/rumahSehat_jwt/.gradle/7.5.1/executionHistory/executionHistory.lock index bee49173f9252190df70ea95a5c57fc2d9d9d9c9..b9a0ff4f87e0b1c708fad8468147e750f3bf1ba7 100644 Binary files a/rumahSehat_jwt/.gradle/7.5.1/executionHistory/executionHistory.lock and b/rumahSehat_jwt/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/rumahSehat_jwt/.gradle/7.5.1/fileHashes/fileHashes.lock b/rumahSehat_jwt/.gradle/7.5.1/fileHashes/fileHashes.lock index 292dbf821e31d0f0cf2656fe47feef29a140dcd6..0e29dddf0542c6f926671c64ac604ae323fd87f6 100644 Binary files a/rumahSehat_jwt/.gradle/7.5.1/fileHashes/fileHashes.lock and b/rumahSehat_jwt/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/rumahSehat_jwt/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/rumahSehat_jwt/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 29131b46b78fa0436c61458831fbad57ca183dd9..3810f614810388dd6ae795cae1c7301db202316e 100644 Binary files a/rumahSehat_jwt/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/rumahSehat_jwt/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ApotekerRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ApotekerRestController.java index f3d77cd1adc3eefdaf8bed09e11a0dd91a6ec071..f6d989900ee915c129dbd540e8f0639f3bf8f98f 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ApotekerRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ApotekerRestController.java @@ -5,6 +5,7 @@ import apap.tk.rumahSehat_jwt.service.ApotekerServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -22,13 +23,13 @@ public class ApotekerRestController { private ApotekerServiceImpl apotekerService; @PostMapping(value = "/add") - private ApotekerModel createApoteker(@Valid @RequestBody ApotekerModel apoteker, BindingResult bindingResult) { + private ApotekerModel createApoteker(@Valid @RequestBody ApotekerModel apoteker, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Apoteker."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Apoteker."); + log.info(authentication.getName() + " added new Apoteker."); return apotekerService.addApoteker(apoteker); } } diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AppointmentRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AppointmentRestController.java index 329bceb1d6b4a040d1be0113f11b476980c94867..b6ffd01cfd9254bfd6eeee64d03294db1a80328f 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AppointmentRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AppointmentRestController.java @@ -6,6 +6,7 @@ import apap.tk.rumahSehat_jwt.service.AppointmentServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -24,7 +25,7 @@ public class AppointmentRestController { private PasienServiceImpl pasienService; @PostMapping(value = "/add") - private AppointmentModel createAppointment(@Valid @RequestBody AppointmentModel appointment, BindingResult bindingResult) { + private AppointmentModel createAppointment(@Valid @RequestBody AppointmentModel appointment, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Appointment."); throw new ResponseStatusException( @@ -37,28 +38,28 @@ public class AppointmentRestController { HttpStatus.BAD_REQUEST, "Create Failed"); } else { - log.info("User added new Appointment."); + log.info(authentication.getName() + " added new Appointment."); return appointmentBaru; } } } @GetMapping(value = "/viewAll/{username}") - private List<AppointmentModel> retrieveListAppointment(@PathVariable("username") String username) { - log.info("User accessed all their Appointment."); + private List<AppointmentModel> retrieveListAppointment(@PathVariable("username") String username, Authentication authentication) { + log.info(authentication.getName() + " accessed all their Appointment."); PasienModel pasien = pasienService.findPasienByUsername(username); List<AppointmentModel> allAppointment = appointmentService.findByPasien(pasien); return allAppointment; } @GetMapping(value = "/viewAllNoUsername") - private List<AppointmentModel> retrieveListAppointment() { - log.info("User accessed all Appointment."); + private List<AppointmentModel> retrieveListAppointment(Authentication authentication) { + log.info(authentication.getName() + " accessed all Appointment."); return appointmentService.findAllAppointment(); } @GetMapping(value = "/view/{kode}") - private AppointmentModel retrieveAppointment(@PathVariable("kode") String kode) { - log.info("User accessed Appointment " + kode + "."); + private AppointmentModel retrieveAppointment(@PathVariable("kode") String kode, Authentication authentication) { + log.info(authentication.getName() + " accessed Appointment " + kode + "."); AppointmentModel appointment = appointmentService.findByKode(kode); return appointment; } diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AuthRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AuthRestController.java index 8961c3144269c8eb85795af3ff8900213c216333..07c09845654d6d9b511ed754a4e78c5fd81c6503 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AuthRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/AuthRestController.java @@ -52,7 +52,7 @@ public class AuthRestController { log.info("User unauthorized, not PASIEN."); throw new ResponseStatusException(HttpStatus.UNAUTHORIZED); } - log.info("User login."); + log.info(authentication.getName() + " login."); return ResponseEntity.ok(new LoginResponse(user.getUsername(), user.getEmail(), jwt)); } } diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/DokterRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/DokterRestController.java index 2957505b2b569d6b1d6f5b7f084ee3c1a790a2e4..5d11d9759e83255c108e9a3bc671fcff67164af0 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/DokterRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/DokterRestController.java @@ -5,6 +5,7 @@ import apap.tk.rumahSehat_jwt.service.DokterServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -19,20 +20,20 @@ public class DokterRestController { private DokterServiceImpl dokterService; @PostMapping(value = "/add") - private DokterModel createDokter(@Valid @RequestBody DokterModel dokter, BindingResult bindingResult) { + private DokterModel createDokter(@Valid @RequestBody DokterModel dokter, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Dokter."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Dokter."); + log.info(authentication.getName() + " added new Dokter."); return dokterService.addDokter(dokter); } } @GetMapping(value = "/viewAll") - private List<DokterModel> retrieveListDokter() { - log.info("User accessed all Dokter."); + private List<DokterModel> retrieveListDokter(Authentication authentication) { + log.info(authentication.getName() + " accessed all Dokter."); return dokterService.findAllDokter(); } } diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/PasienRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/PasienRestController.java index 7118e73102d8c0f0f2d12f283ce7c8b1486cecd9..0171a073a424f485596874bd8c5f73f45cc15718 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/PasienRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/PasienRestController.java @@ -6,6 +6,7 @@ import apap.tk.rumahSehat_jwt.service.PasienServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -21,7 +22,7 @@ public class PasienRestController { private PasienServiceImpl pasienService; @PostMapping(value = "/add") - private PasienModel createPasien(@Valid @RequestBody PasienModel pasien, BindingResult bindingResult) { + private PasienModel createPasien(@Valid @RequestBody PasienModel pasien, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Pasien."); throw new ResponseStatusException( @@ -31,27 +32,27 @@ public class PasienRestController { throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Pasien Role must be PASIEN"); } else{ - log.info("User added new Pasien."); + log.info(authentication.getName() + " added new Pasien."); return pasienService.addPasien(pasien); } } @GetMapping(value = "/viewAll") - private List<PasienModel> retrieveListPasien() { - log.info("User accessed all Pasien."); + private List<PasienModel> retrieveListPasien(Authentication authentication) { + log.info(authentication.getName() + " accessed all Pasien."); return pasienService.findAllPasien(); } @GetMapping(value = "/view/{username}") - private PasienModel retrieveCurrentPasien(@PathVariable("username") String username) { - log.info("User accessed username Pasien " + username +"."); + private PasienModel retrieveCurrentPasien(@PathVariable("username") String username, Authentication authentication) { + log.info(authentication.getName() + " accessed username Pasien " + username +"."); return pasienService.findPasienByUsername(username); } @PutMapping(value = "view/topup/{username}") - private PasienModel topUpSaldo(@PathVariable("username") String username, @RequestBody PasienModel pasien) { + private PasienModel topUpSaldo(@PathVariable("username") String username, @RequestBody PasienModel pasien, Authentication authentication) { try { - log.info("User topup saldo"); + log.info(authentication.getName() + " topup saldo"); return pasienService.topUp(pasien); } catch (NoSuchElementException e) { log.info("Pasien with username: " + username + "not found."); diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ResepRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ResepRestController.java index ddb3e31ba7fd45e73384ea6c95b5fe73a07f7e0b..927641cd618fce8ed0b441dfe171ae5bfdb1173d 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ResepRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/ResepRestController.java @@ -8,6 +8,7 @@ import apap.tk.rumahSehat_jwt.service.ResepServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -25,27 +26,27 @@ public class ResepRestController { private AppointmentServiceImpl appointmentService; @PostMapping(value = "/add") - private ResepModel createResep(@Valid @RequestBody ResepModel resep, BindingResult bindingResult) { + private ResepModel createResep(@Valid @RequestBody ResepModel resep, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Resep."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Resep."); + log.info(authentication.getName() + " added new Resep."); return resepService.addResep(resep); } } @GetMapping(value = "/view/{kodeApt}") - private ResepModel retrieveResep(@PathVariable("kodeApt") String kodeApt) { - log.info("User accessed Resep for Appointment " + kodeApt + "."); + private ResepModel retrieveResep(@PathVariable("kodeApt") String kodeApt, Authentication authentication) { + log.info(authentication.getName() + " accessed Resep for Appointment " + kodeApt + "."); AppointmentModel appointment = appointmentService.findByKode(kodeApt); ResepModel resep = resepService.findByAppointment(appointment); return resep; } @GetMapping(value = "/get-jumlah/{id}") - private List<JumlahModel> retrieveJumlah(@PathVariable("id") Long id) { - log.info("User accessed all Jumlah for Resep " + id + "."); + private List<JumlahModel> retrieveJumlah(@PathVariable("id") Long id, Authentication authentication) { + log.info(authentication.getName() + " accessed all Jumlah for Resep " + id + "."); ResepModel resep = resepService.findResepById(id); return resep.getListJumlah(); } diff --git a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/TagihanRestController.java b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/TagihanRestController.java index e3d8bf3a4864c96987382a76c8f4c10c87aa849d..30f4bcd1a51dc406d5bab25abb2b6ed4a77797dd 100644 --- a/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/TagihanRestController.java +++ b/rumahSehat_jwt/src/main/java/apap/tk/rumahSehat_jwt/restController/TagihanRestController.java @@ -5,6 +5,7 @@ import apap.tk.rumahSehat_jwt.service.TagihanServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.security.core.Authentication; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; @@ -19,31 +20,31 @@ public class TagihanRestController { private TagihanServiceImpl tagihanService; @PostMapping(value = "/add") - private TagihanModel createTagihan(@Valid @RequestBody TagihanModel tagihan, BindingResult bindingResult) { + private TagihanModel createTagihan(@Valid @RequestBody TagihanModel tagihan, BindingResult bindingResult, Authentication authentication) { if (bindingResult.hasFieldErrors()) { log.info("Body has invalid type or missing field when creating Tagihan."); throw new ResponseStatusException( HttpStatus.BAD_REQUEST, "Request body has invalid type or missing field."); } else { - log.info("User added new Tagihan."); + log.info(authentication.getName() + " added new Tagihan."); return tagihanService.addTagihan(tagihan); } } @GetMapping(value = "/viewAll") - private List<TagihanModel> retrieveListTagihan() { - log.info("User accessed all Tagihan."); + private List<TagihanModel> retrieveListTagihan(Authentication authentication) { + log.info(authentication.getName() + " accessed all Tagihan."); return tagihanService.findAllTagihan(); } @GetMapping(value = "/viewAll/{pasien}") - private List<TagihanModel> retrieveListTagihanOfPasien(@PathVariable("pasien") String pasien) { - log.info("User accessed all Tagihan for Pasien " + pasien + "."); + private List<TagihanModel> retrieveListTagihanOfPasien(@PathVariable("pasien") String pasien, Authentication authentication) { + log.info(authentication.getName() + " accessed all Tagihan for Pasien " + pasien + "."); return tagihanService.findTagihanOfPasien(pasien); } @PutMapping(value = "/pay/{pasien}/{tagihan}") - private TagihanModel updateTagihan(@PathVariable("pasien") String pasien, @PathVariable String tagihan) { - log.info("User update Tagihan " + tagihan + "."); + private TagihanModel updateTagihan(@PathVariable("pasien") String pasien, @PathVariable String tagihan, Authentication authentication) { + log.info(authentication.getName() + " update Tagihan " + tagihan + "."); return tagihanService.payTagihan(pasien, tagihan); } } diff --git a/rumahSehat_mobile/android/local.properties b/rumahSehat_mobile/android/local.properties index 254f92be77e0a119ecfffe40bca900792b227c9b..264303e9b0b90fcf945505a2cc66626634d432ca 100644 --- a/rumahSehat_mobile/android/local.properties +++ b/rumahSehat_mobile/android/local.properties @@ -1,6 +1,6 @@ -sdk.dir=C:\\Users\\aherm\\AppData\\Local\\Android\\sdk +sdk.dir=/Users/davidjohan/Library/Android/sdk ======= -flutter.sdk=C:\\flutter +flutter.sdk=/Users/davidjohan/Developer/flutter flutter.buildMode=debug flutter.versionName=1.0.0 flutter.versionCode=1 \ No newline at end of file