refactor: 使用 Hutool工具类优化空值判断- 在多个控制器和服务实现类中,将原始的空值判断替换为 Hutool 工具类中的方法

- 使用 ObjectUtil.isNull() 替换原始的 == null 判断
- 使用 ObjectUtil.isNotNull() 替换原始的 != null 判断
- 在某些情况下,使用 StrUtil.isBlank() 替换原始的 == null 判断,以更准确地检查字符串是否为空
This commit is contained in:
ikmkj
2025-08-02 19:53:47 +08:00
parent f858a9bcd6
commit 81678da683
10 changed files with 27 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
package com.test.bijihoudaun.controller;
import cn.hutool.core.util.ObjectUtil;
import com.test.bijihoudaun.common.response.R;
import com.test.bijihoudaun.entity.MarkdownFile;
import com.test.bijihoudaun.entity.MarkdownFileVO;
@@ -36,7 +37,7 @@ public class MarkdownController {
@GetMapping("/{id}")
public R<String> getMarkdownContent(@PathVariable Long id) {
MarkdownFile file = markdownFileService.getMarkdownById(id);
if (file != null) {
if (ObjectUtil.isNotNull(file)) {
return R.success(file.getContent());
}
return R.fail();
@@ -89,7 +90,7 @@ public class MarkdownController {
@PathVariable Long id,
@RequestBody String title) {
MarkdownFile updatedFile = markdownFileService.updateMarkdownTitle(id, title);
if (updatedFile != null) {
if (ObjectUtil.isNotNull(updatedFile)) {
return R.success(updatedFile);
}
return R.fail("文件未找到或更新失败");