Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public class Menu extends BaseEntity {
@Column(nullable = false)
private String name;

@Column(nullable = false)
@Column(name = "cost_price", nullable = false)
private int costPrice;

@Column(nullable = false)
@Column(name = "sale_price", nullable = false)
private int salePrice;

@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public enum MenuCategory {
BRAISED,
SEASONED,
STIR_FRY,
GRILLED;
STEAMED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
import java.time.LocalDateTime;
@Repository
public interface MenuRepository extends JpaRepository<Menu, Long> {
@Query(value = "SELECT m.* FROM menus m JOIN stores s ON m.store_id = s.store_id WHERE " +
"s.latitude BETWEEN :minLat AND :maxLat " +
"AND s.longitude BETWEEN :minLng AND :maxLng " +
"AND ST_Distance_Sphere(POINT(s.longitude, s.latitude), POINT(:lng, :lat)) <= 2000 " +
"AND m.quantity > 0 " +
"AND m.deadline > :now", nativeQuery = true)
@Query(value = """
SELECT m.* FROM menus m
JOIN stores s ON m.store_id = s.store_id
WHERE s.latitude BETWEEN :minLat AND :maxLat AND s.longitude BETWEEN :minLng AND :maxLng
AND ST_Distance_Sphere(POINT(s.longitude, s.latitude), POINT(:lng, :lat)) <= 2000
AND m.quantity > 0 AND m.deadline > :now
""", nativeQuery = true)
List<Menu> findNearbyMenus(
double lat,
double lng,
LocalDateTime now,
double minLat,
double maxLat,
double minLng,
double maxLng
@Param("lat") double lat,
@Param("lng") double lng,
@Param("now") LocalDateTime now,
@Param("minLat") double minLat,
@Param("maxLat") double maxLat,
@Param("minLng") double minLng,
@Param("maxLng") double maxLng
);


Expand Down