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); }