Ver Fonte

'暂停对system依赖'

yq há 2 anos atrás
pai
commit
90d72c0e5f
17 ficheiros alterados com 708 adições e 1214 exclusões
  1. 150 150
      base-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java
  2. 212 211
      base-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
  3. 29 29
      base-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java
  4. 0 1
      base-modules/pom.xml
  5. 0 74
      base-modules/service-auth/pom.xml
  6. 0 21
      base-modules/service-auth/src/main/java/com/ruoyi/auth/RuoYiAuthApplication.java
  7. 0 87
      base-modules/service-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
  8. 0 39
      base-modules/service-auth/src/main/java/com/ruoyi/auth/form/LoginBody.java
  9. 0 11
      base-modules/service-auth/src/main/java/com/ruoyi/auth/form/RegisterBody.java
  10. 0 160
      base-modules/service-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
  11. 0 10
      base-modules/service-auth/src/main/resources/banner.txt
  12. 0 25
      base-modules/service-auth/src/main/resources/bootstrap.yml
  13. 0 74
      base-modules/service-auth/src/main/resources/logback.xml
  14. 48 48
      base-modules/service-file/src/main/java/com/ruoyi/file/controller/SysFileController.java
  15. 50 50
      base-modules/service-file/src/main/java/com/ruoyi/file/service/LocalSysFileServiceImpl.java
  16. 45 45
      base-modules/service-file/src/main/java/com/ruoyi/file/service/MinioSysFileServiceImpl.java
  17. 174 179
      base-modules/service-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java

+ 150 - 150
base-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java

@@ -1,150 +1,150 @@
-package com.ruoyi.common.datascope.aspect;
-
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.springframework.stereotype.Component;
-import com.ruoyi.common.core.utils.StringUtils;
-import com.ruoyi.common.core.web.domain.BaseEntity;
-import com.ruoyi.common.datascope.annotation.DataScope;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.domain.SysRole;
-import com.ruoyi.system.api.domain.SysUser;
-import com.ruoyi.system.api.model.LoginUser;
-
-/**
- * 数据过滤处理
- * 
- * @author ruoyi
- */
-@Aspect
-@Component
-public class DataScopeAspect
-{
-    /**
-     * 全部数据权限
-     */
-    public static final String DATA_SCOPE_ALL = "1";
-
-    /**
-     * 自定数据权限
-     */
-    public static final String DATA_SCOPE_CUSTOM = "2";
-
-    /**
-     * 部门数据权限
-     */
-    public static final String DATA_SCOPE_DEPT = "3";
-
-    /**
-     * 部门及以下数据权限
-     */
-    public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
-
-    /**
-     * 仅本人数据权限
-     */
-    public static final String DATA_SCOPE_SELF = "5";
-
-    /**
-     * 数据权限过滤关键字
-     */
-    public static final String DATA_SCOPE = "dataScope";
-
-    @Before("@annotation(controllerDataScope)")
-    public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable
-    {
-        clearDataScope(point);
-        handleDataScope(point, controllerDataScope);
-    }
-
-    protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope)
-    {
-        // 获取当前的用户
-        LoginUser loginUser = SecurityUtils.getLoginUser();
-        if (StringUtils.isNotNull(loginUser))
-        {
-            SysUser currentUser = loginUser.getSysUser();
-            // 如果是超级管理员,则不过滤数据
-            if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
-            {
-                dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
-                        controllerDataScope.userAlias());
-            }
-        }
-    }
-
-    /**
-     * 数据范围过滤
-     * 
-     * @param joinPoint 切点
-     * @param user 用户
-     * @param deptAlias 部门别名
-     * @param userAlias 用户别名
-     */
-    public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias)
-    {
-        StringBuilder sqlString = new StringBuilder();
-
-        for (SysRole role : user.getRoles())
-        {
-            String dataScope = role.getDataScope();
-            if (DATA_SCOPE_ALL.equals(dataScope))
-            {
-                sqlString = new StringBuilder();
-                break;
-            }
-            else if (DATA_SCOPE_CUSTOM.equals(dataScope))
-            {
-                sqlString.append(StringUtils.format(
-                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
-                        role.getRoleId()));
-            }
-            else if (DATA_SCOPE_DEPT.equals(dataScope))
-            {
-                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
-            }
-            else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
-            {
-                sqlString.append(StringUtils.format(
-                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
-                        deptAlias, user.getDeptId(), user.getDeptId()));
-            }
-            else if (DATA_SCOPE_SELF.equals(dataScope))
-            {
-                if (StringUtils.isNotBlank(userAlias))
-                {
-                    sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
-                }
-                else
-                {
-                    // 数据权限为仅本人且没有userAlias别名不查询任何数据
-                    sqlString.append(" OR 1=0 ");
-                }
-            }
-        }
-
-        if (StringUtils.isNotBlank(sqlString.toString()))
-        {
-            Object params = joinPoint.getArgs()[0];
-            if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
-            {
-                BaseEntity baseEntity = (BaseEntity) params;
-                baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
-            }
-        }
-    }
-
-    /**
-     * 拼接权限sql前先清空params.dataScope参数防止注入
-     */
-    private void clearDataScope(final JoinPoint joinPoint)
-    {
-        Object params = joinPoint.getArgs()[0];
-        if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
-        {
-            BaseEntity baseEntity = (BaseEntity) params;
-            baseEntity.getParams().put(DATA_SCOPE, "");
-        }
-    }
-}
+//package com.ruoyi.common.datascope.aspect;
+//
+//import org.aspectj.lang.JoinPoint;
+//import org.aspectj.lang.annotation.Aspect;
+//import org.aspectj.lang.annotation.Before;
+//import org.springframework.stereotype.Component;
+//import com.ruoyi.common.core.utils.StringUtils;
+//import com.ruoyi.common.core.web.domain.BaseEntity;
+//import com.ruoyi.common.datascope.annotation.DataScope;
+//import com.ruoyi.common.security.utils.SecurityUtils;
+//import com.ruoyi.system.api.domain.SysRole;
+//import com.ruoyi.system.api.domain.SysUser;
+//import com.ruoyi.system.api.model.LoginUser;
+//
+///**
+// * 数据过滤处理
+// *
+// * @author ruoyi
+// */
+//@Aspect
+//@Component
+//public class DataScopeAspect
+//{
+//    /**
+//     * 全部数据权限
+//     */
+//    public static final String DATA_SCOPE_ALL = "1";
+//
+//    /**
+//     * 自定数据权限
+//     */
+//    public static final String DATA_SCOPE_CUSTOM = "2";
+//
+//    /**
+//     * 部门数据权限
+//     */
+//    public static final String DATA_SCOPE_DEPT = "3";
+//
+//    /**
+//     * 部门及以下数据权限
+//     */
+//    public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
+//
+//    /**
+//     * 仅本人数据权限
+//     */
+//    public static final String DATA_SCOPE_SELF = "5";
+//
+//    /**
+//     * 数据权限过滤关键字
+//     */
+//    public static final String DATA_SCOPE = "dataScope";
+//
+//    @Before("@annotation(controllerDataScope)")
+//    public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable
+//    {
+//        clearDataScope(point);
+//        handleDataScope(point, controllerDataScope);
+//    }
+//
+//    protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope)
+//    {
+//        // 获取当前的用户
+//        LoginUser loginUser = SecurityUtils.getLoginUser();
+//        if (StringUtils.isNotNull(loginUser))
+//        {
+//            SysUser currentUser = loginUser.getSysUser();
+//            // 如果是超级管理员,则不过滤数据
+//            if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
+//            {
+//                dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
+//                        controllerDataScope.userAlias());
+//            }
+//        }
+//    }
+//
+//    /**
+//     * 数据范围过滤
+//     *
+//     * @param joinPoint 切点
+//     * @param user 用户
+//     * @param deptAlias 部门别名
+//     * @param userAlias 用户别名
+//     */
+//    public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias)
+//    {
+//        StringBuilder sqlString = new StringBuilder();
+//
+//        for (SysRole role : user.getRoles())
+//        {
+//            String dataScope = role.getDataScope();
+//            if (DATA_SCOPE_ALL.equals(dataScope))
+//            {
+//                sqlString = new StringBuilder();
+//                break;
+//            }
+//            else if (DATA_SCOPE_CUSTOM.equals(dataScope))
+//            {
+//                sqlString.append(StringUtils.format(
+//                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
+//                        role.getRoleId()));
+//            }
+//            else if (DATA_SCOPE_DEPT.equals(dataScope))
+//            {
+//                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
+//            }
+//            else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
+//            {
+//                sqlString.append(StringUtils.format(
+//                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
+//                        deptAlias, user.getDeptId(), user.getDeptId()));
+//            }
+//            else if (DATA_SCOPE_SELF.equals(dataScope))
+//            {
+//                if (StringUtils.isNotBlank(userAlias))
+//                {
+//                    sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
+//                }
+//                else
+//                {
+//                    // 数据权限为仅本人且没有userAlias别名不查询任何数据
+//                    sqlString.append(" OR 1=0 ");
+//                }
+//            }
+//        }
+//
+//        if (StringUtils.isNotBlank(sqlString.toString()))
+//        {
+//            Object params = joinPoint.getArgs()[0];
+//            if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
+//            {
+//                BaseEntity baseEntity = (BaseEntity) params;
+//                baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
+//            }
+//        }
+//    }
+//
+//    /**
+//     * 拼接权限sql前先清空params.dataScope参数防止注入
+//     */
+//    private void clearDataScope(final JoinPoint joinPoint)
+//    {
+//        Object params = joinPoint.getArgs()[0];
+//        if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
+//        {
+//            BaseEntity baseEntity = (BaseEntity) params;
+//            baseEntity.getParams().put(DATA_SCOPE, "");
+//        }
+//    }
+//}

