-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update search query and refactory code
- Loading branch information
Showing
12 changed files
with
128 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 13 additions & 4 deletions
17
src/main/java/com/github/nhatoriginal/spring/repository/MenuItemRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MenuItem, UUID> { | ||
List<MenuItem> findByNameContaining(String name); | ||
|
||
@Query(nativeQuery = true, value = "SELECT * FROM menu_items WHERE menu_id = :menuId") | ||
List<MenuItem> findAllByMenuId(UUID menuId); | ||
List<MenuItem> findByNameContainingAndIsDeleteFalse(String name); | ||
List<MenuItem> findAllByMenuIdAndNameContainingAndIsDeleteFalse(UUID menuId, String name); | ||
@Modifying | ||
@Transactional | ||
@Query(nativeQuery = true, value = "UPDATE menu_items SET is_delete = :b WHERE id = :id") | ||
void updateIsDelete(UUID id, boolean b); | ||
@Query(nativeQuery = true, value = "SELECT * FROM menu_items WHERE id = :id AND is_delete = false") | ||
Optional<MenuItem> findByIdAndIsDeleteFalse(UUID id); | ||
@Query(nativeQuery = true, value = "SELECT * FROM menu_items WHERE is_delete = false") | ||
List<MenuItem> findAllWithIsDeleteFalse(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters