Browse Source

为小程序提供两个接口

master
yangzongjia 2 years ago
parent
commit
a14107ae44
  1. 28
      yxt-supervise-monitor-biz/src/main/java/com/yxt/supervise/monitor/biz/device/YDeviceRest.java
  2. 13
      yxt-supervise-monitor-biz/src/main/java/com/yxt/supervise/monitor/biz/device/YDeviceService.java

28
yxt-supervise-monitor-biz/src/main/java/com/yxt/supervise/monitor/biz/device/YDeviceRest.java

@ -153,4 +153,32 @@ public class YDeviceRest {
rb.setData(yDeviceService.getDataInfoRes(ckId));
return rb;
}
/***************************小程序调用接口部分开始***************************************/
@ApiOperation("通过仓库ID获取设备信息")
@GetMapping("/getDeviceListBySid")
public ResultBean getDeviceListBySid(String sid,String deviceName) {
return yDeviceService.getDeviceListBySid(sid,deviceName);
}
@ApiOperation("获取token")
@GetMapping("/getToken")
public ResultBean getToken() {
ResultBean rb = ResultBean.fireSuccess();
String spToken = "";
String url = "https://api2.hik-cloud.com/v1/ezviz/account/info";
try {
String result = HttpUtils.sendGet(url, SyncService.haiKangToken);
JSONObject jsonObject = JSONObject.parseObject(result);
JSONObject dataJson = (JSONObject) jsonObject.get("data");
String appKey = dataJson.get("appKey").toString();
spToken = dataJson.get("token").toString();
} catch (Exception e) {
System.out.println(e);
}
return rb.setData(spToken);
}
/***************************小程序调用接口部分结束***************************************/
}

13
yxt-supervise-monitor-biz/src/main/java/com/yxt/supervise/monitor/biz/device/YDeviceService.java

@ -279,4 +279,17 @@ public class YDeviceService extends ServiceImpl<YDeviceMapper, Device> {
map.put("ezvizToken", spToken);
return map;
}
/***************************小程序调用接口部分开始***************************************/
public ResultBean getDeviceListBySid(String sid, String deviceName) {
ResultBean rb = ResultBean.fireSuccess();
QueryWrapper<Device> wrapper = new QueryWrapper<>();
wrapper.eq("ckId", sid);
wrapper.eq("name", deviceName);
wrapper.eq("type", "1");
Device devices = this.getOne(wrapper);
rb.setData(devices);
return rb;
}
/***************************小程序调用接口部分结束***************************************/
}

Loading…
Cancel
Save