org.springframework.data.domain.Sort.Direction#DESC源码实例Demo

下面列出了org.springframework.data.domain.Sort.Direction#DESC 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hermes   文件: DictionaryServiceImpl.java
@Override
public Page<Dictionary> queryByCondition(final Dictionary dictionary, final String id, String page, String size) throws Exception {
	 Pageable pageable = new PageRequest(Integer.valueOf(Strings.empty(page, "0")), Integer.valueOf(Strings.empty(size, "10")), new Sort(Direction.DESC,  "createTime"));
	 return  dictionaryRepository.findAll(new Specification<Dictionary>() {
		@Override
		public Predicate toPredicate(Root<Dictionary> root, CriteriaQuery<?> query,CriteriaBuilder cb) {
			List<Predicate> list = new ArrayList<Predicate>();
			if (StringUtils.isNotEmpty(dictionary.getCode())) {
				list.add(cb.like(root.<String>get("code"), "%"+dictionary.getCode().trim()+"%"));
			}
			if (StringUtils.isNotEmpty(dictionary.getName())) {
				list.add(cb.like(root.<String>get("name"), "%"+dictionary.getName().trim()+"%"));
			}
			if (StringUtils.isNotEmpty(id)) {
				list.add(cb.equal(root.<String>get("type").<String>get("id"), id));
			}
			return cb.and(list.toArray(new Predicate[list.size()]));
		}
	},pageable);
}
 
源代码2 项目: hawkbit   文件: ActionStatusBeanQuery.java
/**
 * Parametric Constructor.
 *
 * @param definition
 *            QueryDefinition contains the query properties.
 * @param queryConfig
 *            Implementation specific configuration.
 * @param sortPropertyIds
 *            The properties participating in sort.
 * @param sortStates
 *            The ascending or descending state of sort properties.
 */
public ActionStatusBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
        final Object[] sortPropertyIds, final boolean[] sortStates) {
    super(definition, queryConfig, sortPropertyIds, sortStates);

    if (isNotNullOrEmpty(queryConfig)) {
        currentSelectedActionId = (Long) queryConfig.get(SPUIDefinitions.ACTIONSTATES_BY_ACTION);
    }

    if (sortStates != null && sortStates.length > 0) {
        // Initialize sort
        sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
        // Add sort
        for (int distId = 1; distId < sortPropertyIds.length; distId++) {
            sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC,
                    (String) sortPropertyIds[distId]));
        }
    }
}
 
源代码3 项目: spring4-sandbox   文件: TaskController.java
private List<TaskDetails> findByStatus(Status status) {
	Sort sort = new Sort(Direction.DESC, "lastModifiedDate");

	List<TaskDetails> detailsList = new ArrayList<>();
	List<Task> tasks = taskRepository.findByStatus(status, sort);

	for (Task task : tasks) {
		TaskDetails details = new TaskDetails();
		details.setId(task.getId());
		details.setName(task.getName());
		details.setDescription(task.getDescription());
		details.setCreatedDate(task.getCreatedDate());
		details.setLastModifiedDate(task.getLastModifiedDate());
		detailsList.add(details);
	}
	return detailsList;
}
 
源代码4 项目: hawkbit   文件: ArtifactBeanQuery.java
/**
 * Parametric Constructor.
 *
 * @param definition
 *            as Def
 * @param queryConfig
 *            as Config
 * @param sortIds
 *            as sort
 * @param sortStates
 *            as Sort status
 */
public ArtifactBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
        final Object[] sortIds, final boolean[] sortStates) {

    super(definition, queryConfig, sortIds, sortStates);

    if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
        baseSwModuleId = (Long) queryConfig.get(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE);
    }

    if (!ArrayUtils.isEmpty(sortStates)) {
        sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);

        for (int targetId = 1; targetId < sortIds.length; targetId++) {
            sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
        }
    }
}
 
源代码5 项目: hawkbit   文件: ActionBeanQuery.java
/**
 * Parametric Constructor.
 *
 * @param definition
 *            QueryDefinition contains the query properties.
 * @param queryConfig
 *            Implementation specific configuration.
 * @param sortPropertyIds
 *            The properties participating in sort.
 * @param sortStates
 *            The ascending or descending state of sort properties.
 */
public ActionBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
        final Object[] sortPropertyIds, final boolean[] sortStates) {
    super(definition, queryConfig, sortPropertyIds, sortStates);

    if (isNotNullOrEmpty(queryConfig)) {
        currentSelectedConrollerId = (String) queryConfig.get(SPUIDefinitions.ACTIONS_BY_TARGET);
    }

    if (sortStates == null || sortStates.length <= 0) {
        return;
    }

    // Initialize sort
    sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
    // Add sort
    for (int distId = 1; distId < sortPropertyIds.length; distId++) {
        sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId]));
    }
}
 
源代码6 项目: spring4-sandbox   文件: TaskController.java
private List<TaskDetails> findByStatus(Status status) {
	Sort sort = new Sort(Direction.DESC, "lastModifiedDate");

	List<TaskDetails> detailsList = new ArrayList<>();
	List<Task> tasks = taskRepository.findByStatus(status, sort);

	for (Task task : tasks) {
		TaskDetails details = new TaskDetails();
		details.setId(task.getId());
		details.setName(task.getName());
		details.setDescription(task.getDescription());
		details.setCreatedDate(task.getCreatedDate());
		details.setLastModifiedDate(task.getLastModifiedDate());
		detailsList.add(details);
	}
	return detailsList;
}
 
源代码7 项目: hermes   文件: CmsController.java
@RequestMapping("notice/{cid}")
public String noticeArticleCategory(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer size, @PathVariable String cid, Model model) {
	Pageable pageable = new PageRequest(page, size, new Sort(Direction.DESC, "order", "updateTime"));
	Page<Article> dataBox = articleService.find(cid, pageable);
	if (dataBox.getContent().size() == 1) {
		return "redirect:/notice/" + cid + "/" + dataBox.getContent().get(0).getId();
	} else {
		model.addAttribute("nav", articleCategoryRepository.findByCode(helpCenterCode));
		model.addAttribute("sel", articleCategoryRepository.findOne(cid));
		model.addAttribute("aeli", dataBox);
		return "cms/notice_li";
	}
}
 
源代码8 项目: activiti6-boot2   文件: AbstractModelsResource.java
protected Sort getSort(String sort, boolean prefixWithProcessModel) {
  String propName;
  Direction direction;
  if (SORT_NAME_ASC.equals(sort)) {
    if (prefixWithProcessModel) {
      propName = "model.name";
    } else {
      propName = "name";
    }
    direction = Direction.ASC;
  } else if (SORT_NAME_DESC.equals(sort)) {
    if (prefixWithProcessModel) {
      propName = "model.name";
    } else {
      propName = "name";
    }
    direction = Direction.DESC;
  } else if (SORT_MODIFIED_ASC.equals(sort)) {
    if (prefixWithProcessModel) {
      propName = "model.lastUpdated";
    } else {
      propName = "lastUpdated";
    }
    direction = Direction.ASC;
  } else {
    // Default sorting
    if (prefixWithProcessModel) {
      propName = "model.lastUpdated";
    } else {
      propName = "lastUpdated";
    }
    direction = Direction.DESC;
  }
  return new Sort(direction, propName);
}
 
源代码9 项目: cloudstreetmarket.com   文件: IndexController.java
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Get overviews of indices", notes = "Return a page of index-overviews")
public PagedResources<IndexResource> getSeveral(
		@RequestParam(value="exchange", required=false) String exchangeId,
		@RequestParam(value="market", required=false) MarketId marketId,
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"previousClose"}, direction=Direction.DESC) Pageable pageable){
	return pagedAssembler.toResource(indexService.gather(exchangeId, marketId, pageable), assembler);
}
 
源代码10 项目: website   文件: BulkImportController.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String detail(Model model, @PathVariable("id") ImportJob importJob, @PageableDefault(size = PAGE_SIZE, sort="createdDate", direction=Direction.DESC) Pageable pageable) {
    ImportJobDto importJobDto = createImportJobDto(importJob);
    model.addAttribute("importJobDto", importJobDto);
    
    return "bulk/detail";
}
 
源代码11 项目: mongodb-file-server   文件: FileServiceImpl.java
@Override
public List<File> listFilesByPage(int pageIndex, int pageSize) {
	Page<File> page = null;
	List<File> list = null;
	
	Sort sort = new Sort(Direction.DESC,"uploadDate"); 
	Pageable pageable = PageRequest.of(pageIndex, pageSize, sort);
	
	page = fileRepository.findAll(pageable);
	list = page.getContent();
	return list;
}
 
源代码12 项目: hermes   文件: PropertiesServiceImpl.java
@Override
public Page<Properties> queryByCondition(final Properties properties, final String typeId,String page, String size) throws Exception {
	 Pageable pageable = new PageRequest(Integer.valueOf(Strings.empty(page, "0")), Integer.valueOf(Strings.empty(size, "10")), new Sort(Direction.DESC,  "createTime"));
	 return  propertiesRepository.findAll(new Specification<Properties>() {
		@Override
		public Predicate toPredicate(Root<Properties> root, CriteriaQuery<?> query,CriteriaBuilder cb) {
			List<Predicate> list = new ArrayList<Predicate>();
			if (StringUtils.isNotEmpty(properties.getCode())) {
				list.add(cb.like(root.<String>get("code"), "%"+properties.getCode().trim()+"%"));
			}
			if (StringUtils.isNotEmpty(properties.getName())) {
				list.add(cb.like(root.<String>get("name"), "%"+properties.getName().trim()+"%"));
			}
			if (StringUtils.isNotEmpty(properties.getStatus())) {
				list.add(cb.equal(root.<String>get("status"), properties.getStatus().trim()));
			}
			if (StringUtils.isNotEmpty(typeId)) {
				list.add(cb.equal(root.<String>get("type").<String>get("id"), typeId));
			}
			Dictionary  dict = dictionaryRepository.findByCodeAndStatus(HermesConstants.PLAT_TYPE,HermesConstants.CODE_00);
			if(dict != null){
			     list.add(cb.notEqual(root.<String>get("type").<String>get("id"), dict.getId()));
			}
			return cb.and(list.toArray(new Predicate[list.size()]));
		}
	},pageable);
}
 
