Commit e70651b9 by 周海宝

Merge branch 'dev' into 'master'

[+]红外设备代码提交

See merge request !8
2 parents 6e8f2c55 3d464a17
package cn.com.glsx.common;
/**
* @author zhouhaibao
* @date 2021/3/20 13:48
*/
public enum DeviceErrorEnum {
NOT_LOGIN_ERROR("1000", "数据不存在"),
SECRET_INVALID_ERROR("1001", "非法密钥"),
PERMISSION_DENY_ERROR("1106", "权限受限"),
DEVICE_IS_OFFLINE_ERROR("2003", "不支持的指令"),
COMMAND_SUPPORT_ERROR("2008", "不支持的指令或值"),
DEVICE_NOT_EXIST_ERROR("2010", "设备不存在"),
COMMANDS_ISSUE_ERROR("1103", "指令下发失败"),
TYPE_IS_ERROR("1104", "类型错误");
private String value;
private String displayName;
DeviceErrorEnum(String value, String displayName) {
this.value = value;
this.displayName = displayName;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public static String searchValue(String key) {
for (DeviceErrorEnum m : DeviceErrorEnum.values()) {
if (m.getValue() == key) {
return m.getDisplayName();
}
}
return null;
}
}
package cn.com.glsx.modules.service; package cn.com.glsx.modules.service;
import cn.com.glsx.common.DeviceErrorEnum;
import cn.com.glsx.modules.model.param.ResponseBody; import cn.com.glsx.modules.model.param.ResponseBody;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -84,8 +85,8 @@ public class DeviceService { ...@@ -84,8 +85,8 @@ public class DeviceService {
if (responseBody != null && responseBody.isSuccess()) { if (responseBody != null && responseBody.isSuccess()) {
return R.ok(); return R.ok();
} }
String errorMessage = responseBody == null ? "调用涂鸦失败" : responseBody.getMsg();
Integer code = responseBody == null ? 500 : responseBody.getCode(); Integer code = responseBody == null ? 500 : responseBody.getCode();
String errorMessage=responseBody == null ? "调用涂鸦失败" : DeviceErrorEnum.searchValue(code+"");
return R.error(code,errorMessage); return R.error(code,errorMessage);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!