提交 ea7be5eb authored 作者: 林业通's avatar 林业通

删除关联房间

上级 0e34a1be
......@@ -130,6 +130,15 @@ public class ShDeviceController {
return R.ok();
}
@Login
@PostMapping("deleteRelation")
@ApiOperation("删除关联房间")
@ApiLog("删除关联房间")
public R deleteRelation(@RequestBody Map<String, Object> params) {
Integer id = (Integer) params.get("id");
return otherShDeviceService.deleteRelation(id);
}
@Login
......
......@@ -3,6 +3,7 @@ package tech.glinfo.enbao.modules.sh.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.glinfo.enbao.modules.sh.entity.ShDeviceDataEntity;
import tech.glinfo.enbao.modules.sh.entity.ShDeviceEntity;
......@@ -21,8 +22,13 @@ public interface OtherShDeviceDao extends BaseMapper<ShDeviceEntity> {
ShDeviceDataEntity getDeviceDataByNumbering(String numbering);
@Select("<script>" +
"SELECT * FROM sh_device a WHERE a.user_id = ${userId} AND a.relat_house = 0" +
"SELECT * FROM sh_device a WHERE a.user_id = ${userId}" +
" </script>")
List<ShDeviceEntity> getDeviceByFlag(Integer userId);
@Update("<script>" +
"UPDATE sh_device SET room_id = null WHERE id = ${id}" +
" </script>")
void deleteRelation(Integer id);
}
......@@ -25,7 +25,7 @@ public interface OtherShFamilyRoomDao extends BaseMapper<ShFamilyRoomEntity> {
@Select("<script>" +
"SELECT a.id, a.name, b.`device` FROM sh_family_room a LEFT JOIN (SELECT COUNT(*) `device`,room_id from sh_device) b ON a.id = b.room_id WHERE a.family_id = ${familyId}" +
"SELECT a.id, a.name, (SELECT COUNT(1) from sh_device b WHERE a.id = b.room_id) `device` FROM sh_family_room a WHERE a.family_id = ${familyId}" +
" </script>")
List<Map<String, Object>> list(Integer familyId);
......
......@@ -25,6 +25,8 @@ public interface OtherShDeviceService extends IService<ShDeviceEntity> {
R updateDeviceData(String value, Integer deviceId);
R deleteRelation(Integer id);
R updateFilterDeviceData(Map<String, Object> map, Integer deviceId);
R info(String id);
......
......@@ -127,6 +127,12 @@ public class OtherShDeviceServiceImpl extends ServiceImpl<OtherShDeviceDao, ShDe
return R.ok();
}
@Override
public R deleteRelation(Integer id) {
this.baseMapper.deleteRelation(id);
return R.ok();
}
@Override
public R updateFilterDeviceData(Map<String, Object> map, Integer deviceId) {
ShDeviceDataEntity entity = shDeviceDataService.getOne(new QueryWrapper<ShDeviceDataEntity>().eq("device_id", deviceId));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论