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

UserFavouriteSaver fully logged

parent d5d16711
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
package com.example.clientproject.services;
import com.example.clientproject.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
//This can be deleted, class "UserFavouriteTagSaver" is being used
@Service
public class UserFavouriteSaver {
@Autowired
JdbcTemplate jdbc;
LoggingService loggingService;
public UserFavouriteSaver(JdbcTemplate jdbc, LoggingService loggingService) {
this.jdbc = jdbc;
this.loggingService = loggingService;
}
/**
* Takes a user dto and saves it to the DB with jdbc
* @param urfDTO UserfavouriteDTO
* @param urfDTO UserFavouriteDTO
* @param session - session
*/
public void save(UserFavouriteDTO urfDTO){
String query = "INSERT INTO User_Shop_Links (Shop_Id, User_Id) VALUES ("+ urfDTO.getShopId() +
public void save(UserFavouriteDTO urfDTO, HttpSession session){
String query = "INSERT INTO mydb.User_Shop_Links (Shop_Id, User_Id) VALUES ("+ urfDTO.getShopId() +
","+urfDTO.getUserId() + ")";
//System.out.println(query);
jdbc.execute(query);
// Log the change
loggingService.logEvent(
"UserShopLink Inserted",
session,
"UserShopLink inserted with Shop Id: " + urfDTO.getShopId() +
" and User Id: " + urfDTO.getUserId() +
" in UserFavouriteSaver.save()"
);
}
}
......@@ -352,4 +352,5 @@ 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');
INSERT INTO Events (Event_Name) VALUES ('UserShopLink Deleted');
\ No newline at end of file
INSERT INTO Events (Event_Name) VALUES ('UserShopLink Deleted');
INSERT INTO Events (Event_Name) VALUES ('UserShopLink Inserted');
\ 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