Удалить 'src/main/java/com/example/demo/ApiController.java'
This commit is contained in:
parent
31b53c130e
commit
f09131edca
@ -1,66 +0,0 @@
|
||||
package com.example.demo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/usertest")
|
||||
public class ApiController {
|
||||
private final Logger log = LoggerFactory.getLogger(ApiController.class);
|
||||
|
||||
List<UserTest> data = new ArrayList<>(List.of(
|
||||
new UserTest("handle1", "email1", "name1", "password1"),
|
||||
new UserTest("handle2", "email2", "name2", "password2")));
|
||||
|
||||
@PostMapping
|
||||
public UserTest create(@RequestBody UserTest user) {
|
||||
data.add(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<UserTest> readAll() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public UserTest read(@PathVariable(name = "id") int id) {
|
||||
return data.get(id);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public UserTest update(@PathVariable(name = "id") int id, @RequestBody UserTest user) {
|
||||
UserTest us = data.get(id);
|
||||
|
||||
if (us != null) {
|
||||
data.remove(id);
|
||||
}
|
||||
|
||||
data.add(id, user);
|
||||
return data.get(id);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public UserTest delete(@PathVariable(name = "id") int id) {
|
||||
UserTest us = data.get(id);
|
||||
|
||||
if (us != null) {
|
||||
data.remove(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user