Skip to content

Commit

Permalink
Merge pull request #37 from UdL-EPS-SoftArch/crud-Location
Browse files Browse the repository at this point in the history
crud-Location and relation
  • Loading branch information
elskater98 authored Feb 29, 2024
2 parents b47e994 + 0ce079d commit 99a1cd2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Location.java
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;
}
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);
}

0 comments on commit 99a1cd2

Please sign in to comment.