Skip to content
Snippets Groups Projects
Commit 91faa014 authored by Wissem BENSIDHOUM's avatar Wissem BENSIDHOUM
Browse files

some corrections

parent d826729f
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 28 deletions
......@@ -2,3 +2,4 @@
# System files
.DS_Store
Thumbs.db
back-skeleton/.env
\ No newline at end of file
......@@ -17,8 +17,8 @@ import java.util.List;
public class CourseController {
private final CourseService courseService;
@GetMapping("")
public List<Course> getAllCourses() {
@GetMapping
public List<Course> getAll() {
return courseService.findAll();
}
}
......@@ -15,7 +15,7 @@ import java.util.List;
public class MajorController {
private final MajorService majorService;
@GetMapping("")
@GetMapping
public List<Major> findAll() {
return majorService.findAll();
}
......
package com.takima.backskeleton.controllers;
import com.takima.backskeleton.DTO.StudentDto;
import com.takima.backskeleton.dto.StudentDto;
import com.takima.backskeleton.models.Student;
import com.takima.backskeleton.services.StudentService;
import lombok.RequiredArgsConstructor;
......@@ -14,7 +14,7 @@ import java.util.List;
@RequiredArgsConstructor
public class StudentController {
private final StudentService studentService;
@GetMapping("")
@GetMapping
public List<Student> listStudents(@RequestParam(required = false) Integer majorId, @RequestParam(required = false) Integer courseId) {
if (majorId != null && courseId !=null) {
return studentService.searchByMajorAndCourse(majorId, courseId);
......@@ -32,7 +32,7 @@ public class StudentController {
studentService.deleteById(id);
}
@PostMapping("")
@PostMapping
public void addStudent(@RequestBody StudentDto studentDto) {
studentService.addStudent(studentDto);
}
......
package com.takima.backskeleton.DAO;
package com.takima.backskeleton.dao;
import com.takima.backskeleton.models.Course;
import org.springframework.data.jpa.repository.JpaRepository;
......
package com.takima.backskeleton.DAO;
package com.takima.backskeleton.dao;
import com.takima.backskeleton.models.Major;
import com.takima.backskeleton.models.Student;
......
package com.takima.backskeleton.DAO;
package com.takima.backskeleton.dao;
import com.takima.backskeleton.models.Student;
import org.springframework.data.jpa.repository.JpaRepository;
......
package com.takima.backskeleton.DTO;
package com.takima.backskeleton.dto;
import com.takima.backskeleton.models.Course;
import com.takima.backskeleton.models.Major;
import com.takima.backskeleton.models.Student;
import lombok.Builder;
import lombok.Getter;
import org.springframework.web.multipart.MultipartFile;
import java.time.Instant;
import java.util.List;
......
package com.takima.backskeleton.DTO;
package com.takima.backskeleton.dto;
import com.takima.backskeleton.models.Student;
......
......@@ -20,6 +20,5 @@ public class Major {
@OneToMany(mappedBy = "major")
@JsonIgnore
private List<Student> students;
}
......@@ -13,9 +13,9 @@ public class Student {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "first_name")
@Column
private String firstName;
@Column(name = "last_name")
@Column
private String lastName;
private Instant birthdate;
@ManyToMany
......
package com.takima.backskeleton.services;
import com.takima.backskeleton.DAO.CourseDao;
import com.takima.backskeleton.dao.CourseDao;
import com.takima.backskeleton.models.Course;
import com.takima.backskeleton.models.Major;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
......
package com.takima.backskeleton.services;
import com.takima.backskeleton.DAO.MajorDao;
import com.takima.backskeleton.dao.MajorDao;
import com.takima.backskeleton.models.Major;
import com.takima.backskeleton.models.Student;
import lombok.RequiredArgsConstructor;
......
package com.takima.backskeleton.services;
import com.takima.backskeleton.DAO.StudentDao;
import com.takima.backskeleton.DTO.StudentDto;
import com.takima.backskeleton.DTO.StudentMapper;
import com.takima.backskeleton.dao.StudentDao;
import com.takima.backskeleton.dto.StudentDto;
import com.takima.backskeleton.dto.StudentMapper;
import com.takima.backskeleton.models.Student;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -20,10 +19,7 @@ public class StudentService {
private final StudentDao studentDao;
public List<Student> findAll() {
Iterable<Student> it = studentDao.findAll();
List <Student> users = new ArrayList<>();
it.forEach(users::add);
return users ;
return studentDao.findAll();
}
public Student getById(Long id) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment