| 12345678910111213141516171819202122232425262728293031323334353637 |
- package com.nju.edu.eval.web;
- import com.nju.edu.eval.exception.MyServiceException;
- import lombok.AllArgsConstructor;
- import lombok.Data;
- import lombok.NoArgsConstructor;
- import org.dom4j.util.AttributeHelper;
- import org.hibernate.service.spi.ServiceException;
- /**
- * @author mars
- */
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
- public class Response {
- private String code;
- private String msg;
- private Object result;
- public Response(String code, String msg) {
- this.code = code;
- this.msg = msg;
- }
- public static Response buildSuccess(Object result) {
- return new Response("00000", "Success", result);
- }
- public static Response buildFailed(String code, ServiceException e) {
- return new Response(code, e.getLocalizedMessage(), null);
- }
- public static Response buildFailed(String code, String msg) {
- return new Response(code, msg, null);
- }
- }
|