com.baomidou.mybatisplus.core.conditions.Wrapper Java Examples
The following examples show how to use
com.baomidou.mybatisplus.core.conditions.Wrapper.
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: SuperServiceImpl.java From microservices-platform with Apache License 2.0 | 6 votes |
@Override public boolean saveOrUpdateIdempotency(T entity, DistributedLock lock, String lockKey, Wrapper<T> countWrapper, String msg) throws Exception { if (null != entity) { Class<?> cls = entity.getClass(); TableInfo tableInfo = TableInfoHelper.getTableInfo(cls); if (null != tableInfo && StrUtil.isNotEmpty(tableInfo.getKeyProperty())) { Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty()); if (StringUtils.checkValNull(idVal) || Objects.isNull(getById((Serializable) idVal))) { if (StrUtil.isEmpty(msg)) { msg = "已存在"; } return this.saveIdempotency(entity, lock, lockKey, countWrapper, msg); } else { return updateById(entity); } } else { throw ExceptionUtils.mpe("Error: Can not execute. Could not find @TableId."); } } return false; }
Example #2
Source File: MenuServiceImpl.java From permission with MIT License | 6 votes |
@Override public List<SysMenu> findByUser(String userName, Wrapper<SysMenu> queryWrapper) { if (userName == null || "".equals(userName) || "admin".equals(userName)) { return this.list(queryWrapper); } SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getName, userName)); if (sysUser == null) { return new ArrayList<>(); } List<SysUserRole> sysUserRoles = userRoleMapper.selectList(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getId())); List<Long> roldIds = sysUserRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); List<SysMenu> result = new ArrayList<>(); for (Long roldId : roldIds) { result.addAll(roleService.findRoleMenus(roldId)); } return result; }
Example #3
Source File: QueryWrapperUtil.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
public static Wrapper<?> fillWrapperOrder(Page<?> page, Wrapper<?> wrapper) { if (null == page) { return wrapper; } if (ObjectUtil.isEmpty(page.orders())) { return wrapper; } QueryWrapper queryWrapper = null == wrapper ? new QueryWrapper() : (QueryWrapper) wrapper; if (ObjectUtil.isNotEmpty(page.orders())) { page.orders().forEach(orderItem -> queryWrapper.orderBy(true, orderItem.isAsc(), StringUtil.toRevertCamelCase(orderItem.getColumn(), CharUtil.UNDERLINE))); page.setOrders(null); } return queryWrapper; }
Example #4
Source File: UserServiceImpl.java From SpringBlade with Apache License 2.0 | 5 votes |
@Override public List<UserExcel> exportUser(Wrapper<User> queryWrapper) { List<UserExcel> userList = baseMapper.exportUser(queryWrapper); userList.forEach(user -> { user.setRoleName(StringUtil.join(sysClient.getRoleNames(user.getRoleId()))); user.setDeptName(StringUtil.join(sysClient.getDeptNames(user.getDeptId()))); user.setPostName(StringUtil.join(sysClient.getPostNames(user.getPostId()))); }); return userList; }
Example #5
Source File: SuperServiceImpl.java From microservices-platform with Apache License 2.0 | 5 votes |
@Override public boolean saveIdempotency(T entity, DistributedLock locker, String lockKey, Wrapper<T> countWrapper, String msg) throws Exception { if (locker == null) { throw new LockException("DistributedLock is null"); } if (StrUtil.isEmpty(lockKey)) { throw new LockException("lockKey is null"); } Object lock = null; try { //加锁 lock = locker.tryLock(lockKey, 10, 60, TimeUnit.SECONDS); if (lock != null) { //判断记录是否已存在 int count = super.count(countWrapper); if (count == 0) { return super.save(entity); } else { if (StrUtil.isEmpty(msg)) { msg = "已存在"; } throw new IdempotencyException(msg); } } else { throw new LockException("锁等待超时"); } } finally { locker.unlock(lock); } }
Example #6
Source File: SysRolePermissionServiceImpl.java From spring-boot-plus with Apache License 2.0 | 5 votes |
@Override public List<Long> getPermissionIdsByRoleId(Long roleId) throws Exception { Wrapper wrapper = lambdaQuery() .select(SysRolePermission::getPermissionId) .eq(SysRolePermission::getRoleId,roleId) .eq(SysRolePermission::getState,StateEnum.ENABLE.getCode()) .getWrapper(); return sysRolePermissionMapper.selectObjs(wrapper); }
Example #7
Source File: SysPermissionServiceImpl.java From spring-boot-plus with Apache License 2.0 | 5 votes |
@Override public boolean isExistsByPermissionIds(List<Long> permissionIds) { if (CollectionUtils.isEmpty(permissionIds)) { return false; } Wrapper wrapper = lambdaQuery().in(SysPermission::getId, permissionIds).getWrapper(); return sysPermissionMapper.selectCount(wrapper).intValue() == permissionIds.size(); }
Example #8
Source File: SysPermissionServiceImpl.java From spring-boot-plus with Apache License 2.0 | 5 votes |
@Override public List<SysPermissionTreeVo> getNavMenuTree() throws Exception { List<Integer> levels = Arrays.asList(MenuLevelEnum.ONE.getCode(), MenuLevelEnum.TWO.getCode()); Wrapper wrapper = lambdaQuery() .in(SysPermission::getLevel, levels) .eq(SysPermission::getState, StateEnum.ENABLE.getCode()) .getWrapper(); List<SysPermission> list = sysPermissionMapper.selectList(wrapper); return convertSysPermissionTreeVoList(list); }
Example #9
Source File: IService.java From spring-cloud-shop with MIT License | 5 votes |
/** * 分页处理service * * @param page 页码 * @param pageSize 一页显示的大小 */ default Response<List<T>> toPage(int page, int pageSize, Wrapper<T> wrapper) { int total = this.count(wrapper); List<T> result = Collections.emptyList(); if (0 < total) { result = this.page(new Page<>(page, pageSize, false), wrapper).getRecords(); } return Response.toResponse(result, total); }
Example #10
Source File: BaseServiceImpl.java From lion with Apache License 2.0 | 5 votes |
/** * 分页查询 * * @param queryWrapper 条件构造器 * @param pageNum 页码值 * @param pageSize 每页大小 * @param orderBy 排序字段 * @return PageInfo 分页对象 */ @Override public PageInfo<T> page(Wrapper<T> queryWrapper, int pageNum, int pageSize, String orderBy) { if (null == orderBy) { PageHelper.startPage(pageNum, pageSize); } else { PageHelper.startPage(pageNum, pageSize, orderBy); } List<T> list = list(queryWrapper); PageInfo<T> pageInfo = new PageInfo<>(list); return pageInfo; }
Example #11
Source File: BaseController.java From ywh-frame with GNU General Public License v3.0 | 5 votes |
/** * 根据其他属性字段修改一条数据 * @param pojo 任意类型实体类 * @param column 具体字段 * @param value 具体字段的值 * @return 返回前端json数据 */ @PostMapping("updateByColumn") public Result update(@RequestBody T pojo, @RequestParam("column") String column, @RequestParam(name = "value") String value){ Wrapper<T> wrapper = Wrappers.<T>update().eq(column,value); boolean flag = service.update(pojo, wrapper); if(flag){ return Result.successJson("成功修改一条数据"); } return Result.errorJson(); }
Example #12
Source File: BaseController.java From ywh-frame with GNU General Public License v3.0 | 5 votes |
/** * 要根据哪个字段删除一条数据 * @param column 要根据哪个字段删除 * @param value 字段的值 * @return 返回前端json数据 */ @DeleteMapping("deleteByColumn") public Result delete(@RequestParam("column") String column, @RequestParam("value") String value){ Wrapper<T> ew = Wrappers.<T>query().eq(column,value); boolean flag = service.remove(ew); if(flag){ return Result.successJson("成功删除一条数据"); } return Result.errorJson(); }
Example #13
Source File: SchemeServiceImpl.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IPage getSchemeVoPage(PageModel pm, SchemeQueryCriteria schemeQueryCriteria) { Wrapper wrapper = QueryWrapperUtil.getWrapper(pm, schemeQueryCriteria); pm.addOrder(OrderItem.desc("a." + Scheme.F_SQL_CREATEDDATE)); IPage<List<SchemeVo>> userVosPage = repository.getSchemeVoPage(pm, wrapper); return userVosPage; }
Example #14
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public <V> List<V> listObjs(Wrapper<T> queryWrapper, Function<? super Object, V> mapper) { return serviceImpl.listObjs(queryWrapper, mapper); }
Example #15
Source File: ServiceImpl.java From spring-cloud-shop with MIT License | 4 votes |
@Override public int count(Wrapper<T> queryWrapper) { Integer total = baseMapper.selectCount(queryWrapper); return null != total ? total : 0; }
Example #16
Source File: UserMapper.java From SpringBootLearn with Apache License 2.0 | 4 votes |
@Override User selectOne(@Param("ew") Wrapper<User> wrapper);
Example #17
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public IPage<Map<String, Object>> pageMaps(IPage<T> page, Wrapper<T> queryWrapper) { return serviceImpl.pageMaps(page, queryWrapper); }
Example #18
Source File: SuperServiceImpl.java From microservices-platform with Apache License 2.0 | 4 votes |
@Override public boolean saveOrUpdateIdempotency(T entity, DistributedLock lock, String lockKey, Wrapper<T> countWrapper) throws Exception { return this.saveOrUpdateIdempotency(entity, lock, lockKey, countWrapper, null); }
Example #19
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public List<T> list(Wrapper<T> queryWrapper) { return serviceImpl.list(queryWrapper); }
Example #20
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public int count(Wrapper<T> queryWrapper) { return serviceImpl.count(queryWrapper); }
Example #21
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public <V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper) { return serviceImpl.getObj(queryWrapper, mapper); }
Example #22
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> getMap(Wrapper<T> queryWrapper) { return serviceImpl.getMap(queryWrapper); }
Example #23
Source File: ServiceImplWrapper.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public List<Map<String, Object>> listMaps(Wrapper<T> queryWrapper) { return serviceImpl.listMaps(queryWrapper); }
Example #24
Source File: PluginDataServiceImpl.java From springboot-plugin-framework-parent with Apache License 2.0 | 4 votes |
@Override public List<PluginData> getByName(String name){ Wrapper<PluginData> wrapper = Wrappers.<PluginData>query() .eq("name", name); return list(wrapper); }
Example #25
Source File: SysBaseApiImpl.java From jeecg-cloud with Apache License 2.0 | 4 votes |
@Override public List<JSONObject> queryAllDepart(Wrapper wrapper) { //noinspection unchecked return JSON.parseArray(JSON.toJSONString(sysDepartService.list(wrapper))).toJavaList(JSONObject.class); }
Example #26
Source File: ServiceImpl.java From spring-cloud-shop with MIT License | 4 votes |
@Override public List<T> list(Wrapper<T> queryWrapper) { return baseMapper.selectList(queryWrapper); }
Example #27
Source File: SysBaseApiImpl.java From jeecg-cloud with Apache License 2.0 | 4 votes |
@Override public List<JSONObject> queryAllUser(Wrapper wrapper) { //noinspection unchecked return JSON.parseArray(JSON.toJSONString(userMapper.selectList(wrapper))).toJavaList(JSONObject.class); }
Example #28
Source File: SysBaseApiImpl.java From jeecg-boot with Apache License 2.0 | 4 votes |
@Override public List<JSONObject> queryAllDepart(Wrapper wrapper) { //noinspection unchecked return JSON.parseArray(JSON.toJSONString(sysDepartService.list(wrapper))).toJavaList(JSONObject.class); }
Example #29
Source File: SysBaseApiImpl.java From jeecg-boot with Apache License 2.0 | 4 votes |
@Override public List<JSONObject> queryAllUser(Wrapper wrapper) { //noinspection unchecked return JSON.parseArray(JSON.toJSONString(userMapper.selectList(wrapper))).toJavaList(JSONObject.class); }
Example #30
Source File: ServiceImpl.java From spring-cloud-shop with MIT License | 4 votes |
@Override public T getOne(Wrapper<T> queryWrapper) { return baseMapper.selectOne(queryWrapper); }