package cn.edu.whu.boot.collection.service.impl;

import cn.edu.whu.boot.collection.domain.TaskSelectId;
import cn.edu.whu.boot.collection.mapper.TaskSelectIdMapper;
import cn.edu.whu.boot.collection.service.ITaskSelectIdService;
import cn.edu.whu.boot.common.domain.CommonConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ITaskSelectIdServiceImpl implements ITaskSelectIdService {

    @Autowired
    private TaskSelectIdMapper taskSelectIdMapper;

    @Override
    public List<TaskSelectId> getTaskSelectIdByTaskIdAndTableName (Integer srcTaskId, String srcTableName,
                                                                   Integer destTaskId, String destTableName)
    {
        return taskSelectIdMapper.getTaskSelectIdByTaskIdAndTableName(srcTaskId, srcTableName, destTaskId, destTableName);
    }

    @Override
    public Integer getMaxSelectOrder (Integer srcTaskId, String srcTableName,
                                      Integer destTaskId, String destTableName)
    {
        return taskSelectIdMapper.getMaxSelectOrder(srcTaskId, srcTableName,destTaskId, destTableName);
    }

    @Override
    public String insertTaskSelectId (TaskSelectId taskSelectId)
    {
        Integer result =  taskSelectIdMapper.insert(taskSelectId);
        if (result == 1)
        {
            return CommonConstant.SUCCEED;
        }
        else
        {
            return CommonConstant.FAILED;
        }
    }

    @Override
    public void delete (Integer taskId){
        taskSelectIdMapper.delete(taskId);
    }
}
