Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
javab_20230928
Commits
1b5760bd
Commit
1b5760bd
authored
Oct 19, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dodatkowe metody RESTowe
parent
cb853633
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
BlogRestController.java
...ng/src/main/java/com/example/demo/BlogRestController.java
+20
-0
BlogService.java
PC26-Spring/src/main/java/com/example/demo/BlogService.java
+8
-0
No files found.
PC26-Spring/src/main/java/com/example/demo/BlogRestController.java
View file @
1b5760bd
...
@@ -4,6 +4,10 @@ import java.util.List;
...
@@ -4,6 +4,10 @@ import java.util.List;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -18,4 +22,20 @@ public class BlogRestController {
...
@@ -18,4 +22,20 @@ public class BlogRestController {
return
blogService
.
getTeksty
();
return
blogService
.
getTeksty
();
}
}
@GetMapping
(
path
=
"/{numer}"
,
produces
=
"application/json"
)
public
String
getTekst
(
@PathVariable
(
"numer"
)
int
i
)
{
return
blogService
.
getTekst
(
i
);
}
@PutMapping
(
path
=
"/{numer}"
,
consumes
=
{
"application/json"
,
"text/plain"
})
public
void
setTekst
(
@PathVariable
(
"numer"
)
int
i
,
@RequestBody
String
tekst
)
{
blogService
.
setTekst
(
i
,
tekst
);
}
@PostMapping
(
consumes
=
{
"application/json"
,
"text/plain"
})
public
void
addTekst
(
@RequestBody
String
tekst
)
{
blogService
.
addTekst
(
tekst
);
}
}
}
PC26-Spring/src/main/java/com/example/demo/BlogService.java
View file @
1b5760bd
...
@@ -14,6 +14,14 @@ public class BlogService {
...
@@ -14,6 +14,14 @@ public class BlogService {
return
Collections
.
unmodifiableList
(
teksty
);
return
Collections
.
unmodifiableList
(
teksty
);
}
}
public
String
getTekst
(
int
i
)
{
return
teksty
.
get
(
i
);
}
public
void
setTekst
(
int
i
,
String
tekst
)
{
teksty
.
set
(
i
,
tekst
);
}
public
void
addTekst
(
String
tekst
)
{
public
void
addTekst
(
String
tekst
)
{
teksty
.
add
(
tekst
);
teksty
.
add
(
tekst
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment