Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PA165 Formula One Team
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Diana Gulčíková
PA165 Formula One Team
Commits
a6279864
There was an error fetching the commit references. Please try again later.
Commit
a6279864
authored
1 year ago
by
Oto Stanko
Browse files
Options
Downloads
Patches
Plain Diff
Get all spare componentf of same name
parent
b162d30b
No related branches found
No related tags found
2 merge requests
!60
Docker
,
!44
20_list_of_spare_components
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
car/src/main/java/cz/muni/pa165/car/rest/CarComponentPairController.java
+23
-3
23 additions, 3 deletions
...va/cz/muni/pa165/car/rest/CarComponentPairController.java
with
23 additions
and
3 deletions
car/src/main/java/cz/muni/pa165/car/rest/CarComponentPairController.java
+
23
−
3
View file @
a6279864
...
...
@@ -6,6 +6,8 @@ import cz.muni.pa165.common_library.dtos.CarComponentDto;
import
cz.muni.pa165.common_library.dtos.CarRequestDto
;
import
cz.muni.pa165.common_library.dtos.CarResponseDto
;
import
io.swagger.v3.oas.annotations.Operation
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -80,10 +82,28 @@ public class CarComponentPairController {
* @return List of components.
*/
@Operation
(
summary
=
"Get all components from component repo"
)
@GetMapping
(
path
=
"/get
c
omponents"
,
@GetMapping
(
path
=
"/get
StoredC
omponents
OfType
"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
CarComponentDto
>>
getAllCarComponents
()
{
return
ResponseEntity
.
ok
(
DbGetter
.
getAllComponentsFromDb
());
public
ResponseEntity
<
List
<
CarComponentDto
>>
getAllCarComponents
(
@RequestParam
Long
carId
,
@RequestParam
Long
componentId
)
{
List
<
CarComponentDto
>
allComponents
=
DbGetter
.
getAllComponentsFromDb
();
var
carComponentsResponse
=
getAllComponentsOfCar
(
carId
);
var
carComponents
=
carComponentsResponse
.
getBody
();
CarComponentDto
requestedComponent
=
null
;
assert
carComponents
!=
null
;
for
(
CarComponentDto
carComponent:
allComponents
)
{
if
(
carComponent
.
getId
().
equals
(
componentId
))
{
requestedComponent
=
carComponent
;
break
;
}
}
assert
requestedComponent
!=
null
;
List
<
CarComponentDto
>
allViableReplacements
=
new
ArrayList
<>();
for
(
CarComponentDto
carComponent:
allComponents
)
{
if
(
carComponent
.
getName
().
equals
(
requestedComponent
.
getName
())
&&
!
carComponent
.
getId
().
equals
(
componentId
))
{
allViableReplacements
.
add
(
carComponent
);
}
}
return
ResponseEntity
.
ok
(
allViableReplacements
);
}
...
...
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