Explorar o código

获取ip地址开关

RuoYi %!s(int64=6) %!d(string=hai) anos
pai
achega
07ffcbf6eb
Modificáronse 28 ficheiros con 27 adicións e 55 borrados
  1. 0 1
      src/main/java/com/ruoyi/common/exception/base/BaseException.java
  2. 10 6
      src/main/java/com/ruoyi/common/utils/AddressUtils.java
  3. 0 1
      src/main/java/com/ruoyi/common/utils/MapDataUtil.java
  4. 0 2
      src/main/java/com/ruoyi/common/utils/StringUtils.java
  5. 0 1
      src/main/java/com/ruoyi/common/utils/TreeUtils.java
  6. 1 20
      src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
  7. 0 1
      src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java
  8. 0 1
      src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Ds.java
  9. 13 0
      src/main/java/com/ruoyi/framework/config/RuoYiConfig.java
  10. 0 1
      src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java
  11. 0 1
      src/main/java/com/ruoyi/framework/shiro/service/PasswordService.java
  12. 0 1
      src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java
  13. 0 1
      src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java
  14. 0 1
      src/main/java/com/ruoyi/project/monitor/job/domain/Job.java
  15. 0 2
      src/main/java/com/ruoyi/project/monitor/job/util/ScheduleRunnable.java
  16. 0 1
      src/main/java/com/ruoyi/project/monitor/online/controller/UserOnlineController.java
  17. 0 1
      src/main/java/com/ruoyi/project/monitor/operlog/domain/OperLog.java
  18. 0 1
      src/main/java/com/ruoyi/project/system/dept/service/IDeptService.java
  19. 0 2
      src/main/java/com/ruoyi/project/system/dict/mapper/DictDataMapper.java
  20. 0 1
      src/main/java/com/ruoyi/project/system/menu/service/IMenuService.java
  21. 0 2
      src/main/java/com/ruoyi/project/system/post/controller/PostController.java
  22. 0 1
      src/main/java/com/ruoyi/project/system/role/domain/Role.java
  23. 0 1
      src/main/java/com/ruoyi/project/system/user/domain/User.java
  24. 0 1
      src/main/java/com/ruoyi/project/system/user/mapper/UserMapper.java
  25. 0 1
      src/main/java/com/ruoyi/project/tool/gen/service/GenServiceImpl.java
  26. 0 1
      src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java
  27. 0 1
      src/main/java/com/ruoyi/project/tool/swagger/TestController.java
  28. 3 1
      src/main/resources/application.yml

+ 0 - 1
src/main/java/com/ruoyi/common/exception/base/BaseException.java

@@ -1,7 +1,6 @@
 package com.ruoyi.common.exception.base;
 
 import org.springframework.util.StringUtils;
