diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraAuthUserController.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraAuthUserController.java index c833136..71d0849 100644 --- a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraAuthUserController.java +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraAuthUserController.java @@ -176,8 +176,8 @@ public class SchisandraAuthUserController { String token = schisandraAuthUserDTO.getToken(); Double deg = schisandraAuthUserDTO.getDeg(); CaptchaResult captchaResult = checkRouteCaptcha.checkCaptcha(token, deg); - String key = redisUtil.buildKey(AUTH_PHONE_PREFIX, schisandraAuthUserDTO.getPhone()); if (captchaResult.getCode() == 0) { + String key = redisUtil.buildKey(AUTH_PHONE_PREFIX, schisandraAuthUserDTO.getPhone()); if (redisUtil.exist(key)) { if (!Objects.equals(redisUtil.get(key), schisandraAuthUserDTO.getActiveCode())) { return CaptchaResult.failWithCode("验证码错误,请重新验证"); @@ -204,11 +204,11 @@ public class SchisandraAuthUserController { return CaptchaResult.failWithCode(); } } else { - return CaptchaResult.fail(); + return CaptchaResult.failWithCode(); } } else { - return CaptchaResult.failWithCode("验证失败!"); + return CaptchaResult.fail(); } } @@ -258,13 +258,13 @@ public class SchisandraAuthUserController { } /** - * @description:找回密码 + * @description: 找回密码 * @param: [schisandraAuthUserDTO] * @return: com.schisandra.auth.common.entity.CaptchaResult * @author zlg * @date: 2024/6/9 0:46 */ - @PostMapping + @PostMapping("findPassword") public CaptchaResult findPassword(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) { if (log.isInfoEnabled()) { log.info("UserController.findPassword.dto:{}", JSON.toJSONString(schisandraAuthUserDTO)); @@ -287,7 +287,7 @@ public class SchisandraAuthUserController { return CaptchaResult.failWithCode("该手机号未注册"); } if (schisandraAuthUserDomainService.findThePassword(schisandraAuthUserBO)) { - return CaptchaResult.ok(); + return CaptchaResult.ok("重置成功!"); } else { return CaptchaResult.failWithCode("修改密码失败"); } diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraOauthController.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraOauthController.java index 7f64d16..8b89f5d 100644 --- a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraOauthController.java +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/SchisandraOauthController.java @@ -4,7 +4,6 @@ import cn.dev33.satoken.stp.StpUtil; import com.schisandra.auth.application.factory.OauthTypeHandlerFactory; import com.schisandra.auth.application.handler.oauth.SchisandraOauthTypeHandler; import com.schisandra.auth.common.entity.Result; -import com.schisandra.auth.common.redis.RedisUtil; import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -15,12 +14,14 @@ import me.zhyd.oauth.model.AuthUser; import me.zhyd.oauth.request.AuthRequest; import me.zhyd.oauth.utils.AuthStateUtils; import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.HashMap; /** * ClassName:SchisandraOauthController @@ -82,10 +83,13 @@ public class SchisandraOauthController { AuthResponse authResponse = authRequest.login(callback); AuthUser data = authResponse.getData(); AuthToken token = data.getToken(); + if (token == null) { + return; + } Result result = schisandraAuthUserDomainService.insertAuthUserByOauth(data, type); - if (result.getSuccess()){ + if (result.getSuccess()) { response.sendRedirect(url + "loading?token=" + token.getAccessToken() + "&userId=" + StpUtil.getLoginIdAsString()); - }else{ + } else { log.error("登录失败"); } } diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/resources/image/2.png b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/resources/image/2.png index b55fb40..b645338 100644 Binary files a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/resources/image/2.png and b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/resources/image/2.png differ diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-domain/src/main/java/com/schisandra/auth/domain/service/impl/SchisandraAuthUserDomainServiceImpl.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-domain/src/main/java/com/schisandra/auth/domain/service/impl/SchisandraAuthUserDomainServiceImpl.java index ffca76d..21df3e6 100644 --- a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-domain/src/main/java/com/schisandra/auth/domain/service/impl/SchisandraAuthUserDomainServiceImpl.java +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-domain/src/main/java/com/schisandra/auth/domain/service/impl/SchisandraAuthUserDomainServiceImpl.java @@ -84,8 +84,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo @Override public boolean findThePassword(SchisandraAuthUserBO schisandraAuthUserBO) { SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO); - Integer count = schisandraAuthUserService.update(schisandraAuthUser); - return count > 0; + return schisandraAuthUserService.updateUserPasswordByPhone(schisandraAuthUser); } /** diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/SchisandraAuthUserService.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/SchisandraAuthUserService.java index 9f388ec..147afd8 100644 --- a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/SchisandraAuthUserService.java +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/SchisandraAuthUserService.java @@ -50,4 +50,6 @@ public interface SchisandraAuthUserService { int insertAuthUserByOauth(SchisandraAuthUser schisandraAuthUser); + + boolean updateUserPasswordByPhone(SchisandraAuthUser schisandraAuthUser); } diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/impl/SchisandraAuthUserServiceImpl.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/impl/SchisandraAuthUserServiceImpl.java index f7e1eec..c7c1dcb 100644 --- a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/impl/SchisandraAuthUserServiceImpl.java +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-infra/src/main/java/com/schisandra/auth/infra/basic/service/impl/SchisandraAuthUserServiceImpl.java @@ -1,6 +1,7 @@ package com.schisandra.auth.infra.basic.service.impl; +import com.mybatisflex.core.update.UpdateChain; import com.schisandra.auth.infra.basic.dao.SchisandraAuthUserDao; import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser; import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthUserTableDef; @@ -57,7 +58,7 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService } /** - * 修改数据 + * 根据主键修改数据 * * @param schisandraAuthUser 实例对象 * @return 实例对象 @@ -84,4 +85,13 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService return schisandraAuthUserDao.insert(schisandraAuthUser); } + @Override + public boolean updateUserPasswordByPhone(SchisandraAuthUser schisandraAuthUser) { + return UpdateChain.of(SchisandraAuthUser.class) + .set(SchisandraAuthUser::getPassword, schisandraAuthUser.getPassword()) + .where(SchisandraAuthUser::getPhone).eq(schisandraAuthUser.getPhone()) + .update(); + + } + }