package cn.axzo.msg.center.notices.manager;

import cn.axzo.msg.center.dal.MNSMessageRequestLogDao;
import cn.axzo.msg.center.domain.entity.MNSMessageRequestLog;
import cn.axzo.msg.center.notices.manager.api.MessageRequestLogManager;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 请求日志处理实现类
 *
 * @author zhaoyong_sh
 * @see MessageRequestLogManagerImpl
 * @since 2021-05-28 10:51
 */
@Service("messageRequestLogManager")
public class MessageRequestLogManagerImpl implements MessageRequestLogManager {

  @Resource
  private MNSMessageRequestLogDao mnsMessageRequestLogDao;

  @Override
  public Long saveRequestLog(MNSMessageRequestLog requestLog) {
    mnsMessageRequestLogDao.save(requestLog);
    return requestLog.getId();
  }

  @Override
  public boolean updateRequestLog(String responseBody, Long id) {
    return mnsMessageRequestLogDao.lambdaUpdate()
        .set(MNSMessageRequestLog::getResponseBody, responseBody)
        .eq(MNSMessageRequestLog::getId, id)
        .update();
  }
}
