mvc fix controllers
This commit is contained in:
parent
55712b5c6e
commit
c5d0bd083f
@ -1,61 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p id="out">Push the button</p>
|
|
||||||
<input id="name"/>
|
|
||||||
<br/>
|
|
||||||
<button onclick="get()">Get</button>
|
|
||||||
<br/>
|
|
||||||
<button onclick="getTest()">Get Test</button>
|
|
||||||
<br/>
|
|
||||||
<button onclick="post()">Post</button>
|
|
||||||
<br/>
|
|
||||||
<button onclick="put()">Put</button>
|
|
||||||
</body>
|
|
||||||
<script>
|
|
||||||
const url = "http://localhost:8080/api";
|
|
||||||
const out = document.getElementById("out");
|
|
||||||
const name = document.getElementById("name");
|
|
||||||
const get = async () => {
|
|
||||||
const res = await fetch(`${url}?name=${name.value}`);
|
|
||||||
const text = await res.text();
|
|
||||||
out.innerText = text;
|
|
||||||
}
|
|
||||||
const getTest = async () => {
|
|
||||||
const res = await fetch(`${url}/test`);
|
|
||||||
const text = await res.text();
|
|
||||||
out.innerText = text;
|
|
||||||
}
|
|
||||||
const post = async () => {
|
|
||||||
if (!name.value) {
|
|
||||||
alert("Name is required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await fetch(url, {
|
|
||||||
method: 'post',
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: name.value
|
|
||||||
});
|
|
||||||
const text = await res.text();
|
|
||||||
out.innerText = text;
|
|
||||||
}
|
|
||||||
const put = async () => {
|
|
||||||
if (!name.value) {
|
|
||||||
alert("Name is required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await fetch(`${url}/${name.value}`, {
|
|
||||||
method: 'put',
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: name.value
|
|
||||||
});
|
|
||||||
const text = await res.text();
|
|
||||||
out.innerText = text;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</html>
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.ip.library.controllers.authors;
|
package com.ip.library.controllers.authors;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -8,14 +9,13 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.ip.library.core.configuration.Constants;
|
import com.ip.library.core.configuration.Constants;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@Controller
|
||||||
@RequestMapping(AuthorController.URL)
|
@RequestMapping(AuthorController.URL)
|
||||||
public class AuthorController {
|
public class AuthorController {
|
||||||
public static final String URL = Constants.API_URL + "/author";
|
public static final String URL = Constants.API_URL + "/author";
|
||||||
|
@ -3,6 +3,7 @@ package com.ip.library.controllers.books;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -11,7 +12,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
import com.ip.library.controllers.types.TypeService;
|
import com.ip.library.controllers.types.TypeService;
|
||||||
@ -20,7 +20,7 @@ import com.ip.library.core.configuration.Constants;
|
|||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
@RestController
|
@Controller
|
||||||
@RequestMapping(BookController.URL)
|
@RequestMapping(BookController.URL)
|
||||||
public class BookController {
|
public class BookController {
|
||||||
public static final String URL = Constants.API_URL + "/book";
|
public static final String URL = Constants.API_URL + "/book";
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ip.library.controllers.types;
|
package com.ip.library.controllers.types;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -8,13 +9,11 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.ip.library.core.configuration.Constants;
|
import com.ip.library.core.configuration.Constants;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
@RestController
|
@Controller
|
||||||
@RequestMapping(TypeController.URL)
|
@RequestMapping(TypeController.URL)
|
||||||
public class TypeController {
|
public class TypeController {
|
||||||
public static final String URL = Constants.API_URL + "/type";
|
public static final String URL = Constants.API_URL + "/type";
|
||||||
|
@ -3,6 +3,7 @@ package com.ip.library.controllers.users;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -11,7 +12,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
import com.ip.library.core.api.PageAttributesMapper;
|
import com.ip.library.core.api.PageAttributesMapper;
|
||||||
@ -19,7 +19,7 @@ import com.ip.library.core.configuration.Constants;
|
|||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
@RestController
|
@Controller
|
||||||
@RequestMapping(UserController.URL)
|
@RequestMapping(UserController.URL)
|
||||||
public class UserController {
|
public class UserController {
|
||||||
public static final String URL = Constants.API_URL + "/user";
|
public static final String URL = Constants.API_URL + "/user";
|
||||||
|
Loading…
Reference in New Issue
Block a user