feat(property): 添加智能灯控功能

This commit is contained in:
zcxlsm 2025-08-20 11:58:37 +08:00
parent a056feae53
commit d392021952
3 changed files with 32 additions and 1 deletions

View File

@ -65,7 +65,7 @@ public class TbLightInfoController extends BaseController {
@SaCheckPermission("property:lightInfo:query")
@GetMapping("/{id}")
public R<TbLightInfoVo> 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<Void> switchSingleLight(@RequestBody TbLightInfoBo bo) {
return toAjax(tbLightInfoService.switchSingleLight(bo));
}
}

View File

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

View File

@ -65,4 +65,11 @@ public interface ITbLightInfoService {
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 单个灯开关控制
*
* @param bo bean
*/
Boolean switchSingleLight(TbLightInfoBo bo);
}