zhubaomin
2025-04-07 ecef3df4890be54c1da2a8a4fc1c8c1f50f1c263
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiResponseVo.java
New file
@@ -0,0 +1,77 @@
package com.dy.testClient.rmiClient;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
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
    * @return 对象
    * @throws Exception 异常
    */
   public static RmiResponseVo jsonToObject(String json, Class<?> clazz)throws Exception{
      try{
         JSONObject jsonObject = JSON.parseObject(json);
         RmiResponseVo vo = jsonObject.to(RmiResponseVo.class) ;
         vo.obj = jsonObject.getObject("obj", clazz);
         return vo ;
      }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;
   }
}