Commit a2938672 authored by suntao's avatar suntao

channel 查询

parent 7614df4a
...@@ -2,21 +2,11 @@ package cn.quantgroup.cashloanflowboss.api.channel.repository.clf; ...@@ -2,21 +2,11 @@ package cn.quantgroup.cashloanflowboss.api.channel.repository.clf;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration; import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import org.springframework.data.domain.Page; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface ChannelConfigurationRepository extends PagingAndSortingRepository<ChannelConfiguration, String> { public interface ChannelConfigurationRepository extends PagingAndSortingRepository<ChannelConfiguration, Long>, JpaSpecificationExecutor<ChannelConfiguration> {
/**
* 获取用户列表(分页)
*
* @param pageable 分页
* @return
*/
Page<ChannelConfiguration> findAllBy(Pageable pageable);
ChannelConfiguration findByRegisteredFrom(Integer channelId);
} }
...@@ -12,6 +12,11 @@ import org.springframework.data.domain.Page; ...@@ -12,6 +12,11 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.persistence.criteria.Predicate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/** /**
* function: * function:
* date: 2019/8/2 * date: 2019/8/2
...@@ -31,13 +36,25 @@ public class ChannelConfService { ...@@ -31,13 +36,25 @@ public class ChannelConfService {
public Page<ChannelConfiguration> getChannelInfo(Pagination pagination, Integer channelId) { public Page<ChannelConfiguration> getChannelInfo(Pagination pagination, Integer channelId) {
if (channelId == null) {
return clfChannelConfigurationRepository.findAllBy(new PageRequest(pagination.getPageNumber(), pagination.getPageSize())); Page<ChannelConfiguration> page = this.clfChannelConfigurationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> {
} else {
ChannelConfiguration channelConfiguration = clfChannelConfigurationRepository.findByRegisteredFrom(channelId); List<Predicate> predicates = new ArrayList<>();
Page<ChannelConfiguration> result = null;
return null; // 指定渠道号
} if (Objects.nonNull(channelId)) {
predicates.add(criteriaBuilder.equal(root.get("channelId"), channelId));
}
// 指定排序
criteriaQuery.orderBy(criteriaBuilder.desc(root.get("id")));
return criteriaQuery.getRestriction();
}, new PageRequest(pagination.getPageNumber(), pagination.getPageSize()));
return page;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment