Skip to content

Commit

Permalink
fix: Person Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
trutzonline committed Apr 17, 2024
1 parent d6b8072 commit 6f03ebe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
29 changes: 0 additions & 29 deletions src/main/java/trutzio/devopstools/EchoController.java

This file was deleted.

8 changes: 7 additions & 1 deletion src/main/java/trutzio/devopstools/Person.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package trutzio.devopstools;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;

@Entity
public class Person {

@Id
String id;
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "person_id_seq")
@SequenceGenerator(name = "person_id_seq")
Long id;

String name;

}
23 changes: 23 additions & 0 deletions src/main/java/trutzio/devopstools/PersonController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package trutzio.devopstools;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersonController {

private final PersonRepository personRepository;

public PersonController(PersonRepository personRepository) {
this.personRepository = personRepository;
}

@GetMapping("/")
// @WithSpan(value = "test span")
public String newPerson() throws InterruptedException {
Person person = new Person();
person.name = "John Doe";
return personRepository.save(person).id.toString();
}

}
2 changes: 1 addition & 1 deletion src/main/java/trutzio/devopstools/PersonRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import org.springframework.data.jpa.repository.JpaRepository;

public interface PersonRepository extends JpaRepository<Person, String> {
public interface PersonRepository extends JpaRepository<Person, Long> {

}

0 comments on commit 6f03ebe

Please sign in to comment.