Java Code Examples for com.ruoyi.common.utils.StringUtils#isNotEmpty()

The following examples show how to use com.ruoyi.common.utils.StringUtils#isNotEmpty() . 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: GenUtils.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 表名转换成Java类名
 */
public static String tableToJava(String tableName)
{
    String autoRemovePre = Global.getAutoRemovePre();
    String tablePrefix = Global.getTablePrefix();
    //多种前缀
    if(tablePrefix.indexOf(",")>0){
        String[] prefixes = StrUtil.splitToArray(tablePrefix,',');
        for(String _prefix : prefixes){
            if(!StrUtil.isEmpty(_prefix)){
                tableName = tableName.replaceFirst(_prefix, "");
            }
        }
    }else {
        if (Constants.AUTO_REOMVE_PRE.equals(autoRemovePre) && StringUtils.isNotEmpty(tablePrefix)) {
            tableName = tableName.replaceFirst(tablePrefix, "");
        }
    }
    return StringUtils.convertToCamelCase(tableName);
}
 
Example 2
Source File: XssFilter.java    From RuoYi-Vue with MIT License 6 votes vote down vote up
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
    String tempExcludes = filterConfig.getInitParameter("excludes");
    String tempEnabled = filterConfig.getInitParameter("enabled");
    if (StringUtils.isNotEmpty(tempExcludes))
    {
        String[] url = tempExcludes.split(",");
        for (int i = 0; url != null && i < url.length; i++)
        {
            excludes.add(url[i]);
        }
    }
    if (StringUtils.isNotEmpty(tempEnabled))
    {
        enabled = Boolean.valueOf(tempEnabled);
    }
}
 
Example 3
Source File: SysProfileController.java    From supplierShop with MIT License 6 votes vote down vote up
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwd(String oldPassword, String newPassword)
{
    SysUser user = ShiroUtils.getSysUser();
    if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
    {
        user.setSalt(ShiroUtils.randomSalt());
        user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
        if (userService.resetUserPwd(user) > 0)
        {
            ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
            return success();
        }
        return error();
    }
    else
    {
        return error("修改密码失败,旧密码错误");
    }
}
 
Example 4
Source File: ExcelUtil.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 获取bean中的属性值
 * 
 * @param vo 实体对象
 * @param field 字段
 * @param excel 注解
 * @return 最终的属性值
 * @throws Exception
 */
private Object getTargetValue(T vo, Field field, Excel excel) throws Exception
{
    Object o = field.get(vo);
    if (StringUtils.isNotEmpty(excel.targetAttr()))
    {
        String target = excel.targetAttr();
        if (target.indexOf(".") > -1)
        {
            String[] targets = target.split("[.]");
            for (String name : targets)
            {
                o = getValue(o, name);
            }
        }
        else
        {
            o = getValue(o, target);
        }
    }
    return o;
}
 
Example 5
Source File: TokenService.java    From RuoYi-Vue with MIT License 6 votes vote down vote up
/**
 * 获取用户身份信息
 * 
 * @return 用户信息
 */
public LoginUser getLoginUser(HttpServletRequest request)
{
    // 获取请求携带的令牌
    String token = getToken(request);
    if (StringUtils.isNotEmpty(token))
    {
        Claims claims = parseToken(token);
        // 解析对应的权限以及用户信息
        String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
        String userKey = getTokenKey(uuid);
        LoginUser user = redisCache.getCacheObject(userKey);
        return user;
    }
    return null;
}
 
Example 6
Source File: SysUserServiceImpl.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 查询用户所属角色组
 * 
 * @param userId 用户ID
 * @return 结果
 */
@Override
public String selectUserRoleGroup(Long userId)
{
    List<SysRole> list = roleMapper.selectRolesByUserId(userId);
    StringBuffer idsStr = new StringBuffer();
    for (SysRole role : list)
    {
        idsStr.append(role.getRoleName()).append(",");
    }
    if (StringUtils.isNotEmpty(idsStr.toString()))
    {
        return idsStr.substring(0, idsStr.length() - 1);
    }
    return idsStr.toString();
}
 
Example 7
Source File: GenTableColumn.java    From supplierShop with MIT License 6 votes vote down vote up
public String readConverterExp()
{
    String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
    StringBuffer sb = new StringBuffer();
    if (StringUtils.isNotEmpty(remarks))
    {
        for (String value : remarks.split(" "))
        {
            if (StringUtils.isNotEmpty(value))
            {
                Object startStr = value.subSequence(0, 1);
                String endStr = value.substring(1);
                sb.append("").append(startStr).append("=").append(endStr).append(",");
            }
        }
        return sb.deleteCharAt(sb.length() - 1).toString();
    }
    else
    {
        return this.columnComment;
    }
}
 
Example 8
Source File: SysUserServiceImpl.java    From ruoyiplus with MIT License 6 votes vote down vote up
/**
 * 查询用户所属角色组
 * 
 * @param userId 用户ID
 * @return 结果
 */
