/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.base.service.messge.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.base.entity.dto.MessagepushDto;
import com.tofly.base.vo.MessagepushVo;
import com.tofly.common.oauth.util.SecurityUtils;
import com.tofly.pojo.message.Messagepush;
import com.tofly.base.mapper.MessagepushMapper;
import com.tofly.base.service.messge.MessagepushService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


/**
 * 消息推送数据表:TF_YWPN_MESSAGEPUSH_W
 *
 * @author admin
 * @date Wed Mar 31 00:00:00 CST 2021
 */
@Service("messagepushService")
public class MessagepushServiceImpl extends ServiceImpl<MessagepushMapper, Messagepush> implements MessagepushService {



    @Override
    public Page<MessagepushVo> getPageInfo(Page<MessagepushVo> page, MessagepushDto dto) {
        // 构造查询对象
        QueryWrapper<MessagepushDto> queryWrapper = new QueryWrapper();
        // 只查出自己的消息
        queryWrapper.eq("t.RECIPIENT", SecurityUtils.getUserId());
        if(null != dto.getBeginTime() && null!=dto.getEndTime()){
            queryWrapper.ge("p.CREATE_TIME",dto.getBeginTime());
            queryWrapper.le("p.CREATE_TIME",dto.getEndTime());
        }

        if(!StringUtils.isEmpty(dto.getFlag())){
            queryWrapper.eq("t.FLAG",dto.getFlag());
        }

        return  baseMapper.searchWeeklyPage(page,queryWrapper);
    }
}
