Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_mszczonow_3
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
alx_mszczonow_3
Commits
04e76a9f
Commit
04e76a9f
authored
Jul 25, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namiasta REST / JSON
parent
216f7078
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
2 deletions
+47
-2
LocationRespository.java
src/main/java/alx/data/LocationRespository.java
+7
-0
Repository5.java
src/main/java/alx/data/Repository5.java
+2
-2
LocationsJson.java
src/main/java/alx/rest/LocationsJson.java
+32
-0
index.html
src/main/resources/templates/index.html
+6
-0
No files found.
src/main/java/alx/data/LocationRespository.java
0 → 100644
View file @
04e76a9f
package
alx
.
data
;
import
alx.model.Location
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
LocationRespository
extends
JpaRepository
<
Location
,
Integer
>
{
}
src/main/java/alx/data/Repository5.java
View file @
04e76a9f
...
...
@@ -7,16 +7,16 @@ import java.util.stream.Collectors;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
alx.model.Employee
;
@Repository
public
interface
Repository5
extends
JpaRepository
<
Employee
,
Integer
>
{
List
<
Employee
>
findByLastName
(
String
name
);
List
<
Employee
>
findByLastNameContainingIgnoringCase
(
String
name
);
List
<
Employee
>
findBySalaryBetween
(
BigDecimal
min
,
BigDecimal
max
);
List
<
Employee
>
findByJob_JobId
(
String
jobId
);
...
...
src/main/java/alx/rest/LocationsJson.java
0 → 100644
View file @
04e76a9f
package
alx
.
rest
;
import
alx.data.LocationRespository
;
import
alx.model.Location
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.server.ResponseStatusException
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/locations"
)
public
class
LocationsJson
{
@Autowired
private
LocationRespository
repo
;
@GetMapping
public
List
<
Location
>
readAll
()
{
return
repo
.
findAll
();
}
@GetMapping
(
"/{id}"
)
public
Location
readOne
(
@PathVariable
Integer
id
)
{
return
repo
.
findById
(
id
).
orElseThrow
(()
->
new
ResponseStatusException
(
HttpStatus
.
NOT_FOUND
,
"Location Not Found"
));
}
}
src/main/resources/templates/index.html
View file @
04e76a9f
...
...
@@ -83,5 +83,11 @@
<p>
Pisane
<a
th:href=
"@{/emps9}"
>
TERAZ
</a></p>
<h2>
REST / JSON
</h2>
<ul>
<li><a
href=
"/locations"
>
locations
</a></li>
<li><a
href=
"/locations/1200"
>
locations/1200
</a></li>
</ul>
</body>
</html>
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