版本更新 v2.2.0

This commit is contained in:
疯狂的狮子li 2021-05-25 14:31:52 +08:00
parent 8a94526110
commit a42ef126cd
29 changed files with 260 additions and 85 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ruoyi-vue-plus", "name": "ruoyi-vue-plus",
"version": "2.1.2", "version": "2.2.0",
"description": "RuoYi-Vue-Plus后台管理系统", "description": "RuoYi-Vue-Plus后台管理系统",
"author": "LionLi", "author": "LionLi",
"license": "MIT", "license": "MIT",

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= webpackConfig.name %></title> <title><%= webpackConfig.name %></title>
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
<style> <style>
html, html,
body, body,

View File

@ -80,7 +80,21 @@
<span>更新日志</span> <span>更新日志</span>
</div> </div>
<el-collapse accordion> <el-collapse accordion>
<el-collapse-item title="v2.1.1 - 2021-5-21"> <el-collapse-item title="v2.2.0 - 2021-5-25">
<ol>
<li>同步升级 RuoYi-Vue 3.5.0</li>
<li>add 增加验证码开关</li>
<li>add 新增IE浏览器版本过低提示页面</li>
<li>update 升级druid到最新版本v1.2.6</li>
<li>update 升级fastjson到最新版1.2.76</li>
<li>update 修改bo加入判断是否设置必填再加载必填注解</li>
<li>update 生成vue模板导出按钮点击后添加遮罩</li>
<li>update Redis设置HashKey序列化</li>
<li>update 优化Redis序列化配置</li>
<li>fix 修复代码生成器中表字段取消必填无法更新问题</li>
</ol>
</el-collapse-item>
<el-collapse-item title="v2.1.2 - 2021-5-21">
<ol> <ol>
<li>update springboot 升级 2.3.11</li> <li>update springboot 升级 2.3.11</li>
<li>update mybatis-plus 升级 3.4.3 分页Plus对象适配更新</li> <li>update mybatis-plus 升级 3.4.3 分页Plus对象适配更新</li>
@ -166,7 +180,7 @@ export default {
data() { data() {
return { return {
// //
version: "2.1.0", version: "2.2.0",
}; };
}, },
methods: { methods: {

View File

@ -18,7 +18,7 @@
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code"> <el-form-item prop="code" v-if="captchaEnabled">
<el-input <el-input
v-model="loginForm.code" v-model="loginForm.code"
auto-complete="off" auto-complete="off"
@ -81,7 +81,8 @@ export default {
code: [{ required: true, trigger: "change", message: "验证码不能为空" }] code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
}, },
loading: false, loading: false,
redirect: undefined redirect: undefined,
captchaEnabled:false
}; };
}, },
watch: { watch: {
@ -99,8 +100,11 @@ export default {
methods: { methods: {
getCode() { getCode() {
getCodeImg().then(res => { getCodeImg().then(res => {
this.codeUrl = "data:image/gif;base64," + res.data.img; this.captchaEnabled = res.data.enabled;
this.loginForm.uuid = res.data.uuid; if(res.data.enabled){
this.codeUrl = "data:image/gif;base64," + res.data.img;
this.loginForm.uuid = res.data.uuid;
}
}); });
}, },
getCookie() { getCookie() {

View File

@ -75,6 +75,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:job:export']" v-hasPermi="['monitor:job:export']"
>导出</el-button> >导出</el-button>
@ -274,6 +275,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -477,12 +480,14 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportJob(queryParams); return exportJob(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }
}; };
</script> </script>

View File

@ -89,6 +89,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:job:export']" v-hasPermi="['monitor:job:export']"
>导出</el-button> >导出</el-button>
@ -175,6 +176,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -288,10 +291,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportJobLog(queryParams); return exportJobLog(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }

View File

@ -83,6 +83,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:logininfor:export']" v-hasPermi="['monitor:logininfor:export']"
>导出</el-button> >导出</el-button>
@ -126,6 +127,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -221,10 +224,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportLogininfor(queryParams); return exportLogininfor(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }

View File

@ -99,6 +99,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:operlog:export']" v-hasPermi="['monitor:operlog:export']"
>导出</el-button> >导出</el-button>
@ -195,6 +196,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -309,10 +312,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportOperlog(queryParams); return exportOperlog(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }

View File

@ -88,6 +88,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:config:export']" v-hasPermi="['system:config:export']"
>导出</el-button> >导出</el-button>
@ -188,6 +189,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -344,10 +347,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportConfig(queryParams); return exportConfig(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
}, },
/** 清理缓存按钮操作 */ /** 清理缓存按钮操作 */
@ -358,4 +363,4 @@ export default {
} }
} }
}; };
</script> </script>

