package com.dsk.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.mapper.SysPushMapper;
import com.dsk.system.domain.SysPush;
import com.dsk.system.service.ISysPushService;
import jodd.bean.BeanException;
import org.springframework.stereotype.Service;

/**
 * 系统推送(SysPush)表服务实现类
 *
 * @author lcl
 * @since 2023-12-14 10:09:24
 */
@Service
public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> implements ISysPushService {

    @Override
    public TableDataInfo<SysPush> pageList(SysPush bean, PageQuery query) {
        if(ObjectUtils.isEmpty(bean.getPushTypeCode())) throw new BeanException("推送类型code不能为空！");
        return TableDataInfo.build(baseMapper.selectPage(query.build(), Wrappers.<SysPush>lambdaQuery()
                .eq(SysPush::getPushTypeCode, bean.getPushTypeCode())
                .orderByDesc(SysPush::getCreateTime)));
    }
}

