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

import java.util.Map;

import org.springframework.stereotype.Service;
import org.apache.commons.lang.StringUtils;
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.admin.dao.PaperDao;
import io.renren.modules.admin.entity.PaperEntity;
import io.renren.modules.admin.service.PaperService;

@Service("paperService")
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String meetingId = (String) params.get("meetingId");
        String title = (String)params.get("title");
        IPage<PaperEntity> page = this.page(
                new Query<PaperEntity>().getPage(params),
                new QueryWrapper<PaperEntity>().eq(StringUtils.isNotBlank(meetingId),"meeting_id", meetingId)
                .like(StringUtils.isNotBlank(title),"title",title)
        );

        return new PageUtils(page);
    }

}