不喜欢废话直接上代码
标准通用返回
package com.luojie.common;
import com.luojie.common.inter.ResponseCommon;
import lombok.Data;
@Data
public class ResponseCommonImpl implements ResponseCommon {
int code;
String msg;
Object entity;
}
package com.luojie.common;
import org.springframework.http.HttpStatus;
public class ResponseUtil {
public static ResponseCommonImpl success(String msg, Object data) {
ResponseCommonImpl common = new ResponseCommonImpl();
common.setCode(HttpStatus.OK.value());
common.setMsg(msg);
common.setEntity(data);
return common;
}
public static ResponseCommonImpl failCommon(String msg, Object data) {
ResponseCommonImpl common = new ResponseCommonImpl();
common.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
common.setMsg(msg);
common.setEntity(data);
return common;
}
}