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
833a713c
There was an error fetching the commit references. Please try again later.
Commit
833a713c
authored
1 year ago
by
Dominika Zemanovičová
Browse files
Options
Downloads
Patches
Plain Diff
Simplify AnswerFacade update
parent
87100035
No related branches found
No related tags found
3 merge requests
!31
M2
,
!30
M2 exercise
,
!29
M2 exercise
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/module-exercise/src/main/java/org/fuseri/moduleexercise/answer/AnswerFacade.java
+5
-22
5 additions, 22 deletions
...n/java/org/fuseri/moduleexercise/answer/AnswerFacade.java
with
5 additions
and
22 deletions
application/module-exercise/src/main/java/org/fuseri/moduleexercise/answer/AnswerFacade.java
+
5
−
22
View file @
833a713c
...
@@ -3,8 +3,6 @@ package org.fuseri.moduleexercise.answer;
...
@@ -3,8 +3,6 @@ package org.fuseri.moduleexercise.answer;
import
jakarta.transaction.Transactional
;
import
jakarta.transaction.Transactional
;
import
org.fuseri.model.dto.exercise.AnswerCreateDto
;
import
org.fuseri.model.dto.exercise.AnswerCreateDto
;
import
org.fuseri.model.dto.exercise.AnswerDto
;
import
org.fuseri.model.dto.exercise.AnswerDto
;
import
org.fuseri.moduleexercise.question.Question
;
import
org.fuseri.moduleexercise.question.QuestionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -16,44 +14,29 @@ import org.springframework.stereotype.Service;
...
@@ -16,44 +14,29 @@ import org.springframework.stereotype.Service;
@Transactional
@Transactional
public
class
AnswerFacade
{
public
class
AnswerFacade
{
private
final
AnswerService
answerService
;
private
final
AnswerService
answerService
;
private
final
QuestionService
questionService
;
private
final
AnswerMapper
mapper
;
private
final
AnswerMapper
mapper
;
/**
/**
* Constructor for AnswerFacade
* Constructor for AnswerFacade
*
*
* @param answerService the service responsible for handling answer-related logic
* @param answerService the service responsible for handling answer-related logic
* @param questionService the service responsible for handling question-related logic
* @param mapper the mapper responsible for converting between DTOs and entities
* @param mapper the mapper responsible for converting between DTOs and entities
*/
*/
@Autowired
@Autowired
public
AnswerFacade
(
AnswerService
answerService
,
QuestionService
questionService
,
AnswerMapper
mapper
)
{
public
AnswerFacade
(
AnswerService
answerService
,
AnswerMapper
mapper
)
{
this
.
answerService
=
answerService
;
this
.
answerService
=
answerService
;
this
.
questionService
=
questionService
;
this
.
mapper
=
mapper
;
this
.
mapper
=
mapper
;
}
}
/**
/**
* Update
an
answer
* Update answer
*
*
* @param id of answer to update
* @param id of answer to update
* @param dto dto with updated answer information
* @param dto dto with updated answer information
*/
*/
public
AnswerDto
update
(
long
id
,
AnswerCreateDto
dto
)
{
public
AnswerDto
update
(
long
id
,
AnswerCreateDto
dto
)
{
var
updatedAnswer
=
mapper
.
fromCreateDto
(
dto
);
return
mapper
.
toDto
(
answerService
.
update
(
id
,
mapper
.
fromCreateDto
(
dto
)));
answerService
.
update
(
id
,
updatedAnswer
);
Question
question
;
question
=
questionService
.
find
(
dto
.
getQuestionId
());
var
questionAnswers
=
question
.
getAnswers
();
questionAnswers
.
removeIf
(
a
->
a
.
getId
()
==
id
);
questionAnswers
.
add
(
updatedAnswer
);
question
.
setAnswers
(
questionAnswers
);
questionService
.
update
(
dto
.
getQuestionId
(),
question
);
return
mapper
.
toDto
(
updatedAnswer
);
}
}
/**
/**
...
...
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