多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 组件源码 ``` /** * <b>方法描述:</b> 变量字段检查(类型、长度) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-04-25 16:03:06 <br/> * 参数格式[['value1','int',2],['value2','String',6]] * * @param list * 入参|待检查列表|{@link com.ylink.ide.trade.runtime.context.JavaList} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "变量字段检查(类型、长度)", style = "判断型", type = "同步组件", comment = "检查字段是否符合给定类型和长度,只支持int(Integer)/Long/String 类型,忽略大小写。参数格式[['value1','int',2],['value2','String',6]]", version = "1.0.0", deprecated = false, author = "admin", date = "2018-04-25 04:03:06") @InParams(param = { @Param(name = "list", comment = "待检查列表", type = List.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_fieldCheck(List list) { if (list == null || list.isEmpty()) return ResultBase .newFailureResult("TPTV0008", "变量字段检查(类型、长度)-列表为空"); for (Object fieds : list) { if (fieds == null || !(fieds instanceof List) || ((List) fieds).size() != 3) continue; List field = (List) fieds; Object value = field.get(0); String type = (String) field.get(1); int length = (Integer) field.get(2); if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("Integer") || type.equalsIgnoreCase("Long")) { if (!(value instanceof Number)) { return ResultBase.newFailureResult("TPTV0009", "变量字段检查[" + value + "]类型不匹配" + type); } } if (type.equalsIgnoreCase("String") || type.equalsIgnoreCase("str")) { if (!(value instanceof String)) { return ResultBase.newFailureResult("TPTV0010", "变量字段检查[" + value + "]类型不匹配" + type); } } if (length != value.toString().length()) { return ResultBase.newFailureResult("TPTV0011", "变量字段检查[" + value + "]长度不匹配" + length); } } return ResultBase.newSuccessResult(); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/94/bf/94bf7fac7cf1628fea6d425bcf7a2574_1868x892.png) # 参数说明及示例 ## 入口参数 待检查列表:输入检查列表,示例: `["123","int",3]`