Skip to content

Commit fe27453

Browse files
authored
♻️ refactor : menu 관련 컬럼명 추가 및 쿼리문 수정
♻️ refactor : menu 관련 컬럼명 추가 및 쿼리문 수정
2 parents 3a375f1 + e33ecf6 commit fe27453

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/main/java/com/example/Centralthon/domain/menu/entity/Menu.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public class Menu extends BaseEntity {
2424
@Column(nullable = false)
2525
private String name;
2626

27-
@Column(nullable = false)
27+
@Column(name = "cost_price", nullable = false)
2828
private int costPrice;
2929

30-
@Column(nullable = false)
30+
@Column(name = "sale_price", nullable = false)
3131
private int salePrice;
3232

3333
@Column(nullable = false)

src/main/java/com/example/Centralthon/domain/menu/entity/enums/MenuCategory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public enum MenuCategory {
99
BRAISED,
1010
SEASONED,
1111
STIR_FRY,
12-
GRILLED;
12+
STEAMED;
1313
}

src/main/java/com/example/Centralthon/domain/menu/repository/MenuRepository.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@
1010
import java.time.LocalDateTime;
1111
@Repository
1212
public interface MenuRepository extends JpaRepository<Menu, Long> {
13-
@Query(value = "SELECT m.* FROM menus m JOIN stores s ON m.store_id = s.store_id WHERE " +
14-
"s.latitude BETWEEN :minLat AND :maxLat " +
15-
"AND s.longitude BETWEEN :minLng AND :maxLng " +
16-
"AND ST_Distance_Sphere(POINT(s.longitude, s.latitude), POINT(:lng, :lat)) <= 2000 " +
17-
"AND m.quantity > 0 " +
18-
"AND m.deadline > :now", nativeQuery = true)
13+
@Query(value = """
14+
SELECT m.* FROM menus m
15+
JOIN stores s ON m.store_id = s.store_id
16+
WHERE s.latitude BETWEEN :minLat AND :maxLat AND s.longitude BETWEEN :minLng AND :maxLng
17+
AND ST_Distance_Sphere(POINT(s.longitude, s.latitude), POINT(:lng, :lat)) <= 2000
18+
AND m.quantity > 0 AND m.deadline > :now
19+
""", nativeQuery = true)
1920
List<Menu> findNearbyMenus(
20-
double lat,
21-
double lng,
22-
LocalDateTime now,
23-
double minLat,
24-
double maxLat,
25-
double minLng,
26-
double maxLng
21+
@Param("lat") double lat,
22+
@Param("lng") double lng,
23+
@Param("now") LocalDateTime now,
24+
@Param("minLat") double minLat,
25+
@Param("maxLat") double maxLat,
26+
@Param("minLng") double minLng,
27+
@Param("maxLng") double maxLng
2728
);
2829

2930

0 commit comments

Comments
 (0)