🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 组件源码 ``` /** * <b>方法描述:</b> 获得对象属性及值列表 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2020-12-16 17:06:11 <br/> * * @param bean * 入参|bean实例|{@link Object} * @param fieldValue * 出参|属性值列表|{@link java.util.Map} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "获得对象属性及值列表", style = "判断型", type = "同步组件", comment = "返回map对象,key为bean属性名称", version = "1.0.0", deprecated = false, author = "admin", date = "2020-12-16 05:06:11") @InParams(param = {@Param(name = "bean", comment = "bean实例", type = Object.class)}) @OutParams(param = {@Param(name = "fieldValue", comment = "属性值列表", type = java.util.Map.class)}) @Returns(returns = {@Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) @Order(value = 2) public static ResultBase P_GetBeanFieldValue(Object bean) { if (bean == null) { return ResultBase.newFailureResult("TPTB0007", "参数错误:赋值的对象参数【bean】不能为空"); } Map result = new HashMap<String, Object>(); try { Class cls = bean.getClass(); do { Field[] fields = cls.getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); Object value = field.get(bean); result.put(field.getName(), value); AppLog.debug("获得对象属性及值列表,类={},字段={},值={}", cls.getName(), field.getName(), value); } cls = cls.getSuperclass(); } while (!cls.getName().equals("java.lang.Object")); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTB0008", "获取对象属性值集合异常:" + AppLog.errorMsg(e)); } return ResultBase.newSuccessResult(result); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/4a/29/4a294eee7c2d6f62b64f706fb5cc54ca_1869x894.png) # 参数说明及示例 ## 入口参数 bean实例:获取容器中的对象,示例: `__INNER__["user"]` ## 出口参数 属性值列表:对象中的属性和值,示例: `__INNER__["result"]`