|
@@ -0,0 +1,199 @@
|
|
|
|
+package com.care.client.controller;
|
|
|
|
+
|
|
|
|
+import com.care.client.service.PassportService;
|
|
|
|
+import com.care.client.service.PinanbaoDeviceService;
|
|
|
|
+import com.care.client.vo.HouseContactVO;
|
|
|
|
+import com.care.client.vo.MemberInfoVO;
|
|
|
|
+import com.care.client.vo.DeviceVO;
|
|
|
|
+import com.care.client.vo.OlderVO;
|
|
|
|
+import com.care.common.exception.BDException;
|
|
|
|
+import com.care.common.util.Result;
|
|
|
|
+import com.care.common.vo.device.StationVO;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Author: lilt
|
|
|
|
+ * @Date: 2021/5/26
|
|
|
|
+ * @Desc:
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@Api(value = "DevApiController", tags = { "我的设备" })
|
|
|
|
+@Slf4j
|
|
|
|
+@RequestMapping("/pinanbao/device")
|
|
|
|
+public class DevApiController {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private PinanbaoDeviceService pinanbaoDeviceService;
|
|
|
|
+ @Resource
|
|
|
|
+ private PassportService passportService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询空闲设备列表
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/my/queryFreeDeviceList")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "选择要添加设备列表(查询空闲设备列表)--二期新增")
|
|
|
|
+ public Result<List<DeviceVO>> queryFreeDeviceList(@RequestHeader(value = "token") String token){
|
|
|
|
+ try {
|
|
|
|
+ MemberInfoVO current = passportService.checkToken(token);
|
|
|
|
+ List<DeviceVO> datas = pinanbaoDeviceService.queryFreeDeviceList(current.getId());
|
|
|
|
+ return Result.success(datas);
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("设备: 列表查询出现异常",e);
|
|
|
|
+ return Result.error( "获取失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 选择空闲设备保存绑定
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/my/bindDevice")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "选择空闲设备保存绑定 --二期新增")
|
|
|
|
+ public Result<Object> bindDevice(HttpServletRequest request, @RequestHeader("token") String token,
|
|
|
|
+ @RequestParam("id") Long id) {
|
|
|
|
+ MemberInfoVO current = passportService.checkToken(token);
|
|
|
|
+ if (this.pinanbaoDeviceService.bindDevice(current.getId(),id)) {
|
|
|
|
+ return Result.success("绑定成功");
|
|
|
|
+ } else{
|
|
|
|
+ return Result.error("绑定失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @DeleteMapping("/my/removeMyDevice/{id}")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "移除设备(解除绑定) -- 二期新增")
|
|
|
|
+ public Result<Object> removeMyDevice(HttpServletRequest request,@RequestHeader("token") String token,
|
|
|
|
+ @PathVariable("id") Long id) {
|
|
|
|
+ try {
|
|
|
|
+ MemberInfoVO current = passportService.checkToken(token);
|
|
|
|
+ this.pinanbaoDeviceService.removeMyDevice(current.getId(),id);
|
|
|
|
+ return Result.success("移除成功!");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("设备: 移除设备出现异常", e);
|
|
|
|
+ return Result.error("移除失败!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 我的设备列表
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/my/myDeviceList")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "我的设备列表")
|
|
|
|
+ public Result<List<DeviceVO>> myDeviceList(@RequestHeader(value = "token") String token){
|
|
|
|
+ try {
|
|
|
|
+ MemberInfoVO current = passportService.checkToken(token);
|
|
|
|
+ List<DeviceVO> datas = pinanbaoDeviceService.queryDeviceByMemberId(current.getId());
|
|
|
|
+ return Result.success(datas);
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("设备: 列表查询出现异常",e);
|
|
|
|
+ return Result.error( "获取失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 我的设备详情
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/my/getMyDeviceInfo")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "设备详情 (包括设备名、场景、响应时间、服务信息等) -- 二期新增")
|
|
|
|
+ public Result<DeviceVO> getMyDeviceInfo(@RequestHeader(value = "token") String token,
|
|
|
|
+ @RequestParam("id") Long id){
|
|
|
|
+ try {
|
|
|
|
+ return Result.success(this.pinanbaoDeviceService.getDeviceInfo(id));
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("设备: 查询详情出现异常",e);
|
|
|
|
+ return Result.error( "获取失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 我的设备-服务站简介
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/my/getMyDevStationInfo")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "服务站简介 -- 二期新增")
|
|
|
|
+ public Result<StationVO> getMyDevStationInfo(@RequestHeader(value = "token") String token,
|
|
|
|
+ @RequestParam("stationId") Long stationId){
|
|
|
|
+ try {
|
|
|
|
+ return Result.success(this.pinanbaoDeviceService.getMyDevStationInfo(stationId));
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("服务站: 查询详情出现异常",e);
|
|
|
|
+ return Result.error( "获取失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/my/updateMyDevice")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "设备修改(设备名,场景、响应时间) -- 二期新增")
|
|
|
|
+ public Result<Object> updateMyDevice(@RequestHeader("token") String token,
|
|
|
|
+ @RequestBody DeviceVO vo){
|
|
|
|
+ try {
|
|
|
|
+ if(this.pinanbaoDeviceService.updateMyDevice(vo)){
|
|
|
|
+ return Result.success("修改成功!");
|
|
|
|
+ } else {
|
|
|
|
+ return Result.error("修改失败!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ log.error("修改设备-出现异常",e);
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("设备: 修改设备出现异常",e);
|
|
|
|
+ return Result.error("修改失败!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询我的设备拥有的被监护人列表
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/my/queryMyOlderListByDeviceId")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "查询我的设备拥有的被监护人列表")
|
|
|
|
+ public Result<List<OlderVO>> queryMyOlderListByDeviceId(@RequestHeader(value = "token") String token,
|
|
|
|
+ @RequestParam("id") Long id){
|
|
|
|
+ try {
|
|
|
|
+ List<OlderVO> datas = pinanbaoDeviceService.queryMyOlderListByDeviceId(id);
|
|
|
|
+ return Result.success(datas);
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("老人: 列表查询出现异常",e);
|
|
|
|
+ return Result.error( "获取失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询我的设备拥有的紧急联系人列表
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/my/queryMyContactListByDeviceId")
|
|
|
|
+ @ApiOperation(tags = {"我的设备"},value = "查询我的设备拥有的紧急联系人列表")
|
|
|
|
+ public Result<List<HouseContactVO>> queryMyContactListByDeviceId(@RequestHeader(value = "token") String token,
|
|
|
|
+ @RequestParam("id") Long id){
|
|
|
|
+ try {
|
|
|
|
+ List<HouseContactVO> datas = pinanbaoDeviceService.queryMyContactListByDeviceId(id);
|
|
|
|
+ return Result.success(datas);
|
|
|
|
+ }catch (BDException e) {
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("联系人: 列表查询出现异常",e);
|
|
|
|
+ return Result.error( "获取失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|