當前位置: 首頁>>代碼示例>>Java>>正文


Java Page.getTotalElements方法代碼示例

本文整理匯總了Java中org.springframework.data.domain.Page.getTotalElements方法的典型用法代碼示例。如果您正苦於以下問題:Java Page.getTotalElements方法的具體用法?Java Page.getTotalElements怎麽用?Java Page.getTotalElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.domain.Page的用法示例。


在下文中一共展示了Page.getTotalElements方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: listForSaleByPage

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
@Transactional(readOnly = true)
public Page<EstateItemDTO> listForSaleByPage(Pageable pageable, Map<String, Object> paramMap) throws Exception {
    String cacheKey = CacheKeyGenerator.generate(EstateItemDTO.class, "listForSaleByPage", pageable, paramMap);

    Page<EstateItemDTO> targetItemPage = new PageX();

    // 讀取緩存數據
    targetItemPage = byteRedisClient.getByteObj(cacheKey, targetItemPage.getClass());
    if (targetItemPage != null && CollectionUtils.isNotEmpty(targetItemPage.getContent())) {
        return new PageX(targetItemPage.getContent(), pageable, targetItemPage.getTotalElements());
    } else {
        Page<EstateItemModel> sourceItemPage = estateItemRepository.findAll(EstateItemSpecification.getForSaleSpec(paramMap), pageable);
        List<EstateItemModel> sourceItemList = sourceItemPage.getContent();

        if (CollectionUtils.isNotEmpty(sourceItemList)) {
            List<EstateItemDTO> targetItemList = new ArrayList();
            for (EstateItemModel model : sourceItemList) {
                EstateItemDTO dto = new EstateItemDTO();
                CachedBeanCopier.copy(model, dto);
                if (StringUtils.isBlank(dto.getCoverUrl())) dto.setCoverUrl("/3rd-party/porto/img/blank.jpg");
                dto.setDetailHref("/estate/" + dto.getHouseCode() + ".shtml");
                dto.setTotalPriceStr(dto.getTotalPrice() + "萬");
                dto.setUnitPriceStr("單價" + dto.getUnitPrice() + "萬");
                dto.setDownPayments(dto.getUnitPriceStr() + ", 首付" + BigDecimal.valueOf(0.3d).multiply(dto.getTotalPrice()).setScale(2, BigDecimal.ROUND_HALF_DOWN) + "萬");
                dto.setAreaStr(dto.getArea() + "平米");
                dto.setFocusNumStr(dto.getFocusNum() + "人關注");
                dto.setWatchNumStr(dto.getWatchNum() + "次帶看");
                dto.setNewEstate(dto.getUpdateTime().isAfter(TimeUtil.nowDateTime().minusDays(3))); // 是當前日期三天前發布的
                targetItemList.add(dto);
            }
            targetItemPage = new PageX(targetItemList, pageable, sourceItemPage.getTotalElements());

            // 數據寫入緩存
            byteRedisClient.setByteObj(cacheKey, targetItemPage, 3600);
        }

        return targetItemPage;
    }
}
 
開發者ID:lupindong,項目名稱:xq_seckill_microservice,代碼行數:41,代碼來源:EstateServiceImpl.java

示例2: getAll

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@GetMapping
public PageResult getAll(Reply reply, Integer uid, String draw,
                         @RequestParam(required = false, defaultValue = "1") int start,
                         @RequestParam(required = false, defaultValue = "10") int length) {
    int pageNo = start / length;
    if (uid!=null){
        User user = userService.findOne(uid);
        reply.setUser(user);
    }

    Page<Reply> page = replyService.findByPage(reply, pageNo, length);
    PageResult<List<Reply>> result = new PageResult<>(
            draw,
            page.getTotalElements(),
            page.getTotalElements(),
            page.getContent());
    return result;
}
 
開發者ID:ChinaLHR,項目名稱:JavaQuarkBBS,代碼行數:19,代碼來源:ReplyController.java

