package com.schoolinout.system.service.impl;

import com.schoolinout.common.utils.DateUtils;
import com.schoolinout.system.domain.AccessLog;
import com.schoolinout.system.domain.dto.InOutLogDto;
import com.schoolinout.system.domain.vo.InOutLogVo;
import com.schoolinout.system.mapper.AccessLogMapper;
import com.schoolinout.system.service.IAccessLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 进出学校记录Service业务层处理
 *
 * @author sakura
 * @date 2024-01-03
 */
@Service
public class AccessLogServiceImpl implements IAccessLogService {
    @Autowired
    private AccessLogMapper accessLogMapper;

    @Override
    public List<InOutLogVo> queryStudentInOutLog(InOutLogDto dto) {
        return accessLogMapper.selectInOutByInOutLogDto(dto);
    }

    /**
     * 查询进出学校记录
     *
     * @param id 进出学校记录主键
     * @return 进出学校记录
     */
    @Override
    public AccessLog selectAccessLogById(Long id) {
        return accessLogMapper.selectAccessLogById(id);
    }

    /**
     * 查询进出学校记录列表
     *
     * @param accessLog 进出学校记录
     * @return 进出学校记录
     */
    @Override
    public List<AccessLog> selectAccessLogList(AccessLog accessLog) {
        return accessLogMapper.selectAccessLogList(accessLog);
    }

    /**
     * 新增进出学校记录
     *
     * @param accessLog 进出学校记录
     * @return 结果
     */
    @Override
    public int insertAccessLog(AccessLog accessLog) {
        accessLog.setCreateTime(DateUtils.getNowDate());
        return accessLogMapper.insertAccessLog(accessLog);
    }

    /**
     * 修改进出学校记录
     *
     * @param accessLog 进出学校记录
     * @return 结果
     */
    @Override
    public int updateAccessLog(AccessLog accessLog) {
        accessLog.setUpdateTime(DateUtils.getNowDate());
        return accessLogMapper.updateAccessLog(accessLog);
    }

    /**
     * 批量删除进出学校记录
     *
     * @param ids 需要删除的进出学校记录主键
     * @return 结果
     */
    @Override
    public int deleteAccessLogByIds(Long[] ids) {
        return accessLogMapper.deleteAccessLogByIds(ids);
    }

    /**
     * 删除进出学校记录信息
     *
     * @param id 进出学校记录主键
     * @return 结果
     */
    @Override
    public int deleteAccessLogById(Long id) {
        return accessLogMapper.deleteAccessLogById(id);
    }
}
