💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
![](https://img.kancloud.cn/42/12/4212ffb11bfb1922d76d8525c41cebf8_1869x893.png)# 组件源码 ``` /** * <b>方法描述:</b> 对象属性赋值 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-06-28 10:11:16 <br/> * * @param bean 入参|赋值对象|{@link Object} * @param fieldValue 入参|属性值列表|{@link java.util.Map} * @param obj 出参|赋值后的对象|{@link Object} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "对象属性赋值", style = "判断型", type = "同步组件", comment = "给指定的对象的属性进行赋值,参数为容器,例:{'key1':'test','key2': __REQ__['name'],'key3':{'key3_1':12},'key4':['abc',2]}", version = "1.0.0", deprecated = false, author = "admin", date = "2018-06-28 10:11:16") @InParams(param = {@Param(name = "bean", comment = "赋值对象", type = Object.class), @Param(name = "fieldValue", comment = "属性值列表", type = java.util.Map.class)}) @OutParams(param = {@Param(name = "obj", comment = "赋值后的对象", type = Object.class)}) @Returns(returns = {@Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) public static ResultBase P_BeanFieldSetValue(Object bean, Map fieldValue) { if (bean == null) { return ResultBase.newFailureResult("TPTB0005", "参数错误:赋值的对象参数【bean】不能为空"); } StringBuffer sb = new StringBuffer(); try { if (fieldValue != null && !fieldValue.isEmpty()) { Class cls = bean.getClass(); setValue(cls, fieldValue, bean, sb); } } catch (Exception e) { AppLog.error("对象属性赋值,出现异常", e); AppLog.error("对象属性赋值,已赋值字段:", sb.toString()); String str = e.getMessage(); if (StringUtil.isEmpty(str)) str = e.getLocalizedMessage(); if (StringUtil.isEmpty(str)) str = e.getCause().getLocalizedMessage(); return ResultBase.newExceptionResult("TPTB0006", "对象属性赋值错误:" + str); } return ResultBase.newSuccessResult(bean); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/42/12/4212ffb11bfb1922d76d8525c41cebf8_1869x893.png) # 参数说明及示例 ## 入口参数 赋值对象:传入一个对象类型,示例: `__INNER__["user"]` 属性值列表: `{ "id":15, "name":"zs" }` ## 出口参数 赋值后的对象:根据输入参数进行赋值,示例: `__INNER__["result"]` > 此组件只能给在容器中的对象赋值,如:创建实体类对象等。