mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、统一抛出ServiceException带占位符的填充方式,不再使用ServiceExceptionUtils;2、新增System服务ErrorCode的国际化;3、Webcad异步导入移除分布式锁,导入解析事务完善;
This commit is contained in:
+7
-1
@@ -22,15 +22,21 @@ public final class ServiceException extends RuntimeException {
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 占位参数
|
||||
*/
|
||||
private transient Object[] args;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public ServiceException() {
|
||||
}
|
||||
|
||||
public ServiceException(ErrorCode errorCode) {
|
||||
public ServiceException(ErrorCode errorCode, Object... args) {
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMsg();
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public ServiceException(Integer code, String message) {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class GlobalErrorCodeConstants {
|
||||
public static final ErrorCode REQUEST_ORGAN_ID_NOT_EXIST = new ErrorCode(400, "global.error.request.organId.notExist");
|
||||
public static final ErrorCode NO_PERMISSION_TO_VISIT_ORG = new ErrorCode(400, "global.error.no.permission.to.visit.org");
|
||||
public static final ErrorCode REQUEST_PARAM_TYPE_ERROR = new ErrorCode(400, "global.error.request.param.type.error");
|
||||
public static final ErrorCode UNAUTHORIZED = new ErrorCode(401, "账号未登录");
|
||||
public static final ErrorCode UNAUTHORIZED = new ErrorCode(401, "global.not.login");
|
||||
public static final ErrorCode FORBIDDEN = new ErrorCode(403, "global.error.no.permission");
|
||||
public static final ErrorCode REQUEST_PARAM_MISSING = new ErrorCode(403, "global.error.request.param.missing");
|
||||
public static final ErrorCode NOT_FOUND = new ErrorCode(404, "global.error.request.not.found");
|
||||
|
||||
+15
-15
@@ -3,13 +3,13 @@ package com.cf.imes.framework.common.util.Assert;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.exception.ErrorCode;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,81 +31,81 @@ public class AssertUtils {
|
||||
* */
|
||||
public static void notEmpty(List<?> array, ErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void empty(List<?> array, ErrorCode errorCode) {
|
||||
if (!ObjectUtils.isEmpty(array)) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void empty(List<?> array, ErrorCode errorCode, Object... params) {
|
||||
if (!ObjectUtils.isEmpty(array)) {
|
||||
throw ServiceExceptionUtil.exception(errorCode, params);
|
||||
throw new ServiceException(errorCode, params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void empty(Object object, ErrorCode errorCode) {
|
||||
if (object != null) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void empty(Object object, ErrorCode errorCode, Object... params) {
|
||||
if (object != null) {
|
||||
throw ServiceExceptionUtil.exception(errorCode, params);
|
||||
throw new ServiceException(errorCode, params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Object object, ErrorCode errorCode) {
|
||||
if (object == null) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void notEmpty(List<?> array ,Object object, ErrorCode errorCode) {
|
||||
if (object == null || ObjectUtils.isEmpty(array)) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void notEmpty(List<?> array, ErrorCode errorCode,Object object) {
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
throw exception(errorCode,object);
|
||||
throw new ServiceException(errorCode,object);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(String str, ErrorCode errorCode) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEquals(Object obj1, Object obj2, ErrorCode errorCode) {
|
||||
if (ObjectUtil.notEqual(obj1, obj2)) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void equals(Object obj1, Object obj2, ErrorCode errorCode) {
|
||||
if (ObjectUtil.equal(obj1, obj2)) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isFalse(boolean expression, ErrorCode errorCode) {
|
||||
if (!expression) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isTrue(boolean expression, ErrorCode errorCode) {
|
||||
if (expression) {
|
||||
throw exception(errorCode);
|
||||
throw new ServiceException(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ public class I18nUtils {
|
||||
* @return
|
||||
*/
|
||||
public String getMessage(String code, Object... args) {
|
||||
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||
return messageSource.getMessage(code, args, code, LocaleContextHolder.getLocale());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user