解决admin项目无法启动问题。
完善验证码模块优化需要优化的项目
This commit is contained in:
parent
956a6e465a
commit
af9ffd1cbf
41
admin/src/main/resources/logback-spring.xml
Normal file
41
admin/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE configuration>
|
||||||
|
<configuration>
|
||||||
|
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||||
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||||
|
<!--应用名称-->
|
||||||
|
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||||
|
<!--日志文件保存路径-->
|
||||||
|
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||||
|
<contextName>${APP_NAME}</contextName>
|
||||||
|
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!--输出到elk的LOGSTASH-->
|
||||||
|
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||||
|
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||||
|
<destination>127.0.0.1:4560</destination>
|
||||||
|
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||||
|
<providers>
|
||||||
|
<timestamp>
|
||||||
|
<timeZone>UTC</timeZone>
|
||||||
|
</timestamp>
|
||||||
|
</providers>
|
||||||
|
<!--自定义字段 区分项目-->
|
||||||
|
<customFields>{"appName":"${APP_NAME}"}</customFields>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
<appender-ref ref="LOGSTASH"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
@ -47,11 +47,8 @@ public class MemberBuyerController {
|
|||||||
public ResultMessage<Object> userLogin(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
public ResultMessage<Object> userLogin(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||||
@NotNull(message = "密码不能为空") @RequestParam String password,
|
@NotNull(message = "密码不能为空") @RequestParam String password,
|
||||||
@RequestHeader String uuid) {
|
@RequestHeader String uuid) {
|
||||||
if (verificationService.check(uuid, VerificationEnums.LOGIN)) {
|
verificationService.check(uuid, VerificationEnums.LOGIN);
|
||||||
return ResultUtil.data(this.memberService.usernameLogin(username, password));
|
return ResultUtil.data(this.memberService.usernameLogin(username, password));
|
||||||
} else {
|
|
||||||
throw new ServiceException(ResultCode.VERIFICATION_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "短信登录接口")
|
@ApiOperation(value = "短信登录接口")
|
||||||
@ -63,11 +60,8 @@ public class MemberBuyerController {
|
|||||||
public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||||
@RequestHeader String uuid) {
|
@RequestHeader String uuid) {
|
||||||
if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) {
|
smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code);
|
||||||
return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
|
return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
|
||||||
} else {
|
|
||||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "注册用户")
|
@ApiOperation(value = "注册用户")
|
||||||
@ -84,12 +78,9 @@ public class MemberBuyerController {
|
|||||||
@RequestHeader String uuid,
|
@RequestHeader String uuid,
|
||||||
@NotNull(message = "验证码不能为空") @RequestParam String code) {
|
@NotNull(message = "验证码不能为空") @RequestParam String code) {
|
||||||
|
|
||||||
boolean result = smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code);
|
smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code);
|
||||||
if (result) {
|
return ResultUtil.data(memberService.register(username, password, mobilePhone));
|
||||||
return ResultUtil.data(memberService.register(username, password, mobilePhone));
|
|
||||||
} else {
|
|
||||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取当前登录用户接口")
|
@ApiOperation(value = "获取当前登录用户接口")
|
||||||
@ -109,13 +100,11 @@ public class MemberBuyerController {
|
|||||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||||
@RequestHeader String uuid) {
|
@RequestHeader String uuid) {
|
||||||
//校验短信验证码是否正确
|
//校验短信验证码是否正确
|
||||||
if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) {
|
smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code);
|
||||||
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
||||||
if (memberService.findByMobile(uuid, mobile)) {
|
memberService.findByMobile(uuid, mobile);
|
||||||
return ResultUtil.success();
|
|
||||||
}
|
return ResultUtil.success();
|
||||||
}
|
|
||||||
throw new ServiceException(ResultCode.VERIFICATION_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "修改密码")
|
@ApiOperation(value = "修改密码")
|
||||||
|
@ -182,7 +182,6 @@ mybatis-plus:
|
|||||||
|
|
||||||
# 日志
|
# 日志
|
||||||
logging:
|
logging:
|
||||||
config: classpath:logback-spring.xml
|
|
||||||
# 输出级别
|
# 输出级别
|
||||||
level:
|
level:
|
||||||
cn.lili: info
|
cn.lili: info
|
||||||
@ -230,11 +229,11 @@ lili:
|
|||||||
system:
|
system:
|
||||||
isDemoSite: false
|
isDemoSite: false
|
||||||
isTestModel: true
|
isTestModel: true
|
||||||
# 脱敏级别:
|
# 脱敏级别:
|
||||||
# 0:不做脱敏处理
|
# 0:不做脱敏处理
|
||||||
# 1:管理端用户手机号等信息脱敏
|
# 1:管理端用户手机号等信息脱敏
|
||||||
# 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏)
|
# 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏)
|
||||||
# sensitiveLevel: 2
|
# sensitiveLevel: 2
|
||||||
|
|
||||||
statistics:
|
statistics:
|
||||||
# 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数
|
# 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数
|
||||||
|
@ -139,7 +139,7 @@ public class VerificationServiceImpl implements VerificationService {
|
|||||||
}
|
}
|
||||||
log.debug("{}{}", randomX, xPos);
|
log.debug("{}{}", randomX, xPos);
|
||||||
//验证结果正确 && 删除标记成功
|
//验证结果正确 && 删除标记成功
|
||||||
if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheResult(verificationEnums, uuid))) {
|
if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) {
|
||||||
//验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致
|
//验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致
|
||||||
cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime());
|
cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime());
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user