diff --git a/src/main/java/com/example/clientproject/services/UpdateKeyInfo.java b/src/main/java/com/example/clientproject/services/UpdateKeyInfo.java index 6903dc97958553b7f9f7b6ce72c2cb29b09b4263..fe28be7d600da4466bd2ab3f4ab38039044d9382 100644 --- a/src/main/java/com/example/clientproject/services/UpdateKeyInfo.java +++ b/src/main/java/com/example/clientproject/services/UpdateKeyInfo.java @@ -2,16 +2,24 @@ package com.example.clientproject.services; import com.example.clientproject.data.shops.Shops; import com.example.clientproject.data.shops.ShopsRepo; +import com.example.clientproject.service.LoggingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpSession; + @Service public class UpdateKeyInfo { - @Autowired ShopsRepo shopsRepo; + LoggingService loggingService; + + public UpdateKeyInfo(ShopsRepo shopsRepo, LoggingService loggingService) { + this.shopsRepo = shopsRepo; + this.loggingService = loggingService; + } - public void updateInfo(KeyInfoDTO kiDTO){ + public void updateInfo(KeyInfoDTO kiDTO, HttpSession session){ Shops shop = shopsRepo.getById((long) kiDTO.getShopId()); shop.setShopName(kiDTO.getShopName()); @@ -25,6 +33,13 @@ public class UpdateKeyInfo { } shopsRepo.save(shop); + // Log the change + loggingService.logEvent( + "Shop Updated", + session, + "Shop updated with Shop Id: " + kiDTO.getShopId() + + " in UpdateKeyInfo.updateInfo()" + ); } } diff --git a/src/main/java/com/example/clientproject/web/restControllers/UpdateKeyInformation.java b/src/main/java/com/example/clientproject/web/restControllers/UpdateKeyInformation.java index e975033706122c37e1028047c7b43474439fed99..b8d4401197ffb70a93758831eb95dcdd70d9a099 100644 --- a/src/main/java/com/example/clientproject/web/restControllers/UpdateKeyInformation.java +++ b/src/main/java/com/example/clientproject/web/restControllers/UpdateKeyInformation.java @@ -28,7 +28,7 @@ public class UpdateKeyInformation { return "BAD SESSION"; } try{ - updateInfo.updateInfo(new KeyInfoDTO(keyInformationForm)); + updateInfo.updateInfo(new KeyInfoDTO(keyInformationForm), session); return "OK"; }catch (Exception e){ e.printStackTrace(); diff --git a/src/main/resources/database/schema.sql b/src/main/resources/database/schema.sql index e04c378018061807041b643dc7d18268ce8e6750..6cdf1a54f1e90d3c0419977540fd0210fdd65adf 100644 --- a/src/main/resources/database/schema.sql +++ b/src/main/resources/database/schema.sql @@ -351,3 +351,4 @@ INSERT INTO Events (Event_Name) VALUES ('New Social'); INSERT INTO Events (Event_Name) VALUES ('New User Permission'); INSERT INTO Events (Event_Name) VALUES ('Stamp Board Updated'); INSERT INTO Events (Event_Name) VALUES ('Reward Deleted'); +INSERT INTO Events (Event_Name) VALUES ('Shop Updated'); \ No newline at end of file