czt
2026-01-19 ac44ace07789c84c3a2612555417c58a3593a027
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
package com.fzzy.igds.api.v1.data;
 
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.io.Serializable;
 
/**
 * @Description 接口回复封装类
 * @Author CZT
 * @Date 2026/1/7 10:02
 */
@Data
public class ApiV1Resp<T> implements Serializable {
 
    /**
     * 返回码
     */
    public static final String CODE_SUCCESS = "200";
    public static final String CODE_ERROR = "400";
 
    /*-----消息头-----*/
    private String sn;         //设备、系统编码
    private String auth;       //权限标识
    private String sign;       //权限签名
    private String outId;      //自定义编码
    private String functionId; //功能码
    private Long timestamp;    //时间戳
    private String respCode;     //返回码
    private String respMsg;      //返回说明
 
    /*-----消息体-----*/
    private T data;
 
 
    public ApiV1Resp() {
        super();
    }
 
    public ApiV1Resp(String respCode, String respMsg, T data, ApiV1Req<Object> req) {
        this.data = data;
        this.sn = req.getSn();
        this.auth = req.getAuth();
        this.sign = req.getSign();
        this.outId = req.getOutId();
        this.functionId = req.getFunctionId();
        this.timestamp = System.currentTimeMillis();
        this.respCode = respCode;
        this.respMsg = respMsg;
    }
 
    public static ApiV1Resp<Object> success(Object data, ApiV1Req<Object> req) {
        return new ApiV1Resp<>(CODE_SUCCESS, null, data, req);
    }
 
    public static ApiV1Resp<Object> error(String respMsg, ApiV1Req<Object> req) {
        return new ApiV1Resp<>(CODE_ERROR, respMsg, null, req);
    }
 
}