疯狂的狮子li
2021-09-26 6f6a3566ac50bcb9bcae4ae68744c9f49b75933c
ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
@@ -1,7 +1,7 @@
package com.ruoyi.common.core.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
@@ -15,28 +15,6 @@
public class BaseController
{
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 响应返回结果
     *
     * @param rows 影响行数
     * @return 操作结果
     */
    protected AjaxResult<Void> toAjax(int rows)
    {
        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
    }
    /**
     * 响应返回结果
     *
     * @param result 结果
     * @return 操作结果
     */
    protected AjaxResult<Void> toAjax(boolean result)
    {
        return result ? success() : error();
    }
    /**
     * 返回成功
@@ -71,6 +49,28 @@
    }
    /**
     * 响应返回结果
     *
     * @param rows 影响行数
     * @return 操作结果
     */
    protected AjaxResult<Void> toAjax(int rows)
    {
        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
    }
    /**
     * 响应返回结果
     *
     * @param result 结果
     * @return 操作结果
     */
    protected AjaxResult<Void> toAjax(boolean result)
    {
        return result ? success() : error();
    }
    /**
     * 页面跳转
     */
    public String redirect(String url)
@@ -81,17 +81,16 @@
    /**
     * 获取用户缓存信息
     */
    public LoginUser getLoginUser()
    public SysUser getUser()
    {
        return SecurityUtils.getLoginUser();
        return SecurityUtils.getUser();
    }
    /**
     * 获取登录用户id
     */
    public Long getUserId()
    {
        return getLoginUser().getUserId();
    public Long getUserId() {
        return SecurityUtils.getUserId();
    }
    /**
@@ -99,7 +98,7 @@
     */
    public Long getDeptId()
    {
        return getLoginUser().getDeptId();
        return SecurityUtils.getDeptId();
    }
    /**
@@ -107,6 +106,6 @@
     */
    public String getUsername()
    {
        return getLoginUser().getUsername();
        return SecurityUtils.getUsername();
    }
}