Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ALFA
Alfa Backend
Commits
42940acb
Commit
42940acb
authored
3 years ago
by
Maurício de Carvalho Lima
Browse files
Options
Download
Email Patches
Plain Diff
add contagem de atividades nas aulas
parent
51276554
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/main/java/ages/alfa/dto/LessonDto.java
+2
-0
src/main/java/ages/alfa/dto/LessonDto.java
src/main/java/ages/alfa/dto/ModuleDto.java
+1
-1
src/main/java/ages/alfa/dto/ModuleDto.java
src/main/java/ages/alfa/model/entity/Lesson.java
+2
-2
src/main/java/ages/alfa/model/entity/Lesson.java
src/main/java/ages/alfa/service/impl/ModuleServiceImpl.java
+27
-24
src/main/java/ages/alfa/service/impl/ModuleServiceImpl.java
with
32 additions
and
27 deletions
+32
-27
src/main/java/ages/alfa/dto/LessonDto.java
View file @
42940acb
...
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import
lombok.*
;
import
javax.persistence.Column
;
import
java.util.List
;
@Getter
@Builder
...
...
@@ -16,5 +17,6 @@ public class LessonDto {
private
String
text
;
private
String
title
;
private
String
description
;
private
List
<
ActivityDto
>
activityList
;
}
This diff is collapsed.
Click to expand it.
src/main/java/ages/alfa/dto/ModuleDto.java
View file @
42940acb
...
...
@@ -16,7 +16,7 @@ public class ModuleDto {
private
Long
classId
;
private
int
nivel
;
private
List
<
LessonDto
>
lessonList
;
private
List
<
ActivityDto
>
activityList
;
//
private List<ActivityDto> activityList;
private
String
title
;
private
String
description
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/ages/alfa/model/entity/Lesson.java
View file @
42940acb
...
...
@@ -37,7 +37,7 @@ public class Lesson implements IActivity, Serializable {
@Column
(
name
=
"title"
,
length
=
256
)
private
String
title
;
@Column
(
name
=
"activitys"
)
private
Integer
activitys
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/ages/alfa/service/impl/ModuleServiceImpl.java
View file @
42940acb
...
...
@@ -29,7 +29,7 @@ public class ModuleServiceImpl implements ModuleService {
private
final
AlternativeRepository
alternativeRepository
;
private
final
ActivityRepository
activityRepository
;
public
List
<
Module
>
findByClassId
(
Long
classId
){
public
List
<
Module
>
findByClassId
(
Long
classId
)
{
return
moduleRepository
.
findAll
(
Example
.
of
(
Module
.
builder
().
classId
(
classId
).
build
()));
}
...
...
@@ -37,6 +37,7 @@ public class ModuleServiceImpl implements ModuleService {
public
Module
save
(
ModuleDto
moduleDto
)
{
Long
lessonId
=
null
;
int
activitys
=
0
;
Module
newModule
=
Module
.
builder
()
.
classId
(
moduleDto
.
getClassId
())
...
...
@@ -55,35 +56,37 @@ public class ModuleServiceImpl implements ModuleService {
.
description
(
lessonDto
.
getDescription
())
.
text
(
lessonDto
.
getText
())
.
build
();
newLesson
.
setActivitys
(
lessonDto
.
getActivityList
().
size
());
newLesson
=
lessonRepository
.
save
(
newLesson
);
lessonId
=
newLesson
.
getId
();
}
for
(
ActivityDto
activityDto
:
moduleDto
.
getActivityList
())
{
Activity
newActivity
=
Activity
.
builder
()
.
lessonId
(
lessonId
)
.
moduleId
(
newModule
.
getId
())
.
title
(
activityDto
.
getTitle
())
.
description
(
activityDto
.
getDescription
())
.
text
(
activityDto
.
getText
())
.
urlImg
(
activityDto
.
getUrlImg
())
.
typeId
(
activityDto
.
getTypeId
())
.
build
();
for
(
ActivityDto
activityDto
:
lessonDto
.
getActivityList
())
{
new
Activity
=
a
ctivity
Repository
.
save
(
newActivity
);
for
(
AlternativeDto
alternativeDto
:
activityDto
.
getAlternativeList
())
{
Alternative
newAlternative
=
Alternative
.
builder
()
.
activityId
(
newA
ctivity
.
get
Id
())
.
correctAnswer
(
alternativeDto
.
isCorrectAnswer
())
.
is
Img
(
a
lternativeDto
.
is
Img
())
.
t
ext
(
alternative
Dto
.
getT
ext
())
Activity
newA
ctivity
=
Activity
.
builder
()
.
lessonId
(
newLesson
.
getId
())
.
moduleId
(
newModule
.
getId
())
.
title
(
activityDto
.
getTitle
()
)
.
description
(
a
ctivity
Dto
.
get
Description
())
.
text
(
activityDto
.
getText
())
.
url
Img
(
a
ctivityDto
.
getUrl
Img
())
.
t
ypeId
(
activity
Dto
.
getT
ypeId
())
.
build
();
alternativeRepository
.
save
(
newAlternative
);
newActivity
=
activityRepository
.
save
(
newActivity
);
for
(
AlternativeDto
alternativeDto
:
activityDto
.
getAlternativeList
())
{
Alternative
newAlternative
=
Alternative
.
builder
()
.
activityId
(
newActivity
.
getId
())
.
correctAnswer
(
alternativeDto
.
isCorrectAnswer
())
.
isImg
(
alternativeDto
.
isImg
())
.
text
(
alternativeDto
.
getText
())
.
build
();
alternativeRepository
.
save
(
newAlternative
);
}
}
}
return
newModule
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help