From d45e13696baaf0e0b603f2ce0c51045900550c82 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 10 Aug 2018 14:36:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96ip=E5=9C=B0=E5=9D=80=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/base/BaseException.java | 1 - .../com/ruoyi/common/utils/AddressUtils.java | 16 ++++++++------ .../com/ruoyi/common/utils/MapDataUtil.java | 1 - .../com/ruoyi/common/utils/StringUtils.java | 2 -- .../com/ruoyi/common/utils/TreeUtils.java | 1 - .../com/ruoyi/common/utils/poi/ExcelUtil.java | 21 +------------------ .../common/utils/security/ShiroUtils.java | 1 - .../framework/aspectj/lang/annotation/Ds.java | 1 - .../ruoyi/framework/config/RuoYiConfig.java | 13 ++++++++++++ .../framework/shiro/realm/UserRealm.java | 1 - .../shiro/service/PasswordService.java | 1 - .../filter/online/OnlineSessionFilter.java | 1 - .../filter/sync/SyncOnlineSessionFilter.java | 1 - .../ruoyi/project/monitor/job/domain/Job.java | 1 - .../monitor/job/util/ScheduleRunnable.java | 2 -- .../controller/UserOnlineController.java | 1 - .../monitor/operlog/domain/OperLog.java | 1 - .../system/dept/service/IDeptService.java | 1 - .../system/dict/mapper/DictDataMapper.java | 2 -- .../system/menu/service/IMenuService.java | 1 - .../post/controller/PostController.java | 2 -- .../project/system/role/domain/Role.java | 1 - .../project/system/user/domain/User.java | 1 - .../system/user/mapper/UserMapper.java | 1 - .../tool/gen/service/GenServiceImpl.java | 1 - .../tool/gen/util/VelocityInitializer.java | 1 - .../project/tool/swagger/TestController.java | 1 - src/main/resources/application.yml | 4 +++- 28 files changed, 27 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/ruoyi/common/exception/base/BaseException.java b/src/main/java/com/ruoyi/common/exception/base/BaseException.java index f63e21ab..fb87008c 100644 --- a/src/main/java/com/ruoyi/common/exception/base/BaseException.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/common/utils/AddressUtils.java b/src/main/java/com/ruoyi/common/utils/AddressUtils.java index 83d4ebac..27399593 100644 --- a/src/main/java/com/ruoyi/common/utils/AddressUtils.java +++ b/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) { diff --git a/src/main/java/com/ruoyi/common/utils/MapDataUtil.java b/src/main/java/com/ruoyi/common/utils/MapDataUtil.java index d3fb5a0c..d750df45 100644 --- a/src/main/java/com/ruoyi/common/utils/MapDataUtil.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/common/utils/StringUtils.java b/src/main/java/com/ruoyi/common/utils/StringUtils.java index 032a2fdc..856a0d33 100644 --- a/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/common/utils/TreeUtils.java b/src/main/java/com/ruoyi/common/utils/TreeUtils.java index 1d090c8d..35cd493f 100644 --- a/src/main/java/com/ruoyi/common/utils/TreeUtils.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 07aab332..d168e9f7 100644 --- a/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/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 } 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 } } - /** - * 将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; - // } - /** * 设置单元格上提示 * diff --git a/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java b/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java index d9830f09..9a7c2626 100644 --- a/src/main/java/com/ruoyi/common/utils/security/ShiroUtils.java +++ b/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; diff --git a/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Ds.java b/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Ds.java index 64f67472..784f27a2 100644 --- a/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Ds.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java b/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java index 2479dcc9..7f3f349b 100644 --- a/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java +++ b/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; + } + } diff --git a/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java b/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java index 7f69aa96..915ab986 100644 --- a/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java +++ b/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; diff --git a/src/main/java/com/ruoyi/framework/shiro/service/PasswordService.java b/src/main/java/com/ruoyi/framework/shiro/service/PasswordService.java index 6fa639f9..9d656792 100644 --- a/src/main/java/com/ruoyi/framework/shiro/service/PasswordService.java +++ b/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; diff --git a/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java b/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java index f4ea6b89..983f836c 100644 --- a/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java +++ b/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; diff --git a/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java b/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java index f0e75dca..05a74c84 100644 --- a/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/monitor/job/domain/Job.java b/src/main/java/com/ruoyi/project/monitor/job/domain/Job.java index b97531cc..8cf998ad 100644 --- a/src/main/java/com/ruoyi/project/monitor/job/domain/Job.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/monitor/job/util/ScheduleRunnable.java b/src/main/java/com/ruoyi/project/monitor/job/util/ScheduleRunnable.java index 6066f494..0b98d907 100644 --- a/src/main/java/com/ruoyi/project/monitor/job/util/ScheduleRunnable.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/monitor/online/controller/UserOnlineController.java b/src/main/java/com/ruoyi/project/monitor/online/controller/UserOnlineController.java index 8aa4e7a4..40455699 100644 --- a/src/main/java/com/ruoyi/project/monitor/online/controller/UserOnlineController.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/monitor/operlog/domain/OperLog.java b/src/main/java/com/ruoyi/project/monitor/operlog/domain/OperLog.java index c28553d1..6bba8a09 100644 --- a/src/main/java/com/ruoyi/project/monitor/operlog/domain/OperLog.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/system/dept/service/IDeptService.java b/src/main/java/com/ruoyi/project/system/dept/service/IDeptService.java index 9354e852..8ed1145d 100644 --- a/src/main/java/com/ruoyi/project/system/dept/service/IDeptService.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/project/system/dict/mapper/DictDataMapper.java b/src/main/java/com/ruoyi/project/system/dict/mapper/DictDataMapper.java index 2e89d369..b75b811f 100644 --- a/src/main/java/com/ruoyi/project/system/dict/mapper/DictDataMapper.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/project/system/menu/service/IMenuService.java b/src/main/java/com/ruoyi/project/system/menu/service/IMenuService.java index ab4ff6a5..95c6a3b3 100644 --- a/src/main/java/com/ruoyi/project/system/menu/service/IMenuService.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/system/post/controller/PostController.java b/src/main/java/com/ruoyi/project/system/post/controller/PostController.java index 8e4ed328..f2bbb617 100644 --- a/src/main/java/com/ruoyi/project/system/post/controller/PostController.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/system/role/domain/Role.java b/src/main/java/com/ruoyi/project/system/role/domain/Role.java index c2a5bf3c..db6870db 100644 --- a/src/main/java/com/ruoyi/project/system/role/domain/Role.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/system/user/domain/User.java b/src/main/java/com/ruoyi/project/system/user/domain/User.java index 5415055c..b4d17fd7 100644 --- a/src/main/java/com/ruoyi/project/system/user/domain/User.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/system/user/mapper/UserMapper.java b/src/main/java/com/ruoyi/project/system/user/mapper/UserMapper.java index b1bb7805..cd2e5188 100644 --- a/src/main/java/com/ruoyi/project/system/user/mapper/UserMapper.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/project/tool/gen/service/GenServiceImpl.java b/src/main/java/com/ruoyi/project/tool/gen/service/GenServiceImpl.java index c4fb994a..545eeaf4 100644 --- a/src/main/java/com/ruoyi/project/tool/gen/service/GenServiceImpl.java +++ b/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; diff --git a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java index e9b0d344..7f932fc3 100644 --- a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java +++ b/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; /** diff --git a/src/main/java/com/ruoyi/project/tool/swagger/TestController.java b/src/main/java/com/ruoyi/project/tool/swagger/TestController.java index cd5b2965..13ab65e5 100644 --- a/src/main/java/com/ruoyi/project/tool/swagger/TestController.java +++ b/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; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a1678204..f26c2792 100644 --- a/src/main/resources/application.yml +++ b/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: