diff --git a/src/main/java/com/peanut/modules/bookAbroad/controller/VisitorController.java b/src/main/java/com/peanut/modules/bookAbroad/controller/VisitorController.java index 2cad2f7..9f3993b 100644 --- a/src/main/java/com/peanut/modules/bookAbroad/controller/VisitorController.java +++ b/src/main/java/com/peanut/modules/bookAbroad/controller/VisitorController.java @@ -2,6 +2,7 @@ package com.peanut.modules.bookAbroad.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; +import com.peanut.common.utils.MD5Utils; import com.peanut.common.utils.R; import com.peanut.modules.book.service.*; import com.peanut.modules.bookAbroad.service.BookAbroadLableService; @@ -37,6 +38,8 @@ public class VisitorController { private BookListeningService bookListeningService; @Autowired private AuthorService authorService; + @Autowired + private com.peanut.modules.common.service.MyUserService userService; //推荐图书 @RequestMapping("/getRecommendBooks") @@ -120,7 +123,33 @@ public class VisitorController { } return R.ok().put("bookList",bookList); } - + /** + * 官网注销账号 + */ + @RequestMapping("/websitCeancelAccount") + public R websitCeancelAccount(@RequestBody Map params) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + if (params.get("account").toString().contains("@")) { + wrapper.eq(MyUserEntity::getEmail,params.get("account").toString()); + }else { + wrapper.eq(MyUserEntity::getTel,params.get("account").toString()); + } + MyUserEntity userEntity = userService.getOne(wrapper); + if (userEntity == null) { + return R.error(500,"The user does not exist!"); + }else { + if (userEntity.getPassword() == null|| userEntity.getPassword().equals("")) { + return R.error(500,"Currently, no password has been set."); + }else { + if (MD5Utils.getSaltverifyMD5(params.get("password").toString(),userEntity.getPassword())){ + userService.removeById(userEntity.getId()); + return R.ok("CeancelAccount successful!"); + }else { + return R.error(500,"The password is error, please try again!"); + } + } + } + } }