package org.springblade.modules.app.service.impl;

import com.wn.common.datamodel.ModelConvertUtil;
import com.wn.common.validator.Validator;
import org.springblade.modules.app.common.dto.MessageLoggingDTO;
import org.springblade.modules.app.constant.ErrorCode;
import org.springblade.modules.app.entity.MessageLoggingDO;
import org.springblade.modules.app.mapper.MessageLoggingMapper;
import org.springblade.modules.app.service.IMessageLoggingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 消息记录表 服务实现类
 * </p>
 *
 * @author huyinuo
 * @since 2022-01-17
 */
@Service
public class MessageLoggingServiceImpl extends ServiceImpl<MessageLoggingMapper, MessageLoggingDO> implements IMessageLoggingService {

    @Override
    public Boolean addMessageLogging(MessageLoggingDTO messageLoggingDTO) {
        Validator.notNull(messageLoggingDTO, ErrorCode.INPUT_PARAMETERS_NULL);
        MessageLoggingDO messageLoggingDO = ModelConvertUtil.copyTo(messageLoggingDTO, MessageLoggingDO.class);
        Validator.isTrue(save(messageLoggingDO), ErrorCode.SAVE_DATA_INTO_DB_ERROR);
        return true;
    }
}
