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.IsJobTicketLockset;
import com.ktg.iscs.domain.vo.ticketLockset.IsJobTicketLocksetVO;
import com.ktg.iscs.mapper.IsJobTicketLocksetMapper;
import com.ktg.iscs.service.IIsJobTicketLocksetService;
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 IsJobTicketLocksetServiceImpl extends ServiceImpl<IsJobTicketLocksetMapper, IsJobTicketLockset> implements IIsJobTicketLocksetService
{
    @Autowired
    private IsJobTicketLocksetMapper isJobTicketLocksetMapper;

    /**
     * 查询作业票锁具
     *
     * @param recordId 作业票锁具主键
     * @return 作业票锁具
     */
    @Override
    public IsJobTicketLockset selectIsJobTicketLocksetByRecordId(Long recordId)
    {
        return isJobTicketLocksetMapper.selectIsJobTicketLocksetByRecordId(recordId);
    }

    /**
     * 查询作业票锁具列表
     *
     * @param isJobTicketLockset 作业票锁具
     * @return 作业票锁具
     */
    @Override
    public List<IsJobTicketLockset> selectIsJobTicketLocksetList(IsJobTicketLockset isJobTicketLockset)
    {
        return isJobTicketLocksetMapper.selectIsJobTicketLocksetList(isJobTicketLockset);
    }

    /**
     * 新增作业票锁具
     *
     * @param isJobTicketLockset 作业票锁具
     * @return 结果
     */
    @Override
    public int insertIsJobTicketLockset(IsJobTicketLockset isJobTicketLockset)
    {
        isJobTicketLockset.setCreateTime(DateUtils.getNowDate());
        return isJobTicketLocksetMapper.insertIsJobTicketLockset(isJobTicketLockset);
    }

    /**
     * 修改作业票锁具
     *
     * @param isJobTicketLockset 作业票锁具
     * @return 结果
     */
    @Override
    public int updateIsJobTicketLockset(IsJobTicketLockset isJobTicketLockset)
    {
        isJobTicketLockset.setUpdateTime(DateUtils.getNowDate());
        return isJobTicketLocksetMapper.updateIsJobTicketLockset(isJobTicketLockset);
    }

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

    /**
     * 删除作业票锁具信息
     *
     * @param recordId 作业票锁具主键
     * @return 结果
     */
    @Override
    public int deleteIsJobTicketLocksetByRecordId(Long recordId)
    {
        return isJobTicketLocksetMapper.deleteIsJobTicketLocksetByRecordId(recordId);
    }

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