Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NSS_part-time_job_portal_implementacia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcel Žec
NSS_part-time_job_portal_implementacia
Commits
231702e1
Commit
231702e1
authored
4 years ago
by
Marcel Žec
Browse files
Options
Downloads
Patches
Plain Diff
CategoryController comments
parent
2f201227
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Part-time_job_portal/src/main/java/cz/cvut/fel/nss/parttimejobportal/rest/CategoryController.java
+24
-5
24 additions, 5 deletions
...ut/fel/nss/parttimejobportal/rest/CategoryController.java
with
24 additions
and
5 deletions
Part-time_job_portal/src/main/java/cz/cvut/fel/nss/parttimejobportal/rest/CategoryController.java
+
24
−
5
View file @
231702e1
...
...
@@ -28,17 +28,32 @@ public class CategoryController {
this
.
categoryService
=
categoryService
;
}
/**
* Method find all Categories.
* @return response with list of Categories
*/
@GetMapping
(
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Category
>>
getAll
()
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
categoryService
.
findAll
());
}
/**
* Method find and return Category by id.
* @param id
* @return response with Category
* @throws NotFoundException - when Category was not found
*/
@GetMapping
(
value
=
"/{id}"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Category
>
get
(
@PathVariable
Long
id
)
throws
NotFoundException
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
categoryService
.
find
(
id
));
}
@PreAuthorize
(
"hasAnyRole('ROLE_SUPERUSER', 'ROLE_ADMIN')"
)
/**
* Create new Category. Available only for user with ADMIN role.
* @param category - JSON representation of Category
* @return response 201
*/
@PreAuthorize
(
"hasRole('ROLE_ADMIN')"
)
@PostMapping
(
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseStatus
(
HttpStatus
.
CREATED
)
public
ResponseEntity
<
Void
>
create
(
@RequestBody
Category
category
){
...
...
@@ -47,7 +62,14 @@ public class CategoryController {
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
build
();
}
@PreAuthorize
(
"hasAnyRole('ROLE_SUPERUSER', 'ROLE_ADMIN')"
)
/**
* Update of Category by id. Available only for user with ADMIN role.
* @param id
* @param category - JSON representation of updated Category
* @return response 204
* @throws NotFoundException - when category was not found
*/
@PreAuthorize
(
"hasRole('ROLE_ADMIN')"
)
@PatchMapping
(
value
=
"/{id}"
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseStatus
(
HttpStatus
.
NO_CONTENT
)
public
ResponseEntity
<
Void
>
update
(
@PathVariable
Long
id
,
@RequestBody
Category
category
)
throws
NotFoundException
{
...
...
@@ -56,7 +78,4 @@ public class CategoryController {
return
ResponseEntity
.
status
(
HttpStatus
.
NO_CONTENT
).
build
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment