Java Code Examples for com.baomidou.mybatisplus.mapper.EntityWrapper#orderBy()

The following examples show how to use com.baomidou.mybatisplus.mapper.EntityWrapper#orderBy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChannelController.java    From app-version with Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "用户登录凭证", paramType = "header", dataType = "string", defaultValue = "Bearer ", required = true),
})
@GetMapping
public ServiceResult list(@RequestParam(required = false, defaultValue = "1") int page,
                          @RequestParam(required = false, defaultValue = "10") int pageSize,
                          @RequestParam(required = false, defaultValue = "") String channelName,
                          @RequestParam(required = false, defaultValue = "") String channelCode,
                          @RequestParam(required = false, defaultValue = "") Integer channelStatus) {
    EntityWrapper<Channel> wrapper = new EntityWrapper<>();
    wrapper.and().eq("app_id", ThreadLocalUtils.USER_THREAD_LOCAL.get().getAppId());
    if (StringUtils.hasLength(channelName)) {
        wrapper.and().like("channel_name", "%" + channelName + "%");
    }
    if (StringUtils.hasLength(channelCode)) {
        wrapper.and().like("channel_code", "%" + channelCode + "%");
    }
    if (channelStatus != null && (channelStatus == 1 || channelStatus == 2 || channelStatus == 3)) {
        wrapper.and().eq("channel_status", channelStatus);
    }
    wrapper.and().eq("del_flag",0);
    wrapper.orderBy("created_time", false);
    return channelService.list(page, pageSize, wrapper);
}
 
Example 2
Source File: BasicServiceTest.java    From app-version with Apache License 2.0 6 votes vote down vote up
@Test
public void formatCreatedBy() throws Exception {
    EntityWrapper<CustomApi> wrapper = new EntityWrapper<>();
    wrapper.and().eq("app_id", ThreadLocalUtils.USER_THREAD_LOCAL.get().getAppId());
    wrapper.andNew().eq("id", 48);
    wrapper.andNew().eq("del_flag", 0);
    wrapper.orderBy("created_time", false);

    Page<CustomApi> pageEntity = new Page<>();
    pageEntity.setSize(10);
    pageEntity.setCurrent(1);
    pageEntity.setRecords(customApiMapper.selectPage(pageEntity, wrapper));
    logger.info("formatCreatedBy前:" + pageEntity.getRecords().toString());
    basicService.formatCreatedBy(pageEntity.getRecords());
    logger.info("formatCreatedBy后:" + pageEntity.getRecords().toString());
}
 
Example 3
Source File: SysLogController.java    From cola-cloud with MIT License 6 votes vote down vote up
/**
 * 查找系统日志
 */
@GetMapping(value = "/list")
@ApiOperation("查找系统日志")
public Result<Page<List<SysLog>>> list(Integer type, String name, Date startDate, Date endDate) {
    EntityWrapper wrapper = new EntityWrapper<>();
    wrapper.like("name", name);
    if (type != null) {
        wrapper.eq("type", type);
    }
    if (startDate != null) {
        wrapper.andNew("create_time >= {0}", startDate);
    }
    //
    if (endDate != null) {
        wrapper.andNew("create_time <= {0}", endDate);
    }
    wrapper.orderBy("id");
    return this.success(sysLogService.selectPage(this.getPagination(), wrapper));
}
 
Example 4
Source File: RnPackageServiceTest.java    From app-version with Apache License 2.0 6 votes vote down vote up
@Test
public void list() throws Exception {
    String routeName = "";
    String routeKey = "";
    String routeValue = "";
    EntityWrapper<RnPackage> wrapper = new EntityWrapper<>();
    wrapper.and().eq("del_flag", 0);
    if (StringUtils.hasLength(routeName)) {
        wrapper.and().like("route_name", "%" + routeName + "%");
    }
    if (StringUtils.hasLength(routeKey)) {
        wrapper.and().like("route_key", "%" + routeKey + "%");
    }

    if (StringUtils.hasLength(routeValue)) {
        wrapper.and().like("route_value", "%" + routeValue + "%");
    }

    wrapper.orderBy("created_time", false);
    ServiceResult result = rnPackageService.list(1, 10, wrapper);
    if (result.getData() != null) {
        logger.info(result.getData().toString());
    }
}
 
Example 5
Source File: AdminCategoryServiceImpl.java    From unimall with Apache License 2.0 5 votes vote down vote up
@Override
public Page<CategoryTreeNodeDTO> queryCategory(Long adminId, Long id, String title, Integer level, Long parentId, Integer pageNo, Integer limit) throws ServiceException {
    EntityWrapper wrapper = new EntityWrapper();
    if (id != null) {
        wrapper.eq("id", id);
    }
    if (title != null) {
        wrapper.like("title", title);
    }
    if (level != null) {
        wrapper.eq("level", level);
    }
    if (parentId != null) {
        wrapper.eq("parent_id", parentId);
    }
    wrapper.orderBy("level");
    Integer count = categoryMapper.selectCount(wrapper);

    List<CategoryDO> categoryDOS = categoryMapper.selectPage(new RowBounds((pageNo - 1) * limit, limit), wrapper);
    List<CategoryTreeNodeDTO> totalCategory = getCategoryList();
    List<CategoryTreeNodeDTO> list = categoryDOS.stream().map(item -> {
        CategoryTreeNodeDTO dto = new CategoryTreeNodeDTO();
        for (CategoryTreeNodeDTO temp : totalCategory) {
            if (temp.getValue().equals(item.getId())) {
                BeanUtils.copyProperties(temp, dto);
                return dto;
            }
        }
        BeanUtils.copyProperties(item, dto);
        ;
        return dto;
    }).collect(Collectors.toList());
    Page<CategoryTreeNodeDTO> page = new Page<>(list, pageNo, limit, count);
    return page;
}
 
Example 6
Source File: DictServiceImpl.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Cacheable(value = "dictCache",key = "#type",unless = "#result == null or #result.size() == 0")
@Override
public List<Dict> getDictByType(String type) {
    EntityWrapper<Dict> wrapper = new EntityWrapper<>();
    wrapper.eq("type",type);
    wrapper.eq("del_flag",false);
    wrapper.orderBy("sort");
    return selectList(wrapper);
}
 
Example 7
Source File: MenuServiceImpl.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Override
public List<ZtreeVO> showTreeMenus() {
    EntityWrapper<Menu> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    wrapper.eq("is_show",true);
    wrapper.orderBy("sort",false);
    List<Menu> totalMenus = baseMapper.selectList(wrapper);
    List<ZtreeVO> ztreeVOs = Lists.newArrayList();
    return getZTree(null,totalMenus,ztreeVOs);
}
 
Example 8
Source File: BlogTagsServiceImpl.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Override
public List<BlogTags> listAll() {
    EntityWrapper<BlogTags> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    wrapper.orderBy("sort",false);
    return selectList(wrapper);
}
 
Example 9
Source File: SysRoleServiceImpl.java    From watchdog-framework with MIT License 5 votes vote down vote up
@Override
public Page<SysRole> list(FindRoleDTO findRoleDTO) {
    EntityWrapper<SysRole> wrapper = new EntityWrapper<>();
    wrapper.orderBy("id",findRoleDTO.getAsc());
    Page<SysRole> rolePage = this.selectPage(new Page<>(findRoleDTO.getPage(),
            findRoleDTO.getPageSize()), wrapper);
    if(findRoleDTO.getHasResource()){
        if(rolePage.getRecords()!=null){
            rolePage.getRecords().forEach(v->
                    v.setResources(roleResourceService.findAllResourceByRoleId(v.getId())));
        }
    }
    return rolePage;
}
 
Example 10
Source File: RoleServiceImpl.java    From xmanager with Apache License 2.0 5 votes vote down vote up
@Override
public void selectDataGrid(PageInfo pageInfo) {
    Page<Role> page = new Page<Role>(pageInfo.getNowpage(), pageInfo.getSize());
    
    EntityWrapper<Role> wrapper = new EntityWrapper<Role>();
    wrapper.orderBy(pageInfo.getSort(), pageInfo.getOrder().equalsIgnoreCase("ASC"));
    selectPage(page, wrapper);
    
    pageInfo.setRows(page.getRecords());
    pageInfo.setTotal(page.getTotal());
}
 
Example 11
Source File: AdminCategoryServiceImpl.java    From unimall with Apache License 2.0 5 votes vote down vote up
private List<CategoryTreeNodeDTO> getCategoryList() {
    List<CategoryTreeNodeDTO> objList = cacheComponent.getObjList(ADMIN_QUERY_CATEGORY_LIST, CategoryTreeNodeDTO.class);
    if (objList != null) {
        return objList;
    }
    EntityWrapper wrapper = new EntityWrapper();
    wrapper.orderBy("level");
    List<CategoryDO> categoryDOS = categoryMapper.selectList(wrapper);
    List<CategoryTreeNodeDTO> list = categoryDOS.stream().map(item -> {
        CategoryTreeNodeDTO dto = new CategoryTreeNodeDTO();
        dto.setLabel(item.getTitle());
        dto.setLevel(item.getLevel());
        dto.setValue(item.getId());
        dto.setParent(item.getParentId());
        dto.setIconUrl(item.getIconUrl());
        dto.setPicUrl(item.getPicUrl());
        if (item.getLevel() == 0) {
            dto.setFullName(dto.getLabel());
        }
        return dto;
    }).collect(Collectors.toList());

    for (CategoryTreeNodeDTO cOne : list) {

        for (CategoryTreeNodeDTO cTwo : list) {
            if (cOne.getParent().equals(cTwo.getValue())) {
                cOne.setFullName(cTwo.getFullName() + "/" + cOne.getLabel());
                break;
            }
        }

    }
    cacheComponent.putObj(ADMIN_QUERY_CATEGORY_LIST, list, 60 * 60);
    return list;
}
 
Example 12
Source File: ResourceServiceImpl.java    From xmanager with Apache License 2.0 5 votes vote down vote up
public List<Resource> selectByType(Integer type) {
    EntityWrapper<Resource> wrapper = new EntityWrapper<Resource>();
    Resource resource = new Resource();
    wrapper.setEntity(resource);
    wrapper.addFilter("resource_type = {0}", type);
    wrapper.orderBy("seq");
    return resourceMapper.selectList(wrapper);
}
 
Example 13
Source File: BasicServiceTest.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Test
public void sortAndroidVersion() throws Exception{
    EntityWrapper<AndroidVersion> androidVersionEntityWrapper = new EntityWrapper<>();
    androidVersionEntityWrapper.and().eq("app_id", 24);
    androidVersionEntityWrapper.and().eq("del_flag", 0);
    androidVersionEntityWrapper.orderBy("app_version", false);

    List<AndroidVersion> list  = androidVersionMapper.selectList(androidVersionEntityWrapper);
    List<AndroidVersion> result = basicService.sortAndroidVersion(list,true);
    System.out.println(result);
}
 
Example 14
Source File: RnRouteServiceTest.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Test
public void list() throws Exception {
    String routeName = "";
    String routeKey = "";
    String routeValue = "";
    Integer routeStatus = 1;
    EntityWrapper<RnRoute> wrapper = new EntityWrapper<>();
    wrapper.and().eq("del_flag", 0);
    if (StringUtils.hasLength(routeName)) {
        wrapper.and().like("route_name", "%" + routeName + "%");
    }
    if (StringUtils.hasLength(routeKey)) {
        wrapper.and().like("route_key", "%" + routeKey + "%");
    }

    if (StringUtils.hasLength(routeValue)) {
        wrapper.and().like("route_value", "%" + routeValue + "%");
    }

    if (routeStatus != null) {
        wrapper.and().eq("route_status", routeStatus);
    }
    wrapper.orderBy("created_time", false);
    ServiceResult result = rnRouteService.list(1, 10, wrapper);
    if (result.getData() != null) {
        logger.info(result.getData().toString());
    }
}
 
