ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> 获得对象字段值 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:50:49 <br/> * * @param bean 入参|bean实例|{@link Object} * @param fieldName 入参|字段名称|{@link java.lang.String} * @param value 出参|字段值|{@link Object} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "获得对象字段值", style = "判断型", type = "同步组件", comment = "获得给定bean的指定字段属性值", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-11 11:50:49") @InParams(param = {@Param(name = "bean", comment = "bean实例", type = Object.class), @Param(name = "fieldName", comment = "字段名称", type = java.lang.String.class)}) @OutParams(param = {@Param(name = "value", comment = "字段值", type = Object.class)}) @Returns(returns = {@Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) public static ResultBase P_GetFieldValue(Object bean, String fieldName) { if (bean == null) { return ResultBase.newFailureResult("TPTB0009", "参数错误:对象参数【bean】不能为空"); } if (StringUtil.isEmpty(fieldName)) { return ResultBase.newFailureResult("TPTB0010", "参数错误:字段参数【fieldName】不能为空"); } try { Class cls = bean.getClass(); return ResultBase.newSuccessResult(CommonsUtils.getFieldValue(cls, bean, fieldName)); } catch (Exception e) { AppLog.error("获得类字段{}值异常:{}", fieldName, e); return ResultBase.newExceptionResult("TPTB0011", "获得对象字段值 异常:" + AppLog.errorMsg(e)); } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/78/a0/78a0bb42aaba54571641feb9edf984ab_1869x889.png) # 参数说明及示例 ## 入口参数 bean实例:获取容器中的对象,示例: `__INNER__["user"]` 字段名称:对象中的属性名称,示例: `"name"` ## 出口参数 字段值:获取对象中对应的字段值,示例: `__INNER__["result"]`