mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
发布 v2.5.1 针对 v2.5.0 版本新特性bug修复
This commit is contained in:
@ -14,11 +14,6 @@ import org.springframework.stereotype.Component;
|
||||
@ConfigurationProperties(prefix = "captcha")
|
||||
public class CaptchaProperties {
|
||||
|
||||
/**
|
||||
* 验证码开关
|
||||
*/
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@ import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.framework.config.properties.CaptchaProperties;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
@ -41,10 +41,10 @@ public class SysLoginService
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private CaptchaProperties captchaProperties;
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private AsyncService asyncService;
|
||||
@ -61,19 +61,12 @@ public class SysLoginService
|
||||
public String login(String username, String password, String code, String uuid)
|
||||
{
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
if(captchaProperties.getEnabled()) {
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
redisCache.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"), request);
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"), request);
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||
// 验证码开关
|
||||
if (captchaOnOff)
|
||||
{
|
||||
validateCapcha(username, code, uuid, request);
|
||||
}
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try
|
||||
@ -102,6 +95,28 @@ public class SysLoginService
|
||||
return tokenService.createToken(loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
* @return 结果
|
||||
*/
|
||||
public void validateCapcha(String username, String code, String uuid, HttpServletRequest request) {
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
redisCache.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"), request);
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"), request);
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*/
|
||||
|
@ -35,10 +35,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
@ -137,14 +134,17 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
||||
for (GenTableColumn cenTableColumn : genTable.getColumns()) {
|
||||
genTableColumnMapper.update(cenTableColumn,
|
||||
new LambdaUpdateWrapper<GenTableColumn>()
|
||||
.set(cenTableColumn.getIsPk() == null, GenTableColumn::getIsPk, null)
|
||||
.set(cenTableColumn.getIsIncrement() == null, GenTableColumn::getIsIncrement, null)
|
||||
.set(cenTableColumn.getIsInsert() == null, GenTableColumn::getIsInsert, null)
|
||||
.set(cenTableColumn.getIsEdit() == null, GenTableColumn::getIsEdit, null)
|
||||
.set(cenTableColumn.getIsList() == null, GenTableColumn::getIsList, null)
|
||||
.set(cenTableColumn.getIsQuery() == null, GenTableColumn::getIsQuery, null)
|
||||
.set(cenTableColumn.getIsRequired() == null, GenTableColumn::getIsRequired, null)
|
||||
.eq(GenTableColumn::getColumnId,cenTableColumn.getColumnId()));
|
||||
.set(StrUtil.isBlank(cenTableColumn.getColumnComment()), GenTableColumn::getColumnComment, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsPk()), GenTableColumn::getIsPk, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsIncrement()), GenTableColumn::getIsIncrement, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsInsert()), GenTableColumn::getIsInsert, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsEdit()), GenTableColumn::getIsEdit, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsList()), GenTableColumn::getIsList, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsQuery()), GenTableColumn::getIsQuery, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getIsRequired()), GenTableColumn::getIsRequired, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getQueryType()), GenTableColumn::getQueryType, null)
|
||||
.set(StrUtil.isBlank(cenTableColumn.getDictType()), GenTableColumn::getDictType, null)
|
||||
.eq(GenTableColumn::getColumnId,cenTableColumn.getColumnId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,10 +180,14 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
||||
if (row > 0) {
|
||||
// 保存列信息
|
||||
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||
List<GenTableColumn> saveColumns = new ArrayList<>();
|
||||
for (GenTableColumn column : genTableColumns) {
|
||||
GenUtils.initColumnField(column, table);
|
||||
saveColumns.add(column);
|
||||
}
|
||||
genTableColumnMapper.insertAll(genTableColumns);
|
||||
if (CollUtil.isNotEmpty(saveColumns)) {
|
||||
genTableColumnMapper.insertAll(saveColumns);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -287,12 +291,16 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
||||
}
|
||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||
|
||||
List<GenTableColumn> saveColumns = new ArrayList<>();
|
||||
dbTableColumns.forEach(column -> {
|
||||
if (!tableColumnNames.contains(column.getColumnName())) {
|
||||
GenUtils.initColumnField(column, table);
|
||||
saveColumns.add(column);
|
||||
}
|
||||
});
|
||||
genTableColumnMapper.insertAll(tableColumns);
|
||||
if (CollUtil.isNotEmpty(saveColumns)) {
|
||||
genTableColumnMapper.insertAll(saveColumns);
|
||||
}
|
||||
|
||||
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(delColumns)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
@ -56,7 +56,7 @@ public class MetaVo {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
this.noCache = noCache;
|
||||
if (StringUtils.ishttp(link)) {
|
||||
if (Validator.isUrl(link)) {
|
||||
this.link = link;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,13 @@ public interface ISysConfigService extends IServicePlus<SysConfig> {
|
||||
*/
|
||||
public String selectConfigByKey(String configKey);
|
||||
|
||||
/**
|
||||
* 获取验证码开关
|
||||
*
|
||||
* @return true开启,false关闭
|
||||
*/
|
||||
public boolean selectCaptchaOnOff();
|
||||
|
||||
/**
|
||||
* 查询参数配置列表
|
||||
*
|
||||
|
@ -93,6 +93,19 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码开关
|
||||
*
|
||||
* @return true开启,false关闭
|
||||
*/
|
||||
public boolean selectCaptchaOnOff() {
|
||||
String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff");
|
||||
if (StrUtil.isEmpty(captchaOnOff)) {
|
||||
return true;
|
||||
}
|
||||
return Convert.toBool(captchaOnOff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询参数配置列表
|
||||
*
|
||||
|
@ -11,7 +11,6 @@ import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysRoleMenu;
|
||||
import com.ruoyi.system.domain.vo.MetaVo;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
@ -19,6 +18,7 @@ import com.ruoyi.system.mapper.SysMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -371,7 +371,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu>
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isInnerLink(SysMenu menu) {
|
||||
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath());
|
||||
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && Validator.isUrl(menu.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.framework.captcha.UnsignedMathGenerator;
|
||||
import com.ruoyi.framework.config.properties.CaptchaProperties;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -26,7 +27,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 验证码操作处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class CaptchaController {
|
||||
@ -47,15 +48,18 @@ public class CaptchaController {
|
||||
@Autowired
|
||||
private CaptchaProperties captchaProperties;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
*/
|
||||
@GetMapping("/captchaImage")
|
||||
public AjaxResult getCode() {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
Boolean enabled = captchaProperties.getEnabled();
|
||||
ajax.put("enabled", enabled);
|
||||
if (!enabled) {
|
||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||
ajax.put("captchaOnOff", captchaOnOff);
|
||||
if (!captchaOnOff) {
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
// 保存验证码信息
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@ -9,7 +10,6 @@ import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -97,7 +97,7 @@ public class SysMenuController extends BaseController
|
||||
{
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !Validator.isUrl(menu.getPath()))
|
||||
{
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class SysMenuController extends BaseController
|
||||
{
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !Validator.isUrl(menu.getPath()))
|
||||
{
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ ruoyi:
|
||||
addressEnabled: true
|
||||
|
||||
captcha:
|
||||
# 验证码开关
|
||||
enabled: true
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
type: math
|
||||
# line 线段干扰 circle 圆圈干扰 shear 扭曲干扰
|
||||
|
@ -285,7 +285,7 @@ export default {
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
// $comment字典
|
||||
${column.javaField}Options: [],
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
@ -327,7 +327,7 @@ export default {
|
||||
created() {
|
||||
this.getList();
|
||||
#foreach ($column in $columns)
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
this.getDicts("${column.dictType}").then(response => {
|
||||
this.${column.javaField}Options = response.data;
|
||||
});
|
||||
@ -379,7 +379,7 @@ export default {
|
||||
});
|
||||
},
|
||||
#foreach ($column in $columns)
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
|
@ -350,7 +350,7 @@ export default {
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
// $comment字典
|
||||
${column.javaField}Options: [],
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
@ -394,7 +394,7 @@ export default {
|
||||
created() {
|
||||
this.getList();
|
||||
#foreach ($column in $columns)
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
this.getDicts("${column.dictType}").then(response => {
|
||||
this.${column.javaField}Options = response.data;
|
||||
});
|
||||
@ -427,7 +427,7 @@ export default {
|
||||
});
|
||||
},
|
||||
#foreach ($column in $columns)
|
||||
#if(${column.dictType} != '')
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
|
Reference in New Issue
Block a user