zhangf
2024-07-26 698995469a3fcdc3164fc486d18bdbe059b6c92e
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.gkhy.fourierSpecialGasMonitor.commons.domain;
 
import com.gkhy.fourierSpecialGasMonitor.commons.enums.ForeignResultCode;
import com.gkhy.fourierSpecialGasMonitor.commons.enums.ResultCode;
 
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
 
public class ForeignResult<T> implements Serializable {
 
    private Integer code;
 
    private String time;
 
    private T data;
 
    private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
    public static ForeignResult success(){
        ForeignResult resultVO = new ForeignResult();
        resultVO.setCode(ForeignResultCode.OK.getCode());
        resultVO.setTime(LocalDateTime.now().format(formatter));
        return resultVO;
    }
 
    public void execSuccess(){
        this.code = ForeignResultCode.OK.getCode();
    }
 
    public void setSuccess(){
        this.code = ForeignResultCode.OK.getCode();
        this.time = LocalDateTime.now().format(formatter);
    }
 
    public ForeignResult() {
        this.code = ForeignResultCode.NOT_OK.getCode();
    }
 
 
    public ForeignResult(Integer code, String time) {
        this.code = code;
        this.time = time;
    }
 
    public ForeignResult(ForeignResultCode resultCode, String time){
        this.code = resultCode.getCode();
        if(time != null && !time.isEmpty()){
            this.time = time;
        }else {
            this.time = LocalDateTime.now().format(formatter);
        }
    }
 
    public ForeignResult(ForeignResultCode code, T data) {
        this.code = code.getCode();
        this.time = LocalDateTime.now().format(formatter);
        this.data = data;
    }
 
 
    public ForeignResult(ForeignResultCode code) {
        this.code = code.getCode();
        this.time = LocalDateTime.now().format(formatter);
    }
 
    //public boolean isSuccess(){
    //    if(this.code == null)
    //        return false;
    //    if(this.code.equals(ForeignResultCode.OK.getCode())){
    //        return true;
    //    }else {
    //        return false;
    //    }
    //}
 
 
 
    public Integer getCode() {
        return code;
    }
 
    public void setCode(Integer code) {
        this.code = code;
    }
 
    public void setCode(ForeignResultCode resultCode){
        this.code = resultCode.getCode();
    }
 
    public String getTime() {
        return time;
    }
 
    public void setTime(String time) {
        this.time = time;
    }
 
    public Object getData() {
        return data;
    }
 
    public void setData(T data) {
        this.data = data;
    }
}