package com.bonus.material.task.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.service.ITmTaskAgreementService;

/**
 * 任务Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class TmTaskAgreementServiceImpl implements ITmTaskAgreementService {
    @Autowired
    private TmTaskAgreementMapper tmTaskAgreementMapper;

    /**
     * 查询任务
     * 
     * @param taskId 任务主键
     * @return 任务
     */
    @Override
    public TmTaskAgreement selectTmTaskAgreementByTaskId(Long taskId) {
        return tmTaskAgreementMapper.selectTmTaskAgreementByTaskId(taskId);
    }

    /**
     * 查询任务列表
     * 
     * @param tmTaskAgreement 任务
     * @return 任务
     */
    @Override
    public List<TmTaskAgreement> selectTmTaskAgreementList(TmTaskAgreement tmTaskAgreement) {
        return tmTaskAgreementMapper.selectTmTaskAgreementList(tmTaskAgreement);
    }

    /**
     * 新增任务
     * 
     * @param tmTaskAgreement 任务
     * @return 结果
     */
    @Override
    public int insertTmTaskAgreement(TmTaskAgreement tmTaskAgreement) {
        tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
        try {
            return tmTaskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改任务
     * 
     * @param tmTaskAgreement 任务
     * @return 结果
     */
    @Override
    public int updateTmTaskAgreement(TmTaskAgreement tmTaskAgreement) {
        tmTaskAgreement.setUpdateTime(DateUtils.getNowDate());
        try {
            return tmTaskAgreementMapper.updateTmTaskAgreement(tmTaskAgreement);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除任务
     * 
     * @param taskIds 需要删除的任务主键
     * @return 结果
     */
    @Override
    public int deleteTmTaskAgreementByTaskIds(Long[] taskIds) {
        return tmTaskAgreementMapper.deleteTmTaskAgreementByTaskIds(taskIds);
    }

    /**
     * 删除任务信息
     * 
     * @param taskId 任务主键
     * @return 结果
     */
    @Override
    public int deleteTmTaskAgreementByTaskId(Long taskId) {
        return tmTaskAgreementMapper.deleteTmTaskAgreementByTaskId(taskId);
    }
}