Example 15
Source File: AdminTypeController.java    From MI-S with MIT License 5 votes vote down vote up
/**
 * 加载分类信息列表
 * @param pages 分页对象
 * @param param  搜索条件
 * @param model
 * @return
 */
@RequestMapping("/list")
public String selectPage(Page pages, String param, Model model) {
    Page<Type> page;
    EntityWrapper<Type> ex = new EntityWrapper<>();
    if (StringUtils.checkValNotNull(param)) {
        ex.where("type_name like concat('%',{0},'%')", param);
    }
    ex.orderBy("sort", true);
    ex.orderBy("create_time", true);
    page = iTypeService.selectPage(new Page(pages.getCurrent(), pages.getSize()), ex);
    model.addAttribute("page", page);
    return "admin/type/typeTable";
}
 
Example 16
Source File: SysLogServiceImpl.java    From xmanager with Apache License 2.0 5 votes vote down vote up
@Override
public void selectDataGrid(PageInfo pageInfo) {
    Page<SysLog> page = new Page<SysLog>(pageInfo.getNowpage(), pageInfo.getSize());
    EntityWrapper<SysLog> wrapper = new EntityWrapper<SysLog>();
    wrapper.orderBy(pageInfo.getSort(), pageInfo.getOrder().equalsIgnoreCase("ASC"));
    selectPage(page, wrapper);
    pageInfo.setRows(page.getRecords());
    pageInfo.setTotal(page.getTotal());
}
 
Example 17
Source File: AdminController.java    From app-version with Apache License 2.0 5 votes vote down vote up
/**
 * 列出所有用户
 *
 * @return 用户列表
 */
@ApiOperation(
        value = "列出所有用户(可分页,查询)",
        notes = "APP版本管理系统的全部用户列表"
)
@ApiImplicitParams({
        @ApiImplicitParam(paramType = "header", dataType = "string", name = "Authorization", value = "用户凭证", required = true),
        @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1"),
        @ApiImplicitParam(name = "pageSize", value = "每页显示数据条数", defaultValue = "10"),
        @ApiImplicitParam(name = "admin", value = "是否是管理员,0:管理员,1:管理员"),
        @ApiImplicitParam(name = "phone", value = "手机号"),
})
@GetMapping("/user/list")
public ServiceResult listUser(@RequestParam(required = false, defaultValue = "1") int page,
                              @RequestParam(required = false, defaultValue = "10") int pageSize,
                              @RequestParam(required = false, defaultValue = "0") int admin,
                              @RequestParam(required = false, defaultValue = "") String phone) {
    EntityWrapper<User> wrapper = new EntityWrapper<>();
    if (admin == 1) {
        wrapper.and().eq("is_admin", 1);
    }
    if (StringUtils.isNotBlank(phone)) {
        wrapper.and().like("phone", "%" + phone + "%");
    }
    wrapper.isNotNull("first_login_time");
    wrapper.orderBy("first_login_time", false);
    return adminService.listUser(page, pageSize, wrapper);
}
 
Example 18
Source File: SysLogServiceImpl.java    From watchdog-framework with MIT License 4 votes vote down vote up
@Override
public Page<SysLog> list(FindLogDTO findLogDTO) {
    EntityWrapper<SysLog> wrapper = new EntityWrapper<>();
    wrapper.orderBy("create_date",findLogDTO.getAsc());
    return this.selectPage(new Page<>(findLogDTO.getPage(),findLogDTO.getPageSize()),wrapper);
}
 
Example 19
Source File: OrganizationServiceImpl.java    From xmanager with Apache License 2.0 4 votes vote down vote up
@Override
public List<Organization> selectTreeGrid() {
    EntityWrapper<Organization> wrapper = new EntityWrapper<Organization>();
    wrapper.orderBy("seq");
    return organizationMapper.selectList(wrapper);
}
 
Example 20
Source File: ResourceServiceImpl.java    From xmanager with Apache License 2.0 4 votes vote down vote up
@Override
public List<Resource> selectAll() {
    EntityWrapper<Resource> wrapper = new EntityWrapper<Resource>();
    wrapper.orderBy("seq");
    return resourceMapper.selectList(wrapper);
}