+ 212 - 211
base-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java

@@ -1,211 +1,212 @@
-package com.ruoyi.common.log.aspect;
-
-import java.util.Collection;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.AfterReturning;
-import org.aspectj.lang.annotation.AfterThrowing;
-import org.aspectj.lang.annotation.Aspect;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-import org.springframework.stereotype.Component;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.multipart.MultipartFile;
-import com.alibaba.fastjson.JSON;
-import com.ruoyi.common.core.utils.ServletUtils;
-import com.ruoyi.common.core.utils.StringUtils;
-import com.ruoyi.common.core.utils.ip.IpUtils;
-import com.ruoyi.common.log.annotation.Log;
-import com.ruoyi.common.log.enums.BusinessStatus;
-import com.ruoyi.common.log.service.AsyncLogService;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.domain.SysOperLog;
-
-/**
- * 操作日志记录处理
- * 
- * @author ruoyi
- */
-@Aspect
-@Component
-public class LogAspect
-{
-    private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
-    
-    @Autowired
-    private AsyncLogService asyncLogService;
-
-    /**
-     * 处理完请求后执行
-     *
-     * @param joinPoint 切点
-     */
-    @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
-    public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult)
-    {
-        handleLog(joinPoint, controllerLog, null, jsonResult);
-    }
-
-    /**
-     * 拦截异常操作
-     * 
-     * @param joinPoint 切点
-     * @param e 异常
-     */
-    @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
-    public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e)
-    {
-        handleLog(joinPoint, controllerLog, e, null);
-    }
-
-    protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult)
-    {
-        try
-        {
-            // *========数据库日志=========*//
-            SysOperLog operLog = new SysOperLog();
-            operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
-            // 请求的地址
-            String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
-            operLog.setOperIp(ip);
-            operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
-            String username = SecurityUtils.getUsername();
-            if (StringUtils.isNotBlank(username))
-            {
-                operLog.setOperName(username);
-            }
-
-            if (e != null)
-            {
-                operLog.setStatus(BusinessStatus.FAIL.ordinal());
-                operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
-            }
-            // 设置方法名称
-            String className = joinPoint.getTarget().getClass().getName();
-            String methodName = joinPoint.getSignature().getName();
-            operLog.setMethod(className + "." + methodName + "()");
-            // 设置请求方式
-            operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
-            // 处理设置注解上的参数
-            getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
-            // 保存数据库
-            asyncLogService.saveSysLog(operLog);
-        }
-        catch (Exception exp)
-        {
-            // 记录本地异常日志
-            log.error("==前置通知异常==");
-            log.error("异常信息:{}", exp.getMessage());
-            exp.printStackTrace();
-        }
-    }
-
-    /**
-     * 获取注解中对方法的描述信息 用于Controller层注解
-     * 
-     * @param log 日志
-     * @param operLog 操作日志
-     * @throws Exception
-     */
-    public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception
-    {
-        // 设置action动作
-        operLog.setBusinessType(log.businessType().ordinal());
-        // 设置标题
-        operLog.setTitle(log.title());
-        // 设置操作人类别
-        operLog.setOperatorType(log.operatorType().ordinal());
-        // 是否需要保存request,参数和值
-        if (log.isSaveRequestData())
-        {
-            // 获取参数的信息,传入到数据库中。
-            setRequestValue(joinPoint, operLog);
-        }
-        // 是否需要保存response,参数和值
-        if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
-        {
-            operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
-        }
-    }
-
-    /**
-     * 获取请求的参数,放到log中
-     * 
-     * @param operLog 操作日志
-     * @throws Exception 异常
-     */
-    private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception
-    {
-        String requestMethod = operLog.getRequestMethod();
-        if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))
-        {
-            String params = argsArrayToString(joinPoint.getArgs());
-            operLog.setOperParam(StringUtils.substring(params, 0, 2000));
-        }
-    }
-
-    /**
-     * 参数拼装
-     */
-    private String argsArrayToString(Object[] paramsArray)
-    {
-        String params = "";
-        if (paramsArray != null && paramsArray.length > 0)
-        {
-            for (Object o : paramsArray)
-            {
-                if (StringUtils.isNotNull(o) && !isFilterObject(o))
-                {
-                    try
-                    {
-                        Object jsonObj = JSON.toJSON(o);
-                        params += jsonObj.toString() + " ";
-                    }
-                    catch (Exception e)
-                    {
-                    }
-                }
-            }
-        }
-        return params.trim();
-    }
-
-    /**
-     * 判断是否需要过滤的对象。
-     * 
-     * @param o 对象信息。
-     * @return 如果是需要过滤的对象,则返回true;否则返回false。
-     */
-    @SuppressWarnings("rawtypes")
-    public boolean isFilterObject(final Object o)
-    {
-        Class<?> clazz = o.getClass();
-        if (clazz.isArray())
-        {
-            return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
-        }
-        else if (Collection.class.isAssignableFrom(clazz))
-        {
-            Collection collection = (Collection) o;
-            for (Object value : collection)
-            {
-                return value instanceof MultipartFile;
-            }
-        }
-        else if (Map.class.isAssignableFrom(clazz))
-        {
-            Map map = (Map) o;
-            for (Object value : map.entrySet())
-            {
-                Map.Entry entry = (Map.Entry) value;
-                return entry.getValue() instanceof MultipartFile;
-            }
-        }
-        return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
-                || o instanceof BindingResult;
-    }
-}
+//package com.ruoyi.common.log.aspect;
+//
+//import java.util.Collection;
+//import java.util.Map;
+//import javax.servlet.http.HttpServletRequest;
+//import javax.servlet.http.HttpServletResponse;
+//
+//import com.usky.system.domain.SysOperLogVO;
+//import org.aspectj.lang.JoinPoint;
+//import org.aspectj.lang.annotation.AfterReturning;
+//import org.aspectj.lang.annotation.AfterThrowing;
+//import org.aspectj.lang.annotation.Aspect;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.http.HttpMethod;
+//import org.springframework.stereotype.Component;
+//import org.springframework.validation.BindingResult;
+//import org.springframework.web.multipart.MultipartFile;
+//import com.alibaba.fastjson.JSON;
+//import com.ruoyi.common.core.utils.ServletUtils;
+//import com.ruoyi.common.core.utils.StringUtils;
+//import com.ruoyi.common.core.utils.ip.IpUtils;
+//import com.ruoyi.common.log.annotation.Log;
+//import com.ruoyi.common.log.enums.BusinessStatus;
+//import com.ruoyi.common.log.service.AsyncLogService;
+//import com.ruoyi.common.security.utils.SecurityUtils;
+//
+///**
+// * 操作日志记录处理
+// *
+// * @author ruoyi
+// */
+//@Aspect
+//@Component
+//public class LogAspect
+//{
+//    private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
+//
+//    @Autowired
+//    private AsyncLogService asyncLogService;
+//
+//    /**
+//     * 处理完请求后执行
+//     *
+//     * @param joinPoint 切点
+//     */
+//    @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
+//    public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult)
+//    {
+//        handleLog(joinPoint, controllerLog, null, jsonResult);
+//    }
+//
+//    /**
+//     * 拦截异常操作
+//     *
+//     * @param joinPoint 切点
+//     * @param e 异常
+//     */
+//    @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
+//    public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e)
+//    {
+//        handleLog(joinPoint, controllerLog, e, null);
+//    }
+//
+//    protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult)
+//    {
+//        try
+//        {
+//            // *========数据库日志=========*//
+//            SysOperLogVO operLog = new SysOperLogVO();
+//            operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
+//            // 请求的地址
+//            String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
+//            operLog.setOperIp(ip);
+//            operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
+//            String username = SecurityUtils.getUsername();
+//            if (StringUtils.isNotBlank(username))
+//            {
+//                operLog.setOperName(username);
+//            }
+//
+//            if (e != null)
+//            {
+//                operLog.setStatus(BusinessStatus.FAIL.ordinal());
+//                operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
+//            }
+//            // 设置方法名称
+//            String className = joinPoint.getTarget().getClass().getName();
+//            String methodName = joinPoint.getSignature().getName();
+//            operLog.setMethod(className + "." + methodName + "()");
+//            // 设置请求方式
+//            operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
+//            // 处理设置注解上的参数
+//            getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
+//            // 保存数据库
+//            asyncLogService.saveSysLog(operLog);
+//        }
+//        catch (Exception exp)
+//        {
+//            // 记录本地异常日志
+//            log.error("==前置通知异常==");
+//            log.error("异常信息:{}", exp.getMessage());
+//            exp.printStackTrace();
+//        }
+//    }
+//
+//    /**
+//     * 获取注解中对方法的描述信息 用于Controller层注解
+//     *
+//     * @param log 日志
+//     * @param operLog 操作日志
+//     * @throws Exception
+//     */
+//    public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLogVO operLog, Object jsonResult) throws Exception
+//    {
+//        // 设置action动作
+//        operLog.setBusinessType(log.businessType().ordinal());
+//        // 设置标题
+//        operLog.setTitle(log.title());
+//        // 设置操作人类别
+//        operLog.setOperatorType(log.operatorType().ordinal());
+//        // 是否需要保存request,参数和值
+//        if (log.isSaveRequestData())
+//        {
+//            // 获取参数的信息,传入到数据库中。
+//            setRequestValue(joinPoint, operLog);
+//        }
+//        // 是否需要保存response,参数和值
+//        if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
+//        {
+//            operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
+//        }
+//    }
+//
+//    /**
+//     * 获取请求的参数,放到log中
+//     *
+//     * @param operLog 操作日志
+//     * @throws Exception 异常
+//     */
+//    private void setRequestValue(JoinPoint joinPoint, SysOperLogVO operLog) throws Exception
+//    {
+//        String requestMethod = operLog.getRequestMethod();
+//        if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))
+//        {
+//            String params = argsArrayToString(joinPoint.getArgs());
+//            operLog.setOperParam(StringUtils.substring(params, 0, 2000));
+//        }
+//    }
+//
+//    /**
+//     * 参数拼装
+//     */
+//    private String argsArrayToString(Object[] paramsArray)
+//    {
+//        String params = "";
+//        if (paramsArray != null && paramsArray.length > 0)
+//        {
+//            for (Object o : paramsArray)
+//            {
+//                if (StringUtils.isNotNull(o) && !isFilterObject(o))
+//                {
+//                    try
+//                    {
+//                        Object jsonObj = JSON.toJSON(o);
+//                        params += jsonObj.toString() + " ";
+//                    }
+//                    catch (Exception e)
+//                    {
+//                    }
+//                }
+//            }
+//        }
+//        return params.trim();
+//    }
+//
+//    /**
+//     * 判断是否需要过滤的对象。
+//     *
+//     * @param o 对象信息。
+//     * @return 如果是需要过滤的对象,则返回true;否则返回false。
+//     */
+//    @SuppressWarnings("rawtypes")
+//    public boolean isFilterObject(final Object o)
+//    {
+//        Class<?> clazz = o.getClass();
+//        if (clazz.isArray())
+//        {
+//            return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
+//        }
+//        else if (Collection.class.isAssignableFrom(clazz))
+//        {
+//            Collection collection = (Collection) o;
+//            for (Object value : collection)
+//            {
+//                return value instanceof MultipartFile;
+//            }
+//        }
+//        else if (Map.class.isAssignableFrom(clazz))
+//        {
+//            Map map = (Map) o;
+//            for (Object value : map.entrySet())
+//            {
+//                Map.Entry entry = (Map.Entry) value;
+//                return entry.getValue() instanceof MultipartFile;
+//            }
+//        }
+//        return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
+//                || o instanceof BindingResult;
+//    }
+//}

