9 changed files with 211 additions and 4 deletions
@ -0,0 +1,36 @@ |
|||||||
|
package com.biutag.supervision.pojo.request.complaintCollection; |
||||||
|
|
||||||
|
|
||||||
|
import com.biutag.supervision.aop.ParamChecked; |
||||||
|
import com.biutag.supervision.util.CheckUtil; |
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@Schema(description = "初核请求") |
||||||
|
public class ComplaintCollectionInitialReviewRequest implements ParamChecked { |
||||||
|
|
||||||
|
@Schema(description = "涉访涉诉编号id") |
||||||
|
private String complaintId; |
||||||
|
|
||||||
|
@Schema(description = "初核工作开展情况") |
||||||
|
private String initWorkDes; |
||||||
|
|
||||||
|
@Schema(description = "初核发现的问题及下步工作计划") |
||||||
|
private String initProblemPlan; |
||||||
|
|
||||||
|
@Schema(description = "初核结论") |
||||||
|
private String initVerdict; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void check() { |
||||||
|
CheckUtil.checkNotBlank(complaintId, "涉访涉诉id不能为空"); |
||||||
|
CheckUtil.checkNotBlank(initWorkDes, "初核工作开展情况不能为空"); |
||||||
|
CheckUtil.checkNotBlank(initProblemPlan, "初核发现的问题及下步工作计划不能为空"); |
||||||
|
CheckUtil.checkNotBlank(initVerdict, "初核结论不能为空"); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,104 @@ |
|||||||
|
package com.biutag.supervision.util; |
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数校验工具类 |
||||||
|
* 用于统一校验请求参数中的字符串,校验失败抛出 IllegalArgumentException |
||||||
|
*/ |
||||||
|
public class CheckUtil { |
||||||
|
|
||||||
|
/** |
||||||
|
* 校验字符串不能为 null 或纯空白字符 |
||||||
|
* |
||||||
|
* @param str 待校验字符串 |
||||||
|
* @param message 异常信息 |
||||||
|
* @throws IllegalArgumentException 如果字符串为 null 或空白 |
||||||
|
*/ |
||||||
|
public static void checkNotBlank(String str, String message) { |
||||||
|
if (StrUtil.isBlank(str)) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 校验字符串不能为 null(允许空字符串) |
||||||
|
* |
||||||
|
* @param str 待校验字符串 |
||||||
|
* @param message 异常信息 |
||||||
|
* @throws IllegalArgumentException 如果字符串为 null |
||||||
|
*/ |
||||||
|
public static void checkNotNull(String str, String message) { |
||||||
|
if (str == null) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 校验字符串长度不能超过指定最大值 |
||||||
|
* |
||||||
|
* @param str 待校验字符串 |
||||||
|
* @param max 最大长度 |
||||||
|
* @param message 异常信息 |
||||||
|
* @throws IllegalArgumentException 如果字符串长度超过 max |
||||||
|
*/ |
||||||
|
public static void checkMaxLength(String str, int max, String message) { |
||||||
|
if (str != null && str.length() > max) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 校验字符串长度不能小于指定最小值 |
||||||
|
* |
||||||
|
* @param str 待校验字符串 |
||||||
|
* @param min 最小长度 |
||||||
|
* @param message 异常信息 |
||||||
|
* @throws IllegalArgumentException 如果字符串长度小于 min |
||||||
|
*/ |
||||||
|
public static void checkMinLength(String str, int min, String message) { |
||||||
|
if (str != null && str.length() < min) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 校验字符串长度必须在指定范围内 |
||||||
|
* |
||||||
|
* @param str 待校验字符串 |
||||||
|
* @param min 最小长度(包含) |
||||||
|
* @param max 最大长度(包含) |
||||||
|
* @param message 异常信息 |
||||||
|
* @throws IllegalArgumentException 如果字符串长度不在 [min, max] 范围内 |
||||||
|
*/ |
||||||
|
public static void checkLengthRange(String str, int min, int max, String message) { |
||||||
|
if (str != null && (str.length() < min || str.length() > max)) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 校验多个字符串是否全部为 null 或纯空白字符(即全部为空) |
||||||
|
* 如果全部为空,则抛出 IllegalArgumentException |
||||||
|
* |
||||||
|
* @param message 异常信息 |
||||||
|
* @param strings 待校验的字符串数组 |
||||||
|
* @throws IllegalArgumentException 如果所有字符串均为 null 或空白 |
||||||
|
*/ |
||||||
|
public static void checkNotAllBlank(String message, String... strings) { |
||||||
|
if (strings == null || strings.length == 0) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
boolean allBlank = true; |
||||||
|
for (String str : strings) { |
||||||
|
if (StrUtil.isNotBlank(str)) { |
||||||
|
allBlank = false; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
if (allBlank) { |
||||||
|
throw new IllegalArgumentException(message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue