Skip to content

Commit 90f97cd

Browse files
committed
ajuste1
1 parent 08e4c0f commit 90f97cd

File tree

14 files changed

+140
-0
lines changed

14 files changed

+140
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

src/.DS_Store

6 KB
Binary file not shown.

src/main/.DS_Store

6 KB
Binary file not shown.

src/main/java/.DS_Store

6 KB
Binary file not shown.

src/main/java/com/.DS_Store

6 KB
Binary file not shown.

src/main/java/com/example/.DS_Store

6 KB
Binary file not shown.
6 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example.rest.Services;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
@Service
6+
public class ProjectoService {
7+
8+
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.rest;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class SpringBootRestApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(SpringBootRestApplication.class, args);
11+
}
12+
13+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.example.rest.controllers;
2+
3+
import com.example.rest.Services.ProjectoService;
4+
import com.example.rest.entities.Project;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.*;
8+
9+
import java.net.URI;
10+
11+
@RestController
12+
@RequestMapping("/v1/projects")
13+
public class ProjectController {
14+
15+
// Injeccion del servicio
16+
private final ProjectoService projectoService;
17+
18+
@Autowired
19+
public ProjectController(ProjectoService projectoService) {
20+
this.projectoService = projectoService;
21+
}
22+
23+
24+
//POST -> /v1/projects crear un Project
25+
@PostMapping
26+
public ResponseEntity<Project> crearProjecto(@RequestBody Project project) {
27+
Project projectoCreado = projectoService.crearProjecto(project);
28+
return ResponseEntity.created(URI.create("/v1/projects" + projectoCreado.getId()))
29+
.body(projectoCreado);
30+
}
31+
32+
// PUT -> /v1/projects/{id} editar un Project
33+
@PutMapping("/{id}")
34+
public ResponseEntity<Project> editarProjecto(@PathVariable("id") Long id,
35+
@RequestBody Project project) {
36+
37+
}
38+
39+
// DELETE -> /v1/projects/{id} eliminar un Project
40+
public ResponseEntity<Void> eliminarProjecto(@PathVariable("id") Long id) {
41+
42+
}
43+
44+
// GET -> /v1/projects/{id} obtener un Project por i
45+
@GetMapping("/{id}")
46+
public ResponseEntity<Project> obtenerProjecto(@PathVariable("id") Long id) {
47+
48+
}
49+
50+
51+
52+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example.rest.controllers;
2+
3+
public class TareaController {
4+
5+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.example.rest.entities;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
@Setter
10+
@Getter
11+
@Builder
12+
@AllArgsConstructor
13+
@NoArgsConstructor
14+
@Entity
15+
@Table(name = "proyecto")
16+
public class Project {
17+
18+
@Id
19+
@GeneratedValue(strategy = GenerationType.IDENTITY)
20+
private Long id;
21+
22+
@Column(name = "nombre")
23+
private String name;
24+
25+
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
26+
private List<Task> userProyectList = new ArrayList<>();
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.rest.entities;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
6+
import java.math.BigDecimal;
7+
8+
@Setter
9+
@Getter
10+
@Builder
11+
@AllArgsConstructor
12+
@NoArgsConstructor
13+
@Entity
14+
@Table(name = "tarea")
15+
public class Task {
16+
17+
@Id
18+
@GeneratedValue(strategy = GenerationType.IDENTITY)
19+
private Long id;
20+
21+
@Column(name = "nombre")
22+
private String name;
23+
24+
@Column(name = "precio")
25+
private BigDecimal price;
26+
27+
@ManyToOne
28+
@JoinColumn(name = "id_proyecto", nullable = false)
29+
private Project project;
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.example.rest.repositories;
2+
3+
public interface ProjectRepository {
4+
}

0 commit comments

Comments
 (0)