Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Joinfut
Joinfut Backend
Commits
52050d30
Commit
52050d30
authored
2 years ago
by
Gabriel Fanto Stundner
💻
Browse files
Options
Download
Email Patches
Plain Diff
#27
Atualizando os filtros
parent
77058404
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/main/java/com/ages/joinfut/controller/AthleteController.java
+16
-77
...n/java/com/ages/joinfut/controller/AthleteController.java
src/main/java/com/ages/joinfut/model/Athlete.java
+7
-1
src/main/java/com/ages/joinfut/model/Athlete.java
src/main/java/com/ages/joinfut/repository/AthleteRepository.java
+7
-1
...n/java/com/ages/joinfut/repository/AthleteRepository.java
target/classes/com/ages/joinfut/JoinfutApplication.class
+0
-0
target/classes/com/ages/joinfut/JoinfutApplication.class
target/test-classes/com/ages/joinfut/JoinfutApplicationTests.class
+0
-0
...st-classes/com/ages/joinfut/JoinfutApplicationTests.class
with
30 additions
and
79 deletions
+30
-79
src/main/java/com/ages/joinfut/controller/AthleteController.java
View file @
52050d30
...
...
@@ -14,6 +14,7 @@ import com.ages.joinfut.service.AthleteService;
import
com.ages.joinfut.service.AdressService
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Example
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -48,8 +49,21 @@ public class AthleteController {
@GetMapping
(
value
=
URL_PLURAL
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ApiModelProperty
(
"Busca em lista de todos os Atletas cadastrados"
)
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAllAthletes
()
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
();
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAllAthletes
(
@RequestParam
(
value
=
"dominantLeg"
,
required
=
false
)
DominantLeg
dominantLeg
,
@RequestParam
(
value
=
"athleteHeight"
,
required
=
false
)
Double
athleteHeight
,
@RequestParam
(
value
=
"age"
,
required
=
false
)
Integer
age
,
@RequestParam
(
value
=
"athleteWeight"
,
required
=
false
)
Double
athleteWeight
,
@RequestParam
(
value
=
"position"
,
required
=
false
)
Position
position
)
{
Athlete
athlete
=
Athlete
.
builder
()
.
dominantLeg
(
dominantLeg
)
.
athleteHeight
(
athleteHeight
)
.
age
(
age
)
.
athleteWeight
(
athleteWeight
)
.
position
(
position
)
.
build
();
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
(
Example
.
of
(
athlete
));
List
<
AthleteDTO
>
athletesDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athletesDTO
,
HttpStatus
.
OK
);
}
...
...
@@ -94,81 +108,6 @@ public class AthleteController {
return
ResponseEntity
.
notFound
().
build
();
}
@GetMapping
(
value
=
URL_PLURAL
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ApiModelProperty
(
"Busca em lista as alturas dos atletas"
)
@Transactional
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAthleteByathleteHeight
(
@RequestParam
(
value
=
"athleteHeight"
,
required
=
false
)
Double
athleteHeight
)
{
if
(
athleteHeight
!=
null
)
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findByathleteHeight
(
athleteHeight
);
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
else
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
();
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
URL_PLURAL
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ApiModelProperty
(
"Busca em lista as idades dos atletas"
)
@Transactional
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAthleteByage
(
@RequestParam
(
value
=
"age"
,
required
=
false
)
Integer
age
)
{
if
(
age
!=
null
)
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findByage
(
age
);
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
else
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
();
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
URL_PLURAL
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ApiModelProperty
(
"Busca em lista os pesos dos atletas"
)
@Transactional
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAthelteByathleteWeight
(
@RequestParam
(
value
=
"athleteWeight"
,
required
=
false
)
Double
athleteWeight
)
{
if
(
athleteWeight
!=
null
)
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findByathleteWeight
(
athleteWeight
);
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
else
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
();
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
URL_PLURAL
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ApiModelProperty
(
"Busca em lista as pernas dominantes dos atletas"
)
@Transactional
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAthleteBydominantLeg
(
@RequestParam
(
value
=
"dominantLeg"
,
required
=
false
)
DominantLeg
dominantLeg
)
{
if
(
dominantLeg
!=
null
)
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findBydominantLeg
(
dominantLeg
);
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
else
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
();
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
URL_PLURAL
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ApiModelProperty
(
"Busca em lista as posições dos atletas"
)
@Transactional
public
ResponseEntity
<
List
<
AthleteDTO
>>
readAthleteByposition
(
@RequestParam
(
value
=
"position"
,
required
=
false
)
Position
position
)
{
if
(
position
!=
null
)
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findByposition
(
position
);
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
else
{
List
<
Athlete
>
athletes
=
athleteRepository
.
findAll
();
List
<
AthleteDTO
>
athleteDTO
=
athleteService
.
convertList
(
athletes
);
return
new
ResponseEntity
<>(
athleteDTO
,
HttpStatus
.
OK
);
}
}
//Adress State
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/ages/joinfut/model/Athlete.java
View file @
52050d30
...
...
@@ -5,7 +5,10 @@ import com.ages.joinfut.Enum.Position;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.hibernate.annotations.Type
;
...
...
@@ -31,6 +34,9 @@ import java.util.List;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@JsonIgnoreProperties
({
"hibernateLazyInitializer"
,
"handler"
})
@Table
(
name
=
"athletes"
,
schema
=
"personas"
)
...
...
@@ -99,7 +105,7 @@ public class Athlete {
private
User
user
;
public
Athlete
()
{}
//
public Athlete() {}
public
Long
getId
()
{
return
getIdAthlete
();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/ages/joinfut/repository/AthleteRepository.java
View file @
52050d30
...
...
@@ -9,13 +9,19 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
import
java.util.Objects
;
@Repository
public
interface
AthleteRepository
extends
JpaRepository
<
Athlete
,
Long
>
{
Athlete
findByidAthlete
(
Long
id
);
List
<
Athlete
>
findByathleteHeight
(
Double
athleteHeight
);
// List<Athlete> findWithFilters(Objects...list) {
// for( Object object : list) {
// if object ! = null
// query += where object ...
// }
// }
List
<
Athlete
>
findByage
(
Integer
age
);
List
<
Athlete
>
findByathleteWeight
(
Double
athleteWeight
);
...
...
This diff is collapsed.
Click to expand it.
target/classes/com/ages/joinfut/JoinfutApplication.class
View file @
52050d30
No preview for this file type
This diff is collapsed.
Click to expand it.
target/test-classes/com/ages/joinfut/JoinfutApplicationTests.class
View file @
52050d30
No preview for this file type
This diff is collapsed.
Click to expand it.
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