package com.yonge.cooleshow.bbs.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yonge.cooleshow.bbs.dao.BbsPrivateMessageDao;
import com.yonge.cooleshow.bbs.dto.MessageReadDto;
import com.yonge.cooleshow.bbs.dto.PrivateMessagePersonVo;
import com.yonge.cooleshow.bbs.dto.search.BbsPrivateMessageSearch;
import com.yonge.cooleshow.bbs.entity.BbsPrivateMessage;
import com.yonge.cooleshow.bbs.service.BbsPrivateMessageService;
import com.yonge.cooleshow.bbs.vo.BbsPrivateMessageVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class BbsPrivateMessageServiceImpl extends ServiceImpl<BbsPrivateMessageDao, BbsPrivateMessage> implements BbsPrivateMessageService {
    private final static Logger log = LoggerFactory.getLogger(BbsPrivateMessageServiceImpl.class);

	@Override
    public BbsPrivateMessageVo detail(Long id) {
        return baseMapper.detail(id);
    }
    
     @Override
    public IPage<BbsPrivateMessageVo> selectPage(IPage<BbsPrivateMessageVo> page, BbsPrivateMessageSearch query){
        return page.setRecords(baseMapper.selectPage(page, query));
    }

    @Override
    public IPage<PrivateMessagePersonVo> selectPersonPage(IPage<PrivateMessagePersonVo> page, BbsPrivateMessageSearch query) {
        return page.setRecords(baseMapper.selectPersonPage(page, query));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean read(MessageReadDto readDto) {
        return baseMapper.read(readDto) ;
    }

    @Override
    public IPage<BbsPrivateMessage> selectReadMessagePage(IPage<BbsPrivateMessage> page, BbsPrivateMessageSearch query) {
        return page.setRecords(baseMapper.selectMessagePage(page, query));
    }

    @Override
    public List<BbsPrivateMessage> selectUnreadMessage(BbsPrivateMessageSearch query) {
        return baseMapper.selectUnreadMessage( query);
    }

}