package com.sundot.airport.item.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sundot.airport.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sundot.airport.item.mapper.FailedMatchItemMapper;
import com.sundot.airport.item.domain.FailedMatchItem;
import com.sundot.airport.item.service.IFailedMatchItemService;

/**
 * 匹配失败物品Service业务层处理
 *
 * @author airport
 * @date 2025-11-21
 */
@Service
public class FailedMatchItemServiceImpl extends ServiceImpl<FailedMatchItemMapper, FailedMatchItem> implements IFailedMatchItemService {
    @Autowired
    private FailedMatchItemMapper failedMatchItemMapper;

    /**
     * 查询匹配失败物品
     *
     * @param id 匹配失败物品主键
     * @return 匹配失败物品
     */
    @Override
    public FailedMatchItem selectFailedMatchItemById(Integer id) {
        return failedMatchItemMapper.selectFailedMatchItemById(id);
    }

    /**
     * 查询匹配失败物品列表
     *
     * @param failedMatchItem 匹配失败物品
     * @return 匹配失败物品
     */
    @Override
    public List<FailedMatchItem> selectFailedMatchItemList(FailedMatchItem failedMatchItem) {
        return failedMatchItemMapper.selectFailedMatchItemList(failedMatchItem);
    }

    /**
     * 根据用户ID查询匹配失败物品列表（按更新时间降序）
     *
     * @param userId 用户ID
     * @return 匹配失败物品集合
     */
    @Override
    public List<FailedMatchItem> selectFailedMatchItemListByUserId(Long userId) {
        return failedMatchItemMapper.selectFailedMatchItemListByUserId(userId);
    }

    /**
     * 新增匹配失败物品
     *
     * @param failedMatchItem 匹配失败物品
     * @return 结果
     */
    @Override
    public int insertFailedMatchItem(FailedMatchItem failedMatchItem) {
        failedMatchItem.setCreateTime(DateUtils.getNowDate());
        failedMatchItem.setUpdateTime(DateUtils.getNowDate());
        return failedMatchItemMapper.insertFailedMatchItem(failedMatchItem);
    }

    /**
     * 修改匹配失败物品
     *
     * @param failedMatchItem 匹配失败物品
     * @return 结果
     */
    @Override
    public int updateFailedMatchItem(FailedMatchItem failedMatchItem) {
        failedMatchItem.setUpdateTime(DateUtils.getNowDate());
        return failedMatchItemMapper.updateFailedMatchItem(failedMatchItem);
    }

    /**
     * 批量删除匹配失败物品
     *
     * @param ids 需要删除的匹配失败物品主键
     * @return 结果
     */
    @Override
    public int deleteFailedMatchItemByIds(Integer[] ids) {
        return failedMatchItemMapper.deleteFailedMatchItemByIds(ids);
    }

    /**
     * 删除匹配失败物品信息
     *
     * @param id 匹配失败物品主键
     * @return 结果
     */
    @Override
    public int deleteFailedMatchItemById(Integer id) {
        return failedMatchItemMapper.deleteFailedMatchItemById(id);
    }
}
