package com.qiankun.service;

import com.qiankun.dao.BloodDao;
import com.qiankun.entity.Activity;
import com.qiankun.entity.Blood;
import com.qiankun.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class BloodService {
    @Autowired
    private BloodDao bloodDao;
    @Transactional
    public void save(Blood blood){
        bloodDao.save(blood);
    }

    public boolean isExistByUserAndActivty(User user, Activity activity) {
        long count = bloodDao.findCountByUserAndActivity(user.getId(),activity.getId());
        if (count > 0){
            return true;
        }else {
            return false;
        }
    }
}
