package com.pjilisense.flxai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pjilisense.flxai.base.service.impl.CrudServiceImpl;
import com.pjilisense.flxai.dao.VoiceRefFilesDao;
import com.pjilisense.flxai.dto.DigitalImgDTO;
import com.pjilisense.flxai.dto.VoiceRefFilesDTO;
import com.pjilisense.flxai.entity.DigitalImgEntity;
import com.pjilisense.flxai.entity.VoiceRefFilesEntity;
import com.pjilisense.flxai.service.VoiceRefFilesService;
import cn.hutool.core.util.StrUtil;
import com.pjilisense.flxai.utils.ConvertUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 音频参考文件
 *
 * @author liushujing liushujing@philisense.com
 * @since 1.0.0 2025-02-28
 */
@Service
public class VoiceRefFilesServiceImpl extends CrudServiceImpl<VoiceRefFilesDao, VoiceRefFilesEntity, VoiceRefFilesDTO> implements VoiceRefFilesService {

    @Override
    public QueryWrapper<VoiceRefFilesEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<VoiceRefFilesEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Override
    public List<VoiceRefFilesDTO> getAll(VoiceRefFilesDTO dto) {
        QueryWrapper<VoiceRefFilesEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(dto.getLanguage()), "language", dto.getLanguage());
        wrapper.eq(StrUtil.isNotBlank(dto.getId()), "id", dto.getId());
        wrapper.like(StrUtil.isNotBlank(dto.getName()), "name", dto.getName());
        wrapper.orderByAsc("id");
        List<VoiceRefFilesEntity> entityList =baseDao.selectList(wrapper);
        return ConvertUtils.sourceToTarget(entityList, VoiceRefFilesDTO.class);
    }

}