|
|
@ -1,48 +1,31 @@ |
|
|
|
package com.yxt.supervise.monitor.biz.call; |
|
|
|
package com.yxt.supervise.monitor.biz.controller; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentity; |
|
|
|
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityDto; |
|
|
|
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityQuery; |
|
|
|
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityVo; |
|
|
|
import com.yxt.supervise.monitor.biz.demobaseentity.DemoBaseentityService; |
|
|
|
import com.yxt.supervise.monitor.biz.util.HttpUtils; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.security.KeyManagementException; |
|
|
|
import java.security.KeyStoreException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Api(tags = "基础实体类") |
|
|
|
@RestController("com.yxt.supervise.monitor.biz.call.CallRest") |
|
|
|
@Api(tags = "接口控制器") |
|
|
|
@RestController("com.yxt.supervise.monitor.biz.controller.CallRest") |
|
|
|
@RequestMapping("/call") |
|
|
|
public class CallRest { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DemoBaseentityService demoBaseentityService; |
|
|
|
|
|
|
|
@ApiOperation("根据条件分页查询数据的列表") |
|
|
|
@PostMapping("/listPage") |
|
|
|
public ResultBean<PagerVo<DemoBaseentityVo>> listPage(@RequestBody PagerQuery<DemoBaseentityQuery> pq) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
PagerVo<DemoBaseentityVo> pv = demoBaseentityService.listPageVo(pq); |
|
|
|
return rb.success().setData(pv); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("获取token") |
|
|
|
@GetMapping("/getCallToken") |
|
|
|
public String getCallToken() throws Exception { |
|
|
@ -149,33 +132,27 @@ public class CallRest { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("新增") |
|
|
|
@PostMapping("/insert") |
|
|
|
public ResultBean save(@RequestBody DemoBaseentityDto dto) { |
|
|
|
return demoBaseentityService.saveInsert(dto); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("修改") |
|
|
|
@PostMapping("/update") |
|
|
|
public ResultBean update(@RequestBody DemoBaseentityDto dto) { |
|
|
|
return demoBaseentityService.saveUpdate(dto); |
|
|
|
@ApiOperation("接入设备") |
|
|
|
@GetMapping("/createDevice") |
|
|
|
public String createDevice(String consumerId) { |
|
|
|
String url = "https://api2.hik-cloud.com/api/v1/open/basic/devices/create"; |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("deviceSerial", consumerId); // 设备序列号 string
|
|
|
|
param.put("groupNo", consumerId); // 组编号 string
|
|
|
|
param.put("validateCode", consumerId); // 验证码 string
|
|
|
|
String result = HttpUtils.sendPostMap(url,param, "35ad3e80-1de4-4477-827e-0473320cf644"); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据sid查询") |
|
|
|
@GetMapping("/fetchVoBySid/{sid}") |
|
|
|
public ResultBean<DemoBaseentityVo> fetchVoBySid(@PathVariable String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
DemoBaseentity entity = demoBaseentityService.fetchBySid(sid); |
|
|
|
DemoBaseentityVo vo = new DemoBaseentityVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return rb.success().setData(vo); |
|
|
|
@ApiOperation("删除设备") |
|
|
|
@GetMapping("/removeDevice") |
|
|
|
public String removeDevice(String consumerId) { |
|
|
|
String url = "https://api2.hik-cloud.com/api/v1/open/basic/devices/update"; |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("deviceName", consumerId); // 设备名称 string
|
|
|
|
param.put("deviceSerial", consumerId); // 设备序列号 string
|
|
|
|
String result = HttpUtils.sendPostMap(url,param, "35ad3e80-1de4-4477-827e-0473320cf644"); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("删除") |
|
|
|
@DeleteMapping("/deleteBySid/{sid}") |
|
|
|
public ResultBean deleteBySid(@PathVariable String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
int i = demoBaseentityService.deleteBySid(sid); |
|
|
|
return rb.success().setMsg("删除成功"); |
|
|
|
} |
|
|
|
} |