package com.playlet.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.PlayletUserTaskMapper;
import com.playlet.system.domain.PlayletUserTask;
import com.playlet.system.service.IPlayletUserTaskService;
import com.playlet.common.core.text.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Date: 2024-03-22 12:02
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 短剧用户任务Service业务层处理
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletUserTaskServiceImpl extends ServiceImpl<PlayletUserTaskMapper, PlayletUserTask> implements IPlayletUserTaskService {

    private final PlayletUserTaskMapper playletUserTaskMapper;

    @Override
    public List<PlayletUserTask> searchByTaskIdList(Long taskId) {
        QueryWrapper<PlayletUserTask> wrapper = new QueryWrapper<>();
        wrapper.lambda().select()
                .eq(PlayletUserTask::getTaskId, taskId)
                .eq(PlayletUserTask::getUserTaskState, 4);
        return playletUserTaskMapper.selectList(wrapper);
    }

    /**
     * 查询短剧用户任务
     *
     * @param id 短剧用户任务主键
     * @return 短剧用户任务
     */
    @Override
    public PlayletUserTask selectPlayletUserTaskById(Long id) {
        return playletUserTaskMapper.selectPlayletUserTaskById(id);
    }

    /**
     * 查询短剧用户任务列表
     *
     * @param playletUserTask 短剧用户任务
     * @return 短剧用户任务
     */
    @Override
    public List<PlayletUserTask> selectPlayletUserTaskList(PlayletUserTask playletUserTask) {
        return playletUserTaskMapper.selectPlayletUserTaskList(playletUserTask);
    }

    /**
     * 新增短剧用户任务
     *
     * @param playletUserTask 短剧用户任务
     * @return 结果
     */
    @Override
    public int insertPlayletUserTask(PlayletUserTask playletUserTask) {
        playletUserTask.setCreateTime(DateUtils.getNowDate());
        return playletUserTaskMapper.insertPlayletUserTask(playletUserTask);
    }

    /**
     * 修改短剧用户任务
     *
     * @param playletUserTask 短剧用户任务
     * @return 结果
     */
    @Override
    public int updatePlayletUserTask(PlayletUserTask playletUserTask) {
        playletUserTask.setUpdateTime(DateUtils.getNowDate());
        return playletUserTaskMapper.updatePlayletUserTask(playletUserTask);
    }

    /**
     * 批量删除短剧用户任务
     *
     * @param ids 需要删除的短剧用户任务主键
     * @return 结果
     */
    @Override
    public int deletePlayletUserTaskByIds(String ids) {
        return playletUserTaskMapper.deletePlayletUserTaskByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除短剧用户任务信息
     *
     * @param id 短剧用户任务主键
     * @return 结果
     */
    @Override
    public int deletePlayletUserTaskById(Long id) {
        return playletUserTaskMapper.deletePlayletUserTaskById(id);
    }
}