源代码13 项目: init-spring   文件: PersonService.java
@Transactional(readOnly = true)
public Page<Person> findAllForPagination(int page, int size)
{
	Pageable pageable = new PageRequest(page, size, new Sort(Direction.DESC, "id"));
	Page<Person> persons = personRepository.findAll(pageable);
	return persons;
}
 
源代码14 项目: hermes   文件: ApiLogServiceImpl.java
/**
 * 外围日志列表
 * @param page
 * @param size
 */
@Override
public Page<ApiLog> queryByCondition(final ApiLogVo apiLogVo, String page, String size) throws Exception {
	 Pageable pageable = new PageRequest(Integer.valueOf(Strings.empty(page, "0")), Integer.valueOf(Strings.empty(size, "10")), new Sort(Direction.DESC,  "createTime"));
	 return  apiLogRepository.findAll(new Specification<ApiLog>() {
		@Override
		public Predicate toPredicate(Root<ApiLog> root, CriteriaQuery<?> query,CriteriaBuilder cb) {
			List<Predicate> list = new ArrayList<Predicate>();
			if (StringUtils.isNotEmpty(apiLogVo.getSerialNo())) {
				list.add(cb.like(root.<String>get("serialNo"), "%"+apiLogVo.getSerialNo().trim()+"%"));
			}
			if (StringUtils.isNotEmpty(apiLogVo.getInterfaceName())) {
				list.add(cb.like(root.<String>get("interfaceName"), "%"+apiLogVo.getInterfaceName().trim()+"%"));
			}
			if (StringUtils.isNotEmpty(apiLogVo.getStatus())) {
				list.add(cb.equal(root.<String>get("dealFlag"), apiLogVo.getStatus().trim()));
			}
			if(StringUtils.isNotEmpty(apiLogVo.getBeginDate()) && StringUtils.isNotEmpty(apiLogVo.getEndDate())){
				Date beginDate = null, endDate = null;
				try{
						beginDate = Calendars.parse("yyyy-MM-dd HH:mm:ss", apiLogVo.getBeginDate());
						endDate = Calendars.parse("yyyy-MM-dd HH:mm:ss", apiLogVo.getEndDate());
				}catch(Exception e){
					Logger.error("日志列表查询:格式化导入开始时间["+beginDate+"],结束时间["+endDate+"],异常,忽略时间查询条件");
				}
				list.add(cb.greaterThanOrEqualTo(root.<Date> get("requestTime"), beginDate));
				list.add(cb.lessThanOrEqualTo(root.<Date> get("requestTime"), endDate));
			}
			return cb.and(list.toArray(new Predicate[list.size()]));
		}
	},pageable);
}
 
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Search for likes", notes = "")
public PagedResources<LikeActionResource> search(
		@ApiParam(value="Action Id: 123") @RequestParam(value="action", required=true) Long actionId,
		@ApiIgnore @PageableDefault(size=10, page=0, sort={"id"}, direction=Direction.DESC) Pageable pageable){
	return pagedAssembler.toResource(likeActionService.findBy(pageable, actionId), assembler);
}
 
@RequestMapping(value="/wallets/{userName}", method=GET)
@ApiOperation(value = "Gets all wallet-items per user", notes = "Return a page of user-activities")
public List<WalletItemDTO> getWallet(
		@PathVariable String userName,
		@ApiIgnore @PageableDefault(size=10, page=0, direction=Direction.DESC) Pageable pageable){
	return walletService.findBy(userName);
}
 
源代码17 项目: cloudstreetmarket.com   文件: UsersController.java
@RequestMapping(method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "List user accounts", notes = "")
public Page<UserDTO> search(
		@Or({
               @Spec(params="cn", path="id", spec=LikeIgnoreCase.class)}	
		) @ApiIgnore Specification<User> spec,
           @ApiParam(value="Contains filter") @RequestParam(value="cn", defaultValue="", required=false) String contain, 
           @ApiIgnore @PageableDefault(size=10, page=0, sort={"balance"}, direction=Direction.DESC) Pageable pageable){
	return communityService.search(spec, pageable);
}
 
源代码18 项目: cloudstreetmarket.com   文件: UsersController.java
@RequestMapping(value="/leaderboard", method=GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Leaderboard", notes = "")
public Page<UserDTO> getLeaders(
           @ApiIgnore @PageableDefault(size=9, page=0, sort={"balanceUSD"}, direction=Direction.DESC) Pageable pageable){
	return communityService.getLeaders(pageable);
}
 
protected Direction getForcedDirection() {
    return Direction.DESC;
}
 
源代码20 项目: jcart   文件: OrderService.java
public List<Order> getAllOrders()
{
	Sort sort = new Sort(Direction.DESC, "createdOn");
	return orderRepository.findAll(sort);
}
 
 同类方法