示例3: getInstancesByNamespace

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@RequestMapping(value = "/by-namespace", method = RequestMethod.GET)
public PageDTO<InstanceDTO> getInstancesByNamespace(
    @RequestParam("appId") String appId, @RequestParam("clusterName") String clusterName,
    @RequestParam("namespaceName") String namespaceName,
    @RequestParam(value = "instanceAppId", required = false) String instanceAppId,
    Pageable pageable) {
  Page<Instance> instances;
  if (Strings.isNullOrEmpty(instanceAppId)) {
    instances = instanceService.findInstancesByNamespace(appId, clusterName,
        namespaceName, pageable);
  } else {
    instances = instanceService.findInstancesByNamespaceAndInstanceAppId(instanceAppId, appId,
        clusterName, namespaceName, pageable);
  }

  List<InstanceDTO> instanceDTOs = BeanUtils.batchTransform(InstanceDTO.class, instances.getContent());
  return new PageDTO<>(instanceDTOs, pageable, instances.getTotalElements());
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:19,代碼來源:InstanceConfigController.java

示例4: list

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@RequestMapping(path="/list")
	public String list(DictionarySearchCriteria criteria
			, Map<String, Object> model) {
		// setting default pageSize and sortFields
		if (criteria.isFirstInitialized()) {
			criteria.setPageSize(10);
			criteria.setSortFields("id:asc");
		}
//		logger.info("----------------------{}-------------------------", DictionaryType.PREDEFINED);
		Page<Dictionary> searchResult = this.dictionaryService.findAll(criteria.getPageable());
		Pagination pagination = new Pagination(criteria.getPageNo(), searchResult.getTotalPages(), searchResult.getTotalElements());
		model.put("searchResult", searchResult);
		model.put("criteria", criteria);
		model.put("pagination", pagination);
		return "tool/dictionary_list";
	}
 
開發者ID:Kevin-Huang-NZ,項目名稱:springboot-jsp-generator,代碼行數:17,代碼來源:DictionaryController.java

示例5: index

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@GetMapping(value = "/blog")
public String index(@RequestParam(value = "page", defaultValue = "0") Integer page,Model model) {
    if(page != 0) page = page -1;

    List<ArticleDto> topArticle = articleService.getArticleRecentPostsTopN(5);
    model.addAttribute("topArticle",topArticle);

    Page<ArticleDto> listArticle = articleService.list(page, ArticleUtils.getIsPublished());
    model.addAttribute("listArticle",listArticle.getContent());

    List<CategoriesDto> categoriesList = categoriesService.getCategoriesArticleCount();
    model.addAttribute("categoriesList",categoriesList);

    PageUtils pageUtils = new PageUtils("/blog?",page,listArticle.getTotalPages(),listArticle.getTotalElements(),itweetProperties.getPagSize());
    model.addAttribute("pb",pageUtils);

    return "front/theme/twts/index";
}
 
開發者ID:realxujiang,項目名稱:itweet-boot,代碼行數:19,代碼來源:TwtsController.java

示例6: findAll

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public <DTO extends IGenericDTO<PK>> Page<DTO> findAll(Class<DTO> dtoClass, Specification<E> spec,
		Pageable pageable) throws Exception {
	Page<E> sp = findAll(spec, pageable);
	Page<DTO> dp = new PageImpl<DTO>(BeanMapper.map(sp.getContent(), dtoClass), pageable, sp.getTotalElements());
	return dp;
}
 
開發者ID:onsoul,項目名稱:os,代碼行數:9,代碼來源:GenericService.java

示例7: getAll

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@GetMapping
public PageResult getAll(String draw,
                         @RequestParam(required = false, defaultValue = "1") int start,
                         @RequestParam(required = false, defaultValue = "10") int length){
    int pageNo = start/length;
    Page<Permission> page = permissionService.findByPage(pageNo, length);
    PageResult<List<Permission>> result = new PageResult<>(
            draw,
            page.getTotalElements(),
            page.getTotalElements(),
            page.getContent());

    return result;
}
 
開發者ID:ChinaLHR,項目名稱:JavaQuarkBBS,代碼行數:15,代碼來源:PermissionController.java

示例8: getUsersByAppRoleId

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
public Page<UserSummary> getUsersByAppRoleId(String roleId, UserQueryParameter request) {
	Page<User> users = appRoleService.listBindUsers(roleId, request);
	return new PageImpl<>(users.getContent().stream().map(UserSummary::from).collect(Collectors.toList()),
						  new PageRequest(request.getStart(), request.getLimit()),
						  users.getTotalElements());
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:8,代碼來源:SysRoleRestSupportImpl.java

示例9: listArchivedUsers

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
public Page<UserSummary> listArchivedUsers(UserQueryParameter queryRequest) {
	queryRequest.setEnabled(null);
	Page<User> userPage = accountService.listArchivedUsers(queryRequest);
	return new PageImpl<>(userPage.getContent().stream().map(UserSummary::from).collect(Collectors.toList()),
						  new PageRequest(queryRequest.getStart(), queryRequest.getLimit()),
						  userPage.getTotalElements());
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:9,代碼來源:ArchivedUserRestSupportImpl.java

示例10: all

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@GetMapping("all")
public String all(@RequestParam(value = "page", defaultValue = "0") int pageNumber, Model model) {
	if (pageNumber < 0) {
		return "redirect:/measurements/all?page=0";
	} else {
		Page<WeightMeasurement> page = measurementsManager.findAsPageDesc(pageNumber, paginationConfig.getPageSize());
		if (pageNumber >= page.getTotalPages() && page.getTotalElements() > 0) {
			return "redirect:/measurements/all?page=0";
		} else {
			model.addAttribute(FatLiningConstants.FIELD_PAGE, pageWrapperFactory.create(page));
			return FatLiningConstants.VIEW_MEASUREMENTS;
		}
	}
}
 
開發者ID:xabgesagtx,項目名稱:fat-lining,代碼行數:15,代碼來源:WeightMeasurementsController.java

示例11: getAppRoles

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
public Page<RoleSummary> getAppRoles(RoleQueryRequest request) {
	Page<AppRole> appRoles = appRoleService.listAppRoles(request);
	return new PageImpl<>(appRoles.getContent().stream().map(RoleSummary::from).collect(Collectors.toList()),
						  new PageRequest(request.getStart(), request.getLimit()),
						  appRoles.getTotalElements());
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:8,代碼來源:SysRoleRestSupportImpl.java

示例12: listBindUsers

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
public Page<User> listBindUsers(String id, UserQueryRequest request) {
	AppRole appRole = findById(id);
	Page<UserRoleRelationship> relationships = relationshipRepository.findByRole(appRole,
																				 new PageRequest(request.getStart(),
																									request.getLimit()));
	return new PageImpl<>(relationships.getContent()
									   .stream()
									   .map(UserRoleRelationship::getUser)
									   .collect(Collectors.toList()),
						  new PageRequest(request.getStart(), request.getLimit()),
						  relationships.getTotalElements());
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:14,代碼來源:RoleServiceImpl.java

示例13: list

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
/**
 *文章列表
 * @param page
 * @param pageSize
 * @param model
 * @return
 */
@RequestMapping(value = "/list",method = RequestMethod.GET)
public String list(@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, Model model) {
    if(page !=0) page = page -1;

    Page<ArticleDto> articleList = articleService.list(page);
    model.addAttribute("articleList",articleList);

    PageUtils pageUtils = new PageUtils("/admin/article/list?",page,articleList.getTotalPages(),articleList.getTotalElements(),pageSize);
    model.addAttribute("pb",pageUtils);

    return "admin/article/a_list";
}
 
開發者ID:realxujiang,項目名稱:itweet-boot,代碼行數:20,代碼來源:ArticleController.java

示例14: findListAll

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@Override
public Page<OrderDTO> findListAll(Pageable pageable) {
    Page<OrderMaster> orderMasterPage = orderMasterRepository.findAll(pageable);
    List<OrderDTO> orderDTOList = OrderMasterToOrderDTOConverter.convert(orderMasterPage.getContent());
    return new PageImpl<OrderDTO>(orderDTOList, pageable, orderMasterPage.getTotalElements());

}
 
開發者ID:ldlood,項目名稱:SpringBoot_Wechat_Sell,代碼行數:8,代碼來源:OrderServiceImpl.java

示例15: tweet

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@GetMapping(value = "/tweet")
public String tweet(@RequestParam(value = "page", defaultValue = "0") Integer page,Model model) {
    if(page != 0) page = page -1;

    model.addAttribute("tweet","selected");
    Page<ArticleDto> listArticle = articleService.list(page, ArticleUtils.getIsPublished(),ArticleUtils.getIsTweet());
    model.addAttribute("listArticle",listArticle);

    PageUtils pageUtils = new PageUtils("/tweet",page,listArticle.getTotalPages(),listArticle.getTotalElements(),itweetProperties.getPagSize());
    model.addAttribute("pb",pageUtils);

    return "front/theme/effe/tweet";
}
 
開發者ID:realxujiang,項目名稱:itweet-boot,代碼行數:14,代碼來源:EffeController.java


注:本文中的org.springframework.data.domain.Page.getTotalElements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。