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 980fd55f2..938b214f4 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 000000000..d2250c821 --- /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 66361d77f..282b15e7a 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); + } }