后台修改用户电话或邮箱接口

This commit is contained in:
wangjinlei
2024-01-29 14:52:59 +08:00
parent 3f46c1f562
commit be8303fc2c
3 changed files with 13 additions and 0 deletions

View File

@@ -126,6 +126,10 @@ public class MyUserController {
*/
@RequestMapping("/update")
public R update(@RequestBody MyUserEntity user){
boolean b = userService.checkUserTelOrEmail(user);
if(!b){
return R.error("电话或邮箱已存在");
}
userService.updateById(user);
return R.ok();
}

View File

@@ -47,6 +47,7 @@ public interface MyUserService extends IService<MyUserEntity> {
boolean checkUserBook(Integer userId,Integer bookId);
boolean checkUserTelOrEmail(MyUserEntity user);
}

View File

@@ -431,4 +431,12 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
}
}
@Override
public boolean checkUserTelOrEmail(MyUserEntity user) {
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(MyUserEntity::getId,user.getId());
wrapper.eq(MyUserEntity::getTel,user.getTel()).or().eq(MyUserEntity::getEmail,user.getEmail());
MyUserEntity one = getOne(wrapper);
return one == null;
}
}