From d66edbeffee5e308504e48372a5bb4d04aa4e843 Mon Sep 17 00:00:00 2001 From: houzhongjian <houzhongyi@126.com> Date: 星期一, 06 一月 2025 13:23:06 +0800 Subject: [PATCH] 租户套餐名称重复判定 --- iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/pojo/CommonResult.java | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/pojo/CommonResult.java b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/pojo/CommonResult.java index 2f39029..063d0a6 100644 --- a/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/pojo/CommonResult.java +++ b/iailab-framework/iailab-common/src/main/java/com/iailab/framework/common/pojo/CommonResult.java @@ -1,11 +1,12 @@ package com.iailab.framework.common.pojo; +import cn.hutool.core.lang.Assert; import com.iailab.framework.common.exception.ErrorCode; import com.iailab.framework.common.exception.ServiceException; import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.iailab.framework.common.exception.util.ServiceExceptionUtil; import lombok.Data; -import org.springframework.util.Assert; import java.io.Serializable; import java.util.Objects; @@ -41,7 +42,7 @@ * 因为 A 方法返回的 CommonResult 对象,不满足调用其的 B 方法的返回,所以需要进行转换。 * * @param result 传入的 result 对象 - * @param <T> 返回的泛型 + * @param <T> 返回的泛型 * @return 新的 CommonResult 对象 */ public static <T> CommonResult<T> error(CommonResult<?> result) { @@ -49,10 +50,18 @@ } public static <T> CommonResult<T> error(Integer code, String message) { - Assert.isTrue(!GlobalErrorCodeConstants.SUCCESS.getCode().equals(code), "code 必须是错误的!"); + cn.hutool.core.lang.Assert.notEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), code, "code 必须是错误的!"); CommonResult<T> result = new CommonResult<>(); result.code = code; result.msg = message; + return result; + } + + public static <T> CommonResult<T> error(ErrorCode errorCode, Object... params) { + Assert.notEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), errorCode.getCode(), "code 必须是错误的!"); + CommonResult<T> result = new CommonResult<>(); + result.code = errorCode.getCode(); + result.msg = ServiceExceptionUtil.doFormat(errorCode.getCode(), errorCode.getMsg(), params); return result; } @@ -65,13 +74,6 @@ result.code = GlobalErrorCodeConstants.SUCCESS.getCode(); result.data = data; result.msg = ""; - return result; - } - - public static CommonResult<String> success() { - CommonResult<String> result = new CommonResult<>(); - result.code = GlobalErrorCodeConstants.SUCCESS.getCode(); - result.msg = "success"; return result; } -- Gitblit v1.9.3