Skip to content

Commit d3cd0bd

Browse files
fix: missing services dependencies inialization
inserted proper initialization to the dependencies from the service layer by their constructors
1 parent 6a845ba commit d3cd0bd

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/main/java/com/vianavitor/simplelibrarygame/service/AuthorService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class AuthorService {
1818
private Author author;
1919

2020
@Autowired
21-
public AuthorService() {}
21+
public AuthorService() {
22+
this.author = new Author();
23+
}
2224

2325
public AuthorService(AuthorRepository repository, Author author) {
2426
this.repository = repository;

src/main/java/com/vianavitor/simplelibrarygame/service/ClassroomService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public class ClassroomService {
3232
private Classroom classroom;
3333

3434
@Autowired
35-
public ClassroomService() { }
35+
public ClassroomService() {
36+
this.classroom = new Classroom();
37+
}
3638

3739
public ClassroomService(
3840
ClassroomRepository repository, ProfessorRepository professorRepository,

src/main/java/com/vianavitor/simplelibrarygame/service/GroupOfBookService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public class GroupOfBookService {
2828
private GroupOfBook groupOfBook;
2929

3030
@Autowired
31-
public GroupOfBookService() {}
31+
public GroupOfBookService() {
32+
this.groupOfBook = new GroupOfBook();
33+
}
3234

3335
public GroupOfBookService(
3436
GroupOfBookRepository repository, BookRepository bookRepository,

src/main/java/com/vianavitor/simplelibrarygame/service/GroupService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public class GroupService {
2020

2121
private Group group;
2222

23+
@Autowired
24+
public GroupService() {
25+
this.group = new Group();
26+
}
27+
2328
public Group create(String name, Long studentId) throws ResourceNotFoundException {
2429
Student owner = studentRepository.findById(studentId)
2530
.orElseThrow(() -> new ResourceNotFoundException("not found student"));

src/main/java/com/vianavitor/simplelibrarygame/service/StudentService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public class StudentService implements ManageableUser<Student> {
3737
private StudentStats stats;
3838

3939
@Autowired
40-
public StudentService() {}
40+
public StudentService() {
41+
this.stats = new StudentStats();
42+
}
4143

4244
public StudentService(
4345
StudentRepository repository, StudentStatsRepository statsRepository,

src/main/java/com/vianavitor/simplelibrarygame/service/StudentStatsService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public class StudentStatsService {
3838
private BookReadHistory history;
3939

4040
@Autowired
41-
public StudentStatsService() {}
41+
public StudentStatsService() {
42+
this.stats = new StudentStats();
43+
this.history = new BookReadHistory();
44+
}
4245

4346
public StudentStatsService(
4447
StudentStatsRepository repository, StudentRepository studentRepository,

0 commit comments

Comments
 (0)