Commit 6bd7e3d5 authored by dmy's avatar dmy

测试环境验证码返回

parent 5b5d46ca
...@@ -8,6 +8,7 @@ import com.pangding.web.cache.CacheName; ...@@ -8,6 +8,7 @@ import com.pangding.web.cache.CacheName;
import com.yanzuoguang.util.exception.CodeException; import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -18,19 +19,20 @@ import java.util.concurrent.TimeUnit; ...@@ -18,19 +19,20 @@ import java.util.concurrent.TimeUnit;
/** /**
* 验证码服务 * 验证码服务
*
*/ */
@Component @Component
public class CodeService { public class CodeService {
private final DefaultKaptcha defaultKaptcha; private final DefaultKaptcha defaultKaptcha;
private final DebugConfig debugConfig;
@CreateCache(name = CacheName.USER_PASSWORD_CODE, cacheType = CacheType.REMOTE, expire = 60, timeUnit = TimeUnit.MINUTES) @CreateCache(name = CacheName.USER_PASSWORD_CODE, cacheType = CacheType.REMOTE, expire = 60, timeUnit = TimeUnit.MINUTES)
private Cache<String, String> cache; private Cache<String, String> cache;
public CodeService(DefaultKaptcha defaultKaptcha) { public CodeService(DefaultKaptcha defaultKaptcha, DebugConfig debugConfig) {
this.defaultKaptcha = defaultKaptcha; this.defaultKaptcha = defaultKaptcha;
this.debugConfig = debugConfig;
} }
...@@ -53,9 +55,9 @@ public class CodeService { ...@@ -53,9 +55,9 @@ public class CodeService {
// 对字节组Base64编码 // 对字节组Base64编码
String img = Base64.getEncoder().encodeToString(out.toByteArray()); String img = Base64.getEncoder().encodeToString(out.toByteArray());
CodeVo code = new CodeVo(StringHelper.getNewID(), img); CodeVo code = new CodeVo(StringHelper.getNewID(), img);
// if (debugConfig.isDebug()) { if (debugConfig.isDebug()) {
// code.setCode(text); code.setCode(text);
// } }
// 验证验证码文字 // 验证验证码文字
cache.put(code.getId(), text); cache.put(code.getId(), text);
return code; return code;
......
package com.pangding.web.authority.vo.code;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class DebugConfig {
@Value("${pd.debug:false}")
private boolean debug;
@Value("${pd.debugLog:false}")
private boolean debugLog;
@Value("${pd.cache:true}")
private boolean cache;
public DebugConfig() {
}
public boolean isDebug() {
return this.debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public boolean isDebugLog() {
return this.debugLog;
}
public void setDebugLog(boolean debugLog) {
this.debugLog = debugLog;
}
public boolean isCache() {
return this.cache;
}
public void setCache(boolean cache) {
this.cache = cache;
}
}
...@@ -6,7 +6,8 @@ eureka: ...@@ -6,7 +6,8 @@ eureka:
yzg: yzg:
logAll: true logAll: true
PrintSql: true PrintSql: true
pd:
debug: true
msg: msg:
payMsgId: 4 payMsgId: 4
......
...@@ -5,7 +5,8 @@ eureka: ...@@ -5,7 +5,8 @@ eureka:
yzg: yzg:
logAll: true logAll: true
PrintSql: true PrintSql: true
pd:
debug: true
msg: msg:
payMsgId: 4 payMsgId: 4
groupProductMsgId: 10 groupProductMsgId: 10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment