响应参数响应进去了参数但是返回不了异常消息

    xiaoxiao2022-07-05  157

    是因为响应实体没有少加了get和set方法例如今天遇到的这个bug没有注意,导致在后台响应的参数是有的,传到前台后,响应的数据取不到,虽然是一个很简单的问题但是,不细心的话真的很难找到,既没有日志,有没有报异常,所以在这里进行记录一下,提醒自己,也是提醒其他的同学,不要自己坑自己,@Date这个参数很重要

    /**  * @Description: TODO * @author   * @date 2019年5月7日  */

    @Date public class BaseResponse implements Serializable{

        private static final long serialVersionUID = 1L;

        protected static final String SUCCESS = "SUCCESS";

        protected static final String FAIL = "FAIL";     @ApiModelProperty(position = 1, required = true, value = "成功 ‘SUCCESS’, 失败 ‘FAIL’", name = "code", example = "")     private String code;

        @ApiModelProperty(position = 2, value = "失败的时候失败Code", name = "errorcode", example = "")     private String errorcode;

        @ApiModelProperty(position = 3, value = "失败的具体描述", name = "errormsg", example = "")     private String errormsg;

        public BaseResponse success() {         this.code = SUCCESS;         this.errorcode = "";         this.errormsg = "";         return this;     }

        public BaseResponse fail(String errorcode, String errormsg) {         this.code = FAIL;         this.errorcode = errorcode;         this.errormsg = errormsg;         return this;     }          public BaseResponse fail( String errormsg) {         this.code = FAIL;         this.errorcode = "1001";         this.errormsg = errormsg;         return this;     } }  

     

    @ApiModel(value = "响应参数", description = "响应参数") @Data @EqualsAndHashCode(callSuper = true) public class EmailMessageInfoResponse extends BaseResponse{     private static final long serialVersionUID = 1L;     public static EmailMessageInfoResponse buildSuccess() {         EmailMessageInfoResponse response = new EmailMessageInfoResponse();         response.success();         return response;     }     public static EmailMessageInfoResponse errorFail(String errorcode, String errormsg) {         EmailMessageInfoResponse response = new EmailMessageInfoResponse();         response.fail(errorcode, errormsg);         return response;     }     public static EmailMessageInfoResponse errorFail(String errormsg) {         System.out.println(errormsg);         EmailMessageInfoResponse response = new EmailMessageInfoResponse();         response.fail(errormsg);         System.out.println(JSON.toJSON(response));         return response;     }

    }

    最新回复(0)