/*
 * 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.pojo.message.Usertask;
import com.tofly.base.mapper.UsertaskMapper;
import com.tofly.base.service.messge.UsertaskService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 待办任务信息表
 *
 * @author admin
 * @date Wed Mar 31 00:00:00 CST 2021
 */
@Service("usertaskService")
public class UsertaskServiceImpl extends ServiceImpl<UsertaskMapper, Usertask> implements UsertaskService {

    @Override
    public Page<Usertask> getUserTaskPage(Page page, Usertask parDto) {
        // 按照时间范围
        QueryWrapper<Usertask> queryWrapper = new QueryWrapper();
        Date startTime = parDto.getStartTime();
        Date endTime = parDto.getEndTime();
        if (null != startTime && null != endTime) {
            queryWrapper.ge("START_TIME", startTime);
            queryWrapper.le("END_TIME", endTime);
            parDto.setStartTime(null);
            parDto.setEndTime(null);
        }
        queryWrapper.setEntity(parDto);
        // 待办事项按级别与任务派发时间降序排列
        queryWrapper.orderByDesc("TLEVEL").orderByDesc("CREATE_TIME");
        return this.page(page, queryWrapper);
    }
}
