package io.renren.modules.generator.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import io.renren.modules.generator.entity.VolumesEntity;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.ImagesDao;
import io.renren.modules.generator.entity.ImagesEntity;
import io.renren.modules.generator.service.ImagesService;


@Service("imagesService")
public class ImagesServiceImpl extends ServiceImpl<ImagesDao, ImagesEntity> implements ImagesService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String imageName = (String) params.get("imageName");
        String imageType = (String) params.get("imageType");
        IPage<ImagesEntity> page = this.page(
                new Query<ImagesEntity>().getPage(params),
                new QueryWrapper<ImagesEntity>()
                        .like(StringUtils.isNotBlank(imageName), "image_name", imageName)
                        .eq(StringUtils.isNotBlank(imageType), "image_type", imageType)
        );

        return new PageUtils(page);
    }

}