Search in sources :

Example 1 with UtilException

use of com.ruoyi.common.exception.UtilException in project RuoYi-Vue-fast by yangzongzhuan.

the class ExcelUtil method exportExcel.

/**
 * 对list数据源将其里面的数据导入到excel表单
 *
 * @return 结果
 */
public AjaxResult exportExcel() {
    OutputStream out = null;
    try {
        writeSheet();
        String filename = encodingFilename(sheetName);
        out = new FileOutputStream(getAbsoluteFile(filename));
        wb.write(out);
        return AjaxResult.success(filename);
    } catch (Exception e) {
        log.error("导出Excel异常{}", e.getMessage());
        throw new UtilException("导出Excel失败,请联系网站管理员!");
    } finally {
        IOUtils.closeQuietly(wb);
        IOUtils.closeQuietly(out);
    }
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) UtilException(com.ruoyi.common.exception.UtilException) IOException(java.io.IOException)

Example 2 with UtilException

use of com.ruoyi.common.exception.UtilException in project RuoYi-Vue by yangzongzhuan.

the class ExcelUtil method exportExcel.

/**
 * 对list数据源将其里面的数据导入到excel表单
 *
 * @return 结果
 */
public AjaxResult exportExcel() {
    OutputStream out = null;
    try {
        writeSheet();
        String filename = encodingFilename(sheetName);
        out = new FileOutputStream(getAbsoluteFile(filename));
        wb.write(out);
        return AjaxResult.success(filename);
    } catch (Exception e) {
        log.error("导出Excel异常{}", e.getMessage());
        throw new UtilException("导出Excel失败,请联系网站管理员!");
    } finally {
        IOUtils.closeQuietly(wb);
        IOUtils.closeQuietly(out);
    }
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) UtilException(com.ruoyi.common.exception.UtilException) IOException(java.io.IOException)

Example 3 with UtilException

use of com.ruoyi.common.exception.UtilException in project RuoYi-Vue-Plus by JavaLionLi.

the class LoginHelper method getUserId.

/**
 * 获取用户id
 */
public static Long getUserId() {
    LoginUser loginUser = getLoginUser();
    if (ObjectUtil.isNull(loginUser)) {
        String loginId = StpUtil.getLoginIdAsString();
        String userId = null;
        for (UserType value : UserType.values()) {
            if (StringUtils.contains(loginId, value.getUserType())) {
                String[] strs = StringUtils.split(loginId, JOIN_CODE);
                // 用户id在总是在最后
                userId = strs[strs.length - 1];
            }
        }
        if (StringUtils.isBlank(userId)) {
            throw new UtilException("登录用户: LoginId异常 => " + loginId);
        }
        return Long.parseLong(userId);
    }
    return loginUser.getUserId();
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) UserType(com.ruoyi.common.enums.UserType)

Example 4 with UtilException

use of com.ruoyi.common.exception.UtilException in project RuoYi-Vue-Oracle by yangzongzhuan.

the class ExcelUtil method exportExcel.

/**
 * 对list数据源将其里面的数据导入到excel表单
 *
 * @return 结果
 */
public AjaxResult exportExcel() {
    OutputStream out = null;
    try {
        writeSheet();
        String filename = encodingFilename(sheetName);
        out = new FileOutputStream(getAbsoluteFile(filename));
        wb.write(out);
        return AjaxResult.success(filename);
    } catch (Exception e) {
        log.error("导出Excel异常{}", e.getMessage());
        throw new UtilException("导出Excel失败,请联系网站管理员!");
    } finally {
        IOUtils.closeQuietly(wb);
        IOUtils.closeQuietly(out);
    }
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) UtilException(com.ruoyi.common.exception.UtilException) IOException(java.io.IOException)

Example 5 with UtilException

use of com.ruoyi.common.exception.UtilException in project RuoYi-Flowable-Plus by KonBAI-Q.

the class LoginHelper method getUserId.

/**
 * 获取用户id
 */
public static Long getUserId() {
    LoginUser loginUser = getLoginUser();
    if (ObjectUtil.isNull(loginUser)) {
        String loginId = StpUtil.getLoginIdAsString();
        String userId = null;
        for (UserType value : UserType.values()) {
            if (StringUtils.contains(loginId, value.getUserType())) {
                String[] strs = StringUtils.split(loginId, JOIN_CODE);
                // 用户id在总是在最后
                userId = strs[strs.length - 1];
            }
        }
        if (StringUtils.isBlank(userId)) {
            throw new UtilException("登录用户: LoginId异常 => " + loginId);
        }
        return Long.parseLong(userId);
    }
    return loginUser.getUserId();
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) UserType(com.ruoyi.common.enums.UserType)

Aggregations

UtilException (com.ruoyi.common.exception.UtilException)6 FileOutputStream (java.io.FileOutputStream)4 IOException (java.io.IOException)4 OutputStream (java.io.OutputStream)4 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)2 UserType (com.ruoyi.common.enums.UserType)2