diff --git a/.gitignore b/.gitignore index fd446f44..2c0e049a 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,8 @@ nbdist/ # Others *.log *.xml.versionsBackup +*.swp !*/build/*.java !*/build/*.html -!*/build/*.xml \ No newline at end of file +!*/build/*.xml diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 494fb4b4..d950b77f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -476,7 +476,7 @@ public class ExcelUtil { if (ColumnType.STRING == attr.cellType()) { - cell.setCellType(CellType.NUMERIC); + cell.setCellType(CellType.STRING); cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); } else if (ColumnType.NUMERIC == attr.cellType()) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java index 19bd77ef..9993b98f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java @@ -5,7 +5,10 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.StringUtils; /** * spring工具类 方便在非spring管理环境中获取bean @@ -13,17 +16,25 @@ import org.springframework.stereotype.Component; * @author ruoyi */ @Component -public final class SpringUtils implements BeanFactoryPostProcessor +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { /** Spring应用上下文环境 */ private static ConfigurableListableBeanFactory beanFactory; + private static ApplicationContext applicationContext; + @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { SpringUtils.beanFactory = beanFactory; } + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + SpringUtils.applicationContext = applicationContext; + } + /** * 获取对象 * @@ -111,4 +122,25 @@ public final class SpringUtils implements BeanFactoryPostProcessor { return (T) AopContext.currentProxy(); } + + /** + * 获取当前的环境配置,无配置返回null + * + * @return 当前的环境配置 + */ + public static String[] getActiveProfiles() + { + return applicationContext.getEnvironment().getActiveProfiles(); + } + + /** + * 获取当前的环境配置,当有多个环境配置时,只获取第一个 + * + * @return 当前的环境配置 + */ + public static String getActiveProfile() + { + final String[] activeProfiles = getActiveProfiles(); + return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java index 67862a33..f80a8771 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java @@ -75,7 +75,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService @Override public SysUserOnline loginUserToUserOnline(LoginUser user) { - if (StringUtils.isNull(user) && StringUtils.isNull(user.getUser())) + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) { return null; } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml index a1c8efd0..2c6f74a2 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml @@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index af54bd9f..3eb449e9 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - where dict_type = #{dictType} + where dict_type = #{dictType} limit 1 diff --git a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index c713ec34..302ca565 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -118,7 +118,7 @@ diff --git a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml index 0b689c77..c82d808f 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -64,12 +64,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index 48331ff9..d57f2a14 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -80,12 +80,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml index f9fc3e61..532b5e56 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml @@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 9ca29a39..a1c926a8 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -92,15 +92,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index f62368e7..112d453d 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -32,17 +32,14 @@ service.interceptors.response.use(res => { // 获取错误信息 const msg = errorCode[code] || res.data.msg || errorCode['default'] if (code === 401) { - MessageBox.confirm( - '登录状态已过期,您可以继续留在该页面,或者重新登录', - '系统提示', - { + MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' } ).then(() => { store.dispatch('LogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + location.href = '/index'; }) }) } else if (code === 500) { diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 5b109a07..838fc1f3 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -54,15 +54,12 @@ export function resetForm(refName) { } // 添加日期范围 -export function addDateRange(params, dateRange) { - var search = params; - search.beginTime = ""; - search.endTime = ""; - if (null != dateRange && '' != dateRange) { - search.beginTime = this.dateRange[0]; - search.endTime = this.dateRange[1]; +export function addDateRange (params = {}, dateRange) { + if (dateRange != null && dateRange !== '') { + params.beginTime = this.dateRange[0] + params.endTime = this.dateRange[1] } - return search; + return params } // 回显数据字典 @@ -83,8 +80,8 @@ export function selectDictLabels(datas, value, separator) { var currentSeparator = undefined === separator ? "," : separator; var temp = value.split(currentSeparator); Object.keys(value.split(currentSeparator)).some((val) => { - Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + temp[val])) { + Object.keys(datas).some((key) => { + if (datas[key].dictValue == ('' + temp[val])) { actions.push(datas[key].dictLabel + currentSeparator); } }) @@ -146,4 +143,3 @@ export function handleTree(data, id, parentId, children, rootId) { }); return treeData != '' ? treeData : data; } -