-
 import com.ruoyi.common.utils.MessageUtils;
 
 /**

+ 10 - 6
src/main/java/com/ruoyi/common/utils/AddressUtils.java

@@ -2,6 +2,7 @@ package com.ruoyi.common.utils;
 
 import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.framework.config.RuoYiConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -21,12 +22,15 @@ public class AddressUtils
         String address = "";
         try
         {
-            address = HttpUtils.sendPost(IP_URL, "ip=" + ip);
-            JSONObject json = JSONObject.parseObject(address);
-            JSONObject object = json.getObject("data", JSONObject.class);
-            String region = object.getString("region");
-            String city = object.getString("city");
-            address = region + " " + city;
+            if (RuoYiConfig.isAddressEnabled())
+            {
+                address = HttpUtils.sendPost(IP_URL, "ip=" + ip);
+                JSONObject json = JSONObject.parseObject(address);
+                JSONObject object = json.getObject("data", JSONObject.class);
+                String region = object.getString("region");
+                String city = object.getString("city");
+                address = region + " " + city;
+            }
         }
         catch (Exception e)
         {

+ 0 - 1
src/main/java/com/ruoyi/common/utils/MapDataUtil.java

@@ -4,7 +4,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import javax.servlet.http.HttpServletRequest;
 
 /**

+ 0 - 2
src/main/java/com/ruoyi/common/utils/StringUtils.java

@@ -2,9 +2,7 @@ package com.ruoyi.common.utils;
 
 import java.util.Collection;
 import java.util.Map;
-
 import org.apache.commons.lang.text.StrBuilder;
-
 import com.ruoyi.common.support.StrFormatter;
 
 /**

+ 0 - 1
src/main/java/com/ruoyi/common/utils/TreeUtils.java

@@ -3,7 +3,6 @@ package com.ruoyi.common.utils;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-
 import com.ruoyi.project.system.menu.domain.Menu;
 
 /**

+ 1 - 20
src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java

@@ -31,7 +31,6 @@ import org.apache.poi.ss.util.CellRangeAddressList;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.ResourceUtils;
-
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
@@ -104,7 +103,7 @@ public class ExcelUtil<T>
                     }
                     else
                     {
-                        // 先设置Cell的类型,然后就可以把纯数字作为String类型读进来了 by zhuyangyong 20171228
+                        // 先设置Cell的类型,然后就可以把纯数字作为String类型读进来了
                         row.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
                         cell = row.getCell(j);
                     }
@@ -351,24 +350,6 @@ public class ExcelUtil<T>
         }
     }
 
-    /**
-     * 将EXCEL中A,B,C,D,E列映射成0,1,2,3
-     * 
-     * @param col
-     */
-    // public static int getExcelCol(String col)
-    // {
-    // col = col.toUpperCase();
-    // // 从-1开始计算,字母重1开始运算。这种总数下来算数正好相同。
-    // int count = -1;
-    // char[] cs = col.toCharArray();
-    // for (int i = 0; i < cs.length; i++)
-    // {
-    // count += (cs[i] - 64) * Math.pow(26, cs.length - 1 - i);
-    // }
-    // return count;
-    // }
-
     /**
      * 设置单元格上提示
      * 

+ 0 - 1
src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java

@@ -6,7 +6,6 @@ import org.apache.shiro.session.Session;
 import org.apache.shiro.subject.PrincipalCollection;
 import org.apache.shiro.subject.SimplePrincipalCollection;
 import org.apache.shiro.subject.Subject;
-
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.framework.shiro.realm.UserRealm;

+ 0 - 1
src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Ds.java

@@ -4,7 +4,6 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-
 import com.ruoyi.framework.aspectj.lang.constant.DataSourceName;
 
 /**

+ 13 - 0
src/main/java/com/ruoyi/framework/config/RuoYiConfig.java

@@ -1,5 +1,6 @@
 package com.ruoyi.framework.config;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
@@ -20,6 +21,8 @@ public class RuoYiConfig
     private String copyrightYear;
     /** 上传路径 */
     private static String profile;
+    /** 获取地址开关 */
+    private static boolean addressEnabled;
 
     public String getName()
     {
@@ -61,4 +64,14 @@ public class RuoYiConfig
         RuoYiConfig.profile = profile;
     }
 
+    public static boolean isAddressEnabled()
+    {
+        return addressEnabled;
+    }
+
+    public void setAddressEnabled(boolean addressEnabled)
+    {
+        RuoYiConfig.addressEnabled = addressEnabled;
+    }
+
 }

+ 0 - 1
src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java

@@ -17,7 +17,6 @@ import org.apache.shiro.subject.PrincipalCollection;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-
 import com.ruoyi.common.exception.user.CaptchaException;
 import com.ruoyi.common.exception.user.RoleBlockedException;
 import com.ruoyi.common.exception.user.UserBlockedException;

+ 0 - 1
src/main/java/com/ruoyi/framework/shiro/service/PasswordService.java

@@ -8,7 +8,6 @@ import org.apache.shiro.crypto.hash.Md5Hash;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
-
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
 import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException;

+ 0 - 1
src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java

@@ -9,7 +9,6 @@ import org.apache.shiro.web.filter.AccessControlFilter;
 import org.apache.shiro.web.util.WebUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-
 import com.ruoyi.common.constant.ShiroConstants;
 import com.ruoyi.common.utils.security.ShiroUtils;
 import com.ruoyi.framework.shiro.session.OnlineSessionDAO;

+ 0 - 1
src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java

@@ -4,7 +4,6 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import org.apache.shiro.web.filter.PathMatchingFilter;
 import org.springframework.beans.factory.annotation.Autowired;
-
 import com.ruoyi.common.constant.ShiroConstants;
 import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
 import com.ruoyi.project.monitor.online.domain.OnlineSession;

+ 0 - 1
src/main/java/com/ruoyi/project/monitor/job/domain/Job.java

@@ -1,7 +1,6 @@
 package com.ruoyi.project.monitor.job.domain;
 
 import java.io.Serializable;
