💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 组件源码 ``` /** * <b>方法描述:</b> 容器字段检查(长度范围) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-04-12 14:33:28 <br/> * * @param ctrls * 入参|检查内容[ [值1,范围开始,范围结束],[值 2,]....]|{@link JavaList} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "字段检查(长度范围)", style = "判断型", type = "同步组件", comment = "检查字符串长度是否在指定范围", version = "1.0.0", deprecated = false, author = "admin", date = "2018-04-12 02:33:28") @InParams(param = { @Param(name = "ctrls", comment = "检查内容[ [字段名1,范围开始,范围结束],[字段2,]....]", type = List.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_limCtrl(List ctrls) { for (Object ctrl : ctrls) { double minctl = 0, maxctl = 0; if (ctrl == null || !(ctrl instanceof List) || ((List) ctrl).size() < 2) { continue; } Object val = ((List) ctrl).get(0).toString(); minctl = Double.valueOf(((List) ctrl).get(1).toString()); if (((List) ctrl).size() > 2) { maxctl = Double.valueOf(((List) ctrl).get(2).toString()); } // value为空不处理 if (val == null) { continue; } else if (val instanceof String) { if (val.toString().length() < minctl || (maxctl > 0 && val.toString().length() > maxctl)) { return ResultBase.newFailureResult("TPTV0001", "字段值" + val.toString() + "长度不正确"); } } else if (val instanceof Integer || val instanceof Double || val instanceof Byte || val instanceof Long || val instanceof Short || val instanceof Short || val instanceof Float) { double fVal = Double.valueOf(val.toString()); if ((minctl != 0 && fVal < minctl) || (maxctl != 0 && fVal > maxctl)) { return ResultBase.newFailureResult("TPTV0002", "字段" + val.toString() + "取值范围不在指定范围"); } } else if (val instanceof java.util.Collection) { java.util.Collection lsVal = (java.util.Collection) val; int nSize = lsVal.size(); if ((minctl != 0 && nSize < minctl) || (maxctl != 0 && nSize > maxctl)) { return ResultBase.newFailureResult("TPTV0003", "列表" + val.toString() + "深度不在指定范围"); } } } return ResultBase.newSuccessResult(); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/75/c5/75c59d8c058240acad008b88ef139c48_1867x890.png) # 参数说明及示例 ## 入口参数 检查内容[ [字段名1,范围开始,范围结束],[字段2,]....]:输入检查列表,示例: `[[__INNER__["x"],0,3],["a",0, 4],["abc",0,3],["asdzxc",0,3]]`