Merge remote-tracking branch 'upstream/master' into master

pull/725/head
Emil.Zhang 2022-04-25 22:27:12 +08:00
commit bbe62c9442
11 changed files with 26 additions and 18 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
*/target/* */target/*
*/*.iml */*.iml
/.gradle/ /.gradle/
/application.pid

View File

@ -13,7 +13,7 @@
**开发文档:** [https://el-admin.vip](https://el-admin.vip) **开发文档:** [https://el-admin.vip](https://el-admin.vip)
**体验地址:** [https://el-admin.xin](https://el-admin.xin) **体验地址:** [https://el-admin.vip/demo](https://el-admin.vip/demo)
**账号密码:** `admin / 123456` **账号密码:** `admin / 123456`

View File

@ -253,7 +253,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
// 1M // 1M
int len = 1024 * 1024; int len = 1024 * 1024;
if (size > (maxSize * len)) { if (size > (maxSize * len)) {
throw new BadRequestException("文件超出规定大小"); throw new BadRequestException("文件超出规定大小:" + maxSize + "MB");
} }
} }

View File

@ -40,7 +40,7 @@ public enum CodeBiEnum {
public static CodeBiEnum find(Integer code) { public static CodeBiEnum find(Integer code) {
for (CodeBiEnum value : CodeBiEnum.values()) { for (CodeBiEnum value : CodeBiEnum.values()) {
if (code.equals(value.getCode())) { if (value.getCode().equals(code)) {
return value; return value;
} }
} }

View File

@ -43,7 +43,7 @@ public enum DataScopeEnum {
public static DataScopeEnum find(String val) { public static DataScopeEnum find(String val) {
for (DataScopeEnum dataScopeEnum : DataScopeEnum.values()) { for (DataScopeEnum dataScopeEnum : DataScopeEnum.values()) {
if (val.equals(dataScopeEnum.getValue())) { if (dataScopeEnum.getValue().equals(val)) {
return dataScopeEnum; return dataScopeEnum;
} }
} }

View File

@ -65,7 +65,7 @@ public enum RequestMethodEnum {
public static RequestMethodEnum find(String type) { public static RequestMethodEnum find(String type) {
for (RequestMethodEnum value : RequestMethodEnum.values()) { for (RequestMethodEnum value : RequestMethodEnum.values()) {
if (type.equals(value.getType())) { if (value.getType().equals(type)) {
return value; return value;
} }
} }

View File

@ -20,6 +20,7 @@ import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.utils.SpringContextHolder; import me.zhengjie.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -43,7 +44,11 @@ import org.springframework.web.bind.annotation.RestController;
public class AppRun { public class AppRun {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(AppRun.class, args); SpringApplication springApplication = new SpringApplication(AppRun.class);
// 监控应用的PID启动时可指定PID路径--spring.pid.file=/home/eladmin/app.pid
// 或者在 application.yml 添加文件路径,方便 killkill `cat /home/eladmin/app.pid`
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
} }
@Bean @Bean

View File

@ -26,18 +26,18 @@ public enum LoginCodeEnum {
/** /**
* *
*/ */
arithmetic, ARITHMETIC,
/** /**
* *
*/ */
chinese, CHINESE,
/** /**
* *
*/ */
chinese_gif, CHINESE_GIF,
/** /**
* *
*/ */
gif, GIF,
spec SPEC
} }

View File

@ -62,7 +62,7 @@ public class LoginProperties {
if (Objects.isNull(loginCode)) { if (Objects.isNull(loginCode)) {
loginCode = new LoginCode(); loginCode = new LoginCode();
if (Objects.isNull(loginCode.getCodeType())) { if (Objects.isNull(loginCode.getCodeType())) {
loginCode.setCodeType(LoginCodeEnum.arithmetic); loginCode.setCodeType(LoginCodeEnum.ARITHMETIC);
} }
} }
return switchCaptcha(loginCode); return switchCaptcha(loginCode);
@ -78,25 +78,25 @@ public class LoginProperties {
Captcha captcha; Captcha captcha;
synchronized (this) { synchronized (this) {
switch (loginCode.getCodeType()) { switch (loginCode.getCodeType()) {
case arithmetic: case ARITHMETIC:
// 算术类型 https://gitee.com/whvse/EasyCaptcha // 算术类型 https://gitee.com/whvse/EasyCaptcha
captcha = new FixedArithmeticCaptcha(loginCode.getWidth(), loginCode.getHeight()); captcha = new FixedArithmeticCaptcha(loginCode.getWidth(), loginCode.getHeight());
// 几位数运算,默认是两位 // 几位数运算,默认是两位
captcha.setLen(loginCode.getLength()); captcha.setLen(loginCode.getLength());
break; break;
case chinese: case CHINESE:
captcha = new ChineseCaptcha(loginCode.getWidth(), loginCode.getHeight()); captcha = new ChineseCaptcha(loginCode.getWidth(), loginCode.getHeight());
captcha.setLen(loginCode.getLength()); captcha.setLen(loginCode.getLength());
break; break;
case chinese_gif: case CHINESE_GIF:
captcha = new ChineseGifCaptcha(loginCode.getWidth(), loginCode.getHeight()); captcha = new ChineseGifCaptcha(loginCode.getWidth(), loginCode.getHeight());
captcha.setLen(loginCode.getLength()); captcha.setLen(loginCode.getLength());
break; break;
case gif: case GIF:
captcha = new GifCaptcha(loginCode.getWidth(), loginCode.getHeight()); captcha = new GifCaptcha(loginCode.getWidth(), loginCode.getHeight());
captcha.setLen(loginCode.getLength()); captcha.setLen(loginCode.getLength());
break; break;
case spec: case SPEC:
captcha = new SpecCaptcha(loginCode.getWidth(), loginCode.getHeight()); captcha = new SpecCaptcha(loginCode.getWidth(), loginCode.getHeight());
captcha.setLen(loginCode.getLength()); captcha.setLen(loginCode.getLength());
break; break;

View File

@ -123,7 +123,7 @@ public class AuthorizationController {
String uuid = properties.getCodeKey() + IdUtil.simpleUUID(); String uuid = properties.getCodeKey() + IdUtil.simpleUUID();
//当验证码类型为 arithmetic时且长度 >= 2 时captcha.text()的结果有几率为浮点型 //当验证码类型为 arithmetic时且长度 >= 2 时captcha.text()的结果有几率为浮点型
String captchaValue = captcha.text(); String captchaValue = captcha.text();
if (captcha.getCharType() - 1 == LoginCodeEnum.arithmetic.ordinal() && captchaValue.contains(".")) { if (captcha.getCharType() - 1 == LoginCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains(".")) {
captchaValue = captchaValue.split("\\.")[0]; captchaValue = captchaValue.split("\\.")[0];
} }
// 保存 // 保存

View File

@ -12,6 +12,8 @@ spring:
redis: redis:
repositories: repositories:
enabled: false enabled: false
# pid:
# file: /自行指定位置/eladmin.pid
#配置 Jpa #配置 Jpa
jpa: jpa: