package com.community.huiju.service.impl;

import com.community.huiju.dao.TaBriskUserMapper;
import com.community.huiju.model.TaBriskUser;
import com.community.huiju.service.AssembleServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * @author FXF
 * @date 2019-05-28
 */
@Service("assembleService")
@Transactional(rollbackFor = Exception.class)
public class AssembleServiceImpl implements AssembleServiceI {
	
	@Autowired
	private TaBriskUserMapper taBriskUserMapper;
	
	/**
	 * 记录日活跃用户，同一个用户当天只记录一次
	 * @param userVerifyId
	 * @param communityId
	 */
	@Override
	public void saveBriskUser(Integer userVerifyId, Integer communityId) {
		//先查看此用户当天是否进入过首页，没进入过则插入
		Date date = new Date();
		List<TaBriskUser> list = taBriskUserMapper.selectByParams(userVerifyId,communityId,date);
		if (list.size() < 1) {
			//插入一条数据
			TaBriskUser taBriskUser = new TaBriskUser();
			taBriskUser.setCommunityId(communityId);
			taBriskUser.setTaUserVerifyId(userVerifyId);
			taBriskUser.setCreateDate(date);
			taBriskUserMapper.saveBriskUser(taBriskUser);
		}
	}
}
