package cn.axzo.msg.center.dal;

import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
import cn.axzo.msg.center.dal.mapper.MessageModuleMapper;
import cn.axzo.msg.center.domain.dto.MsgModuleDTO;
import cn.axzo.msg.center.domain.dto.SyncModuleDataDTO;
import cn.axzo.msg.center.domain.entity.MessageModule;
import cn.axzo.msg.center.domain.persistence.BaseEntity;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * 消息模块(MessageModule)表数据库访问层
 *
 * @author zhangran
 * @since 2022-03-28 14:59:16
 */
@Service
@Slf4j
public class MessageModuleDao extends ServiceImpl<MessageModuleMapper, MessageModule>{


  public List<MessageModule> listMoudleByUserType(ReceiveTypeEnum receiveTypeEnum) {
  return this.lambdaQuery().eq(MessageModule::getOwnedType,receiveTypeEnum)
      .eq(BaseEntity::getIsDelete,0).list();
  }

  public List<MsgModuleDTO> listModuleByRelationIdsOrTypeIds(Set<Integer> oldTypeIds, Set<Long> relationIds) {
  return this.baseMapper.listModuleByRelationIdsOrTypeIds(oldTypeIds,relationIds);
  }

  public void insertBatchSql(List<SyncModuleDataDTO> adds) {
    this.baseMapper.navtiveBatchSql(adds);
  }
}

