|
|
@@ -20,6 +20,7 @@ import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -146,6 +147,37 @@ public class BrandServiceImpl implements BrandService {
|
|
|
}, pageInfo);
|
|
|
}
|
|
|
|
|
|
+ public Page<BrandInfo> getBrandInfoPage(final PageInfo pageInfo, String keyword, String inital){
|
|
|
+ if (StringUtils.hasText(keyword)) {
|
|
|
+ SimpleExpression[] simpleArrs = new SimpleExpression[2];
|
|
|
+ simpleArrs[0] = new SimpleExpression("nameCn", keyword, Operator.LIKE, true);
|
|
|
+ simpleArrs[1] = new SimpleExpression("nameEn", keyword, Operator.LIKE, true);
|
|
|
+ LogicalExpression logical1 = new LogicalExpression(simpleArrs, Operator.OR);
|
|
|
+ pageInfo.expression(logical1);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(inital)){
|
|
|
+ if ("0~9".equals(inital)) {
|
|
|
+ String[] initals = new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
|
|
+ SimpleExpression[] numEx = new SimpleExpression[10];
|
|
|
+ for (int i = 0; i < 10; i++){
|
|
|
+ numEx[i] = new SimpleExpression("inital", initals[i], Operator.EQ, true);
|
|
|
+ }
|
|
|
+ LogicalExpression logical2 = new LogicalExpression(numEx, Operator.OR);
|
|
|
+ pageInfo.expression(logical2);
|
|
|
+ } else {
|
|
|
+ pageInfo.filter("inital", inital);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageInfo.sorting(Sort.Direction.ASC, "nameEn");
|
|
|
+ return brandInfoDao.findAll(new Specification<BrandInfo>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<BrandInfo> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
+ query.where(pageInfo.getPredicates(root, query, builder));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Brand findByUuid(String uuid) {
|
|
|
// 这个因为是接口错误的话直接返回
|