View File

@ -75,6 +75,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:dict:export']" v-hasPermi="['system:dict:export']"
>导出</el-button> >导出</el-button>
@ -169,6 +170,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -343,10 +346,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportData(queryParams); return exportData(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }

View File

@ -94,6 +94,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:dict:export']" v-hasPermi="['system:dict:export']"
>导出</el-button> >导出</el-button>
@ -196,6 +197,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -348,10 +351,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportType(queryParams); return exportType(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
}, },
/** 清理缓存按钮操作 */ /** 清理缓存按钮操作 */
@ -362,4 +367,4 @@ export default {
} }
} }
}; };
</script> </script>

View File

@ -176,7 +176,7 @@
</template> </template>
<script> <script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice, exportNotice } from "@/api/system/notice"; import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
export default { export default {
@ -340,4 +340,4 @@ export default {
} }
} }
}; };
</script> </script>

View File

@ -74,6 +74,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:post:export']" v-hasPermi="['system:post:export']"
>导出</el-button> >导出</el-button>
@ -112,7 +113,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
@ -163,6 +164,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -315,12 +318,14 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportPost(queryParams); return exportPost(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }
}; };
</script> </script>

View File

@ -94,6 +94,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:role:export']" v-hasPermi="['system:role:export']"
>导出</el-button> >导出</el-button>
@ -258,6 +259,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -599,10 +602,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportRole(queryParams); return exportRole(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }

View File

