Java Code Examples for tk.mybatis.mapper.entity.Example#createCriteria()

The following examples show how to use tk.mybatis.mapper.entity.Example#createCriteria() . 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: UacMenuCommonController.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * 检测菜单URL唯一性
 *
 * @param uacMenuCheckUrlDto the uac menu check url dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/checkMenuUrl")
@ApiOperation(httpMethod = "POST", value = "检测菜单URL唯一性")
public Wrapper<Boolean> checkUacMenuUrl(@ApiParam(name = "uacMenuCheckUrlDto", value = "id与url") @RequestBody UacMenuCheckUrlDto uacMenuCheckUrlDto) {
	logger.info("检测菜单URL唯一性 uacMenuCheckUrlDto={}", uacMenuCheckUrlDto);

	Long id = uacMenuCheckUrlDto.getMenuId();
	String url = uacMenuCheckUrlDto.getUrl();

	Example example = new Example(UacMenu.class);
	Example.Criteria criteria = example.createCriteria();

	if (id != null) {
		criteria.andNotEqualTo("id", id);
	}
	criteria.andEqualTo("url", url);

	int result = uacMenuService.selectCountByExample(example);
	return WrapMapper.ok(result < 1);
}
 
Example 2
Source File: UacMenuCommonController.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * 检测菜单名称唯一性
 *
 * @param uacMenuCheckNameDto the uac menu check name dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/checkMenuName")
@ApiOperation(httpMethod = "POST", value = "检测菜单名称唯一性")
public Wrapper<Boolean> checkUacMenuName(@ApiParam(name = "uacMenuCheckNameDto", value = "id与name") @RequestBody UacMenuCheckNameDto uacMenuCheckNameDto) {
	logger.info("校验菜单名称唯一性 uacMenuCheckNameDto={}", uacMenuCheckNameDto);
	Long id = uacMenuCheckNameDto.getMenuId();
	Long pid = uacMenuCheckNameDto.getPid();
	String menuName = uacMenuCheckNameDto.getMenuName();

	Example example = new Example(UacMenu.class);
	Example.Criteria criteria = example.createCriteria();

	if (id != null) {
		criteria.andNotEqualTo("id", id);
	}
	criteria.andEqualTo("menuName", menuName);
	criteria.andEqualTo("pid", pid);

	int result = uacMenuService.selectCountByExample(example);
	return WrapMapper.ok(result < 1);
}
 
Example 3
Source File: GemDictionaryServiceImpl.java    From gem with MIT License 6 votes vote down vote up
/**
 * @Description:递归遍历所有的字典组
 * @param list 字典数据集合
 * @author: Ryan
 * @date 2018年11月5日
 */
public List<GemDictionary> getDicChildrenList(List<GemDictionary> list,String name, String code) {
	if(list!=null && list.size()>0) {
		for (GemDictionary dictionary : list) {
			Example example = new Example(GemDictionary.class);
			Criteria createCriteria = example.createCriteria();
			createCriteria.andEqualTo("parentId",dictionary.getId());
			List<String> dicTypeList = new ArrayList<>();
			dicTypeList.add("1");
			dicTypeList.add("2");
			createCriteria.andIn("dicType",dicTypeList);
			if(GemFrameStringUtlis.isNotBlank(name) && !name.equalsIgnoreCase("null") && name.length()>0) {
				createCriteria.andLike("name","%"+name+"%");
			}
			if(GemFrameStringUtlis.isNotBlank(code) && !code.equalsIgnoreCase("null") && code.length()>0) {
				createCriteria.andLike("code","%"+code+"%");
			}
			example.setOrderByClause("dic_sort asc");
			List<GemDictionary> selectByExample = dictionaryMapper.selectByExample(example);
			dictionary.setChildren(selectByExample);
			getDicChildrenList(selectByExample,name,code);
		}
	}
	return list;
}
 
Example 4
Source File: UacUserCommonController.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * 校验登录名唯一性.
 *
 * @param checkLoginNameDto the check login name dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/checkLoginName")
@ApiOperation(httpMethod = "POST", value = "校验登录名唯一性")
public Wrapper<Boolean> checkLoginName(@ApiParam(name = "loginName", value = "登录名") @RequestBody CheckLoginNameDto checkLoginNameDto) {
	logger.info("校验登录名唯一性 checkLoginNameDto={}", checkLoginNameDto);

	Long id = checkLoginNameDto.getUserId();
	String loginName = checkLoginNameDto.getLoginName();

	Example example = new Example(UacUser.class);
	Example.Criteria criteria = example.createCriteria();
	criteria.andEqualTo("loginName", loginName);
	if (id != null) {
		criteria.andNotEqualTo("id", id);
	}

	int result = uacUserService.selectCountByExample(example);
	return WrapMapper.ok(result < 1);
}
 
