package com.ssj.service.sys.push.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.sys.push.domain.SconPushMessage;
import com.ssj.dao.sys.push.dao.SconPushMessageDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.sys.push.service.SconPushMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service(version = "1.0")
@Transactional
public class SconPushMessageServiceImpl extends BaseServiceImpl<SconPushMessage,String> implements SconPushMessageService {
    @Autowired
    private SconPushMessageDao dao;

    @Override
    public PagingAndSortingRepository<SconPushMessage, String> getDao() {
        return dao;
    }

    @Override
    public SconPushMessage savePushMessage(String pushUserId, int platformType, String title, String content, String type) {
        SconPushMessage sm = new SconPushMessage();
        sm.setPushUserId(pushUserId);
        sm.setTitle(title);
        sm.setContent(content);
        sm.setPlatformType(platformType);
        sm.setPlatform(type);
        sm.setCreateTime(new Date());
        return this.save(sm);
    }

	@Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
	public List<String> findByLikeContent(String pushUserId,
			String content, int limit) {
		return dao.findByLikeContent(pushUserId, content, limit);
	}

    @Override
    public void deleteByLikeContent(String pushUserId, String content) {
                dao.deleteByLikeContent(pushUserId,content);
    }

}
