From 5b789179e44be67963d80c6e5d6f71a065c4b680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Sat, 12 Oct 2024 09:52:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=95=86=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/ss/device/domain/DeviceBO.java | 11 +++++++++++ .../web/controller/agent/AgentDeviceController.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java index 5abecbfa..d15f87f4 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java @@ -92,4 +92,15 @@ public class DeviceBO extends Device { bo.setSuitIds(getSuitIds()); return bo; } + + /** + * 过滤代理商更新字段 + * @return + */ + public DeviceBO filterUpdateByAgent() { + DeviceBO bo = new DeviceBO(); + bo.setDeviceId(getDeviceId()); + bo.setAgentServiceRate(getAgentServiceRate()); + return bo; + } } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/agent/AgentDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/agent/AgentDeviceController.java index ed17330e..43a1646a 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/agent/AgentDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/agent/AgentDeviceController.java @@ -3,6 +3,7 @@ package com.ruoyi.web.controller.agent; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.ss.device.domain.DeviceBO; import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.service.DeviceService; @@ -44,4 +45,14 @@ public class AgentDeviceController extends BaseController { return toAjax(deviceService.unbind(deviceId)); } + @ApiOperation("代理商修改设备") + @PutMapping + public AjaxResult update(@RequestBody DeviceBO data) { + DeviceVO device = deviceService.selectById(data.getDeviceId()); + if (!deviceValidator.isAgent(device, getUserId())) { + return error("您不是该设备的代理商,无权操作"); + } + DeviceBO bo = data.filterUpdateByAgent(); + return toAjax(deviceService.updateSmDevice(bo)); + } }