All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.didiglobal.logi.security.dao.impl.MessageDaoImpl Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.didiglobal.logi.security.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.didiglobal.logi.security.common.entity.Message;
import com.didiglobal.logi.security.common.po.MessagePO;
import com.didiglobal.logi.security.dao.MessageDao;
import com.didiglobal.logi.security.dao.mapper.MessageMapper;
import com.didiglobal.logi.security.util.CopyBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author cjm
 */
@Component
public class MessageDaoImpl extends BaseDaoImpl implements MessageDao {

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public void insert(Message message) {
        MessagePO messagePO = CopyBeanUtil.copy(message, MessagePO.class);
        messageMapper.insert(messagePO);
        message.setId(messagePO.getId());
    }

    @Override
    public void update(Message message) {
        messageMapper.updateById(CopyBeanUtil.copy(message, MessagePO.class));
    }

    @Override
    public void insertBatch(List messageList) {
        if(CollectionUtils.isEmpty(messageList)) {
            return;
        }
        List messagePOList = CopyBeanUtil.copyList(messageList, MessagePO.class);
        for(MessagePO messagePO : messagePOList) {
            messageMapper.insert(messagePO);
        }

    }

    @Override
    public List selectListByUserIdAndReadTag(Integer userId, Boolean readTag) {
        QueryWrapper queryWrapper = getQueryWrapper();
        queryWrapper
                .eq( userId != null, FieldConstant.USER_ID, userId)
                .eq(readTag != null, FieldConstant.READ_TAG, readTag);
        return CopyBeanUtil.copyList(messageMapper.selectList(queryWrapper), Message.class);
    }

    @Override
    public List selectListByMessageIdList(List messageIdList) {
        QueryWrapper queryWrapper = getQueryWrapper();
        queryWrapper.in(FieldConstant.ID, messageIdList);
        return CopyBeanUtil.copyList(messageMapper.selectList(queryWrapper), Message.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy