Commit 62eeb670 authored by tangwei's avatar tangwei

增加字段长度验证

parent 59c29c85
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -434,6 +435,41 @@ public class VideoServiceImpl extends ServiceImpl<VideoMapper, Video> implements ...@@ -434,6 +435,41 @@ public class VideoServiceImpl extends ServiceImpl<VideoMapper, Video> implements
if (ValidationUtil.isEmpty(x.getBizOrgName())) { if (ValidationUtil.isEmpty(x.getBizOrgName())) {
throw new RuntimeException("机构/部门名称不能为空,请修改后上传!"); throw new RuntimeException("机构/部门名称不能为空,请修改后上传!");
} }
//字段长度效验
if (ValidationUtil.isEmpty(x.getName())&&x.getName().length()>100) {
throw new RuntimeException("错误行" + rowNum + ":名字过长");
}
if (ValidationUtil.isEmpty(x.getCode())&&x.getCode().length()>100) {
throw new RuntimeException("错误行" + rowNum + ":编号过长");
}
if (ValidationUtil.isEmpty(x.getUrl())&&x.getUrl().length()>255) {
throw new RuntimeException("错误行" + rowNum + ":视频地址过长");
}
if (ValidationUtil.isEmpty(x.getToken())&&x.getToken().length()>255) {
throw new RuntimeException("错误行" + rowNum + ":token过长");
}
if (ValidationUtil.isEmpty(x.getBizOrgCode())&&x.getBizOrgCode().length()>64) {
throw new RuntimeException("错误行" + rowNum + ":机构编码过长");
}
if (ValidationUtil.isEmpty(x.getBizOrgName())&&x.getBizOrgName().length()>128) {
throw new RuntimeException("错误行" + rowNum + ":机构名称过长");
}
if (ValidationUtil.isEmpty(x.getAddress())&&x.getAddress().length()>2000) {
throw new RuntimeException("错误行" + rowNum + ":地址过长");
}
if (ValidationUtil.isEmpty(x.getRemark())&&x.getRemark().length()>255) {
throw new RuntimeException("错误行" + rowNum + ":备注过长");
}
if (ValidationUtil.isEmpty(x.getImg())&&x.getImg().length()>100) {
throw new RuntimeException("错误行" + rowNum + ":备注过长");
}
// if (!urlPattern.matcher(x.getUrl().trim()).matches()) { // if (!urlPattern.matcher(x.getUrl().trim()).matches()) {
// throw new RuntimeException("错误行" + rowNum + ":视频地址格式有误,仅支持协议+ip+端口的格式"); // throw new RuntimeException("错误行" + rowNum + ":视频地址格式有误,仅支持协议+ip+端口的格式");
// } // }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment