package com.ics.admin.service.impl;

import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ics.admin.mapper.meeting.RoomServeMapper;
import com.ics.admin.domain.meeting.RoomServe;
import com.ics.admin.service.meeting.IRoomServeService;

/**
 * 服务Service业务层处理
 * 
 * @author chen
 * @date 2024-02-25
 */
@Service
public class RoomServeServiceImpl extends ServiceImpl<RoomServeMapper, RoomServe> implements IRoomServeService {
    @Autowired
    private RoomServeMapper roomServeMapper;

    /**
     * 查询服务
     * 
     * @param id 服务ID
     * @return 服务
     */
    @Override
    public RoomServe selectRoomServeById(Long id) {
        return roomServeMapper.selectById(id);
    }

    /**
     * 查询服务列表
     * 
     * @param roomServe 服务
     * @return 服务
     */
    @Override
    public List<RoomServe> selectRoomServeList(RoomServe roomServe) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(roomServe.getServeType() !=null ,"serve_type",roomServe.getServeType());
        queryWrapper.like(roomServe.getServeName() !=null ,"serve_name",roomServe.getServeName());
        queryWrapper.eq(roomServe.getParkId() !=null,"park_id", roomServe.getParkId());
        queryWrapper.eq(roomServe.getTenantId() !=null,"tenant_id", roomServe.getTenantId());
        return roomServeMapper.selectList(queryWrapper);
    }

    /**
     * 新增服务
     * 
     * @param roomServe 服务
     * @return 结果
     */
    @Override
    public int insertRoomServe(RoomServe roomServe) {
        return roomServeMapper.insert(roomServe);
    }

    /**
     * 修改服务
     * 
     * @param roomServe 服务
     * @return 结果
     */
    @Override
    public int updateRoomServe(RoomServe roomServe) {
        return roomServeMapper.updateById(roomServe);
    }

    /**
     * 删除服务对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteRoomServeByIds(String ids) {
        String[] idsArray = StrUtil.split(ids,",");
        return roomServeMapper.deleteBatchIds(CollUtil.toList(idsArray));
    }

    /**
     * 删除服务信息
     * 
     * @param id 服务ID
     * @return 结果
     */
    @Override
    public int deleteRoomServeById(Long id) {
        return roomServeMapper.deleteRoomServeById(id);
    }
}
