Add repositories for new entities and cleanup
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
package com.petshop.backend.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "stores")
|
||||
public class Store {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "store_name", nullable = false, length = 100)
|
||||
private String storeName;
|
||||
|
||||
@Column(name = "store_location", length = 200)
|
||||
private String storeLocation;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Store() {
|
||||
}
|
||||
|
||||
public Store(Long id, String storeName, String storeLocation, LocalDateTime createdAt) {
|
||||
this.id = id;
|
||||
this.storeName = storeName;
|
||||
this.storeLocation = storeLocation;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public String getStoreLocation() {
|
||||
return storeLocation;
|
||||
}
|
||||
|
||||
public void setStoreLocation(String storeLocation) {
|
||||
this.storeLocation = storeLocation;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Store store = (Store) o;
|
||||
return Objects.equals(id, store.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Store{" +
|
||||
"id=" + id +
|
||||
", storeName='" + storeName + '\'' +
|
||||
", storeLocation='" + storeLocation + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.petshop.backend.repository;
|
||||
|
||||
import com.petshop.backend.entity.ActivityLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ActivityLogRepository extends JpaRepository<ActivityLog, Long> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.petshop.backend.repository;
|
||||
|
||||
import com.petshop.backend.entity.Employee;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.petshop.backend.repository;
|
||||
|
||||
import com.petshop.backend.entity.Store;
|
||||
import com.petshop.backend.entity.StoreLocation;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -9,10 +9,10 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface StoreRepository extends JpaRepository<Store, Long> {
|
||||
public interface StoreRepository extends JpaRepository<StoreLocation, Long> {
|
||||
|
||||
@Query("SELECT s FROM Store s WHERE " +
|
||||
@Query("SELECT s FROM StoreLocation s WHERE " +
|
||||
"LOWER(s.storeName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.storeLocation) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Store> searchStores(@Param("q") String query, Pageable pageable);
|
||||
"LOWER(s.address) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<StoreLocation> searchStores(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user