package com.ann.demo.service.impl;

import com.ann.demo.entity.filing.MessageSubordinate;
import com.ann.demo.repository.MessageSubordinateRepository;
import com.ann.demo.service.MessageSubordinateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2019/7/9 16:43
 * @Created by  ljx
 */
@Service
public class MessageSubordinateServiceImpl implements MessageSubordinateService {

    static final Logger logger = LoggerFactory.getLogger(MessageSubordinateServiceImpl.class);

    @Autowired
    MessageSubordinateRepository subordinateRepository;

    @Override
    public void save(MessageSubordinate messageSubordinate) {
        //打日志信息
        try {
            subordinateRepository.save(messageSubordinate);
        } catch (Exception e) {
            logger.error("出错咯！错误信息:" + e);
        }
    }

    @Override
    public boolean countByMessageId(String messageId) {
        try {
            if (messageId != null) {
                if (subordinateRepository.countByMessageId(messageId) > 0)
                    return false;
                return true;
            }
        } catch (Exception e) {
            logger.error("查询消息ID与消息内容出错咯！错误信息:" + e);
        }
        return false;
    }
}
