package com.wzj.soopin.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzj.soopin.member.convert.FeedbackConvert;
import com.wzj.soopin.member.convert.MemberConvert;
import com.wzj.soopin.member.domain.bo.FeedbackBO;
import com.wzj.soopin.member.domain.po.Feedback;
import com.wzj.soopin.member.domain.po.Member;
import com.wzj.soopin.member.domain.po.MemberBlock;
import com.wzj.soopin.member.domain.vo.FeedbackVO;
import com.wzj.soopin.member.mapper.FeedbackMapper;
import com.wzj.soopin.member.mapper.MemberBlockMapper;
import com.wzj.soopin.member.mapper.MemberMapper;
import com.wzj.soopin.member.service.IFeedbackService;
import com.wzj.soopin.member.service.IMemberBlockService;
import com.wzj.soopin.member.util.MemberCacheHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 意见反馈Service业务层处理
 *
 * @author zcc
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class MemberBlockServiceImpl extends ServiceImpl<MemberBlockMapper, MemberBlock> implements IMemberBlockService {


    @Override
    public boolean hasBlocked(Long myId, Long vloggerId) {
        return this.count(new UpdateWrapper<MemberBlock>()
                .eq("member_id", myId)
                .eq("block_member_id", vloggerId)) > 0;
    }

    @Override
    public boolean addBlock(Long myId, Long vloggerId) {
        return this.save( MemberBlock.builder().memberId(myId).blockMemberId(vloggerId).build());
    }


    @Override
    public void  removeBlock(Long myId, Long vloggerId) {
         baseMapper.delete(new UpdateWrapper<MemberBlock>()
                .eq("member_id", myId)
                .eq("block_member_id", vloggerId));
    }
}
