package com.aegis.notification.service.channel;

import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aegis.notification.domain.Notification;
import com.aegis.notification.mapper.NotificationMapper;

/**
 * 站内消息渠道
 * 
 * @author aegis
 */
@Service
public class StationChannel implements INotificationChannel {
    
    @Autowired
    private NotificationMapper notificationMapper;
    
    @Override
    public boolean send(Notification notification) {
        // 站内消息直接保存到数据库，状态为sent
        notification.setStatus("sent");
        notification.setSendTime(new Date());
        int result = notificationMapper.updateNotification(notification);
        return result > 0;
    }
    
    @Override
    public String getChannelName() {
        return "station";
    }
    
    @Override
    public boolean supports(String channel) {
        return "station".equals(channel);
    }
}