@Override
public String selectUserRoleGroup(Long userId)
{
    List<SysRole> list = roleMapper.selectRolesByUserId(userId);
    StringBuffer idsStr = new StringBuffer();
    for (SysRole role : list)
    {
        idsStr.append(role.getRoleName()).append(",");
    }
    if (StringUtils.isNotEmpty(idsStr.toString()))
    {
        return idsStr.substring(0, idsStr.length() - 1);
    }
    return idsStr.toString();
}
 
Example 9
Source File: ExcelUtil.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 创建表格样式
 */
public void setDataValidation(Excel attr, Row row, int column)
{
    if (attr.name().indexOf("注:") >= 0)
    {
        sheet.setColumnWidth(column, 6000);
    }
    else
    {
        // 设置列宽
        sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
        row.setHeight((short) (attr.height() * 20));
    }
    // 如果设置了提示信息则鼠标放上去提示.
    if (StringUtils.isNotEmpty(attr.prompt()))
    {
        // 这里默认设了2-101列提示.
        setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
    }
    // 如果设置了combo属性则本列只能选择不能输入
    if (attr.combo().length > 0)
    {
        // 这里默认设了2-101列只能选择不能输入.
        setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
    }
}
 
Example 10
Source File: SysJob.java    From ruoyiplus with MIT License 5 votes vote down vote up
public Date getNextValidTime()
{
    if (StringUtils.isNotEmpty(cronExpression))
    {
        return CronUtils.getNextExecution(cronExpression);
    }
    return null;
}
 
Example 11
Source File: ExcelUtil.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 以类的属性的get方法方法形式获取值
 * 
 * @param o
 * @param name
 * @return value
 * @throws Exception
 */
private Object getValue(Object o, String name) throws Exception
{
    if (StringUtils.isNotEmpty(name))
    {
        Class<?> clazz = o.getClass();
        String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
        Method method = clazz.getMethod(methodName);
        o = method.invoke(o);
    }
    return o;
}
 
Example 12
Source File: SqlUtil.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 检查字符,防止注入绕过
 */
public static String escapeOrderBySql(String value)
{
    if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
    {
        return StringUtils.EMPTY;
    }
    return value;
}
 
Example 13
Source File: YamlUtil.java    From supplierShop with MIT License 5 votes vote down vote up
public static void dumpYaml(String fileName, Map<?, ?> map) throws IOException
{
    if (StringUtils.isNotEmpty(fileName))
    {
        FileWriter fileWriter = new FileWriter(YamlUtil.class.getResource(fileName).getFile());
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        yaml.dump(map, fileWriter);
    }
}
 
Example 14
Source File: SqlUtil.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 检查字符,防止注入绕过
 */
public static String escapeOrderBySql(String value)
{
    if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
    {
        return StringUtils.EMPTY;
    }
    return value;
}
 
Example 15
Source File: SysMenuServiceImpl.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 查询系统所有权限
 * 
 * @return 权限列表
 */
@Override
public LinkedHashMap<String, String> selectPermsAll(Long userId)
{
    LinkedHashMap<String, String> section = new LinkedHashMap<>();
    List<SysMenu> permissions = selectMenuAll(userId);
    if (StringUtils.isNotEmpty(permissions))
    {
        for (SysMenu menu : permissions)
        {
            section.put(menu.getUrl(), MessageFormat.format(PREMISSION_STRING, menu.getPerms()));
        }
    }
    return section;
}
 
Example 16
Source File: SysMenuServiceImpl.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 根据用户ID查询权限
 * 
 * @param userId 用户ID
 * @return 权限列表
 */
@Override
public Set<String> selectMenuPermsByUserId(Long userId)
{
    List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
    Set<String> permsSet = new HashSet<>();
    for (String perm : perms)
    {
        if (StringUtils.isNotEmpty(perm))
        {
            permsSet.addAll(Arrays.asList(perm.trim().split(",")));
        }
    }
    return permsSet;
}
 
Example 17
Source File: SysJob.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getNextValidTime()
{
    if (StringUtils.isNotEmpty(cronExpression))
    {
        return CronUtils.getNextExecution(cronExpression);
    }
    return null;
}
 
Example 18
Source File: LogoutFilter.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 退出跳转URL
 */
@Override
protected String getRedirectUrl(ServletRequest request, ServletResponse response, Subject subject)
{
    String url = getLoginUrl();
    if (StringUtils.isNotEmpty(url))
    {
        return url;
    }
    return super.getRedirectUrl(request, response, subject);
}
 
Example 19
Source File: ExcelUtil.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 以类的属性的get方法方法形式获取值
 * 
 * @param o
 * @param name
 * @return value
 * @throws Exception
 */
private Object getValue(Object o, String name) throws Exception
{
    if (StringUtils.isNotEmpty(name))
    {
        Class<?> clazz = o.getClass();
        String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
        Method method = clazz.getMethod(methodName);
        o = method.invoke(o);
    }
    return o;
}
 
Example 20
Source File: YamlUtil.java    From ruoyiplus with MIT License 4 votes vote down vote up
public static Map<?, ?> loadYaml(String fileName) throws FileNotFoundException
{
    InputStream in = YamlUtil.class.getClassLoader().getResourceAsStream(fileName);
    if(in == null) return null;
    return StringUtils.isNotEmpty(fileName) ? (LinkedHashMap<?, ?>) new Yaml().load(in) : null;
}