Example 5
Source File: GemOrganizationServiceImpl.java    From gem with MIT License 6 votes vote down vote up
/**
 * @Description: 递归查询组织机构树
 * @param listOrganization 组织机构集合
 * @author: Ryan
 * @date 2018年11月6日
 */
public List<GemOrganization> getOrganZtree(List<GemOrganization> listOrganization,List<Long> ids){
	if(listOrganization!=null && listOrganization.size()>0) {
		for (GemOrganization organization : listOrganization) {
			Long id = organization.getId();
			Example example = new Example(GemOrganization.class);
			Criteria createCriteria = example.createCriteria();
			createCriteria.andEqualTo("parentId", id);
			if(ids!=null && ids.size()>0) {
				createCriteria.andIn("id", ids);
			}
			List<GemOrganization> selectByExample = organizationMapper.selectByExample(example);
			organization.setChildren(selectByExample);
			getOrganZtree(selectByExample,ids);
		}
	}
	return listOrganization;
}
 
Example 6
Source File: JobLogServiceImpl.java    From FEBS-Security with Apache License 2.0 6 votes vote down vote up
@Override
public List<JobLog> findAllJobLogs(JobLog jobLog) {
	try {
		Example example = new Example(JobLog.class);
		Criteria criteria = example.createCriteria();
		if (StringUtils.isNotBlank(jobLog.getBeanName())) {
			criteria.andCondition("bean_name=", jobLog.getBeanName());
		}
		if (StringUtils.isNotBlank(jobLog.getMethodName())) {
			criteria.andCondition("method_name=", jobLog.getMethodName());
		}
		if (StringUtils.isNotBlank(jobLog.getStatus())) {
			criteria.andCondition("status=", Long.valueOf(jobLog.getStatus()));
		}
		example.setOrderByClause("log_id desc");
		return this.selectByExample(example);
	} catch (Exception e) {
		log.error("获取调度日志信息失败", e);
		return new ArrayList<>();
	}
}
 
Example 7
Source File: UserController.java    From easyweb with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@PostMapping("/index")
@ApiOperation(value = "用户管理-首页接口")
@RequiresPermissions("upms:user:read")
public Page<SysUser> index(HttpServletRequest request,
                              HttpServletResponse response, SysUser user){
    Page<SysUser> pg=new Page<SysUser>(request,response);
    Example example=new Example(SysUser.class);
    Example.Criteria criteria= example.createCriteria();
    User loginUser=UserUtils.getUser();
    if(!loginUser.isAdmin()){//超级管理员无需
        criteria.andEqualTo("companyId", loginUser.getCompany().getId());
    }
    if(!StringUtils.isEmpty(user.getLoginName())) {
        criteria.andLike("loginName", "%"+user.getLoginName()+"%");
    }
    if(!StringUtils.isEmpty(user.getName())) {
        criteria.andLike("name", "%"+user.getName()+"%");
    }
    pg= userService.selectPageByExample(example,pg);
    return pg;
}
 
Example 8
Source File: UacRoleCommonController.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * 验证角色编码是否存在.
 *
 * @param checkRoleCodeDto the check role code dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/checkRoleCode")
@ApiOperation(httpMethod = "POST", value = "验证角色编码是否存在")
public Wrapper<Boolean> checkUacRoleCode(@ApiParam(name = "roleCode", value = "角色编码") @RequestBody CheckRoleCodeDto checkRoleCodeDto) {

	logger.info("校验角色编码唯一性 checkRoleCodeDto={}", checkRoleCodeDto);

	Long id = checkRoleCodeDto.getRoleId();
	String roleCode = checkRoleCodeDto.getRoleCode();

	Example example = new Example(UacRole.class);
	Example.Criteria criteria = example.createCriteria();

	if (id != null) {
		criteria.andNotEqualTo("id", id);
	}
	criteria.andEqualTo("roleCode", roleCode);

	int result = uacRoleService.selectCountByExample(example);
	return WrapMapper.ok(result < 1);
}
 
