package com.ktg.iscs.mapper;

import com.ktg.common.mapper.BaseMapperX;
import com.ktg.common.query.LambdaQueryWrapperX;
import com.ktg.iscs.domain.IsJobCard;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 工作卡Mapper接口
 *
 * @author cgj
 * @date 2024-11-12
 */
@Mapper
public interface IsJobCardMapper extends BaseMapperX<IsJobCard>
{
    /**
     * 查询工作卡
     *
     * @param cardId 工作卡主键
     * @return 工作卡
     */
    IsJobCard selectIsJobCardByCardId(Long cardId);

    /**
     * 查询工作卡列表
     *
     * @param isJobCard 工作卡
     * @return 工作卡集合
     */
    List<IsJobCard> selectIsJobCardList(IsJobCard isJobCard);

    /**
     * 新增工作卡
     *
     * @param isJobCard 工作卡
     * @return 结果
     */
    int insertIsJobCard(IsJobCard isJobCard);

    /**
     * 修改工作卡
     *
     * @param isJobCard 工作卡
     * @return 结果
     */
    int updateIsJobCard(IsJobCard isJobCard);

    /**
     * 删除工作卡
     *
     * @param cardId 工作卡主键
     * @return 结果
     */
    int deleteIsJobCardByCardId(Long cardId);

    /**
     * 批量删除工作卡
     *
     * @param cardIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteIsJobCardByCardIds(Long[] cardIds);

    default IsJobCard selectByNfc(String cardNfc) {
        return selectOne(new LambdaQueryWrapperX<IsJobCard>()
                .eq(IsJobCard::getCardNfc, cardNfc));
    }

    default IsJobCard selectByUserId(Long userId) {
        return selectOne(new LambdaQueryWrapperX<IsJobCard>().eq(IsJobCard::getUserId, userId));
    }
}
