package com.srs.dormitory.service.impl;

import java.util.List;

import com.srs.common.utils.DateUtils;
import com.srs.dormitory.domain.DmsAccommodations;
import com.srs.dormitory.mapper.DmsAccommodationsMapper;
import com.srs.dormitory.service.IDmsAccommodationsService;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 外宿申请Service业务层处理
 *
 * @author srs
 * @date 2025-11-11
 */
@Service
public class DmsAccommodationsServiceImpl extends ServiceImpl<DmsAccommodationsMapper, DmsAccommodations> implements IDmsAccommodationsService {
    @Autowired
    private DmsAccommodationsMapper dmsAccommodationsMapper;

    /**
     * 查询外宿申请
     *
     * @param id 外宿申请主键
     * @return 外宿申请
     */
    @Override
    public DmsAccommodations selectDmsAccommodationsById(Long id) {
        return dmsAccommodationsMapper.selectDmsAccommodationsById(id);
    }

    /**
     * 查询外宿申请列表
     *
     * @param dmsAccommodations 外宿申请
     * @return 外宿申请
     */
    @Override
    public List<DmsAccommodations> selectDmsAccommodationsList(DmsAccommodations dmsAccommodations) {
        return dmsAccommodationsMapper.selectDmsAccommodationsList(dmsAccommodations);
    }

    /**
     * 新增外宿申请
     *
     * @param dmsAccommodations 外宿申请
     * @return 结果
     */
    @Override
    public int insertDmsAccommodations(DmsAccommodations dmsAccommodations) {
                dmsAccommodations.setCreateTime(DateUtils.getNowDate());
            return dmsAccommodationsMapper.insertDmsAccommodations(dmsAccommodations);
    }

    /**
     * 修改外宿申请
     *
     * @param dmsAccommodations 外宿申请
     * @return 结果
     */
    @Override
    public int updateDmsAccommodations(DmsAccommodations dmsAccommodations) {
                dmsAccommodations.setUpdateTime(DateUtils.getNowDate());
        return dmsAccommodationsMapper.updateDmsAccommodations(dmsAccommodations);
    }

    /**
     * 批量删除外宿申请
     *
     * @param ids 需要删除的外宿申请主键
     * @return 结果
     */
    @Override
    public int deleteDmsAccommodationsByIds(Long[] ids) {
        return dmsAccommodationsMapper.deleteDmsAccommodationsByIds(ids);
    }

    /**
     * 删除外宿申请信息
     *
     * @param id 外宿申请主键
     * @return 结果
     */
    @Override
    public int deleteDmsAccommodationsById(Long id) {
        return dmsAccommodationsMapper.deleteDmsAccommodationsById(id);
    }

    @Override
    public  DmsAccommodations getStuDormitory(String stuNo){
        return  dmsAccommodationsMapper.getStuDormitory(stuNo);
    }
}
