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
Merge requests
!23
An error occurred while fetching the assigned milestone of the selected merge_request.
M2 course tests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
M2 course tests
M2-course-tests
into
M2
Overview
1
Commits
30
Pipelines
14
Changes
1
Merged
Ester Vilímková
requested to merge
M2-course-tests
into
M2
1 year ago
Overview
1
Commits
30
Pipelines
14
Changes
1
Expand
0
0
Merge request reports
Viewing commit
94f69d60
Prev
Next
Show latest version
1 file
+
0
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
94f69d60
Removing unused mapToPageDto from LectureMapper
· 94f69d60
Ester Vilímková
authored
1 year ago
application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureMapper.java
+
55
−
9
Options
@@ -2,24 +2,70 @@ package org.fuseri.modulelanguageschool.lecture;
import
org.fuseri.model.dto.lecture.LectureCreateDto
;
import
org.fuseri.model.dto.lecture.LectureDto
;
import
org.fuseri.modulelanguageschool.course.CourseService
;
import
org.fuseri.modulelanguageschool.user.User
;
import
org.fuseri.modulelanguageschool.user.UserService
;
import
org.mapstruct.Mapper
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Mapper
(
componentModel
=
"spring"
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
UserService
.
class
}
)
public
interface
LectureMapper
{
LectureDto
mapToDto
(
Lecture
lecture
);
Lecture
mapToLecture
(
LectureDto
lectureDto
);
default
LectureDto
mapToDto
(
Lecture
lecture
)
{
if
(
lecture
==
null
)
{
return
null
;
}
List
<
LectureDto
>
mapToList
(
List
<
Lecture
>
lectures
);
var
dto
=
new
LectureDto
(
lecture
.
getLectureFrom
(),
lecture
.
getLectureTo
(),
lecture
.
getTopic
(),
lecture
.
getCapacity
(),
lecture
.
getLecturer
()
==
null
?
null
:
lecture
.
getLecturer
().
getId
(),
lecture
.
getCourse
().
getId
(),
new
ArrayList
<>(
lecture
.
getStudents
().
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
())));
dto
.
setId
(
lecture
.
getId
());
return
dto
;
}
default
Lecture
mapToLecture
(
LectureDto
lectureDto
,
CourseService
courseService
,
UserService
userService
)
{
if
(
lectureDto
==
null
)
{
return
null
;
}
var
lecture
=
new
Lecture
(
lectureDto
.
getLectureFrom
(),
lectureDto
.
getLectureTo
(),
lectureDto
.
getTopic
(),
lectureDto
.
getCapacity
(),
courseService
.
findById
(
lectureDto
.
getCourseId
()),
userService
.
find
(
lectureDto
.
getLecturerId
()),
new
ArrayList
<>());
lecture
.
setId
(
lectureDto
.
getId
());
for
(
Long
userId
:
lectureDto
.
getStudents
())
{
lecture
.
enrolStudent
(
userService
.
find
(
userId
));
}
return
lecture
;
}
default
Page
<
LectureDto
>
mapToPageDto
(
Page
<
Lecture
>
lectures
)
{
return
new
PageImpl
<>(
mapToList
(
lectures
.
getContent
()),
lectures
.
getPageable
(),
lectures
.
getTotalPages
());
default
List
<
LectureDto
>
mapToList
(
List
<
Lecture
>
lectures
)
{
if
(
lectures
==
null
)
{
return
null
;
}
return
new
ArrayList
<>(
lectures
.
stream
().
map
(
this
::
mapToDto
).
toList
());
}
Lecture
mapToLecture
(
LectureCreateDto
dto
);
default
Lecture
mapToLecture
(
LectureCreateDto
lectureDto
,
CourseService
courseService
)
{
if
(
lectureDto
==
null
)
{
return
null
;
}
return
new
Lecture
(
lectureDto
.
getLectureFrom
(),
lectureDto
.
getLectureTo
(),
lectureDto
.
getTopic
(),
lectureDto
.
getCapacity
(),
courseService
.
findById
(
lectureDto
.
getCourseId
()),
null
,
new
ArrayList
<>());
}
}
Loading