Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sprachschulsystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Jan Pokorný
Sprachschulsystem
Commits
5affdde6
There was an error fetching the commit references. Please try again later.
Commit
5affdde6
authored
2 years ago
by
Dominika Zemanovičová
Committed by
Martin Gargalovič
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add QuestionService
parent
a07699b2
No related branches found
No related tags found
3 merge requests
!31
M2
,
!28
M2 user
,
!27
Draft: M2 user
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/module-exercise/src/main/java/org/fuseri/moduleexercise/question/QuestionService.java
+61
-0
61 additions, 0 deletions
...a/org/fuseri/moduleexercise/question/QuestionService.java
with
61 additions
and
0 deletions
application/module-exercise/src/main/java/org/fuseri/moduleexercise/question/QuestionService.java
0 → 100644
+
61
−
0
View file @
5affdde6
package
org.fuseri.moduleexercise.question
;
import
jakarta.persistence.EntityNotFoundException
;
import
lombok.Getter
;
import
org.fuseri.moduleexercise.common.DomainService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* Represent a service for managing Question entities
*/
@Service
public
class
QuestionService
extends
DomainService
<
Question
>
{
/**
* The repository instance used by this service
*/
@Getter
private
final
QuestionRepository
repository
;
/**
* Construct a new instance of QuestionService with the specified repository
*
* @param repository the repository instance to be used by this service
*/
@Autowired
public
QuestionService
(
QuestionRepository
repository
)
{
this
.
repository
=
repository
;
}
/**
* Retrieve the Question entity with the specified ID
*
* @param id the ID of the Question entity to retrieve
* @return the Question entity with the specified ID
* @throws EntityNotFoundException if no Question entity exists with the specified ID
*/
@Transactional
(
readOnly
=
true
)
public
Question
find
(
String
id
)
{
return
repository
.
findById
(
id
)
.
orElseThrow
(()
->
new
EntityNotFoundException
(
"Question '"
+
id
+
"' not found."
));
}
/**
* Retrieve a page of Question entities associated with the specified exercise ID
*
* @param exerciseId the ID of the exercise to retrieve questions for
* @param page the page number to retrieve (0-indexed)
* @return a page of Question entities associated with the specified exercise ID
*/
@Transactional
(
readOnly
=
true
)
public
Page
<
Question
>
findByExerciseId
(
String
exerciseId
,
int
page
)
{
return
repository
.
findByExerciseId
(
exerciseId
,
PageRequest
.
of
(
page
,
DomainService
.
DEFAULT_PAGE_SIZE
));
}
}
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