Author: Yang Lu School: Liaoning Institute of Science and Technology Major: Computer Science and Technology Class: BZ246 Tech Stack: - Backend: Spring Boot 2.7.18 + JPA + MySQL - Frontend: HTML5 + CSS3 + JavaScript Features: - User Management (Admin/Staff/Customer roles) - Vehicle Archive Management - Service Order Management - Parts Inventory Management - Online Appointment Service - Data Statistics and Analysis Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
55 lines
1.3 KiB
Java
55 lines
1.3 KiB
Java
package com.carmaintenance.dto;
|
|
|
|
import lombok.Data;
|
|
|
|
/**
|
|
* 统一API响应结果
|
|
*/
|
|
@Data
|
|
public class Result<T> {
|
|
|
|
private Integer code;
|
|
private String message;
|
|
private T data;
|
|
|
|
private Result() {}
|
|
|
|
private Result(Integer code, String message, T data) {
|
|
this.code = code;
|
|
this.message = message;
|
|
this.data = data;
|
|
}
|
|
|
|
public static <T> Result<T> success() {
|
|
return new Result<>(200, "操作成功", null);
|
|
}
|
|
|
|
public static <T> Result<T> success(T data) {
|
|
return new Result<>(200, "操作成功", data);
|
|
}
|
|
|
|
public static <T> Result<T> success(String message, T data) {
|
|
return new Result<>(200, message, data);
|
|
}
|
|
|
|
public static <T> Result<T> error(String message) {
|
|
return new Result<>(500, message, null);
|
|
}
|
|
|
|
public static <T> Result<T> error(Integer code, String message) {
|
|
return new Result<>(code, message, null);
|
|
}
|
|
|
|
public static <T> Result<T> unauthorized(String message) {
|
|
return new Result<>(401, message, null);
|
|
}
|
|
|
|
public static <T> Result<T> forbidden(String message) {
|
|
return new Result<>(403, message, null);
|
|
}
|
|
|
|
public static <T> Result<T> notFound(String message) {
|
|
return new Result<>(404, message, null);
|
|
}
|
|
}
|