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

import org.apache.commons.lang.StringUtils;
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.admin.dao.PaperviewDao;
import io.renren.modules.admin.entity.PaperviewEntity;
import io.renren.modules.admin.service.PaperviewService;


@Service("paperviewService")
public class PaperviewServiceImpl extends ServiceImpl<PaperviewDao, PaperviewEntity> implements PaperviewService {

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

        return new PageUtils(page);
    }

}