Add repositories for new entities and cleanup

This commit is contained in:
2026-03-05 16:40:53 -07:00
parent 90197ededd
commit a018c98ce7
5 changed files with 23 additions and 154 deletions

View File

@@ -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 +
'}';
}
}

View File

@@ -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> {
}

View File

@@ -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> {
}

View File

@@ -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);
}

View File

@@ -1,58 +0,0 @@
#!/bin/bash
ADMIN_TOKEN="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTc3MjczMzAxOSwiZXhwIjoxNzcyODE5NDE5fQ.__RqJbY2_HMjMlF6MoU8LagTu8pxjmizYYg4BQ0ahxRn9PV5iSQO3WRnCnujyE04AOY5yjTDEakOZOTEpiDFSw"
STAFF_TOKEN="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdGFmZiIsImlhdCI6MTc3MjczMzAyMCwiZXhwIjoxNzcyODE5NDIwfQ.m7jC_QMWmJsj-kc4Qb-9cQwUEnJEAYJ7mbpKJOMISSup1rONwloN3Heio6Iw5ysIkjNt6uZbwIX2SZygbxQSVg"
BASE_URL="http://localhost:8080/api/v1"
PASS=0
FAIL=0
TOTAL=0
test_endpoint() {
local method=$1
local path=$2
local token=$3
local expected_status=$4
local data=$5
local desc=$6
TOTAL=$((TOTAL + 1))
if [ -z "$data" ]; then
response=$(curl -s -w "\n%{http_code}" -X $method "$BASE_URL$path" -H "Authorization: Bearer $token" -H "Content-Type: application/json")
else
response=$(curl -s -w "\n%{http_code}" -X $method "$BASE_URL$path" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "$data")
fi
status=$(echo "$response" | tail -n1)
body=$(echo "$response" | head -n-1)
if [ "$status" = "$expected_status" ]; then
echo "✓ PASS: $desc ($method $path) - $status"
PASS=$((PASS + 1))
echo "$body" | jq '.' 2>/dev/null || echo "$body"
else
echo "✗ FAIL: $desc ($method $path) - Expected $expected_status, got $status"
FAIL=$((FAIL + 1))
echo "$body"
fi
echo "---"
}
echo "========================================="
echo "PHASE 1: DROPDOWN ENDPOINTS (7 endpoints)"
echo "========================================="
test_endpoint "GET" "/dropdowns/pets" "$STAFF_TOKEN" "200" "" "Get pets dropdown"
test_endpoint "GET" "/dropdowns/customers" "$STAFF_TOKEN" "200" "" "Get customers dropdown"
test_endpoint "GET" "/dropdowns/services" "$STAFF_TOKEN" "200" "" "Get services dropdown"
test_endpoint "GET" "/dropdowns/products" "$STAFF_TOKEN" "200" "" "Get products dropdown"
test_endpoint "GET" "/dropdowns/categories" "$STAFF_TOKEN" "200" "" "Get categories dropdown"
test_endpoint "GET" "/dropdowns/stores" "$STAFF_TOKEN" "200" "" "Get stores dropdown"
test_endpoint "GET" "/dropdowns/suppliers" "$ADMIN_TOKEN" "200" "" "Get suppliers dropdown (admin)"
echo ""
echo "========================================="
echo "SUMMARY: Phase 1"
echo "========================================="
echo "Total: $TOTAL | Pass: $PASS | Fail: $FAIL"