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.DigitalImgDao;
import com.pjilisense.flxai.dto.DigitalImgDTO;
import com.pjilisense.flxai.entity.AppToolsSetEntity;
import com.pjilisense.flxai.entity.DigitalImgEntity;
import com.pjilisense.flxai.service.DigitalImgService;
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;

/**
 * ${comments}
 *
 * @author liushujing liushujing@philisense.com
 * @since 1.0.0 2025-02-26
 */
@Service
public class DigitalImgServiceImpl extends CrudServiceImpl<DigitalImgDao, DigitalImgEntity, DigitalImgDTO> implements DigitalImgService {

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

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

        return wrapper;
    }

    @Override
    public List<DigitalImgDTO> getAllByType(String imgType) {
        QueryWrapper<DigitalImgEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(imgType), "img_type", imgType);
        wrapper.orderByAsc("id");
        List<DigitalImgEntity> entityList =baseDao.selectList(wrapper);
        return ConvertUtils.sourceToTarget(entityList, DigitalImgDTO.class);
    }
}