Skip to content

Commit

Permalink
feat(BE) : 기프티콘 삭제를 위한 쿼리 추가 및 다른 기프티콘 select 쿼리에 삭제 여부 판별 추가(#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktykty0722 committed Feb 22, 2023
1 parent a6ed88b commit 808064f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface GifticonRepository extends CrudRepository<Gifticon, Long> {
"barcode, " +
"expiresAt, " +
"usedAt, " +
"price FROM gifticon WHERE id = :id")
"price FROM gifticon WHERE id = :id AND deleted = 0")
Optional<Gifticon> findById(@Param("id") long id);

@Modifying
Expand Down Expand Up @@ -58,7 +58,7 @@ void addGifticon(
"expiresAt, " +
"usedAt, " +
"price FROM gifticon WHERE uid = :uid AND (usedAt >= (select now())) AND " +
"(itemName LIKE concat('%', :keyword, '%') OR brandName LIKE concat('%', :keyword, '%'))")
"(itemName LIKE concat('%', :keyword, '%') OR brandName LIKE concat('%', :keyword, '%')) AND deleted = 0")
List<Gifticon> findByUid(@Param("uid") long uid, @Param("keyword") String keyword);

@Modifying
Expand All @@ -78,6 +78,10 @@ void addGifticon(
"barcode, " +
"expiresAt, " +
"usedAt, " +
"price FROM gifticon WHERE uid = :uid AND usedAt <= (select now())")
"price FROM gifticon WHERE uid = :uid AND usedAt <= (select now()) AND deleted = 0")
List<Gifticon> findUsedByUid(@Param("uid") long uid);

@Modifying
@Query("UPDATE gifticon SET deleted = 1 WHERE id = :id")
void deleteGifticon(@Param("id") long id);
}

0 comments on commit 808064f

Please sign in to comment.