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:'" + "数据异常" + '\'' +
|
'}';
|
}
|
|
}
|