From af9ffd1cbfd6cc1a52880e0c5777aa4ffc802543 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 3 Nov 2021 09:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3admin=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20=E5=AE=8C=E5=96=84=E9=AA=8C=E8=AF=81=E7=A0=81=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BC=98=E5=8C=96=E9=9C=80=E8=A6=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/main/resources/logback-spring.xml | 41 +++++++++++++++++++ .../passport/MemberBuyerController.java | 35 ++++++---------- config/application.yml | 11 +++-- .../service/impl/VerificationServiceImpl.java | 2 +- 4 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 admin/src/main/resources/logback-spring.xml diff --git a/admin/src/main/resources/logback-spring.xml b/admin/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..8e2f8cac9 --- /dev/null +++ b/admin/src/main/resources/logback-spring.xml @@ -0,0 +1,41 @@ + + + + + + + + + + ${APP_NAME} + + + + ${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log + 30 + + + ${FILE_LOG_PATTERN} + + + + + + + 127.0.0.1:4560 + + + + UTC + + + + {"appName":"${APP_NAME}"} + + + + + + + + \ No newline at end of file diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index d81bc53ef..affadd30b 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -47,11 +47,8 @@ public class MemberBuyerController { public ResultMessage userLogin(@NotNull(message = "用户名不能为空") @RequestParam String username, @NotNull(message = "密码不能为空") @RequestParam String password, @RequestHeader String uuid) { - if (verificationService.check(uuid, VerificationEnums.LOGIN)) { - return ResultUtil.data(this.memberService.usernameLogin(username, password)); - } else { - throw new ServiceException(ResultCode.VERIFICATION_ERROR); - } + verificationService.check(uuid, VerificationEnums.LOGIN); + return ResultUtil.data(this.memberService.usernameLogin(username, password)); } @ApiOperation(value = "短信登录接口") @@ -63,11 +60,8 @@ public class MemberBuyerController { public ResultMessage smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile, @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { - if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { - return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); - } else { - throw new ServiceException(ResultCode.VERIFICATION_SMS_ERROR); - } + smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code); + return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); } @ApiOperation(value = "注册用户") @@ -84,12 +78,9 @@ public class MemberBuyerController { @RequestHeader String uuid, @NotNull(message = "验证码不能为空") @RequestParam String code) { - boolean result = smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code); - if (result) { - return ResultUtil.data(memberService.register(username, password, mobilePhone)); - } else { - throw new ServiceException(ResultCode.VERIFICATION_SMS_ERROR); - } + smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code); + return ResultUtil.data(memberService.register(username, password, mobilePhone)); + } @ApiOperation(value = "获取当前登录用户接口") @@ -109,13 +100,11 @@ public class MemberBuyerController { @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { //校验短信验证码是否正确 - if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) { - //校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟 - if (memberService.findByMobile(uuid, mobile)) { - return ResultUtil.success(); - } - } - throw new ServiceException(ResultCode.VERIFICATION_ERROR); + smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code); + //校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟 + memberService.findByMobile(uuid, mobile); + + return ResultUtil.success(); } @ApiOperation(value = "修改密码") diff --git a/config/application.yml b/config/application.yml index e3e810291..c729b1833 100644 --- a/config/application.yml +++ b/config/application.yml @@ -182,7 +182,6 @@ mybatis-plus: # 日志 logging: - config: classpath:logback-spring.xml # 输出级别 level: cn.lili: info @@ -230,11 +229,11 @@ lili: system: isDemoSite: false isTestModel: true -# 脱敏级别: -# 0:不做脱敏处理 -# 1:管理端用户手机号等信息脱敏 -# 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) -# sensitiveLevel: 2 + # 脱敏级别: + # 0:不做脱敏处理 + # 1:管理端用户手机号等信息脱敏 + # 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) + # sensitiveLevel: 2 statistics: # 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数 diff --git a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java index be0bbf6a1..7694f0f2d 100644 --- a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java @@ -139,7 +139,7 @@ public class VerificationServiceImpl implements VerificationService { } 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()); return true;