我想知道如何从返回json的pgsqlplsql函数中读取json。如何在spring引导React式应用程序中读取函数返回的json对象?
pgsql函数示例
CREATE OR REPLACE FUNCTION public.fn_get_relatedcontent(
_assetid integer,
_fldname text)
RETURNS json
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$DECLARE
dataresult json;
BEGIN
select array_to_json(array_agg(t)) into dataresult from (
select * from table1
) t;
return dataresult ;
END;$BODY$;
和java模式
public class FnResult implements Serializable {
@Column(value = "fn_get_relatedcontent")
private Json dataset;
}
和存储库
@Repository
public interface AssetRelatedContentRepository extends ReactiveCrudRepository<FnResult, BigInteger> {
@Query("SELECT * FROM public.fn_get_relatedcontent(:assetId,:fieldName)")
Flux<AssetRelatedContent> findAssetRelatedContent(Integer assetId,String fieldName);
}
这是非常直截了当的nodejs,我是一个新手,以 Spring 启动React。提前谢谢。
暂无答案!
目前还没有任何答案,快来回答吧!