+ 29 - 29
base-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java

@@ -1,29 +1,29 @@
-package com.ruoyi.common.log.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-import com.ruoyi.common.core.constant.SecurityConstants;
-import com.ruoyi.system.api.RemoteLogService;
-import com.ruoyi.system.api.domain.SysOperLog;
-
-/**
- * 异步调用日志服务
- * 
- * @author ruoyi
- */
-@Service
-public class AsyncLogService
-{
-    @Autowired
-    private RemoteLogService remoteLogService;
-
-    /**
-     * 保存系统日志记录
-     */
-    @Async
-    public void saveSysLog(SysOperLog sysOperLog)
-    {
-        remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
-    }
-}
+//package com.ruoyi.common.log.service;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.scheduling.annotation.Async;
+//import org.springframework.stereotype.Service;
+//import com.ruoyi.common.core.constant.SecurityConstants;
+//import com.ruoyi.system.api.RemoteLogService;
+//import com.ruoyi.system.api.domain.SysOperLog;
+//
+///**
+// * 异步调用日志服务
+// *
+// * @author ruoyi
+// */
+//@Service
+//public class AsyncLogService
+//{
+//    @Autowired
+//    private RemoteLogService remoteLogService;
+//
+//    /**
+//     * 保存系统日志记录
+//     */
+//    @Async
+//    public void saveSysLog(SysOperLog sysOperLog)
+//    {
+//        remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
+//    }
+//}

+ 0 - 1
base-modules/pom.xml

@@ -9,7 +9,6 @@
     <modelVersion>4.0.0</modelVersion>
 
     <modules>
-        <module>service-auth</module>
         <module>service-gen</module>
         <module>service-job</module>
         <module>service-file</module>

+ 0 - 74
base-modules/service-auth/pom.xml

@@ -1,74 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <groupId>com.usky</groupId>
-        <artifactId>base-modules</artifactId>
-        <version>0.0.1</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-    
-    <artifactId>service-auth</artifactId>
-	
-    <description>
-        service-auth认证授权中心
-    </description>
-    
-    <dependencies>
-        
-        <!-- SpringCloud Alibaba Nacos -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
-        </dependency>
-        
-        <!-- SpringCloud Alibaba Nacos Config -->
-        <dependency>
-            <groupId>com.alibaba.cloud</groupId>
-            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-        </dependency>
-        
-        <!-- SpringCloud Alibaba Sentinel -->
-<!--        <dependency>-->
-<!--            <groupId>com.alibaba.cloud</groupId>-->
-<!--            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>-->
-<!--        </dependency>-->
-		
-        <!-- SpringBoot Web -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
-        
-        <!-- SpringBoot Actuator -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
-		
-        <!-- RuoYi Common Security-->
-        <dependency>
-            <groupId>com.usky</groupId>
-            <artifactId>ruoyi-common-security</artifactId>
-        </dependency>
-        
-    </dependencies>
-	
-    <build>
-        <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-   
-</project>

+ 0 - 21
base-modules/service-auth/src/main/java/com/ruoyi/auth/RuoYiAuthApplication.java

@@ -1,21 +0,0 @@
-package com.ruoyi.auth;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import com.ruoyi.common.security.annotation.EnableRyFeignClients;
-
-/**
- * 认证授权中心
- * 
- * @author ruoyi
- */
-@EnableRyFeignClients
-@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
-public class RuoYiAuthApplication
-{
-    public static void main(String[] args)
-    {
-        SpringApplication.run(RuoYiAuthApplication.class, args);
-    }
-}

+ 0 - 87
base-modules/service-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java

@@ -1,87 +0,0 @@
-package com.ruoyi.auth.controller;
-
-import javax.servlet.http.HttpServletRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.auth.form.LoginBody;
-import com.ruoyi.auth.form.RegisterBody;
-import com.ruoyi.auth.service.SysLoginService;
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.common.core.utils.JwtUtils;
-import com.ruoyi.common.core.utils.StringUtils;
-import com.ruoyi.common.security.auth.AuthUtil;
-import com.ruoyi.common.security.service.TokenService;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.model.LoginUser;
-
-/**
- * token 控制
- * 
- * @author ruoyi
- */
-@RestController
-public class TokenController
-{
-    @Autowired
-    private TokenService tokenService;
-
-    @Autowired
-    private SysLoginService sysLoginService;
-
-    @PostMapping("login")
-    public R<?> login(@RequestBody LoginBody form)
-    {
-        // 用户登录
-        LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
-        // 获取登录token
-        return R.ok(tokenService.createToken(userInfo));
-    }
-
-    @PostMapping("login1")
-    public R<?> login1(@RequestBody LoginBody form)
-    {
-        // 用户登录
-        LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
-        // 获取登录token
-        return R.ok(tokenService.createToken(userInfo));
-    }
-
-    @DeleteMapping("logout")
-    public R<?> logout(HttpServletRequest request)
-    {
-        String token = SecurityUtils.getToken(request);
-        if (StringUtils.isNotEmpty(token))
-        {
-            String username = JwtUtils.getUserName(token);
-            // 删除用户缓存记录
-            AuthUtil.logoutByToken(token);
-            // 记录用户退出日志
-            sysLoginService.logout(username);
-        }
-        return R.ok();
-    }
-
-    @PostMapping("refresh")
-    public R<?> refresh(HttpServletRequest request)
-    {
-        LoginUser loginUser = tokenService.getLoginUser(request);
-        if (StringUtils.isNotNull(loginUser))
-        {
-            // 刷新令牌有效期
-            tokenService.refreshToken(loginUser);
-            return R.ok();
-        }
-        return R.ok();
-    }
-
-    @PostMapping("register")
-    public R<?> register(@RequestBody RegisterBody registerBody)
-    {
-        // 用户注册
-        sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
-        return R.ok();
-    }
-}

+ 0 - 39
base-modules/service-auth/src/main/java/com/ruoyi/auth/form/LoginBody.java

@@ -1,39 +0,0 @@
-package com.ruoyi.auth.form;
-
-/**
- * 用户登录对象
- * 
- * @author ruoyi
- */
-public class LoginBody
-{
-    /**
-     * 用户名
-     */
-    private String username;
-
-    /**
-     * 用户密码
-     */
-    private String password;
-
-    public String getUsername()
-    {
-        return username;
-    }
-
-    public void setUsername(String username)
-    {
-        this.username = username;
-    }
-
-    public String getPassword()
-    {
-        return password;
-    }
-
-    public void setPassword(String password)
-    {
-        this.password = password;
-    }
-}

+ 0 - 11
base-modules/service-auth/src/main/java/com/ruoyi/auth/form/RegisterBody.java

@@ -1,11 +0,0 @@
-package com.ruoyi.auth.form;
-
-/**
- * 用户注册对象
- * 
- * @author ruoyi
- */
-public class RegisterBody extends LoginBody
-{
-
-}

+ 0 - 160
base-modules/service-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java

@@ -1,160 +0,0 @@
-package com.ruoyi.auth.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import com.ruoyi.common.core.constant.Constants;
-import com.ruoyi.common.core.constant.SecurityConstants;
-import com.ruoyi.common.core.constant.UserConstants;
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.common.core.enums.UserStatus;
-import com.ruoyi.common.core.exception.ServiceException;
-import com.ruoyi.common.core.utils.ServletUtils;
-import com.ruoyi.common.core.utils.StringUtils;
-import com.ruoyi.common.core.utils.ip.IpUtils;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.RemoteLogService;
-import com.ruoyi.system.api.RemoteUserService;
-import com.ruoyi.system.api.domain.SysLogininfor;
-import com.ruoyi.system.api.domain.SysUser;
-import com.ruoyi.system.api.model.LoginUser;
-
-/**
- * 登录校验方法
- * 
- * @author ruoyi
- */
-@Component
-public class SysLoginService
-{
-    @Autowired
-    private RemoteLogService remoteLogService;
-
-    @Autowired
-    private RemoteUserService remoteUserService;
-
-    /**
-     * 登录
-     */
-    public LoginUser login(String username, String password)
-    {
-        // 用户名或密码为空 错误
-        if (StringUtils.isAnyBlank(username, password))
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
-            throw new ServiceException("用户/密码必须填写");
-        }
-        // 密码如果不在指定范围内 错误
-        if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
-                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
-            throw new ServiceException("用户密码不在指定范围");
-        }
-        // 用户名不在指定范围内 错误
-        if (username.length() < UserConstants.USERNAME_MIN_LENGTH
-                || username.length() > UserConstants.USERNAME_MAX_LENGTH)
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
-            throw new ServiceException("用户名不在指定范围");
-        }
-
-        // 查询用户信息
-        R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
-
-        if (R.FAIL == userResult.getCode())
-        {
-            throw new ServiceException(userResult.getMsg());
-        }
-
-        if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
-            throw new ServiceException("登录用户:" + username + " 不存在");
-        }
-        LoginUser userInfo = userResult.getData();
-        SysUser user = userResult.getData().getSysUser();
-        if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
-            throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
-        }
-        if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
-            throw new ServiceException("对不起,您的账号:" + username + " 已停用");
-        }
-        if (!SecurityUtils.matchesPassword(password, user.getPassword()))
-        {
-            recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误");
-            throw new ServiceException("用户不存在/密码错误");
-        }
-        recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
-        return userInfo;
-    }
-
-    public void logout(String loginName)
-    {
-        recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
-    }
-
-    /**
-     * 注册
-     */
-    public void register(String username, String password)
-    {
-        // 用户名或密码为空 错误
-        if (StringUtils.isAnyBlank(username, password))
-        {
-            throw new ServiceException("用户/密码必须填写");
-        }
-        if (username.length() < UserConstants.USERNAME_MIN_LENGTH
-                || username.length() > UserConstants.USERNAME_MAX_LENGTH)
-        {
-            throw new ServiceException("账户长度必须在2到20个字符之间");
-        }
-        if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
-                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
-        {
-            throw new ServiceException("密码长度必须在5到20个字符之间");
-        }
-
-        // 注册用户信息
-        SysUser sysUser = new SysUser();
-        sysUser.setUserName(username);
-        sysUser.setNickName(username);
-        sysUser.setPassword(SecurityUtils.encryptPassword(password));
-        R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
-
-        if (R.FAIL == registerResult.getCode())
-        {
-            throw new ServiceException(registerResult.getMsg());
-        }
-        recordLogininfor(username, Constants.REGISTER, "注册成功");
-    }
-
-    /**
-     * 记录登录信息
-     * 
-     * @param username 用户名
-     * @param status 状态
-     * @param message 消息内容
-     * @return
-     */
-    public void recordLogininfor(String username, String status, String message)
-    {
-        SysLogininfor logininfor = new SysLogininfor();
-        logininfor.setUserName(username);
-        logininfor.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest()));
-        logininfor.setMsg(message);
-        // 日志状态
-        if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
-        {
-            logininfor.setStatus(Constants.LOGIN_SUCCESS_STATUS);
-        }
-        else if (Constants.LOGIN_FAIL.equals(status))
-        {
-            logininfor.setStatus(Constants.LOGIN_FAIL_STATUS);
-        }
-        remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER);
-    }
-}

