调整日期类型和金额类型入参的最大长度限制,文本类型可以绕过长度检查,进行数值返回

master
wangsq 1 year ago
parent 366123a133
commit dee9f45ccf
  1. 20
      src/main/java/com/ynxbd/push/entity/enums/MsgParamEnum.java

@ -67,9 +67,11 @@ public enum MsgParamEnum {
throw new Exception(key + "参数为空");
}
}
// 判断长度是否合法
if (value.length() > LENGTH) {
throw new Exception(key + "参数长度过长");
if (this != THING && this != CHARACTER_STRING) {
// 判断长度是否合法
if (value.length() > LENGTH) {
throw new Exception(key + "参数长度过长");
}
}
return value;
}
@ -84,6 +86,10 @@ public enum MsgParamEnum {
return val;
}
public static void main(String[] args) {
String s = valSubstring(20, "地址地址地址地址地址地址地址地址址1231");
System.out.println(s);
}
/**
* 获取参数
@ -119,7 +125,7 @@ public enum MsgParamEnum {
}
Map<String, String> keyMap = new HashMap<>();
String value = getStrValue(paramsMap, key, canNull);
if (this == THING) {
if (this == TIME) {
if (value.contains(":")) {
value = value.replaceAll(":", ":");
}
@ -129,11 +135,11 @@ public enum MsgParamEnum {
} catch (Exception e) {
throw new Exception("[" + key + "][" + value + "] 金额异常");
}
} else {
if (value.length() > this.LENGTH) {
} else if (this == THING || this == CHARACTER_STRING) {
if (value.length() > LENGTH) {
keyMap.put("old_value", value);
}
value = valSubstring(this.LENGTH, value);
value = valSubstring(LENGTH, value);
}
keyMap.put("value", value);
if (!ObjectUtils.isEmpty(color)) {

Loading…
Cancel
Save