Add controller, DTO
This commit is contained in:
parent
9728282bbc
commit
08e3bb426d
5 changed files with 109 additions and 0 deletions
13
src/main/java/fr/teamflash/archy/ServInitializer.java
Normal file
13
src/main/java/fr/teamflash/archy/ServInitializer.java
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package fr.teamflash.archy;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(ArchyApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package fr.teamflash.archy.controller;
|
||||
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("exemple")
|
||||
public class exempleController {
|
||||
|
||||
@GetMapping("hello")
|
||||
public ResponseEntity hello() {
|
||||
return new ResponseEntity("Bonjour", HttpStatusCode.valueOf(201));
|
||||
}
|
||||
|
||||
@GetMapping("holla")
|
||||
public ResponseEntity holla(@RequestParam("name") String nom, @RequestParam("firstname") String prenom) {
|
||||
return new ResponseEntity("Bonjour " + prenom + " " + nom, HttpStatusCode.valueOf(200));
|
||||
}
|
||||
|
||||
@GetMapping("somme")
|
||||
public ResponseEntity somme(@RequestParam("valeur") List<Integer> valeurs) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < valeurs.size(); i++) {
|
||||
sum += valeurs.get(i);
|
||||
}
|
||||
return new ResponseEntity(sum, HttpStatusCode.valueOf(200));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package fr.teamflash.archy.controller;
|
||||
|
||||
public class userController {
|
||||
}
|
||||
35
src/main/java/fr/teamflash/archy/dto/userDTO.java
Normal file
35
src/main/java/fr/teamflash/archy/dto/userDTO.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package fr.teamflash.archy.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class userDTO {
|
||||
private String name;
|
||||
private String firstName;
|
||||
private LocalDate birthDate;
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LocalDate getBirthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
public void setBirthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
}
|
||||
22
src/main/java/fr/teamflash/archy/dto/userDisplayDTO.java
Normal file
22
src/main/java/fr/teamflash/archy/dto/userDisplayDTO.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package fr.teamflash.archy.dto;
|
||||
|
||||
public class userDisplayDTO {
|
||||
private String displayName;
|
||||
private Integer age;
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String name, String firstName) {
|
||||
this.displayName = name + " " + firstName;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue