package com.playlet.system.service.impl;

import java.util.List;

import com.playlet.common.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.playlet.system.mapper.PlayletTaskMapper;
import com.playlet.system.domain.PlayletTask;
import com.playlet.system.service.IPlayletTaskService;
import com.playlet.common.core.text.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Date: 2024-03-21 23:50
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 任务Service业务层处理
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletTaskServiceImpl extends ServiceImpl<PlayletTaskMapper, PlayletTask> implements IPlayletTaskService {

    private final PlayletTaskMapper playletTaskMapper;

    /**
     * 查询任务
     *
     * @param id 任务主键
     * @return 任务
     */
    @Override
    public PlayletTask selectPlayletTaskById(Long id) {
        return playletTaskMapper.selectPlayletTaskById(id);
    }

    /**
     * 查询任务列表
     *
     * @param playletTask 任务
     * @return 任务
     */
    @Override
    public List<PlayletTask> selectPlayletTaskList(PlayletTask playletTask) {
        return playletTaskMapper.selectPlayletTaskList(playletTask);
    }

    /**
     * 新增任务
     *
     * @param playletTask 任务
     * @return 结果
     */
    @Override
    public int insertPlayletTask(PlayletTask playletTask) {
        playletTask.setCreateTime(DateUtils.getNowDate());
        return playletTaskMapper.insertPlayletTask(playletTask);
    }

    /**
     * 修改任务
     *
     * @param playletTask 任务
     * @return 结果
     */
    @Override
    public int updatePlayletTask(PlayletTask playletTask) {
        playletTask.setUpdateTime(DateUtils.getNowDate());
        return playletTaskMapper.updatePlayletTask(playletTask);
    }

    /**
     * 批量删除任务
     *
     * @param ids 需要删除的任务主键
     * @return 结果
     */
    @Override
    public int deletePlayletTaskByIds(String ids) {
        return playletTaskMapper.deletePlayletTaskByIds(Convert.toStrArray(ids));
    }

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

    @Override
    public List<PlayletTask> selectPlayletTaskListByUser(PlayletTask playletTask) {
        return playletTaskMapper.selectPlayletTaskListByUser(playletTask);
    }
}