+ 0 - 10
base-modules/service-auth/src/main/resources/banner.txt

@@ -1,10 +0,0 @@
-Spring Boot Version: ${spring-boot.version}
-Spring Application Name: ${spring.application.name}
-                            _                        _    _     
-                           (_)                      | |  | |    
- _ __  _   _   ___   _   _  _  ______   __ _  _   _ | |_ | |__  
-| '__|| | | | / _ \ | | | || ||______| / _` || | | || __|| '_ \ 
-| |   | |_| || (_) || |_| || |        | (_| || |_| || |_ | | | |
-|_|    \__,_| \___/  \__, ||_|         \__,_| \__,_| \__||_| |_|
-                      __/ |                                     
-                     |___/                                      

+ 0 - 25
base-modules/service-auth/src/main/resources/bootstrap.yml

@@ -1,25 +0,0 @@
-# Tomcat
-server: 
-  port: 9200
-
-# Spring
-spring: 
-  application:
-    # 应用名称
-    name: service-auth
-  profiles:
-    # 环境配置
-    active: dev
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: 172.16.120.165:8848
-      config:
-        # 配置中心地址
-        server-addr: 172.16.120.165:8848
-        # 配置文件格式
-        file-extension: yml
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 0 - 74
base-modules/service-auth/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-	<property name="log.path" value="/var/log/uskycloud/auth" />
-   <!-- 日志输出格式 -->
-	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
-
-    <!-- 控制台输出 -->
-	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder>
-			<pattern>${log.pattern}</pattern>
-		</encoder>
-	</appender>
-
-    <!-- 系统日志输出 -->
-	<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-			<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-			<!-- 日志最大的历史 60天 -->
-			<maxHistory>60</maxHistory>
-		</rollingPolicy>
-		<encoder>
-			<pattern>${log.pattern}</pattern>
-		</encoder>
-		<filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-	</appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-			<!-- 日志最大的历史 60天 -->
-			<maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-			<!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-			<!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-	<logger name="com.ruoyi" level="info" />
-	<!-- Spring日志级别控制  -->
-	<logger name="org.springframework" level="warn" />
-
-	<root level="info">
-		<appender-ref ref="console" />
-	</root>
-	
-	<!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info" />
-        <appender-ref ref="file_error" />
-    </root>
-</configuration>

+ 48 - 48
base-modules/service-file/src/main/java/com/ruoyi/file/controller/SysFileController.java

@@ -1,48 +1,48 @@
-package com.ruoyi.file.controller;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.common.core.utils.file.FileUtils;
-import com.ruoyi.file.service.ISysFileService;
-import com.ruoyi.system.api.domain.SysFile;
-
-/**
- * 文件请求处理
- * 
- * @author ruoyi
- */
-@RestController
-public class SysFileController
-{
-    private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
-
-    @Autowired
-    private ISysFileService sysFileService;
-
-    /**
-     * 文件上传请求
-     */
-    @PostMapping("upload")
-    public R<SysFile> upload(MultipartFile file)
-    {
-        try
-        {
-            // 上传并返回访问地址
-            String url = sysFileService.uploadFile(file);
-            SysFile sysFile = new SysFile();
-            sysFile.setName(FileUtils.getName(url));
-            sysFile.setUrl(url);
-            return R.ok(sysFile);
-        }
-        catch (Exception e)
-        {
-            log.error("上传文件失败", e);
-            return R.fail(e.getMessage());
-        }
-    }
-}
+//package com.ruoyi.file.controller;
+//
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.PostMapping;
+//import org.springframework.web.bind.annotation.RestController;
+//import org.springframework.web.multipart.MultipartFile;
+//import com.ruoyi.common.core.domain.R;
+//import com.ruoyi.common.core.utils.file.FileUtils;
+//import com.ruoyi.file.service.ISysFileService;
+//import com.ruoyi.system.api.domain.SysFile;
+//
+///**
+// * 文件请求处理
+// *
+// * @author ruoyi
+// */
+//@RestController
+//public class SysFileController
+//{
+//    private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
+//
+//    @Autowired
+//    private ISysFileService sysFileService;
+//
+//    /**
+//     * 文件上传请求
+//     */
+//    @PostMapping("upload")
+//    public R<SysFile> upload(MultipartFile file)
+//    {
+//        try
+//        {
+//            // 上传并返回访问地址
+//            String url = sysFileService.uploadFile(file);
+//            SysFile sysFile = new SysFile();
+//            sysFile.setName(FileUtils.getName(url));
+//            sysFile.setUrl(url);
+//            return R.ok(sysFile);
+//        }
+//        catch (Exception e)
+//        {
+//            log.error("上传文件失败", e);
+//            return R.fail(e.getMessage());
+//        }
+//    }
+//}

+ 50 - 50
base-modules/service-file/src/main/java/com/ruoyi/file/service/LocalSysFileServiceImpl.java

@@ -1,50 +1,50 @@
-package com.ruoyi.file.service;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.file.utils.FileUploadUtils;
-
-/**
- * 本地文件存储
- * 
- * @author ruoyi
- */
-@Primary
-@Service
-public class LocalSysFileServiceImpl implements ISysFileService
-{
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String localFilePrefix;
-
-    /**
-     * 域名或本机访问地址
-     */
-    @Value("${file.domain}")
-    public String domain;
-    
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String localFilePath;
-
-    /**
-     * 本地文件上传接口
-     * 
-     * @param file 上传的文件
-     * @return 访问地址
-     * @throws Exception
-     */
-    @Override
-    public String uploadFile(MultipartFile file) throws Exception
-    {
-        String name = FileUploadUtils.upload(localFilePath, file);
-        String url = domain + localFilePrefix + name;
-        return url;
-    }
-}
+//package com.ruoyi.file.service;
+//
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.context.annotation.Primary;
+//import org.springframework.stereotype.Service;
+//import org.springframework.web.multipart.MultipartFile;
+//import com.ruoyi.file.utils.FileUploadUtils;
+//
+///**
+// * 本地文件存储
+// *
+// * @author ruoyi
+// */
+//@Primary
+//@Service
+//public class LocalSysFileServiceImpl implements ISysFileService
+//{
+//    /**
+//     * 资源映射路径 前缀
+//     */
+//    @Value("${file.prefix}")
+//    public String localFilePrefix;
+//
+//    /**
+//     * 域名或本机访问地址
+//     */
+//    @Value("${file.domain}")
+//    public String domain;
+//
+//    /**
+//     * 上传文件存储在本地的根路径
+//     */
+//    @Value("${file.path}")
+//    private String localFilePath;
+//
+//    /**
+//     * 本地文件上传接口
+//     *
+//     * @param file 上传的文件
+//     * @return 访问地址
+//     * @throws Exception
+//     */
+//    @Override
+//    public String uploadFile(MultipartFile file) throws Exception
+//    {
+//        String name = FileUploadUtils.upload(localFilePath, file);
+//        String url = domain + localFilePrefix + name;
+//        return url;
+//    }
+//}

+ 45 - 45
base-modules/service-file/src/main/java/com/ruoyi/file/service/MinioSysFileServiceImpl.java

@@ -1,45 +1,45 @@
-package com.ruoyi.file.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.file.config.MinioConfig;
-import com.ruoyi.file.utils.FileUploadUtils;
-import io.minio.MinioClient;
-import io.minio.PutObjectArgs;
-
-/**
- * Minio 文件存储
- * 
- * @author ruoyi
- */
-@Service
-public class MinioSysFileServiceImpl implements ISysFileService
-{
-    @Autowired
-    private MinioConfig minioConfig;
-
-    @Autowired
-    private MinioClient client;
-
-    /**
-     * 本地文件上传接口
-     * 
-     * @param file 上传的文件
-     * @return 访问地址
-     * @throws Exception
-     */
-    @Override
-    public String uploadFile(MultipartFile file) throws Exception
-    {
-        String fileName = FileUploadUtils.extractFilename(file);
-        PutObjectArgs args = PutObjectArgs.builder()
-                .bucket(minioConfig.getBucketName())
-                .object(fileName)
-                .stream(file.getInputStream(), file.getSize(), -1)
-                .contentType(file.getContentType())
-                .build();
-        client.putObject(args);
-        return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
-    }
-}
+//package com.ruoyi.file.service;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//import org.springframework.web.multipart.MultipartFile;
+//import com.ruoyi.file.config.MinioConfig;
+//import com.ruoyi.file.utils.FileUploadUtils;
+//import io.minio.MinioClient;
+//import io.minio.PutObjectArgs;
+//
+///**
+// * Minio 文件存储
+// *
+// * @author ruoyi
+// */
+//@Service
+//public class MinioSysFileServiceImpl implements ISysFileService
+//{
+//    @Autowired
+//    private MinioConfig minioConfig;
+//
+//    @Autowired
+//    private MinioClient client;
+//
+//    /**
+//     * 本地文件上传接口
+//     *
+//     * @param file 上传的文件
+//     * @return 访问地址
+//     * @throws Exception
+//     */
+//    @Override
+//    public String uploadFile(MultipartFile file) throws Exception
+//    {
+//        String fileName = FileUploadUtils.extractFilename(file);
+//        PutObjectArgs args = PutObjectArgs.builder()
+//                .bucket(minioConfig.getBucketName())
+//                .object(fileName)
+//                .stream(file.getInputStream(), file.getSize(), -1)
+//                .contentType(file.getContentType())
+//                .build();
+//        client.putObject(args);
+//        return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
+//    }
+//}

+ 174 - 179
base-modules/service-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java

@@ -5,191 +5,186 @@ import java.io.IOException;
 import java.nio.file.Paths;
 import java.util.Objects;
 import org.apache.commons.io.FilenameUtils;
+import org.springframework.util.MimeTypeUtils;
 import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException;
-import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException;
-import com.ruoyi.common.core.exception.file.InvalidExtensionException;
-import com.ruoyi.common.core.utils.DateUtils;
-import com.ruoyi.common.core.utils.StringUtils;
-import com.ruoyi.common.core.utils.file.MimeTypeUtils;
-import com.ruoyi.common.core.utils.uuid.Seq;
+
 
 /**
  * 文件上传工具类
- * 
+ *
  * @author ruoyi
  */
 public class FileUploadUtils
 {
-    /**
-     * 默认大小 50M
-     */
-    public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
-
-    /**
-     * 默认的文件名最大长度 100
-     */
-    public static final int DEFAULT_FILE_NAME_LENGTH = 100;
-
-    /**
-     * 根据文件路径上传
-     *
-     * @param baseDir 相对应用的基目录
-     * @param file 上传的文件
-     * @return 文件名称
-     * @throws IOException
-     */
-    public static final String upload(String baseDir, MultipartFile file) throws IOException
-    {
-        try
-        {
-            return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
-        }
-        catch (Exception e)
-        {
-            throw new IOException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * 文件上传
-     *
-     * @param baseDir 相对应用的基目录
-     * @param file 上传的文件
-     * @param allowedExtension 上传文件类型
-     * @return 返回上传成功的文件名
-     * @throws FileSizeLimitExceededException 如果超出最大大小
-     * @throws FileNameLengthLimitExceededException 文件名太长
-     * @throws IOException 比如读写文件出错时
-     * @throws InvalidExtensionException 文件校验异常
-     */
-    public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
-            throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
-            InvalidExtensionException
-    {
-        int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
-        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
-        {
-            throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
-        }
-
-        assertAllowed(file, allowedExtension);
-
-        String fileName = extractFilename(file);
-
-        String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
-        file.transferTo(Paths.get(absPath));
-        return getPathFileName(fileName);
-    }
-
-    /**
-     * 编码文件名
-     */
-    public static final String extractFilename(MultipartFile file)
-    {
-        return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
-                FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
-    }
-
-    private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
-    {
-        File desc = new File(uploadDir + File.separator + fileName);
-
-        if (!desc.exists())
-        {
-            if (!desc.getParentFile().exists())
-            {
-                desc.getParentFile().mkdirs();
-            }
-        }
-        return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
-    }
-
-    private static final String getPathFileName(String fileName) throws IOException
-    {
-        String pathFileName = "/" + fileName;
-        return pathFileName;
-    }
-
-    /**
-     * 文件大小校验
-     *
-     * @param file 上传的文件
-     * @throws FileSizeLimitExceededException 如果超出最大大小
-     * @throws InvalidExtensionException 文件校验异常
-     */
-    public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
-            throws FileSizeLimitExceededException, InvalidExtensionException
-    {
-        long size = file.getSize();
-        if (size > DEFAULT_MAX_SIZE)
-        {
-            throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
-        }
-
-        String fileName = file.getOriginalFilename();
-        String extension = getExtension(file);
-        if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
-        {
-            if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
-            {
-                throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
-                        fileName);
-            }
-            else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
-            {
-                throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
-                        fileName);
-            }
-            else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
-            {
-                throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
-                        fileName);
-            }
-            else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
-            {
-                throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
-                        fileName);
-            }
-            else
-            {
-                throw new InvalidExtensionException(allowedExtension, extension, fileName);
-            }
-        }
-    }
-
-    /**
-     * 判断MIME类型是否是允许的MIME类型
-     *
-     * @param extension 上传文件类型
-     * @param allowedExtension 允许上传文件类型
-     * @return true/false
-     */
-    public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
-    {
-        for (String str : allowedExtension)
-        {
-            if (str.equalsIgnoreCase(extension))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 获取文件名的后缀
-     * 
-     * @param file 表单文件
-     * @return 后缀名
-     */
-    public static final String getExtension(MultipartFile file)
-    {
-        String extension = FilenameUtils.getExtension(file.getOriginalFilename());
-        if (StringUtils.isEmpty(extension))
-        {
-            extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
-        }
-        return extension;
-    }
+//    /**
+//     * 默认大小 50M
+//     */
+//    public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
+//
+//    /**
+//     * 默认的文件名最大长度 100
+//     */
+//    public static final int DEFAULT_FILE_NAME_LENGTH = 100;
+//
+//    /**
+//     * 根据文件路径上传
+//     *
+//     * @param baseDir 相对应用的基目录
+//     * @param file 上传的文件
+//     * @return 文件名称
+//     * @throws IOException
+//     */
+//    public static final String upload(String baseDir, MultipartFile file) throws IOException
+//    {
+//        try
+//        {
+//            return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
+//        }
+//        catch (Exception e)
+//        {
+//            throw new IOException(e.getMessage(), e);
+//        }
+//    }
+//
+//    /**
+//     * 文件上传
+//     *
+//     * @param baseDir 相对应用的基目录
+//     * @param file 上传的文件
+//     * @param allowedExtension 上传文件类型
+//     * @return 返回上传成功的文件名
+//     * @throws FileSizeLimitExceededException 如果超出最大大小
+//     * @throws FileNameLengthLimitExceededException 文件名太长
+//     * @throws IOException 比如读写文件出错时
+//     * @throws InvalidExtensionException 文件校验异常
+//     */
+//    public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
+//            throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
+//            InvalidExtensionException
+//    {
+//        int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
+//        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
+//        {
+//            throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
+//        }
+//
+//        assertAllowed(file, allowedExtension);
+//
+//        String fileName = extractFilename(file);
+//
+//        String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
+//        file.transferTo(Paths.get(absPath));
+//        return getPathFileName(fileName);
+//    }
+//
+//    /**
+//     * 编码文件名
+//     */
+//    public static final String extractFilename(MultipartFile file)
+//    {
+//        return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
+//                FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
+//    }
+//
+//    private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
+//    {
+//        File desc = new File(uploadDir + File.separator + fileName);
+//
+//        if (!desc.exists())
+//        {
+//            if (!desc.getParentFile().exists())
+//            {
+//                desc.getParentFile().mkdirs();
+//            }
+//        }
+//        return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
+//    }
+//
+//    private static final String getPathFileName(String fileName) throws IOException
+//    {
+//        String pathFileName = "/" + fileName;
+//        return pathFileName;
+//    }
+//
+//    /**
+//     * 文件大小校验
+//     *
+//     * @param file 上传的文件
+//     * @throws FileSizeLimitExceededException 如果超出最大大小
+//     * @throws InvalidExtensionException 文件校验异常
+//     */
+//    public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
+//            throws FileSizeLimitExceededException, InvalidExtensionException
+//    {
+//        long size = file.getSize();
+//        if (size > DEFAULT_MAX_SIZE)
+//        {
+//            throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
+//        }
+//
+//        String fileName = file.getOriginalFilename();
+//        String extension = getExtension(file);
+//        if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
+//        {
+//            if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
+//            {
+//                throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
+//                        fileName);
+//            }
+//            else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
+//            {
+//                throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
+//                        fileName);
+//            }
+//            else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
+//            {
+//                throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
+//                        fileName);
+//            }
+//            else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
+//            {
+//                throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
+//                        fileName);
+//            }
+//            else
+//            {
+//                throw new InvalidExtensionException(allowedExtension, extension, fileName);
+//            }
+//        }
+//    }
+//
+//    /**
+//     * 判断MIME类型是否是允许的MIME类型
+//     *
+//     * @param extension 上传文件类型
+//     * @param allowedExtension 允许上传文件类型
+//     * @return true/false
+//     */
+//    public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
+//    {
+//        for (String str : allowedExtension)
+//        {
+//            if (str.equalsIgnoreCase(extension))
+//            {
+//                return true;
+//            }
+//        }
+//        return false;
+//    }
+//
+//    /**
+//     * 获取文件名的后缀
+//     *
+//     * @param file 表单文件
+//     * @return 后缀名
+//     */
+//    public static final String getExtension(MultipartFile file)
+//    {
+//        String extension = FilenameUtils.getExtension(file.getOriginalFilename());
+//        if (StringUtils.isEmpty(extension))
+//        {
+//            extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
+//        }
+//        return extension;
+//    }
 }