package cn.axzo.msg.center.dal.mapper;


import cn.axzo.msg.center.api.request.QueryMessageRecordReq;
import cn.axzo.msg.center.api.response.MessageRecordRes;
import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
import cn.axzo.msg.center.domain.dto.UpdateReadDTO;
import cn.axzo.msg.center.domain.entity.MessageRecord;
import cn.axzo.msg.center.service.dto.IdentifyAndReceiveType;
import cn.axzo.msg.center.util.IterableMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 消息记录(MessageRecord)表数据库访问层
 *
 * @author zhangran
 * @since 2022-03-28 14:59:16
 */
/*@Mapper*/
public interface MessageRecordMapper extends IterableMapper<MessageRecord> {

  void batchInsertWithId(@Param("records") List<MessageRecord> records);

  void deleteRecordsPhysically(@Param("ids") List<Long> ids);

  List<MsgStatisticsDTO> statisticsMsg(@Param("bizType") Integer bizType,
                                       @Param("personId") Long personId,
                                       @Param("identityId") Long identityId,
                                       @Param("receiveType") Integer receiveType);

  IPage<MessageNewResDTO> pageMsgInfo(@Param("req") CmsMsgQueryReqDTO req,
                                      IPage page,
                                      @Param("personId") Long personId,
                                      @Param("states") List<Integer> states,
                                      @Param("identifies") List<IdentifyAndReceiveType> identities);

  IPage<MessageNewResDTO> mixIdentityPageMsgInfo(@Param("req") CmsMsgQueryReqDTO req, IPage page,
                                              @Param("identityIds") List<Long> identityIds, @Param("personId") Long personId,
                                              @Param("states")List<Integer> states);

  IPage<MessageNewResDTO> pageMsgInfo4WechatAndTrade(@Param("req") CmsMsgQueryReqDTO req, IPage page,
      @Param("moduleIds") List<Long> moduleIds, @Param("personId") Long personId,
      @Param("receiveType") Integer receiveType, @Param("states") List<Integer> states);

  void readAllMsg(@Param("ids") List<Long> collect);

  int updateHasRead(@Param("req") UpdateReadDTO request);

  IPage<MessageNewResDTO> queryUnReadList(@Param("req") QueryMessageRecordReq req, IPage page);
  IPage<MessageRecordRes> querySent(IPage<MessageRecordRes> page, @Param("req") QueryMessageRecordReq request);
}