@ -131,6 +131,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:user:export']" v-hasPermi="['system:user:export']"
>导出</el-button> >导出</el-button>
@ -356,6 +357,8 @@ export default {
return { return {
// //
loading: true, loading: true,
//
exportLoading: false,
// //
ids: [], ids: [],
// //
@ -637,10 +640,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return exportUser(queryParams); return exportUser(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
}, },
/** 导入按钮操作 */ /** 导入按钮操作 */

View File

@ -13,16 +13,16 @@
<description>RuoYi-Vue-Plus后台管理系统</description> <description>RuoYi-Vue-Plus后台管理系统</description>
<properties> <properties>
<ruoyi-vue-plus.version>2.1.2</ruoyi-vue-plus.version> <ruoyi-vue-plus.version>2.2.0</ruoyi-vue-plus.version>
<spring-boot.version>2.3.11.RELEASE</spring-boot.version> <spring-boot.version>2.3.11.RELEASE</spring-boot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<druid.version>1.2.4</druid.version> <druid.version>1.2.6</druid.version>
<knife4j.version>3.0.2</knife4j.version> <knife4j.version>3.0.2</knife4j.version>
<swagger-annotations.version>1.5.22</swagger-annotations.version> <swagger-annotations.version>1.5.22</swagger-annotations.version>
<fastjson.version>1.2.75</fastjson.version> <fastjson.version>1.2.76</fastjson.version>
<poi.version>4.1.2</poi.version> <poi.version>4.1.2</poi.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
<jwt.version>0.9.1</jwt.version> <jwt.version>0.9.1</jwt.version>

View File

@ -12,7 +12,7 @@ import java.util.Set;
/** /**
* 登录用户身份权限 * 登录用户身份权限
* *
* @author ruoyi * @author ruoyi
*/ */
@ -81,6 +81,7 @@ public class LoginUser implements UserDetails
return user.getPassword(); return user.getPassword();
} }
@JsonIgnore
@Override @Override
public String getUsername() public String getUsername()
{ {
@ -99,7 +100,7 @@ public class LoginUser implements UserDetails
/** /**
* 指定用户是否解锁,锁定的用户无法进行身份验证 * 指定用户是否解锁,锁定的用户无法进行身份验证
* *
* @return * @return
*/ */
@JsonIgnore @JsonIgnore
@ -111,7 +112,7 @@ public class LoginUser implements UserDetails
/** /**
* 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
* *
* @return * @return
*/ */
@JsonIgnore @JsonIgnore
@ -123,7 +124,7 @@ public class LoginUser implements UserDetails
/** /**
* 是否可用 ,禁用的用户不能身份验证 * 是否可用 ,禁用的用户不能身份验证
* *
* @return * @return
*/ */
@JsonIgnore @JsonIgnore
@ -133,6 +134,7 @@ public class LoginUser implements UserDetails
return true; return true;
} }
@JsonIgnore
@Override @Override
public Collection<? extends GrantedAuthority> getAuthorities() public Collection<? extends GrantedAuthority> getAuthorities()
{ {

View File

@ -1,6 +1,7 @@
package com.ruoyi.common.filter; package com.ruoyi.common.filter;
import cn.hutool.core.lang.Validator; import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HtmlUtil; import cn.hutool.http.HtmlUtil;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -15,7 +16,7 @@ import java.io.IOException;
/** /**
* XSS过滤处理 * XSS过滤处理
* *
* @author ruoyi * @author ruoyi
*/ */
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
@ -94,12 +95,12 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
/** /**
* 是否是Json请求 * 是否是Json请求
* *
* @param request * @param request
*/ */
public boolean isJsonRequest() public boolean isJsonRequest()
{ {
String header = super.getHeader(HttpHeaders.CONTENT_TYPE); String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header); return StrUtil.startWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
} }
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.framework.aspectj; package com.ruoyi.framework.aspectj;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -36,7 +37,7 @@ import java.util.Map;
/** /**
* 操作日志记录处理 * 操作日志记录处理
* *
* @author ruoyi * @author ruoyi
*/ */
@Aspect @Aspect
@ -64,7 +65,7 @@ public class LogAspect
/** /**
* 拦截异常操作 * 拦截异常操作
* *
* @param joinPoint 切点 * @param joinPoint 切点
* @param e 异常 * @param e 异常
*/ */
@ -130,7 +131,7 @@ public class LogAspect
/** /**
* 获取注解中对方法的描述信息 用于Controller层注解 * 获取注解中对方法的描述信息 用于Controller层注解
* *
* @param log 日志 * @param log 日志
* @param operLog 操作日志 * @param operLog 操作日志
* @throws Exception * @throws Exception
@ -153,7 +154,7 @@ public class LogAspect
/** /**
* 获取请求的参数放到log中 * 获取请求的参数放到log中
* *
* @param operLog 操作日志 * @param operLog 操作日志
* @throws Exception 异常 * @throws Exception 异常
*/ */
@ -198,7 +199,7 @@ public class LogAspect
{ {
for (int i = 0; i < paramsArray.length; i++) for (int i = 0; i < paramsArray.length; i++)
{ {
if (!isFilterObject(paramsArray[i])) if (Validator.isNotNull(paramsArray[i]) && !isFilterObject(paramsArray[i]))
{ {
Object jsonObj = JSON.toJSON(paramsArray[i]); Object jsonObj = JSON.toJSON(paramsArray[i]);
params += jsonObj.toString() + " "; params += jsonObj.toString() + " ";
@ -210,7 +211,7 @@ public class LogAspect
/** /**
* 判断是否需要过滤的对象 * 判断是否需要过滤的对象
* *
* @param o 对象信息 * @param o 对象信息
* @return 如果是需要过滤的对象则返回true否则返回false * @return 如果是需要过滤的对象则返回true否则返回false
*/ */

View File

@ -1,5 +1,6 @@
package com.ruoyi.framework.config; package com.ruoyi.framework.config;
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -7,15 +8,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
/** /**
* redis配置 * redis配置
* *
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
@ -29,16 +25,17 @@ public class RedisConfig extends CachingConfigurerSupport
RedisTemplate<Object, Object> template = new RedisTemplate<>(); RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory); template.setConnectionFactory(connectionFactory);
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); GenericFastJsonRedisSerializer serializer = new GenericFastJsonRedisSerializer();
StringRedisSerializer keySerializer = new StringRedisSerializer();
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);
// 使用StringRedisSerializer来序列化和反序列化redis的key值 // 使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer()); template.setKeySerializer(keySerializer);
template.setValueSerializer(serializer);
// Hash的key也采用StringRedisSerializer的序列化方式
template.setHashKeySerializer(keySerializer);
template.setHashValueSerializer(serializer);
template.afterPropertiesSet(); template.afterPropertiesSet();
return template; return template;
} }

View File

@ -13,12 +13,29 @@ import org.springframework.stereotype.Component;
@Component @Component
@ConfigurationProperties(prefix = "captcha") @ConfigurationProperties(prefix = "captcha")
public class CaptchaProperties { public class CaptchaProperties {
// 验证码类型
/**
* 验证码开关
*/
private Boolean enabled;
/**
* 验证码类型
*/
private String type; private String type;
// 验证码类别
/**
* 验证码类别
*/
private String category; private String category;
// 数字验证码位数
/**
* 数字验证码位数
*/
private Integer numberLength; private Integer numberLength;
// 字符验证码长度
/**
* 字符验证码长度
*/
private Integer charLength; private Integer charLength;
} }

View File

@ -1,26 +1,33 @@
package com.ruoyi.framework.web.service; package com.ruoyi.framework.web.service;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.exception.user.CaptchaException; import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.CaptchaExpireException; import com.ruoyi.common.exception.user.CaptchaExpireException;
import com.ruoyi.common.exception.user.UserPasswordNotMatchException; import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.framework.config.properties.CaptchaProperties;
import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory; import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/** /**
* 登录校验方法 * 登录校验方法
* *
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
@ -35,9 +42,15 @@ public class SysLoginService
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
@Autowired
private CaptchaProperties captchaProperties;
@Autowired
private ISysUserService userService;
/** /**
* 登录验证 * 登录验证
* *
* @param username 用户名 * @param username 用户名
* @param password 密码 * @param password 密码
* @param code 验证码 * @param code 验证码
@ -46,19 +59,19 @@ public class SysLoginService
*/ */
public String login(String username, String password, String code, String uuid) public String login(String username, String password, String code, String uuid)
{ {
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; if(captchaProperties.getEnabled()) {
String captcha = redisCache.getCacheObject(verifyKey); String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
redisCache.deleteObject(verifyKey); String captcha = redisCache.getCacheObject(verifyKey);
if (captcha == null) redisCache.deleteObject(verifyKey);
{ if (captcha == null) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException(); throw new CaptchaExpireException();
} }
if (!code.equalsIgnoreCase(captcha)) if (!code.equalsIgnoreCase(captcha)) {
{ AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); throw new CaptchaException();
throw new CaptchaException(); }
} }
// 用户验证 // 用户验证
Authentication authentication = null; Authentication authentication = null;
try try
@ -82,7 +95,19 @@ public class SysLoginService
} }
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal(); LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUser());
// 生成token // 生成token
return tokenService.createToken(loginUser); return tokenService.createToken(loginUser);
} }
/**
* 记录登录信息
*/
public void recordLoginInfo(SysUser user)
{
user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
user.setLoginDate(DateUtils.getNowDate());
user.setUpdateBy(user.getUserName());
userService.updateUserProfile(user);
}
} }

