package com.srs.dormitory.service.impl;

import java.util.List;

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

/**
 * 外宿申请附件Service业务层处理
 *
 * @author srs
 * @date 2025-12-05
 */
@Service
public class DmsOutsideAccommodationAttachmentServiceImpl extends ServiceImpl<DmsOutsideAccommodationAttachmentMapper,DmsOutsideAccommodationAttachment> implements IDmsOutsideAccommodationAttachmentService {
    @Autowired
    private DmsOutsideAccommodationAttachmentMapper dmsOutsideAccommodationAttachmentMapper;

    /**
     * 查询外宿申请附件
     *
     * @param id 外宿申请附件主键
     * @return 外宿申请附件
     */
    @Override
    public DmsOutsideAccommodationAttachment selectDmsOutsideAccommodationAttachmentById(Long id) {
        return dmsOutsideAccommodationAttachmentMapper.selectDmsOutsideAccommodationAttachmentById(id);
    }

    /**
     * 查询外宿申请附件列表
     *
     * @param dmsOutsideAccommodationAttachment 外宿申请附件
     * @return 外宿申请附件
     */
    @Override
    public List<DmsOutsideAccommodationAttachment> selectDmsOutsideAccommodationAttachmentList(DmsOutsideAccommodationAttachment dmsOutsideAccommodationAttachment) {
        return dmsOutsideAccommodationAttachmentMapper.selectDmsOutsideAccommodationAttachmentList(dmsOutsideAccommodationAttachment);
    }

    @Override
    public int batchInsertDmsOutsideAccommodationAttachment(List<DmsOutsideAccommodationAttachment> list) {
        // 统一设置默认值（如创建时间）
        for (DmsOutsideAccommodationAttachment attach : list) {
            attach.setCreateTime(DateUtils.getNowDate()); // 批量设置创建时间
            // 其他默认值（如状态等）
        }
        // 调用Mapper层批量插入方法
        return dmsOutsideAccommodationAttachmentMapper.batchInsertDmsOutsideAccommodationAttachment(list);
    }

    /**
     * 新增外宿申请附件
     *
     * @param dmsOutsideAccommodationAttachment 外宿申请附件
     * @return 结果
     */
    @Override
    public int insertDmsOutsideAccommodationAttachment(DmsOutsideAccommodationAttachment dmsOutsideAccommodationAttachment) {
                dmsOutsideAccommodationAttachment.setCreateTime(DateUtils.getNowDate());
            return dmsOutsideAccommodationAttachmentMapper.insertDmsOutsideAccommodationAttachment(dmsOutsideAccommodationAttachment);
    }

    /**
     * 修改外宿申请附件
     *
     * @param dmsOutsideAccommodationAttachment 外宿申请附件
     * @return 结果
     */
    @Override
    public int updateDmsOutsideAccommodationAttachment(DmsOutsideAccommodationAttachment dmsOutsideAccommodationAttachment) {
        return dmsOutsideAccommodationAttachmentMapper.updateDmsOutsideAccommodationAttachment(dmsOutsideAccommodationAttachment);
    }

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

    @Override
    public int deleteOutsideAccommodationAttachmentNameAndStuName(String attachmentName, String studentName) {
        return dmsOutsideAccommodationAttachmentMapper.deleteOutsideAccommodationAttachmentNameAndStuName(attachmentName, studentName);
    }

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