Commit b17db481 authored by 廖旭伟's avatar 廖旭伟

添加设备详情接口

parent cb2a1770
......@@ -69,4 +69,14 @@ public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, Device
return result;
}
@Override
public DeviceEntity get(Long key, Context context) throws AppException {
DeviceEntity deviceEntity = new DeviceEntity();
Rest<DevicePdu> result = deviceFeign.info(key);
if (result.getCode().equals(YesNoEnum.YES.getValue())) {
BeanUtils.copyProperties(result.getData(), deviceEntity, BeanUtil.getNullPropertyNames(result.getData()));
}
return deviceEntity;
}
}
\ No newline at end of file
package com.mortals.xhx.module.device.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
......@@ -28,6 +32,9 @@ import java.util.Map;
@Slf4j
public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceService, DeviceEntity, Long> {
@Autowired
private IDeviceFeign deviceFeign;
@Override
@PostMapping({"list"})
@UnAuth
......@@ -82,4 +89,44 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@RequestMapping(value = {"info"},method = {RequestMethod.POST, RequestMethod.GET})
@UnAuth
public String info(Long id) {
Map<String, Object> model = new HashMap();
if (id == null) {
return this.createFailJsonResp("请选择待查看" + this.getModuleDesc() + "信息");
} else {
JSONObject ret = new JSONObject();
String busiDesc = "查看" + this.getModuleDesc();
Context context = this.getContext();
try {
DeviceEntity deviceEntity = new DeviceEntity();
Rest<DevicePdu> result = deviceFeign.info(id);
if (result.getCode().equals(YesNoEnum.YES.getValue())) {
BeanUtils.copyProperties(result.getData(), deviceEntity, BeanUtil.getNullPropertyNames(result.getData()));
model.put("dict",result.getDict());
model.put("msg",result.getMsg());
}
if (deviceEntity == null) {
throw new Exception(busiDesc + ",不存在或已被删除");
}
ret.put("data", deviceEntity);
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var8) {
this.doException(this.request, busiDesc, model, var8);
Object msg = model.get("message_info");
return this.createFailJsonResp(msg == null ? "系统异常" : msg.toString());
}
this.init(model, context);
ret.put("code", 1);
ret.put("msg", model.remove("message_info"));
ret.put("dict", model.remove("dict"));
return ret.toJSONString();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment