package com.ai.da.mapper.primary;

import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.CloudTask;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CloudTaskMapper extends CommonMapper<CloudTask> {
    @Update("UPDATE cloud_task SET completed_num = completed_num + 1, update_time = NOW() WHERE task_id = #{taskIdBatch}")
    @Options(useGeneratedKeys = false, flushCache = Options.FlushCachePolicy.TRUE)
    void increaseCompletedNum(@Param("taskIdBatch") String taskIdBatch);
    @Select("SELECT * FROM cloud_task WHERE task_id = #{taskId} FOR UPDATE")
    CloudTask selectForUpdate(String taskId);
}
