package com.chuanghai.attendance.common.utils; import java.io.Serializable; /** * @Author: codingliang * @Description: 接口统一返回 * @Date: 2021-04-29 12:10 * @Version: V1.0 **/ public class CommonResult extends BaseResult implements Serializable { private static final long serialVersionUID = 3616484754899974346L; public static CommonResult ok() { return ok("1", "执行成功"); } public static CommonResult ok(String code, String msg) { return baseCreate(code, msg, true); } public static CommonResult fail() { return fail("-1", "执行失败"); } public static CommonResult fail(String code, String msg) { return baseCreate(code, msg, false); } private static CommonResult baseCreate(String code, String msg, boolean success) { CommonResult result = new CommonResult(); result.setCode(code); result.setSuccess(success); result.setMessage(msg); return result; } public CommonResult setResult(T data) { this.setData(data); return this; } public T getData() { return (T) super.getData(); } public static CommonResult result(String code, String msg, Boolean b) { return baseCreate(code, msg, b); } }