package com.ktg.iscs.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktg.common.core.text.Convert;
import com.ktg.common.utils.DateUtils;
import com.ktg.iscs.domain.IsJobTicketKey;
import com.ktg.iscs.domain.vo.ticketKey.IsJobTicketKeyVO;
import com.ktg.iscs.mapper.IsJobTicketKeyMapper;
import com.ktg.iscs.service.IIsJobTicketKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作业票钥匙Service业务层处理
 *
 * @author cgj
 * @date 2024-11-19
 */
@Service
public class IsJobTicketKeyServiceImpl extends ServiceImpl<IsJobTicketKeyMapper, IsJobTicketKey> implements IIsJobTicketKeyService
{
    @Autowired
    private IsJobTicketKeyMapper isJobTicketKeyMapper;

    /**
     * 查询作业票钥匙
     *
     * @param recordId 作业票钥匙主键
     * @return 作业票钥匙
     */
    @Override
    public IsJobTicketKey selectIsJobTicketKeyByRecordId(Long recordId)
    {
        return isJobTicketKeyMapper.selectIsJobTicketKeyByRecordId(recordId);
    }

    /**
     * 查询作业票钥匙列表
     *
     * @param isJobTicketKey 作业票钥匙
     * @return 作业票钥匙
     */
    @Override
    public List<IsJobTicketKey> selectIsJobTicketKeyList(IsJobTicketKey isJobTicketKey)
    {
        return isJobTicketKeyMapper.selectIsJobTicketKeyList(isJobTicketKey);
    }

    /**
     * 新增作业票钥匙
     *
     * @param isJobTicketKey 作业票钥匙
     * @return 结果
     */
    @Override
    public int insertIsJobTicketKey(IsJobTicketKey isJobTicketKey)
    {
        isJobTicketKey.setCreateTime(DateUtils.getNowDate());
        return isJobTicketKeyMapper.insertIsJobTicketKey(isJobTicketKey);
    }

    /**
     * 修改作业票钥匙
     *
     * @param isJobTicketKey 作业票钥匙
     * @return 结果
     */
    @Override
    public int updateIsJobTicketKey(IsJobTicketKey isJobTicketKey)
    {
        isJobTicketKey.setUpdateTime(DateUtils.getNowDate());
        return isJobTicketKeyMapper.updateIsJobTicketKey(isJobTicketKey);
    }

    /**
     * 批量删除作业票钥匙
     *
     * @param recordIds 需要删除的作业票钥匙主键
     * @return 结果
     */
    @Override
    public int deleteIsJobTicketKeyByRecordIds(String recordIds)
    {
        Assert.notBlank(recordIds, "请选择需要删除的数据!");
        Long[] longIds = Convert.toLongArray(recordIds);
        return isJobTicketKeyMapper.deleteIsJobTicketKeyByRecordIds(longIds);
    }

    /**
     * 删除作业票钥匙信息
     *
     * @param recordId 作业票钥匙主键
     * @return 结果
     */
    @Override
    public int deleteIsJobTicketKeyByRecordId(Long recordId)
    {
        return isJobTicketKeyMapper.deleteIsJobTicketKeyByRecordId(recordId);
    }

    @Override
    public List<IsJobTicketKeyVO> getListByTicketId(Long ticketId) {
        return isJobTicketKeyMapper.getListByTicketId(ticketId);
    }
}
