Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ASE_Y2S1_CP_G4
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joshua Gill
ASE_Y2S1_CP_G4
Commits
ee11b626
Commit
ee11b626
authored
3 years ago
by
Joshua Gill
Browse files
Options
Downloads
Patches
Plain Diff
UserFavouriteSaver fully logged
parent
d5d16711
No related branches found
No related tags found
2 merge requests
!114
LoggingService service class, new method to add a log to the "Logs" table when...
,
!107
Issue complete
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/example/clientproject/services/UserFavouriteSaver.java
+21
-9
21 additions, 9 deletions
...om/example/clientproject/services/UserFavouriteSaver.java
src/main/resources/database/schema.sql
+2
-1
2 additions, 1 deletion
src/main/resources/database/schema.sql
with
23 additions
and
10 deletions
src/main/java/com/example/clientproject/services/UserFavouriteSaver.java
+
21
−
9
View file @
ee11b626
package
com.example.clientproject.services
;
package
com.example.clientproject.services
;
import
com.example.clientproject.service.LoggingService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpSession
;
//This can be deleted, class "UserFavouriteTagSaver" is being used
//This can be deleted, class "UserFavouriteTagSaver" is being used
@Service
@Service
public
class
UserFavouriteSaver
{
public
class
UserFavouriteSaver
{
@Autowired
JdbcTemplate
jdbc
;
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
* 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
){
public
void
save
(
UserFavouriteDTO
urfDTO
,
HttpSession
session
){
String
query
=
"INSERT INTO mydb.User_Shop_Links (Shop_Id, User_Id) VALUES ("
+
urfDTO
.
getShopId
()
+
String
query
=
"INSERT INTO User_Shop_Links (Shop_Id, User_Id) VALUES ("
+
urfDTO
.
getShopId
()
+
","
+
urfDTO
.
getUserId
()
+
")"
;
","
+
urfDTO
.
getUserId
()
+
")"
;
//System.out.println(query);
jdbc
.
execute
(
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()"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/database/schema.sql
+
2
−
1
View file @
ee11b626
...
@@ -352,4 +352,5 @@ INSERT INTO Events (Event_Name) VALUES ('New User Permission');
...
@@ -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
(
'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'
);
INSERT
INTO
Events
(
Event_Name
)
VALUES
(
'Shop Updated'
);
INSERT
INTO
Events
(
Event_Name
)
VALUES
(
'UserShopLink Deleted'
);
INSERT
INTO
Events
(
Event_Name
)
VALUES
(
'UserShopLink Deleted'
);
\ No newline at end of file
INSERT
INTO
Events
(
Event_Name
)
VALUES
(
'UserShopLink Inserted'
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment