Skip to content
Snippets Groups Projects
Commit 49853a10 authored by Joshua Gill's avatar Joshua Gill
Browse files

UpdateKeyInfo fully logged

parent 6778cebd
No related branches found
No related tags found
2 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!107Issue complete
...@@ -2,16 +2,24 @@ package com.example.clientproject.services; ...@@ -2,16 +2,24 @@ package com.example.clientproject.services;
import com.example.clientproject.data.shops.Shops; import com.example.clientproject.data.shops.Shops;
import com.example.clientproject.data.shops.ShopsRepo; import com.example.clientproject.data.shops.ShopsRepo;
import com.example.clientproject.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
@Service @Service
public class UpdateKeyInfo { public class UpdateKeyInfo {
@Autowired
ShopsRepo shopsRepo; 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()); Shops shop = shopsRepo.getById((long) kiDTO.getShopId());
shop.setShopName(kiDTO.getShopName()); shop.setShopName(kiDTO.getShopName());
...@@ -25,6 +33,13 @@ public class UpdateKeyInfo { ...@@ -25,6 +33,13 @@ public class UpdateKeyInfo {
} }
shopsRepo.save(shop); shopsRepo.save(shop);
// Log the change
loggingService.logEvent(
"Shop Updated",
session,
"Shop updated with Shop Id: " + kiDTO.getShopId() +
" in UpdateKeyInfo.updateInfo()"
);
} }
} }
...@@ -28,7 +28,7 @@ public class UpdateKeyInformation { ...@@ -28,7 +28,7 @@ public class UpdateKeyInformation {
return "BAD SESSION"; return "BAD SESSION";
} }
try{ try{
updateInfo.updateInfo(new KeyInfoDTO(keyInformationForm)); updateInfo.updateInfo(new KeyInfoDTO(keyInformationForm), session);
return "OK"; return "OK";
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
......
...@@ -351,3 +351,4 @@ INSERT INTO Events (Event_Name) VALUES ('New Social'); ...@@ -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 ('New User Permission');
INSERT INTO Events (Event_Name) VALUES ('Stamp Board Updated'); INSERT INTO Events (Event_Name) VALUES ('Stamp Board Updated');
INSERT INTO Events (Event_Name) VALUES ('Reward Deleted'); INSERT INTO Events (Event_Name) VALUES ('Reward Deleted');
INSERT INTO Events (Event_Name) VALUES ('Shop Updated');
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment