Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
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
idatt2106-v23-03
backend
Commits
4a2cd9f1
Commit
4a2cd9f1
authored
1 year ago
by
Anders Austlid
Browse files
Options
Downloads
Patches
Plain Diff
Added initial achievement service
parent
2c03b208
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/AchievementService.java
+44
-0
44 additions, 0 deletions
...tt2016/v233/SmartMat/service/user/AchievementService.java
with
44 additions
and
0 deletions
src/main/java/ntnu/idatt2016/v233/SmartMat/service/user/AchievementService.java
0 → 100644
+
44
−
0
View file @
4a2cd9f1
package
ntnu.idatt2016.v233.SmartMat.service.user
;
import
lombok.AllArgsConstructor
;
import
ntnu.idatt2016.v233.SmartMat.entity.user.Achievement
;
import
ntnu.idatt2016.v233.SmartMat.repository.user.AchievementRepository
;
import
org.springframework.stereotype.Service
;
import
java.util.Optional
;
/**
* Service for achievements
*
* @author Anders
* @version 1.0
* @since 19.04.2023
*/
@Service
@AllArgsConstructor
public
class
AchievementService
{
private
AchievementRepository
achievementRepository
;
/**
* Adds an achievement to the database
* @param achievementName name of achievement to add
* @param achievementDescription description of achievement to add
*/
public
void
addAchievement
(
String
achievementName
,
String
achievementDescription
){
achievementRepository
.
save
(
Achievement
.
builder
()
.
achievementName
(
achievementName
)
.
achievementDescription
(
achievementDescription
)
.
build
());
}
/**
* Gets an achievement from the database
* @param achievementName name of achievement to get
* @return an optional containing the achievement if it exists
*/
public
Optional
<
Achievement
>
getAchievement
(
String
achievementName
){
return
achievementRepository
.
findByAchievementName
(
achievementName
);
}
}
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