package com.bonus.canteen.core.notice.notice.v2.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.common.houqin.constant.LeConstants;
import com.bonus.canteen.core.notice.notice.v2.dto.InformRangeUpdateWhetherDTO;
import com.bonus.canteen.core.notice.notice.v2.mapper.InformRangeMapper;
import com.bonus.canteen.core.notice.notice.v2.model.InformRange;
import com.bonus.canteen.core.notice.notice.v2.service.InformRangeService;
import org.springframework.stereotype.Service;


@Service
public class InformRangeServiceImpl extends ServiceImpl<InformRangeMapper, InformRange> implements InformRangeService {

   @Override
   public Long queryUnreadInformNum(Long custId) {
      return ((InformRangeMapper)this.baseMapper).selectCount(Wrappers.lambdaQuery(InformRange.class)
              .eq(InformRange::getCustId, custId)
              .eq(InformRange::getWhether, LeConstants.COMMON_NO));
   }

   @Override
   public int updateWhether(InformRangeUpdateWhetherDTO content) {
      return ((InformRangeMapper)this.baseMapper).update(null,Wrappers.lambdaUpdate(InformRange.class)
              .set(InformRange::getWhether, LeConstants.COMMON_YES)
              .eq(InformRange::getCustId, content.getCustId())
              .eq(InformRange::getInformhisId, content.getInformhisId()));
   }
}
