Skip to content

Commit 3618808

Browse files
committed
added getPersonById method and task service bug fixed
1 parent 13bd8aa commit 3618808

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

person-service/src/main/java/com/cevher/ms/person/domain/Person.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
@AllArgsConstructor
1616
@NoArgsConstructor
1717
public class Person {
18-
1918
@Id
2019
@GeneratedValue(strategy = GenerationType.AUTO)
2120
private Long id;
21+
private Long parentId;
2222
private String userName;
2323
private String password;
2424
private String firstName;
2525
private String lastName;
2626
private String email;
2727
private Long departmentId;
28-
2928
}

person-service/src/main/java/com/cevher/ms/person/service/PersonService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ public List<Person> findAllPerson() {
4747
log.info("findAllPerson method of PersonService");
4848
return personRepository.findAll();
4949
}
50+
51+
public Person getPersonById(Long personId) {
52+
return personRepository.findById(personId).orElse(new Person());
53+
}
5054
}

person-service/src/main/java/com/cevher/ms/person/web/rest/PersonController.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,25 @@ public Person savePerson(@RequestBody Person person) {
2222
log.info("savePerson by PersonController");
2323
return personService.savePerson(person);
2424
}
25+
2526
@GetMapping("/")
2627
public List<Person> findAllPerson() {
2728
log.info("findAllPerson by PersonController");
2829
return personService.findAllPerson();
2930
}
31+
3032
@GetMapping("/{id}")
33+
public Person getPersonById(
34+
@PathVariable("id") Long personId) {
35+
log.info("getPersonWithDepartment by PersonController");
36+
return personService.getPersonById(personId);
37+
}
38+
39+
@GetMapping("/rel/{id}")
3140
public ResponseTempVM getPersonWithDepartment(
3241
@PathVariable("id") Long personId) {
3342
log.info("getPersonWithDepartment by PersonController");
3443
return personService.getPersonWithDepartment(personId);
3544
}
3645

37-
}
46+
}

task-service/src/main/java/com/cevher/ms/task/web/rest/TaskController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,15 @@ public Task findByTaskId(@PathVariable("id") Long id){
3333
log.info("findByTaskId method of TaskController");
3434
return taskService.findByTaskId(id);
3535
}
36+
37+
/**
38+
* Get Task with all relationship information
39+
* @param id task ID
40+
* @return Return Task with all relationship ResponseVM
41+
*/
42+
@GetMapping("/rel/{id}")
43+
public ResponseVM findByTaskIdWithRelationShip(@PathVariable("id") Long id){
44+
log.info("findByTaskId method of TaskController");
45+
return taskService.findByTaskIdWithPersonAndDepartment(id);
46+
}
3647
}

0 commit comments

Comments
 (0)