企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 /** * <b>方法描述:</b> 获取值 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2020-06-09 17:44:58 <br/> * * @param key * 入参|键|{@link java.lang.String} * @param value * 出参|查询结果值|{@link java.lang.String} * @return -1 异常<br/> * 1 成功<br/> */ @Component(label = "获取值", style = "判断型", type = "同步组件", comment = "key不存在则返回null,如果key存在但value不是string类型的,则返回一个error", version = "1.0.0", deprecated = false, author = "admin", date = "2020-06-09 05:44:58") @InParams(param = { @Param(name = "key", comment = "键", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "value", comment = "查询结果值", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_getByKey(String key) { try { Object obj = redisTemplate.opsForValue().get(key); return ResultBase.newSuccessResult(obj.toString()); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTR5003", "没有String 类型key:" + key); } } 交易中组件使用方式: ![](https://img.kancloud.cn/c3/7d/c37dec8d9e454d3e76132b103f8ad681_950x750.jpg) ## 参数说明及示例 键:redis中的key,示例: `"qwer"` 查询结果值:通过key获取的redis中的值,示例: `__INNER__["result"]` > key不存在则返回null,如果key存在但value不是string类型的,则返回一个error