package com.openhis.appointmentmanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.openhis.appointmentmanage.domain.ClinicRoom;
import com.openhis.appointmentmanage.mapper.ClinicRoomMapper;
import com.openhis.appointmentmanage.service.IClinicRoomService;
import org.springframework.stereotype.Service;

/**
 * 诊室维护Service实现类
 *
 * @author system
 * @date 2025-12-09
 */
@Service
public class ClinicRoomServiceImpl extends ServiceImpl<ClinicRoomMapper, ClinicRoom> implements IClinicRoomService {

    @Override
    public Page<ClinicRoom> selectClinicRoomPage(Page<ClinicRoom> page, ClinicRoom clinicRoom) {
        return baseMapper.selectPage(page, new LambdaQueryWrapper<ClinicRoom>()
                .like(clinicRoom.getOrgName() != null, ClinicRoom::getOrgName, clinicRoom.getOrgName())
                .like(clinicRoom.getRoomName() != null, ClinicRoom::getRoomName, clinicRoom.getRoomName())
                .orderByDesc(ClinicRoom::getCreateTime));
    }

    @Override
    public ClinicRoom selectClinicRoomById(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public int insertClinicRoom(ClinicRoom clinicRoom) {
        return baseMapper.insert(clinicRoom);
    }

    @Override
    public int updateClinicRoom(ClinicRoom clinicRoom) {
        return baseMapper.updateById(clinicRoom);
    }

    @Override
    public int deleteClinicRoomById(Long id) {
        return baseMapper.deleteById(id);
    }
}
