企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 /** * <b>方法描述:</b> 字段是否存在 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-09 09:45:58 <br/> * * @param key * 入参|key|{@link java.lang.String} * @param field * 入参|字段|{@link java.lang.String} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "字段是否存在", style = "判断型", type = "同步组件", comment = "判断hash中指定字段是否存在", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-09 09:45:58") @InParams(param = { @Param(name = "key", comment = "key", type = java.lang.String.class), @Param(name = "field", comment = "字段", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "不存在"), @Return(id = "1", desp = "成功") }) public static ResultBase P_hexists(String key, String field) { try { if (redisTemplate.opsForHash().hasKey(key, field)) return ResultBase.newSuccessResult(); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTR1008", "字段是否存在 异常:" + AppLog.errorMsg(e)); } return ResultBase.newFailureResult("TPTR1009", "field不存在"); } 交易中组件使用方式: ![](https://img.kancloud.cn/97/9c/979c846fbe2b0a8a29e7e7476149fe11_1652x1099.jpg) ## 参数说明及示例 key:redis中的key,示例: `"123qwer"` 字段:需要确定字段是否存在的字段名,示例: `"qwer"`