修改bug

This commit is contained in:
hzj
2024-12-11 15:05:09 +08:00
parent 9bc072ec8b
commit eb54a13226
6 changed files with 13 additions and 3 deletions

View File

@@ -23,7 +23,6 @@ public class CarryCapacityDeviceParam {
/**
* 设备名称
*/
@Pattern(regexp = PatternRegex.DES32_REGEX, message = ValidMessage.DATA_TOO_LONG)
private String devName;
private String devScale;

View File

@@ -31,7 +31,6 @@ public class CarryCapacityUserParam {
/**
* 用户名称
*/
@Pattern(regexp = PatternRegex.DES32_REGEX, message = ValidMessage.DATA_TOO_LONG)
private String userName;
/**

View File

@@ -16,10 +16,14 @@ import java.util.regex.Pattern;
*/
public class CheckStringUtil {
public static void checkName(String name) {
Pattern pattern = Pattern.compile(PatternRegex.SPECIAL_REGEX);
Pattern pattern = Pattern.compile(PatternRegex.SPECIALCHARACTER);
if(pattern.matcher(name).find()){
throw new BusinessException(ValidMessage.NAME_SPECIAL_REGEX);
}
}
// public static void main(String[] args) {
// checkName("100迈岭站2djvjva13ad");
// }
}

View File

@@ -57,7 +57,10 @@ public class CarryCapacityDevicePOServiceImpl extends ServiceImpl<CarryCapacityD
* @return 结果
*/
private void checkName(CarryCapacityDeviceParam carryCapacityDeviceParam, boolean isUpdate) {
if(carryCapacityDeviceParam.getDevName().length()>32){
throw new BusinessException("超过最大长度");
}
CheckStringUtil.checkName(carryCapacityDeviceParam.getDevName());
LambdaQueryWrapper<CarryCapacityDevicePO> lambdaQueryWrapper = new LambdaQueryWrapper<>();

View File

@@ -61,7 +61,10 @@ public class CarryCapacityUserPOServiceImpl extends ServiceImpl<CarryCapacityUse
* @return 结果
*/
private void checkName(CarryCapacityUserParam carryCapacityUserParam, boolean isUpdate) {
if(carryCapacityUserParam.getUserName().length()>32){
throw new BusinessException("超过最大长度");
}
CheckStringUtil.checkName(carryCapacityUserParam.getUserName());
LambdaQueryWrapper<CarryCapacityUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//条件组合where state = 1 and name = ?

View File

@@ -260,6 +260,8 @@ public interface PatternRegex {
*/
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,20}$";
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";
/**
* uuid 32位正则数字 、 字母
*/