Commit 311de82d by 吕明尚

删除房间设备中间表

parent 14c2388e
......@@ -82,12 +82,6 @@ public class SRoom extends BaseEntity
@TableField(exist = false)
private String packIds;
/**
* 设备ID
*/
@TableField(exist = false)
private String deviceIds;
/**
* 套餐集合
......
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 包房设备关系Mapper接口
*
* @author wuwenlong
* @date 2023-11-08
*/
public interface RoomDeviceMapper extends BaseMapper<RoomDevice> {
/**
* 查询包房设备关系
*
* @param id 包房设备关系主键
* @return 包房设备关系
*/
public RoomDevice selectRoomDeviceById(Long id);
/**
* 查询包房设备关系列表
*
* @param RoomDevice 包房设备关系
* @return 包房设备关系集合
*/
public List<RoomDevice> selectRoomDeviceList(RoomDevice RoomDevice);
/**
* 新增包房设备关系
*
* @param RoomDevice 包房设备关系
* @return 结果
*/
public int insertRoomDevice(RoomDevice RoomDevice);
/**
* 修改包房设备关系
*
* @param RoomDevice 包房设备关系
* @return 结果
*/
public int updateRoomDevice(RoomDevice RoomDevice);
/**
* 删除包房设备关系
*
* @param id 包房设备关系主键
* @return 结果
*/
public int deleteRoomDeviceById(Long id);
/**
* 批量删除包房设备关系
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteRoomDeviceByIds(Long[] ids);
List<Long> selectDeviceListByRoomId(Long id);
}
......@@ -37,11 +37,6 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
@Autowired
private IRoomPackService roomPackService;
@Autowired
private DeviceService deviceService;
@Autowired
public RoomDeviceService roomDeviceService;
/**
* 查询房间
......@@ -127,23 +122,6 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
});
roomPackService.saveBatch(SRoomPackList);
}
//判断设备id
if (!sRoom.getDeviceIds().isEmpty()) {
List<Device> deviceList = deviceService.selectDeviceListByIds(Arrays.asList(sRoom.getDeviceIds().split(",")).stream().map(Long::valueOf).collect(Collectors.toList()));
if (CollectionUtils.isEmpty(deviceList)) {
throw new RuntimeException("设备不存在");
}
List<Long> list = Arrays.asList(sRoom.getDeviceIds().split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
List<RoomDevice> SRoomDeviceList = new ArrayList<>();
list.stream().forEach(o -> {
RoomDevice SRoomDevice = new RoomDevice();
SRoomDevice.setDeviceId(o);
SRoomDevice.setRoomId(sRoom.getId());
SRoomDevice.setCreateTime(DateUtils.getNowDate());
SRoomDeviceList.add(SRoomDevice);
});
roomDeviceService.saveBatch(SRoomDeviceList);
}
} catch (Exception e) {
throw new RuntimeException("新增房间失败");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment