💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 一、概述 有时候同一个实体,在不同业务中,需要将字段改为另外一个名字显示; ## 二、解决方案 在controller中,加上配置; ``` @RayDynamicRenameFieldsInListEntityGroup({ // @RayDynamicRenameFieldsInListEntity(renameFieldPairs = "showUsedFlow:usedFlow;showLeftFlow:leftFlow;showFlowQuota:flowQuota")// }) ``` ## 三、完整方案 可以支持分页、普通列表以及单个实体的字段改名,支持多重组合等; 分页: ``` @RayDynamicRenameFieldsInPageEntityGroup @RayDynamicRenameFieldsInPageEntity ``` 普通列表: ``` @RayDynamicRenameFieldsInListEntityGroup @RayDynamicRenameFieldsInListEntity ``` 单个实体: ``` @RayDynamicRenameFieldsInSingleEntityGroup @RayDynamicRenameFieldsInSingleEntity ``` 其他一些注意事项可以类比参考:[项目实战/后端开发/返回结果处理/返回字段过滤](%E8%BF%94%E5%9B%9E%E5%AD%97%E6%AE%B5%E8%BF%87%E6%BB%A4.md) ## 四、组合使用实例 ``` @PostMapping(RayOauthServerConstants.rayOauthApiUrlPrefix + apiRequestSimpleUrl) @RayDynamicFilterFieldsInListEntityGroup({ // @RayDynamicFilterFieldsInListEntity(listObject = "listobject", excludeFields = "relaxRate,executeRate,usedFlow,leftFlow,flowQuota"), // @RayDynamicFilterFieldsInListEntity(listObject = "historyList", excludeFields = "relaxRate,executeRate,usedFlow,leftFlow,flowQuota")// }) @RayDynamicRenameFieldsInListEntityGroup({ // @RayDynamicRenameFieldsInListEntity(listObject = "listobject", renameFieldPairs = "showUsedFlow:usedFlow;showLeftFlow:leftFlow;showFlowQuota:flowQuota"), // @RayDynamicRenameFieldsInListEntity(listObject = "historyList", renameFieldPairs = "showUsedFlow:usedFlow;showLeftFlow:leftFlow;showFlowQuota:flowQuota")// }) public ResponseEntity<ResponseObject> view(@RequestHeader(required = false) String rayOauthServerAppId, @RequestHeader(required = false) String rayOauthServerTimeStamp, @RequestHeader(required = false) String rayOauthServerSignature, @RequestParam(required = false) String userCode) throws Exception { return ResponseEntity.ok(commonQueryFlow.response(getOauthClient(), getOauthApi(), getOauthApiRequest(), getOauthRequestParameters())); } ```