Commit 449c7023 authored by Alexandre Ducarne's avatar Alexandre Ducarne

馃摝 Use Lombok Annotations

parent 353afdbc
...@@ -26,6 +26,7 @@ repositories { ...@@ -26,6 +26,7 @@ repositories {
dependencies { dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
developmentOnly 'org.springframework.boot:spring-boot-devtools' developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java' runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
......
...@@ -4,10 +4,7 @@ import com.RESTAPI.RESTAPI.Entities.User; ...@@ -4,10 +4,7 @@ import com.RESTAPI.RESTAPI.Entities.User;
import com.RESTAPI.RESTAPI.Repositories.UserRepository; import com.RESTAPI.RESTAPI.Repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller // This means that this class is a Controller @Controller // This means that this class is a Controller
@RequestMapping(path="/user") // This means URL's start with /demo (after Application path) @RequestMapping(path="/user") // This means URL's start with /demo (after Application path)
...@@ -16,7 +13,7 @@ public class UserController { ...@@ -16,7 +13,7 @@ public class UserController {
// Which is auto-generated by Spring, we will use it to handle the data // Which is auto-generated by Spring, we will use it to handle the data
private UserRepository userRepository; private UserRepository userRepository;
@GetMapping(path="/add") // Map ONLY GET Requests @PutMapping(path="/add") // Map ONLY GET Requests
public @ResponseBody public @ResponseBody
String addNewUser (@RequestParam String name String addNewUser (@RequestParam String name
, @RequestParam String email) { , @RequestParam String email) {
......
package com.RESTAPI.RESTAPI.Entities; package com.RESTAPI.RESTAPI.Entities;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
@Entity // This tells Hibernate to make a table out of this class @Entity // This tells Hibernate to make a table out of this class
@Getter
@Setter
public class User { public class User {
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id; private Integer id;
private String name; private String name;
private String email; private String email;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment