package top.continew.admin.system.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import top.continew.admin.system.model.entity.TaskPreDeductDO;
import top.continew.starter.data.mp.base.BaseMapper;

/**
 * 任务预扣减记录 Mapper
 *
 * @author jiay
 * @since 2025/08/28 00:00
 */
public interface TaskPreDeductMapper extends BaseMapper<TaskPreDeductDO> {

    /**
     * 重置用户预扣减余额为0（用户登录时调用）
     *
     * @param userId 用户ID
     * @return 影响行数
     */
    @Update("UPDATE t_task_pre_deduct SET pre_deduct_amount = 0 WHERE user_id = #{userId}")
    int resetPreDeductByUserId(@Param("userId") Long userId);
}