-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from UdL-EPS-SoftArch/crud-Location
crud-Location and relation
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/cat/udl/eps/softarch/demo/domain/Location.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cat.udl.eps.softarch.demo.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
|
||
public class Location extends UriEntity<Long> { | ||
@Id | ||
private Long id; | ||
|
||
private String address; | ||
|
||
private float longitude; | ||
|
||
private float latitude; | ||
|
||
private String municipality; | ||
|
||
private String postalCode; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "shelter_id") | ||
private Shelter shelter; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cat.udl.eps.softarch.demo.repository; | ||
|
||
import cat.udl.eps.softarch.demo.domain.Location; | ||
import cat.udl.eps.softarch.demo.domain.Shelter; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource | ||
public interface LocationRepository extends CrudRepository<Location, Long>, PagingAndSortingRepository<Location, Long> { | ||
|
||
Location findByShelterId(@Param("shelter_id") Long shelterId); | ||
} |