企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 /** * <b>方法描述:</b> 添加元素 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2020-06-10 16:42:57 <br/> * * @param key * 入参|key|{@link java.lang.String} * @param list * 入参|列表|{@link java.util.List} * @param length * 出参|添加数量|{@link long} * @return -1 异常<br/> * 1 成功<br/> */ @Component(label = "添加元素", style = "判断型", type = "同步组件", comment = "集合不存,新建集合;元素存在,忽略;返回新成功添加到集合里元素的数量", version = "1.0.0", deprecated = false, author = "admin", date = "2020-06-10 04:42:57") @InParams(param = { @Param(name = "key", comment = "key", type = java.lang.String.class), @Param(name = "list", comment = "列表", type = java.util.List.class) }) @OutParams(param = { @Param(name = "length", comment = "添加数量", type = long.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_sadd(String key, List list) { try { long cnt = redisTemplate.opsForSet().add(key, list.toArray()); return ResultBase.newSuccessResult(cnt); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTR4001", "key对应的数据结构不是Set类型"); } } 交易中组件使用方式: ![](https://img.kancloud.cn/24/65/2465f3f9602429db58e9b40c08b7370e_950x750.jpg) ## 参数说明及示例 key:redis中的key,示例: `"qwer"` 列表:需要添加到redis中的集合,示例: `["1","2","3","4"]` 添加数量:返回redis对应key成功添加的数量,示例: `__INNER__["size"]` > 集合不存,新建集合;元素存在,忽略;返回新成功添加到集合里元素的数量