package com.zehong.system.service.impl;

import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.TSafeTrainLedger;
import com.zehong.system.mapper.TSafeTrainLedgerMapper;
import com.zehong.system.service.ITSafeTrainLedgerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 安全培训台账Service业务层处理
 * 
 * @author zehong
 * @date 2026-03-27
 */
@Service
public class TSafeTrainLedgerServiceImpl implements ITSafeTrainLedgerService 
{
    @Resource
    private TSafeTrainLedgerMapper tSafeTrainLedgerMapper;

    /**
     * 查询安全培训台账
     * 
     * @param trainId 安全培训台账ID
     * @return 安全培训台账
     */
    @Override
    public TSafeTrainLedger selectTSafeTrainLedgerById(Long trainId)
    {
        return tSafeTrainLedgerMapper.selectTSafeTrainLedgerById(trainId);
    }

    /**
     * 查询安全培训台账列表
     * 
     * @param tSafeTrainLedger 安全培训台账
     * @return 安全培训台账
     */
    @Override
    public List<TSafeTrainLedger> selectTSafeTrainLedgerList(TSafeTrainLedger tSafeTrainLedger)
    {
        return tSafeTrainLedgerMapper.selectTSafeTrainLedgerList(tSafeTrainLedger);
    }

    /**
     * 新增安全培训台账
     * 
     * @param tSafeTrainLedger 安全培训台账
     * @return 结果
     */
    @Override
    public int insertTSafeTrainLedger(TSafeTrainLedger tSafeTrainLedger)
    {
        tSafeTrainLedger.setCreateTime(DateUtils.getNowDate());
        tSafeTrainLedger.setCreateBy(SecurityUtils.getLoginUser().getUser().getNickName());
        return tSafeTrainLedgerMapper.insertTSafeTrainLedger(tSafeTrainLedger);
    }

    /**
     * 修改安全培训台账
     * 
     * @param tSafeTrainLedger 安全培训台账
     * @return 结果
     */
    @Override
    public int updateTSafeTrainLedger(TSafeTrainLedger tSafeTrainLedger)
    {
        tSafeTrainLedger.setUpdateTime(DateUtils.getNowDate());
        tSafeTrainLedger.setUpdateBy(SecurityUtils.getLoginUser().getUser().getNickName());
        return tSafeTrainLedgerMapper.updateTSafeTrainLedger(tSafeTrainLedger);
    }

    /**
     * 批量删除安全培训台账
     * 
     * @param trainIds 需要删除的安全培训台账ID
     * @return 结果
     */
    @Override
    public int deleteTSafeTrainLedgerByIds(Long[] trainIds)
    {
        return tSafeTrainLedgerMapper.deleteTSafeTrainLedgerByIds(trainIds);
    }

    /**
     * 删除安全培训台账信息
     * 
     * @param trainId 安全培训台账ID
     * @return 结果
     */
    @Override
    public int deleteTSafeTrainLedgerById(Long trainId)
    {
        return tSafeTrainLedgerMapper.deleteTSafeTrainLedgerById(trainId);
    }
}
