package com.rj.service.impl;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rj.entity.AudioManagementSegments;
import com.rj.mapper.AudioManagementSegmentsMapper;
import com.rj.service.IAudioManagementSegmentsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 录音分段管理表 服务实现类
 * </p>
 *
 * 对应表：audio_management_segments
 */
@Service
public class AudioManagementSegmentsServiceImpl
        extends ServiceImpl<AudioManagementSegmentsMapper, AudioManagementSegments>
        implements IAudioManagementSegmentsService {
    @Override
    @InterceptorIgnore(tenantLine = "true")  // 禁用多租户拦截
    public boolean updateNoTenant(AudioManagementSegments entity,
                          LambdaUpdateWrapper<AudioManagementSegments> updateWrapper) {
        return super.update(entity, updateWrapper);
    }

    @Override
    public List<AudioManagementSegments> listSegmentsNeedingMinioUpload(int limit) {
        int safeLimit = Math.max(1, Math.min(limit, 500));
        return baseMapper.listSegmentsNeedingMinioUpload(safeLimit);
    }

    @Override
    public boolean updateAudioFileUrlByIdIgnoreTenant(String id, String audioFileUrl) {
        return baseMapper.updateAudioFileUrlByIdIgnoreTenant(id, audioFileUrl) > 0;
    }

}

