办学质量监测教学评价系统
ageer
2024-02-27 a079ef44e53acd9e8df51dbb31cf5aea4f9be5bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.xmzs.midjourney.result;
 
import com.xmzs.midjourney.ReturnCode;
import lombok.Getter;
 
@Getter
public class Message<T> {
    private final int code;
    private final String description;
    private final T result;
 
    public static <Y> Message<Y> success() {
        return new Message<>(ReturnCode.SUCCESS, "成功");
    }
 
    public static <T> Message<T> success(T result) {
        return new Message<>(ReturnCode.SUCCESS, "成功", result);
    }
 
    public static <T> Message<T> success(int code, String description, T result) {
        return new Message<>(code, description, result);
    }
 
    public static <Y> Message<Y> notFound() {
        return new Message<>(ReturnCode.NOT_FOUND, "数据未找到");
    }
 
    public static <Y> Message<Y> validationError() {
        return new Message<>(ReturnCode.VALIDATION_ERROR, "校验错误");
    }
 
    public static <Y> Message<Y> failure() {
        return new Message<>(ReturnCode.FAILURE, "系统异常");
    }
 
    public static <Y> Message<Y> failure(String description) {
        return new Message<>(ReturnCode.FAILURE, description);
    }
 
    public static <Y> Message<Y> of(int code, String description) {
        return new Message<>(code, description);
    }
 
    public static <T> Message<T> of(int code, String description, T result) {
        return new Message<>(code, description, result);
    }
 
    private Message(int code, String description) {
        this(code, description, null);
    }
 
    private Message(int code, String description, T result) {
        this.code = code;
        this.description = description;
        this.result = result;
    }
}