lyh
13 小时以前 78aeb8a8c97a884a640d46755e4be706bde48b7d
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
package com.lxzn.webservice.ext;
 
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.lxzn.framework.utils.JsonMapper;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
 
import java.io.IOException;
import java.io.Serializable;
 
/**
 * @Description:
 * @Author: zhangherong
 * @Date: Created in 2020/12/24 18:23
 * @Version: 1.0
 * @Modified By:
 */
@Data
@NoArgsConstructor
@Slf4j
public class MesResultModel implements Serializable {
    //"1" 成功  "0"失败
    @JsonProperty("FLAG")
    @JSONField(name = "FLAG")
    private String succFlag;
    //数据失败原因
    @JsonProperty("MSG")
    @JSONField(name = "MSG")
    private String error;
 
    public static String error( String msg) {
        MesResultModel model = new MesResultModel();
        model.setSuccFlag("0");
        model.setError(msg);
        JsonMapper mapper = new JsonMapper();
        try {
            return mapper.toJson(model);
        } catch (IOException e) {
            log.error(e.getMessage());
            return jsonError();
        }
    }
 
    public static String success(String s){
        MesResultModel model = new MesResultModel();
        model.setSuccFlag("1");
        model.setError(s);
        JsonMapper mapper = new JsonMapper();
        try {
            return mapper.toJson(model);
        } catch (IOException e) {
            log.error(e.getMessage());
            return jsonError();
        }
    }
 
    public static String jsonError(){
        return "{" +
                "FLAG:'" + "0" + '\'' +
                ", MSG:'" + "数据异常" + '\'' +
                '}';
    }
 
}