Browse Source

add cms unbind device

huodongdong 6 năm trước cách đây
mục cha
commit
83fe73e0b3

+ 32 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/controller/user/TerminalDeviceController.java

@@ -0,0 +1,32 @@
+package cn.rankin.cmsweb.controller.user;
+
+import cn.rankin.cmsweb.service.user.TerminalDeviceService;
+import cn.rankin.cmsweb.service.user.TerminalUserService;
+import cn.rankin.common.utils.api.model.APIResult;
+import cn.rankin.common.utils.api.model.BaseCode;
+import cn.rankin.data.api.user.vo.TerminalUserVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(value = "/device")
+public class TerminalDeviceController {
+
+    @Autowired
+    private TerminalUserService terminalUserService;
+
+    @Autowired
+    private TerminalDeviceService terminalDeviceService;
+
+    @RequestMapping(value = "/unbind/{userId}", method = RequestMethod.DELETE)
+    public APIResult<Boolean> deviceUnbind(@PathVariable String userId) {
+        APIResult<TerminalUserVo> userApiResult = terminalUserService.getUser(userId);
+        if (!userApiResult.getSuccess()) {
+            return APIResult.error(new BaseCode(userApiResult.getCode(), userApiResult.getMessage()));
+        }
+        return terminalDeviceService.deviceUnbind(userId);
+    }
+}

+ 14 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/service/user/TerminalDeviceService.java

@@ -0,0 +1,14 @@
+package cn.rankin.cmsweb.service.user;
+
+import cn.rankin.common.utils.api.model.APIResult;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient(name = "${service.user.name}")
+public interface TerminalDeviceService {
+
+    @RequestMapping(value = "/device/unbind", method = RequestMethod.DELETE)
+    APIResult<Boolean> deviceUnbind(@RequestParam("userId") String userId);
+}

+ 4 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/service/ResourceService.java

@@ -133,6 +133,10 @@ public class ResourceService {
             return errResult;
         }
 
+        ResourceRemote resourceRemote = result.getData();
+        if (resourceRemote == null) {
+            return APIResult.ok(new Page<>());
+        }
         List<Resource> resourceList = result.getData().toNativeResource();
         Page<Resource> page = new Page((long) resourceList.size());
         page.setList(resourceList);