Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.company.app.controller;

import com.company.app.entity.HumanEntity;
import com.company.app.entity.Human;
import com.company.app.service.HumanService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -17,7 +17,7 @@ public HumanController(HumanService humanService) {
}

@GetMapping(value = "/humans")
public List<HumanEntity> getAll() {
public List<Human> getAll() {
return humanService.getAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@Entity
@Table(name = "humans")
public class HumanEntity {
public class Human {

@Basic
@Column(name = "id")
Expand All @@ -20,10 +20,10 @@ public class HumanEntity {
@Column(name = "age")
private int age;

public HumanEntity() {
public Human() {
}

public HumanEntity(String nickname, int age) {
public Human(String nickname, int age) {
this.nickname = nickname;
this.age = age;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.company.app.repository;

import com.company.app.entity.HumanEntity;
import com.company.app.entity.Human;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface HumanRepository extends JpaRepository<HumanEntity, Integer> {
public interface HumanRepository extends JpaRepository<Human, Integer> {
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.company.app.service;

import com.company.app.entity.HumanEntity;
import com.company.app.entity.Human;

import java.util.List;

public interface HumanService {

List<HumanEntity> getAll();
HumanEntity getOneById(Integer id);
List<Human> getAll();
Human getOneById(Integer id);
void create(String nickname, int age);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.company.app.service.impl;

import com.company.app.entity.HumanEntity;
import com.company.app.entity.Human;
import com.company.app.repository.HumanRepository;
import com.company.app.service.HumanService;
import org.springframework.stereotype.Service;
Expand All @@ -17,17 +17,17 @@ public HumanServiceImpl(HumanRepository humanRepository) {
}

@Override
public List<HumanEntity> getAll() {
public List<Human> getAll() {
return humanRepository.findAll();
}

@Override
public HumanEntity getOneById(Integer id) {
public Human getOneById(Integer id) {
return humanRepository.getOne(id);
}

@Override
public void create(String nickname, int age) {
humanRepository.save(new HumanEntity(nickname, age));
humanRepository.save(new Human(nickname, age));
}
}