1
0

5 Коммитууд 021da9c780 ... 0026ebdc29

Эзэн SHA1 Мессеж Огноо
  Yangzw 0026ebdc29 加入用户注销功能,只是简单的注销,团队没有做处理 1 долоо хоног өмнө
  Yangzw 14ff0b16ba Merge branch 'dev/2024/1101/update-app-Y' of feifan/mall-backend-app into master 1 сар өмнө
  Yangzw 647998f90a Merge branch 'dev/2024/1101/update-app-Y' of feifan/mall-backend-app into master 1 сар өмнө
  Yangzw 87f4a57895 Merge branch 'dev/2024/1101/update-app-Y' of feifan/mall-backend-app into master 1 сар өмнө
  Yangzw 6ec7c0d0bb Merge branch 'dev/2024/1101/update-app-Y' of feifan/mall-backend-app into master 1 сар өмнө

+ 15 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/controller/app/auth/AppAuthController.java

@@ -63,6 +63,21 @@ public class AppAuthController {
         return success(true);
     }
 
+    @PostMapping("/deleteUser")
+    @Operation(summary = "用户注销")
+    @Parameter(name = "deleteUser", description = "用户注销", required = true)
+    public CommonResult<Boolean> deleteUser(HttpServletRequest request){
+        authService.deleteUser(getLoginUserId());
+
+        String token = SecurityFrameworkUtils.obtainAuthorization(request,
+                securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
+        if (StrUtil.isNotBlank(token)) {
+            authService.logout(token);
+        }
+
+        return success(true);
+    }
+
     @PostMapping("/refresh-token")
     @Operation(summary = "刷新令牌")
     @Parameter(name = "refreshToken", description = "刷新令牌", required = true)

+ 6 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/auth/MemberAuthService.java

@@ -103,4 +103,10 @@ public interface MemberAuthService {
      * @return 跳转登录
      */
     String redirectLogin();
+
+    /**
+     * 注销用户
+     * @param loginUserId 用户id
+     */
+    void deleteUser(Long loginUserId);
 }

+ 5 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/auth/MemberAuthServiceImpl.java

@@ -220,6 +220,11 @@ public class MemberAuthServiceImpl implements MemberAuthService {
         return url + "/login" + "?accessToken=" + token.getAccessToken() + "&refreshToken=" + token.getRefreshToken();
     }
 
+    @Override
+    public void deleteUser(Long loginUserId) {
+        userService.deleteUserById(loginUserId);
+    }
+
     @Override
     public AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO) {
         // 获得对应的手机号信息

+ 6 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserService.java

@@ -280,4 +280,10 @@ public interface MemberUserService {
      * @return 用户名
      */
     String getUsernameByUserId(Long userId);
+
+    /**
+     * 注销用户
+     * @param loginUserId 用户id
+     */
+    void deleteUserById(Long loginUserId);
 }

+ 5 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserServiceImpl.java

@@ -520,6 +520,11 @@ public class MemberUserServiceImpl implements MemberUserService {
         return null;
     }
 
+    @Override
+    public void deleteUserById(Long loginUserId) {
+        memberUserMapper.deleteById(loginUserId);
+    }
+
     private Boolean isSubscribe(String openid, int maxRetries) {
         String requestUrl = StrUtil.format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={}&openid={}&lang=zh_CN", getAccessToken(), openid);
         String returnMsg = HttpUtil.get(requestUrl);