From 11e48acc8183091d332eb16f078cbde05bd0d5a9 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Thu, 18 Sep 2025 08:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/AppAuthController.java | 11 ---- .../controller/AppUserCenterController.java | 54 +++++++++++++++++++ .../app/service/AppRegisterService.java | 10 ++++ 3 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 fys-admin/src/main/java/com/fuyuanshen/app/controller/AppUserCenterController.java diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java index 980fd55f..938b214f 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppAuthController.java @@ -125,17 +125,6 @@ public class AppAuthController { } - - - /** - * 退出登录 - */ - @PostMapping("/logout") - public R logout() { - loginService.logout(); - return R.ok("退出成功"); - } - /** * 用户注销 */ diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppUserCenterController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppUserCenterController.java new file mode 100644 index 00000000..d2250c82 --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppUserCenterController.java @@ -0,0 +1,54 @@ +package com.fuyuanshen.app.controller; + +import com.fuyuanshen.app.model.AppRegisterBody; +import com.fuyuanshen.app.service.AppLoginService; +import com.fuyuanshen.app.service.AppRegisterService; +import com.fuyuanshen.common.core.domain.R; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * APP我的 + * + */ +@Slf4j +@RequiredArgsConstructor +@RestController +@RequestMapping("/app/userCenter") +public class AppUserCenterController { + + private final AppLoginService loginService; + private final AppRegisterService registerService; + /** + * 用户注销 + */ + @PostMapping("/cancelAccount") + public R cancelAccount() { + loginService.cancelAccount(); + return R.ok("用户注销成功"); + } + + + /** + * 修改密码 + */ + @PostMapping("/updatePassword") + public R updatePassword(@Validated @RequestBody AppRegisterBody body) { + registerService.updatePassword(body); + return R.ok(); + } + + /** + * 退出登录 + */ + @PostMapping("/logout") + public R logout() { + loginService.logout(); + return R.ok("退出成功"); + } +} diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppRegisterService.java b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppRegisterService.java index 66361d77..282b15e7 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppRegisterService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppRegisterService.java @@ -19,6 +19,7 @@ import com.fuyuanshen.common.core.utils.SpringUtils; import com.fuyuanshen.common.core.utils.StringUtils; import com.fuyuanshen.common.log.event.LogininforEvent; import com.fuyuanshen.common.redis.utils.RedisUtils; +import com.fuyuanshen.common.satoken.utils.AppLoginHelper; import com.fuyuanshen.common.tenant.helper.TenantHelper; import com.fuyuanshen.common.web.config.properties.CaptchaProperties; import com.fuyuanshen.system.domain.SysUser; @@ -142,4 +143,13 @@ public class AppRegisterService { .set("password", password); userMapper.update(updateWrapper); } + + public void updatePassword(AppRegisterBody body) { + String username = AppLoginHelper.getUsername(); + String password = body.getPassword(); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("user_name", username) + .set("password", password); + userMapper.update(updateWrapper); + } }