From 302d2a962d8c99eba5cbd8ca82c83dd6d5a7f63d Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期三, 03 十一月 2021 12:55:44 +0800 Subject: [PATCH] 实体类转化工具 --- src/main/java/com/platform/util/FormatConversion.java | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/platform/util/FormatConversion.java b/src/main/java/com/platform/util/FormatConversion.java new file mode 100644 index 0000000..66790be --- /dev/null +++ b/src/main/java/com/platform/util/FormatConversion.java @@ -0,0 +1,28 @@ +package com.platform.util; + +import com.alibaba.fastjson.JSONObject; +import com.platform.exception.PlatTipsException; +import com.platform.resultTool.PlatformCode; +import org.apache.poi.ss.formula.functions.T; + +import java.io.Serializable; + +/** + * 绫诲瀷杞寲宸ュ叿 + */ +public class FormatConversion { + + /** + * @param data 杞寲鐨勬暟鎹� + * @param tClass 杞寲鎴愮殑瀵硅薄 + * @return + */ + public static Object jsonToEntity(String data,Class tClass) { + try{ + return JSONObject.parseObject(data, tClass); + }catch (Exception e){ + throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"鏁版嵁鏍煎紡閿欒"); + } + } + +} -- Gitblit v1.8.0