Skip to content

Commit e287b7a

Browse files
committed
Subida Logica de negocio
1 parent eab295f commit e287b7a

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

src/main/java/com/example/postgresql/student/Student.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@ public class Student {
88
private Long id;
99
private String name;
1010
private String email;
11-
private LocalDateTime dob;
11+
private LocalDate dob;
1212
private Integer age;
1313

14-
public Student(long id, String marta, String email, LocalDate of, int age) {
15-
}
1614

17-
public Student(Long id, String name, String email, LocalDateTime dob, Integer age) {
15+
16+
public Student(Long id, String name, String email, LocalDate dob, Integer age) {
1817
this.id = id;
1918
this.name = name;
2019
this.email = email;
2120
this.dob = dob;
2221
this.age = age;
2322
}
2423

25-
public Student(String name, String email, LocalDateTime dob, Integer age) {
24+
public Student(String name, String email, LocalDate dob, Integer age) {
2625
this.name = name;
2726
this.email = email;
2827
this.dob = dob;
@@ -53,11 +52,11 @@ public void setEmail(String email) {
5352
this.email = email;
5453
}
5554

56-
public LocalDateTime getDob() {
55+
public LocalDate getDob() {
5756
return dob;
5857
}
5958

60-
public void setDob(LocalDateTime dob) {
59+
public void setDob(LocalDate dob) {
6160
this.dob = dob;
6261
}
6362

src/main/java/com/example/postgresql/student/StudentController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
import org.springframework.web.bind.annotation.RequestMapping;
55
import org.springframework.web.bind.annotation.RestController;
66

7-
import java.time.LocalDate;
8-
import java.time.Month;
97
import java.util.List;
108

119
@RestController
1210
@RequestMapping(path = "api/v1/student")
1311
public class StudentController {
1412

13+
14+
private final StudentService studentService;
15+
16+
public StudentController(StudentService studentService) {
17+
this.studentService = studentService;
18+
}
19+
1520
@GetMapping
1621
public List<Student> getStudent(){
17-
return List.of(new Student(1L,
18-
"Marta",
19-
"marta.des@gmail.com",
20-
LocalDate.of(2000, Month.FEBRUARY, 8),
21-
21)
22-
);
22+
return studentService.getStudent();
2323
}
2424
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.example.postgresql.student;
2+
3+
import java.time.LocalDate;
4+
import java.time.Month;
5+
import java.util.List;
6+
7+
public class StudentService {
8+
9+
10+
public List<Student> getStudent(){
11+
return List.of(
12+
new Student(
13+
1L,
14+
"Juancho",
15+
"juanchito@gmail.com",
16+
LocalDate.of(2000, Month.FEBRUARY, 3),
17+
21
18+
)
19+
);
20+
}
21+
}

0 commit comments

Comments
 (0)