package com.ssj.service.weixin.story.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;
import com.ssj.bean.weixin.story.bean.StoryCardPraise;
import com.ssj.dao.weixin.story.dao.StoryCardPraiseDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.weixin.story.service.StoryCardPraiseService;


/** 
 * @author  ZhangCaibao 
 * @version 2018年3月22日 下午3:14:41 
 * 类说明 
 */
@Service(version="1.0")
@Transactional
public class StoryCardPraiseServiceImpl extends BaseServiceImpl<StoryCardPraise, String> implements StoryCardPraiseService{

	@Autowired
	private  StoryCardPraiseDao  storyCardPraiseDao; 
	@Override
	public PagingAndSortingRepository<StoryCardPraise, String> getDao() {
		return storyCardPraiseDao;
	}
	@Override
	public void saveStoryCardPraise(String userId, String storyCardId) {
		StoryCardPraise storyCardPraise =storyCardPraiseDao.findByUserIdAndStoryCardId(userId, storyCardId);
		if(storyCardPraise==null){
			storyCardPraise = new StoryCardPraise();
			storyCardPraise.setCreateTime(new Date());
			storyCardPraise.setStat(1);
			storyCardPraise.setUserId(userId);
			storyCardPraise.setStoryCardId(storyCardId);
			this.save(storyCardPraise);
		}
		
	}
	

}
