package com.codvision.base.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.codvision.base.entity.SysNoticeUserMapper;
import com.codvision.base.entity.vo.SysNoticeUserMapperVO;
import com.codvision.base.mapper.SysNoticeUserMapperMapper;
import com.codvision.base.service.ISysNoticeUserMapperService;
import com.codvision.webcore.bean.QueryPage;
import com.codvision.webcore.service.impl.BaseServiceImpl;
import com.codvision.webcore.util.PageUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lingee
 * @since 2023-12-01
 */
@Service
public class SysNoticeUserMapperServiceImpl extends BaseServiceImpl<SysNoticeUserMapperMapper, SysNoticeUserMapper, SysNoticeUserMapperVO> implements ISysNoticeUserMapperService {

    @Override
    public SysNoticeUserMapperVO getDetail(Long id) {
        SysNoticeUserMapperVO vo = new SysNoticeUserMapperVO();
        SysNoticeUserMapper po = this.getById(id);
        if (null != po) {
            BeanUtil.copyProperties(po, vo);
        }
        return vo;
    }

    @Override
    public IPage<SysNoticeUserMapperVO> getPageResult(QueryPage<SysNoticeUserMapper> queryPage) {
        QueryWrapper<SysNoticeUserMapper> queryWrapper = queryPage.getWrapper();
        IPage<SysNoticeUserMapperVO> pageResult = this.getBasePage(queryPage.getPage(), queryWrapper);
        return pageResult;
    }

    @Override
    public List<SysNoticeUserMapperVO> listAll(SysNoticeUserMapper queryBean) {
        QueryWrapper<SysNoticeUserMapper> wrapper = PageUtil.initWrapper(queryBean);
        List<SysNoticeUserMapper> list = this.list(wrapper);
        return BeanUtil.copyToList(list, SysNoticeUserMapperVO.class);
    }

    @Override
    public void markAllRead(Integer uid, Integer type) {
        this.getBaseMapper().markAllRead(uid, type);
    }

}
