From 1e3eeec2d3a470d066d21900586b912dfef58c91 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期四, 17 四月 2025 15:07:41 +0800 Subject: [PATCH] 优化代码 --- pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/RmiResponseVo.java | 78 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/RmiResponseVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/RmiResponseVo.java new file mode 100644 index 0000000..853f77d --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/RmiResponseVo.java @@ -0,0 +1,78 @@ +package com.dy.testServer.forRmi; + +import com.alibaba.fastjson2.JSON; + +public class RmiResponseVo { + + public boolean success = true ; + + public String errorInfo ; + + public String code ; + + public Object obj ; + + /** + * 瀵硅薄杞垚json + * @return json + * @throws Exception 寮傚父 + */ + public String toJson()throws Exception{ + try{ + return JSON.toJSONString(this) ; + //return new JSONSerializer().exclude(new String[]{"class", "*.class"}).deepSerialize(this); + }catch(Exception e){ + throw new Exception(e.getMessage() , e ) ; + } + } + /** + * json杞垚瀵硅薄 + * @param json + * @param clazz + * @return 瀵硅薄 + * @throws Exception 寮傚父 + */ + public static RmiResponseVo jsonToObject(String json, Class<?> clazz)throws Exception{ + try{ + return JSON.parseObject(json, RmiResponseVo.class) ; + //JSONDeserializer<RmiResponseVo> jsonD = new JSONDeserializer<>() ; + //jsonD.use("obj", clazz) ; + //RmiResponseVo resp = jsonD.deserialize(json, RmiResponseVo.class) ; + //return resp ; + }catch(Exception e){ + throw new Exception(e.getMessage() , e ) ; + } + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getErrorInfo() { + return errorInfo; + } + + public void setErrorInfo(String errorInfo) { + this.errorInfo = errorInfo; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Object getObj() { + return obj; + } + + public void setObj(Object obj) { + this.obj = obj; + } +} -- Gitblit v1.8.0