[Microservice] - Integrate database
This commit is contained in:
@@ -29,6 +29,16 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
BIN
microservice/profilemanagement/src/main/.DS_Store
vendored
Normal file
BIN
microservice/profilemanagement/src/main/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
package com.ayoosh.profilemanagement.dao;
|
||||
|
||||
import com.ayoosh.profilemanagement.domain.EmployeeProfile;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ProfileRepository extends JpaRepository<EmployeeProfile,Integer> {
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
package com.ayoosh.profilemanagement.domain;
|
||||
|
||||
public class EmployeeProfile {
|
||||
private int id;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "employee_profile")
|
||||
public class EmployeeProfile {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
@Column(name = "address")
|
||||
private String address;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -27,6 +37,5 @@ public class EmployeeProfile {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String address;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ayoosh.profilemanagement.service;
|
||||
|
||||
import com.ayoosh.profilemanagement.dao.ProfileRepository;
|
||||
import com.ayoosh.profilemanagement.domain.EmployeeProfile;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -8,15 +10,18 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
public class EmployeeProfileServiceImpl implements EmployeeProfileService {
|
||||
|
||||
@Autowired
|
||||
ProfileRepository repository;
|
||||
List<EmployeeProfile> employeeProfileList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addEmployeeProfile(EmployeeProfile profile) {
|
||||
employeeProfileList.add(profile);
|
||||
repository.save(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmployeeProfile> getEmployeeProfiles() {
|
||||
return employeeProfileList;
|
||||
return repository.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
BIN
microservice/profilemanagement/src/test/.DS_Store
vendored
Normal file
BIN
microservice/profilemanagement/src/test/.DS_Store
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user