View File

@ -143,6 +143,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
.set(cenTableColumn.getIsEdit() == null, GenTableColumn::getIsEdit, null) .set(cenTableColumn.getIsEdit() == null, GenTableColumn::getIsEdit, null)
.set(cenTableColumn.getIsList() == null, GenTableColumn::getIsList, null) .set(cenTableColumn.getIsList() == null, GenTableColumn::getIsList, null)
.set(cenTableColumn.getIsQuery() == null, GenTableColumn::getIsQuery, null) .set(cenTableColumn.getIsQuery() == null, GenTableColumn::getIsQuery, null)
.set(cenTableColumn.getIsRequired() == null, GenTableColumn::getIsRequired, null)
.eq(GenTableColumn::getColumnId,cenTableColumn.getColumnId())); .eq(GenTableColumn::getColumnId,cenTableColumn.getColumnId()));
} }
} }
@ -458,4 +459,4 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
} }
return genPath + File.separator + VelocityUtils.getFileName(template, table); return genPath + File.separator + VelocityUtils.getFileName(template, table);
} }
} }

View File

@ -52,6 +52,12 @@ public class CaptchaController {
*/ */
@GetMapping("/captchaImage") @GetMapping("/captchaImage")
public AjaxResult getCode() { public AjaxResult getCode() {
Map<String, Object> ajax = new HashMap<>();
Boolean enabled = captchaProperties.getEnabled();
ajax.put("enabled", enabled);
if (!enabled) {
return AjaxResult.success(ajax);
}
// 保存验证码信息 // 保存验证码信息
String uuid = IdUtil.simpleUUID(); String uuid = IdUtil.simpleUUID();
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
@ -90,7 +96,6 @@ public class CaptchaController {
code = captcha.getCode(); code = captcha.getCode();
} }
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
Map<String,Object> ajax = new HashMap<>();
ajax.put("uuid", uuid); ajax.put("uuid", uuid);
ajax.put("img", captcha.getImageBase64()); ajax.put("img", captcha.getImageBase64());
return AjaxResult.success(ajax); return AjaxResult.success(ajax);

View File

@ -14,6 +14,8 @@ ruoyi:
addressEnabled: false addressEnabled: false
captcha: captcha:
# 验证码开关
enabled: true
# 验证码类型 math 数组计算 char 字符验证 # 验证码类型 math 数组计算 char 字符验证
type: math type: math
# line 线段干扰 circle 圆圈干扰 shear 扭曲干扰 # line 线段干扰 circle 圆圈干扰 shear 扭曲干扰

View File

@ -29,10 +29,12 @@ public class ${ClassName}AddBo {
#if($column.javaType == 'Date') #if($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end #end
#if($column.isRequired==1)
#if($column.javaType == 'String') #if($column.javaType == 'String')
@NotBlank(message = "$column.columnComment不能为空") @NotBlank(message = "$column.columnComment不能为空")
#else #else
@NotNull(message = "$column.columnComment不能为空") @NotNull(message = "$column.columnComment不能为空")
#end
#end #end
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end #end

View File

@ -29,10 +29,12 @@ public class ${ClassName}EditBo {
#if($column.javaType == 'Date') #if($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end #end
#if($column.isRequired==1)
#if($column.javaType == 'String') #if($column.javaType == 'String')
@NotBlank(message = "$column.columnComment不能为空") @NotBlank(message = "$column.columnComment不能为空")
#else #else
@NotNull(message = "$column.columnComment不能为空") @NotNull(message = "$column.columnComment不能为空")
#end
#end #end
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end #end

View File

@ -108,6 +108,7 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['${moduleName}:${businessName}:export']" v-hasPermi="['${moduleName}:${businessName}:export']"
>导出</el-button> >导出</el-button>
@ -158,7 +159,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
@ -354,6 +355,8 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
#if($table.sub) #if($table.sub)
@ -630,10 +633,12 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }).then(() => {
this.exportLoading = true;
return export${BusinessName}(queryParams); return export${BusinessName}(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
this.exportLoading = false;
}) })
} }
} }