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 cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.test.bijihoudaun.common.response.R;
|
||||
import com.test.bijihoudaun.entity.Grouping;
|
||||
import com.test.bijihoudaun.service.GroupingService;
|
||||
@@ -24,7 +25,7 @@ public class GroupingController {
|
||||
@Operation(summary = "创建分组")
|
||||
@PostMapping
|
||||
public R<Grouping> createGrouping(@RequestBody Grouping grouping) {
|
||||
if (grouping.getParentId() == null) {
|
||||
if (ObjectUtil.isNull(grouping.getParentId())) {
|
||||
grouping.setParentId(0L);
|
||||
}
|
||||
Grouping created = groupingService.createGrouping(grouping);
|
||||
|
||||
Reference in New Issue
Block a user