From d39202195230b0c9d0d15d1a2b2804e59923b1fa Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Wed, 20 Aug 2025 11:58:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(property):=20=E6=B7=BB=E5=8A=A0=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E7=81=AF=E6=8E=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TbLightInfoController.java | 12 +++++++++++- .../smartDevicesImpl/TbLightInfoServiceImpl.java | 14 ++++++++++++++ .../smartDevicesService/ITbLightInfoService.java | 7 +++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/smartDevicesController/TbLightInfoController.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/smartDevicesController/TbLightInfoController.java index 18af959b..65622f90 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/smartDevicesController/TbLightInfoController.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/smartDevicesController/TbLightInfoController.java @@ -65,7 +65,7 @@ public class TbLightInfoController extends BaseController { @SaCheckPermission("property:lightInfo:query") @GetMapping("/{id}") public R getInfo(@NotNull(message = "主键不能为空") - @PathVariable("id") Long id) { + @PathVariable("id") Long id) { return R.ok(tbLightInfoService.queryById(id)); } @@ -103,4 +103,14 @@ public class TbLightInfoController extends BaseController { @PathVariable("ids") Long[] ids) { return toAjax(tbLightInfoService.deleteWithValidByIds(List.of(ids), true)); } + + /** + * 灯开关控制 + * + * @param bo bean + */ + @PostMapping("/switch") + public R switchSingleLight(@RequestBody TbLightInfoBo bo) { + return toAjax(tbLightInfoService.switchSingleLight(bo)); + } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbLightInfoServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbLightInfoServiceImpl.java index f926e4e1..dfc34603 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbLightInfoServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbLightInfoServiceImpl.java @@ -143,4 +143,18 @@ public class TbLightInfoServiceImpl implements ITbLightInfoService { } return baseMapper.deleteByIds(ids) > 0; } + + /** + * 单个灯开关控制 + * + * @param bo bean + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean switchSingleLight(TbLightInfoBo bo){ + TbLightInfo update = MapstructUtils.convert(bo, TbLightInfo.class); + boolean flag = baseMapper.updateById(update) > 0; + Assert.isTrue(flag, "修改灯开关失败"); + return flag; + } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbLightInfoService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbLightInfoService.java index 4816e290..9f3c6969 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbLightInfoService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbLightInfoService.java @@ -65,4 +65,11 @@ public interface ITbLightInfoService { * @return 是否删除成功 */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 单个灯开关控制 + * + * @param bo bean + */ + Boolean switchSingleLight(TbLightInfoBo bo); }