refactor: 使用 Hutool工具类优化空值判断- 在多个控制器和服务实现类中,将原始的空值判断替换为 Hutool 工具类中的方法
- 使用 ObjectUtil.isNull() 替换原始的 == null 判断 - 使用 ObjectUtil.isNotNull() 替换原始的 != null 判断 - 在某些情况下,使用 StrUtil.isBlank() 替换原始的 == null 判断,以更准确地检查字符串是否为空
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.test.bijihoudaun.controller;
|
||||
|
||||
import com.test.bijihoudaun.bo.UpdatePasswordBo;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.test.bijihoudaun.common.response.R;
|
||||
import com.test.bijihoudaun.entity.User;
|
||||
import com.test.bijihoudaun.service.RegistrationCodeService;
|
||||
@@ -69,7 +70,7 @@ public class UserController {
|
||||
String username = userDetails.getUsername();
|
||||
User user = userService.getOne(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<User>().eq("username", username));
|
||||
|
||||
if (user == null) {
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
return R.fail("无法获取用户信息,删除失败");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user