Skip to content

Commit 7168e11

Browse files
committed
creación de componentes DepartmentController DepartmentEntity, DepartmentService & DepartmentRepository
1 parent 4e63782 commit 7168e11

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed

Readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CREATING COMPONENTS
2+
- Crear Entity Department (@Entity) con sus atributos e ID (@Id)
3+
- Crear DepartmentService Interface (@Service) y DepartmentServiceImpl
4+
- Crear DepartmentRepository Interface (@Repository) y extends JpaRepository<Department,Long> :
5+
JpaRepository<_entity, dataType_Id_entity_>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example.springbootapirest.controller;
2+
3+
import org.springframework.web.bind.annotation.RestController;
4+
5+
6+
@RestController
7+
public class DepartmentController {
8+
9+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.example.springbootapirest.entity;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.GenerationType;
6+
import javax.persistence.Id;
7+
8+
@Entity
9+
public class Department {
10+
11+
@Id
12+
@GeneratedValue(strategy = GenerationType.AUTO)
13+
private Long departmentId;
14+
private String departmentName;
15+
private String departmentAddress;
16+
private String departmentCode;
17+
18+
public Department() {
19+
}
20+
21+
@Override
22+
public String toString() {
23+
final StringBuffer sb = new StringBuffer("Department{");
24+
sb.append("departmentId=").append(departmentId);
25+
sb.append(", departmentName='").append(departmentName).append('\'');
26+
sb.append(", departmentAddress='").append(departmentAddress).append('\'');
27+
sb.append(", departmentCode='").append(departmentCode).append('\'');
28+
sb.append('}');
29+
return sb.toString();
30+
}
31+
32+
public Long getDepartmentId() {
33+
return departmentId;
34+
}
35+
36+
public void setDepartmentId(Long departmentId) {
37+
this.departmentId = departmentId;
38+
}
39+
40+
public String getDepartmentName() {
41+
return departmentName;
42+
}
43+
44+
public void setDepartmentName(String departmentName) {
45+
this.departmentName = departmentName;
46+
}
47+
48+
public String getDepartmentAddress() {
49+
return departmentAddress;
50+
}
51+
52+
public void setDepartmentAddress(String departmentAddress) {
53+
this.departmentAddress = departmentAddress;
54+
}
55+
56+
public String getDepartmentCode() {
57+
return departmentCode;
58+
}
59+
60+
public void setDepartmentCode(String departmentCode) {
61+
this.departmentCode = departmentCode;
62+
}
63+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.springbootapirest.repository;
2+
3+
import com.example.springbootapirest.entity.Department;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.stereotype.Repository;
6+
7+
@Repository
8+
public interface DepartmentRepository extends JpaRepository<Department,Long> { // Indicamos el entity y el tipo de su ID
9+
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.springbootapirest.service;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
@Service
6+
public interface DepartmentService {
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.example.springbootapirest.service;
2+
3+
public class DepartmentServiceImpl implements DepartmentService{
4+
}

0 commit comments

Comments
 (0)