diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml
index 881c46e..182ec63 100644
--- a/.github/workflows/build_and_test.yml
+++ b/.github/workflows/build_and_test.yml
@@ -1,23 +1,23 @@
-
-name: Java CI with Maven
-
-on:
- pull_request:
- branches: [ "main" ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 21
- uses: actions/setup-java@v4
- with:
- java-version: '21'
- distribution: 'temurin'
- cache: maven
- - name: Build with Maven
- run: mvn clean install
-
+#
+#name: Java CI with Maven
+#
+#on:
+# pull_request:
+# branches: [ "main" ]
+#
+#jobs:
+# build:
+#
+# runs-on: ubuntu-latest
+#
+# steps:
+# - uses: actions/checkout@v4
+# - name: Set up JDK 21
+# uses: actions/setup-java@v4
+# with:
+# java-version: '21'
+# distribution: 'temurin'
+# cache: maven
+# - name: Build with Maven
+# run: mvn clean install
+#
diff --git a/pom.xml b/pom.xml
index 757b32d..6af4e92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -125,6 +125,15 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 21
+ --enable-preview
+
+
\ No newline at end of file
diff --git a/src/main/java/com/github/nhatoriginal/spring/config/JwtAuthenticationFilter.java b/src/main/java/com/github/nhatoriginal/spring/config/JwtAuthenticationFilter.java
index 3aeaed3..de22425 100644
--- a/src/main/java/com/github/nhatoriginal/spring/config/JwtAuthenticationFilter.java
+++ b/src/main/java/com/github/nhatoriginal/spring/config/JwtAuthenticationFilter.java
@@ -65,7 +65,10 @@ protected void doFilterInternal(@NonNull HttpServletRequest request,
filterChain.doFilter(request, response);
return;
}
-
+ if (isPublicEndpoint(request)) {
+ filterChain.doFilter(request, response);
+ return;
+ }
try {
String authHeader = request.getHeader("Authorization");
if (StringUtils.isEmpty(authHeader) || !StringUtils.startsWith(authHeader, "Bearer ")) {
@@ -110,7 +113,9 @@ private boolean isPreflightRequest(HttpServletRequest request) {
private boolean isAuthEndpoint(HttpServletRequest request) {
return request.getRequestURI().contains("/api/v1/auth");
}
-
+ private boolean isPublicEndpoint(HttpServletRequest request) {
+ return Objects.equals(request.getRequestURI(), "/api/v1/menu-item") && request.getMethod().equals("GET");
+ }
private void setAuthenticationContext(UserDetails userDetails, HttpServletRequest request) {
SecurityContext context = SecurityContextHolder.createEmptyContext();
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(
diff --git a/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java b/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java
index 569ea93..e9582bc 100644
--- a/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java
+++ b/src/main/java/com/github/nhatoriginal/spring/controller/MenuItemController.java
@@ -36,10 +36,10 @@ public ResponseEntity create(@RequestBody MenuItemDetailDto m
}
@PreAuthorize("hasAuthority('ROLE_OWNER')")
@GetMapping(Endpoint.MenuItem.GET_ALL_BY_MENU_ID)
- public ResponseEntity> findAllByMenuId(@PathVariable UUID menuId) {
- return ResponseEntity.ok(menuItemService.findAllByMenuId(menuId));
+ public ResponseEntity> findAllByMenuId(@PathVariable UUID menuId, @RequestParam(defaultValue = "") String name) {
+ return ResponseEntity.ok(menuItemService.findAllByMenuId(menuId, name));
}
- @PreAuthorize("hasAuthority('ROLE_OWNER')")
+ @PreAuthorize("hasAuthority('ROLE_OWNER')")
@PatchMapping(Endpoint.MenuItem.UPDATE)
public MenuItemDetailDto update(@PathVariable UUID id, @RequestBody MenuItemDetailDto menuItemDto) {
return menuItemService.update(id, menuItemDto);
@@ -53,8 +53,4 @@ public ResponseEntity delete(@PathVariable UUID id) {
public MenuItemDetailDto findById(@PathVariable UUID id) {
return menuItemService.findById(id);
}
-// @GetMapping("")
-// public List findAllByOwner() {
-// return menuItemService.findAll(null);
-// }
}
diff --git a/src/main/java/com/github/nhatoriginal/spring/model/MenuItem.java b/src/main/java/com/github/nhatoriginal/spring/model/MenuItem.java
index 1d1c005..056162f 100644
--- a/src/main/java/com/github/nhatoriginal/spring/model/MenuItem.java
+++ b/src/main/java/com/github/nhatoriginal/spring/model/MenuItem.java
@@ -29,7 +29,7 @@ public class MenuItem {
@Column(name = "name", nullable = false)
private String name;
- @Column(name = "description", nullable = true)
+ @Column(name = "description")
private String description;
@Column(name = "image_url", nullable = false)
@@ -37,7 +37,8 @@ public class MenuItem {
@JsonManagedReference
@OneToMany(mappedBy = "menuItem")
private List menuItemOptions;
-
+ @Column(name="is_delete", nullable = false)
+ private boolean isDelete = false;
@OneToMany(mappedBy = "menuItem")
private List reviews;
@JsonManagedReference
diff --git a/src/main/java/com/github/nhatoriginal/spring/repository/MenuItemRepository.java b/src/main/java/com/github/nhatoriginal/spring/repository/MenuItemRepository.java
index 42e158d..c43430c 100644
--- a/src/main/java/com/github/nhatoriginal/spring/repository/MenuItemRepository.java
+++ b/src/main/java/com/github/nhatoriginal/spring/repository/MenuItemRepository.java
@@ -1,17 +1,26 @@
package com.github.nhatoriginal.spring.repository;
+import jakarta.transaction.Transactional;
+import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.github.nhatoriginal.spring.model.MenuItem;
-
+import java.util.Optional;
import java.util.List;
import java.util.UUID;
@Repository
public interface MenuItemRepository extends JpaRepository