Example 9
Source File: CommentServiceImpl.java    From gpmall with Apache License 2.0 6 votes vote down vote up
@Override
public TotalCommentResponse totalComment(TotalCommentRequest request) {
    TotalCommentResponse response = new TotalCommentResponse();
    try {
        request.requestCheck();
        String itemId = request.getItemId();
        Integer type = request.getType();
        Example example = new Example(Comment.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("itemId", itemId);
        if (type != null) {
            criteria.andEqualTo("type", type.byteValue());
        }
        int count = commentMapper.selectCountByExample(example);
        response.setCode(CommentRetCode.SUCCESS.getCode());
        response.setMsg(CommentRetCode.SUCCESS.getMessage());
        response.setTotal(count);
    } catch (Exception e) {
        ExceptionProcessorUtil.handleException(response, e);
    }
    return response;
}
 
Example 10
Source File: RoleController.java    From easyweb with Apache License 2.0 6 votes vote down vote up
/**
 * 获取所有角色列表
 * @param model
 * @return
 */
@PostMapping("/index")
@ResponseBody
public Page<SysRole> index(HttpServletRequest request,
                           HttpServletResponse response, SysRole model) {
    Page<SysRole> pg = new Page<SysRole>(request, response,-1);

    Example example = new Example(SysRole.class);
    Example.Criteria criteria = example.createCriteria();
    if (!StringUtils.isEmpty(model.getName())) {
        criteria.andLike("name", "%" + model.getName() + "%");
    }
    User curentUser= UserUtils.getUser();
    if(curentUser.isAdmin()){
        if (!StringUtils.isEmpty(model.getOfficeId())) {
            criteria.andEqualTo("officeId", model.getOfficeId());
        }
    }else{
        criteria.andEqualTo("officeId",curentUser.getCompany().getId());
    }
    pg = service.selectPageByExample(example, pg);
    return pg;
}
 
Example 11
Source File: UacActionCommonController.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * 检测权限编码是否已存在
 *
 * @param uacActionCheckCodeDto the uac action check code dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/checkActionCode")
@ApiOperation(httpMethod = "POST", value = "检测权限编码是否已存在")
public Wrapper<Boolean> checkActionCode(@ApiParam(name = "uacActionCheckCodeDto", value = "id与url") @RequestBody UacActionCheckCodeDto uacActionCheckCodeDto) {
	logger.info("校验权限编码唯一性 uacActionCheckCodeDto={}", uacActionCheckCodeDto);

	Long id = uacActionCheckCodeDto.getActionId();
	String actionCode = uacActionCheckCodeDto.getActionCode();

	Example example = new Example(UacAction.class);
	Example.Criteria criteria = example.createCriteria();

	if (id != null) {
		criteria.andNotEqualTo("id", id);
	}
	criteria.andEqualTo("actionCode", actionCode);

	int result = uacActionService.selectCountByExample(example);
	return WrapMapper.ok(result < 1);
}
 
Example 12
Source File: GoodsService.java    From leyou with Apache License 2.0 6 votes vote down vote up
/**
 * 通过spu_id删除tb_sku
 * 通过sku_id删除tb_stock
 *
 * @param spuId
 */
private void deleteSkuAndStock(Long spuId) {
    // 通过spu_id查询sku
    Sku querySku = new Sku();
    querySku.setSpuId(spuId);
    List<Sku> skus = this.skuMapper.select(querySku);
    // 删除sku
    if (!CollectionUtils.isEmpty(skus)) {
        // 获得sku_id集合
        List<Long> ids = skus.stream().map(sku -> sku.getId()).collect(Collectors.toList());
        // 通过sku_id删除tb_stock
        Example example = new Example(Stock.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andIn("skuId", ids);
        this.stockMapper.deleteByExample(example);
    }
    // 删除sku
    this.skuMapper.delete(querySku);
}
 
Example 13
Source File: UacUserCommonController.java    From paascloud-master with Apache License 2.0 6 votes vote down vote up
/**
 * 校验用户电话号码唯一性.
 *
 * @param checkUserPhoneDto the check user phone dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/checkUserPhone")
@ApiOperation(httpMethod = "POST", value = "校验用户电话号码唯一性")
public Wrapper<Boolean> checkUserPhone(@ApiParam(name = "checkUserPhoneDto", value = "校验用户电话号码唯一性Dto") @RequestBody CheckUserPhoneDto checkUserPhoneDto) {
	logger.info(" 校验用户电话号码唯一性 checkUserPhoneDto={}", checkUserPhoneDto);
	Long id = checkUserPhoneDto.getUserId();
	String mobileNo = checkUserPhoneDto.getMobileNo();
	Example example = new Example(UacUser.class);
	Example.Criteria criteria = example.createCriteria();
	criteria.andEqualTo("mobileNo", mobileNo);

	if (id != null) {
		criteria.andNotEqualTo("id", id);
	}

	int result = uacUserService.selectCountByExample(example);
	return WrapMapper.ok(result < 1);
}
 
Example 14
Source File: GemOrganizationServiceImpl.java    From gem with MIT License 5 votes vote down vote up
/**
 * @Description:查询组织机构树
 * @param name 名称
 * @param time 事件
 * @author: Ryan
 * @date 2018年11月22日
 */
@Override
public List<GemOrganization> findOrganZtree(String name,String time) {
	arrayList.clear();
	List<Long> organIds = getOrganIds(name,time);
	Example example = new Example(GemOrganization.class);
	Criteria createCriteria = example.createCriteria();
	createCriteria.andIsNull("parentId");
	if(organIds!=null && organIds.size()>0) {
		createCriteria.andIn("id", organIds);
	}
	List<GemOrganization> selectByExample = organizationMapper.selectByExample(example);
	return getOrganZtree(selectByExample,organIds);
}
 
Example 15
Source File: SysDictService.java    From easyweb with Apache License 2.0 5 votes vote down vote up
/**
 * 获取子字典
 *
 * @param parentId
 * @return
 */
public List<SysDict> getDicByParentId(String parentId) {
    Example example = new Example(SysDict.class);
    Example.Criteria criteria = example.createCriteria();
    if (parentId == null)
        parentId = "0";
    criteria.andEqualTo("parentId", parentId);
    return mapper.selectByExample(example);
}
 
Example 16
Source File: SysRoleResourcesServiceImpl.java    From OneBlog with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 通过角色id批量删除
 * @param roleId
 */
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void removeByRoleId(Long roleId) {
    //删除
    Example example = new Example(SysRoleResources.class);
    Example.Criteria criteria = example.createCriteria();
    criteria.andEqualTo("roleId", roleId);
    resourceMapper.deleteByExample(example);
}
 
Example 17
Source File: SysUserServiceImpl.java    From cloud-template with MIT License 5 votes vote down vote up
@Override
public List<SysUser> list(SysUser user) {
    Example example = new Example(SysUser.class);
    Example.Criteria criteria = example.createCriteria();
    if (user.getUsername() != null && !user.getUsername().isEmpty()) {
        criteria.andCondition("username=", user.getUsername());
    }
    return this.selectByExample(example);
}
 
Example 18
Source File: GemPermissionsServiceImpl.java    From gem with MIT License 5 votes vote down vote up
/**
 * @Description: 根据角色和菜单获取权限-按钮(包含未选中)
 * @param roleId 角色主键
 * @param permissionId 权限(菜单)主键
 * @author: Ryan
 * @date 2018年11月5日
 */
@Override
public List<GemPermissions> findPermissionSelectByRoleIdAndPermissionId(Long roleId,Long permissionId) {
	List<GemPermissions> permissionButtonListByPermissionId = new ArrayList<GemPermissions>();
	if(roleId != null){
		//根据菜单获取对应的按钮
		Example example = new Example(GemPermissions.class);
		Example.Criteria createCriteria = example.createCriteria();
		createCriteria.andEqualTo("menusType",1);
		createCriteria.andEqualTo("parentId",permissionId);
		example.setOrderByClause("per_sort asc");
		permissionButtonListByPermissionId = permissionsMapper.selectByExample(example);
		//根据菜单和角色获取对应的按钮
		Map<String, Object> hashMap = new HashMap<String,Object>();
		hashMap.put("roleId", roleId);
		hashMap.put("permissionId", permissionId);
		List<GemPermissions> permissionButtonListByRoleIdAndPermissionId = permissionsMapper.findPermissionButtonByRoleIdAndPermissionId(hashMap);
		for (int i = 0 ; i < permissionButtonListByPermissionId.size() ; i++){
			for (int j = 0 ; j < permissionButtonListByRoleIdAndPermissionId.size() ; j++){
				if(permissionButtonListByPermissionId.get(i).getId().equals(permissionButtonListByRoleIdAndPermissionId.get(j).getId())){
					permissionButtonListByPermissionId.get(i).setSelected(true);
					continue;
				}
			}
		}
	}else{
		return null;
	}
	return permissionButtonListByPermissionId;
}
 
Example 19
Source File: GemPermissionsServiceImpl.java    From gem with MIT License 5 votes vote down vote up
/**
 * @Description: 查看菜单下的按钮
 * @param parentId 菜单主键
 * @author: Ryan
 * @date 2018年11月5日
 */
@Override
public List<GemPermissions> findPermissionButtonByParentId(Long parentId) {
	Example example = new Example(GemPermissions.class);
	Example.Criteria createCriteria = example.createCriteria();
	createCriteria.andEqualTo("parentId",parentId);
	createCriteria.andEqualTo("menusType",1);
	example.setOrderByClause("per_sort asc");
	List<GemPermissions> selectByExample = permissionsMapper.selectByExample(example);
	return selectByExample;
}
 
Example 20
Source File: GemPermissionsServiceImpl.java    From gem with MIT License 5 votes vote down vote up
/**
 * @Description: 获取权限数据
 * @param menusType 菜单0为菜单1按钮
 * @author: Ryan
 * @date 2018年11月5日
 */
private List<GemPermissions> findPermissionMenu(Integer menusType) {
	Example example = new Example(GemPermissions.class);
	Example.Criteria createCriteria = example.createCriteria();
	createCriteria.andEqualTo("menusType",menusType);
	example.setOrderByClause("per_sort asc");
	List<GemPermissions> selectByExample = permissionsMapper.selectByExample(example);
	return selectByExample;
}