-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get products owned by normal user
- Loading branch information
Showing
4 changed files
with
86 additions
and
5 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
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
22 changes: 22 additions & 0 deletions
22
...application/src/main/java/com/pda/productapplication/repository/ProductSpecification.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.pda.productapplication.repository; | ||
|
||
import com.pda.productapplication.entity.Corp; | ||
import com.pda.productapplication.entity.Product; | ||
import jakarta.persistence.criteria.Join; | ||
import jakarta.persistence.criteria.JoinType; | ||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
public class ProductSpecification { | ||
// 상품명과 회사명을 기준으로 필터링 | ||
public static Specification<Product> equalProductName(String name) { | ||
return (root, query, criteriaBuilder) -> | ||
criteriaBuilder.equal(root.get("name"), name); | ||
} | ||
|
||
public static Specification<Product> equalCorpName(String corpName) { | ||
return (root, query, criteriaBuilder) -> { | ||
Join<Product, Corp> corpJoin = root.join("corp", JoinType.INNER); | ||
return criteriaBuilder.equal(corpJoin.get("name"), corpName); | ||
}; | ||
} | ||
} |
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
9f18cb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JpaSpecificationExecutor 사용