-
 import com.ruoyi.common.constant.ScheduleConstants;
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import com.ruoyi.framework.web.domain.BaseEntity;

+ 0 - 2
src/main/java/com/ruoyi/project/monitor/job/util/ScheduleRunnable.java

@@ -1,9 +1,7 @@
 package com.ruoyi.project.monitor.job.util;
 
 import java.lang.reflect.Method;
-
 import org.springframework.util.ReflectionUtils;
-
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.spring.SpringUtils;
 

+ 0 - 1
src/main/java/com/ruoyi/project/monitor/online/controller/UserOnlineController.java

@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
-
 import com.ruoyi.common.utils.security.ShiroUtils;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.constant.BusinessType;

+ 0 - 1
src/main/java/com/ruoyi/project/monitor/operlog/domain/OperLog.java

@@ -1,7 +1,6 @@
 package com.ruoyi.project.monitor.operlog.domain;
 
 import java.util.Date;
-
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import com.ruoyi.framework.web.domain.BaseEntity;
 

+ 0 - 1
src/main/java/com/ruoyi/project/system/dept/service/IDeptService.java

@@ -2,7 +2,6 @@ package com.ruoyi.project.system.dept.service;
 
 import java.util.List;
 import java.util.Map;
-
 import com.ruoyi.project.system.dept.domain.Dept;
 
 /**

+ 0 - 2
src/main/java/com/ruoyi/project/system/dict/mapper/DictDataMapper.java

@@ -1,9 +1,7 @@
 package com.ruoyi.project.system.dict.mapper;
 
 import java.util.List;
-
 import org.apache.ibatis.annotations.Param;
-
 import com.ruoyi.project.system.dict.domain.DictData;
 
 /**

+ 0 - 1
src/main/java/com/ruoyi/project/system/menu/service/IMenuService.java

@@ -3,7 +3,6 @@ package com.ruoyi.project.system.menu.service;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import com.ruoyi.project.system.menu.domain.Menu;
 import com.ruoyi.project.system.role.domain.Role;
 

+ 0 - 2
src/main/java/com/ruoyi/project/system/post/controller/PostController.java

@@ -1,7 +1,6 @@
 package com.ruoyi.project.system.post.controller;
 
 import java.util.List;
-
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -11,7 +10,6 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
-
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;

+ 0 - 1
src/main/java/com/ruoyi/project/system/role/domain/Role.java

@@ -1,7 +1,6 @@
 package com.ruoyi.project.system.role.domain;
 
 import java.util.Arrays;
-
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import com.ruoyi.framework.web.domain.BaseEntity;
 

+ 0 - 1
src/main/java/com/ruoyi/project/system/user/domain/User.java

@@ -3,7 +3,6 @@ package com.ruoyi.project.system.user.domain;
 import java.util.Arrays;
 import java.util.Date;
 import org.apache.shiro.crypto.SecureRandomNumberGenerator;
-
 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import com.ruoyi.framework.web.domain.BaseEntity;
 import com.ruoyi.project.system.dept.domain.Dept;

+ 0 - 1
src/main/java/com/ruoyi/project/system/user/mapper/UserMapper.java

@@ -1,7 +1,6 @@
 package com.ruoyi.project.system.user.mapper;
 
 import com.ruoyi.project.system.user.domain.User;
-
 import java.util.List;
 
 /**

+ 0 - 1
src/main/java/com/ruoyi/project/tool/gen/service/GenServiceImpl.java

@@ -12,7 +12,6 @@ import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.StringUtils;

+ 0 - 1
src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java

@@ -2,7 +2,6 @@ package com.ruoyi.project.tool.gen.util;
 
 import java.util.Properties;
 import org.apache.velocity.app.Velocity;
-
 import com.ruoyi.common.constant.Constants;
 
 /**

+ 0 - 1
src/main/java/com/ruoyi/project/tool/swagger/TestController.java

@@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import io.swagger.annotations.Api;

+ 3 - 1
src/main/resources/application.yml

@@ -8,6 +8,8 @@ ruoyi:
   copyrightYear: 2018
   #头像上传路径
   profile: D:/profile/
+  # 获取ip地址开关
+  addressEnabled: false
 #开发环境配置
 server:
   #服务端口
@@ -54,7 +56,7 @@ spring:
        max-request-size:  30MB
   devtools:
     restart:
-      #禁用devtools模块的热部署功能
+      #热部署开关
       enabled: true
 # MyBatis
 mybatis: